summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2018-09-13 11:50:56 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2018-09-13 11:51:08 +0000
commitaee413961dbfbc5dff84fa511c5f1a43f95087c1 (patch)
tree03ee60129336a201d8b767494be7a22de619e799
parentReleasing progress-linux version 3:6.03+dfsg1-2~dschinn1. (diff)
downloadsyslinux-aee413961dbfbc5dff84fa511c5f1a43f95087c1.zip
syslinux-aee413961dbfbc5dff84fa511c5f1a43f95087c1.tar.xz
Merging upstream version 3:6.04~git20171011.af7e95c3+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
-rw-r--r--Makefile53
-rw-r--r--NEWS2
-rw-r--r--codepage/Makefile2
-rw-r--r--com32/Makefile18
-rw-r--r--com32/chain/Makefile2
-rw-r--r--com32/chain/chain.c2
-rw-r--r--com32/chain/chain.h2
-rw-r--r--com32/chain/mangle.c2
-rw-r--r--com32/chain/mangle.h2
-rw-r--r--com32/chain/options.c30
-rw-r--r--com32/chain/options.h2
-rw-r--r--com32/chain/partiter.c150
-rw-r--r--com32/chain/partiter.h4
-rw-r--r--com32/chain/utility.c2
-rw-r--r--com32/chain/utility.h2
-rw-r--r--com32/cmenu/Makefile6
-rw-r--r--com32/elflink/ldlinux/Makefile2
-rw-r--r--com32/elflink/ldlinux/adv.c2
-rw-r--r--com32/elflink/ldlinux/cli.c2
-rw-r--r--com32/elflink/ldlinux/execute.c4
-rw-r--r--com32/elflink/ldlinux/getadv.c2
-rw-r--r--com32/elflink/ldlinux/kernel.c8
-rw-r--r--com32/elflink/ldlinux/ldlinux.c28
-rw-r--r--com32/elflink/ldlinux/readconfig.c6
-rw-r--r--com32/elflink/ldlinux/setadv.c2
-rw-r--r--com32/gplinclude/cpuid.h2
-rw-r--r--com32/gpllib/Makefile2
-rw-r--r--com32/gpllib/acpi/xsdt.c2
-rw-r--r--com32/gpllib/disk/write.c6
-rw-r--r--com32/gpllib/dmi/dmi.c26
-rw-r--r--com32/gpllib/dmi/dmi_bios.c4
-rw-r--r--com32/gpllib/dmi/dmi_cache.c5
-rw-r--r--com32/gpllib/dmi/dmi_chassis.c9
-rw-r--r--com32/gpllib/dmi/dmi_memory.c26
-rw-r--r--com32/gpllib/dmi/dmi_processor.c51
-rw-r--r--com32/hdt/Makefile2
-rw-r--r--com32/hdt/hdt-cli-cpu.c178
-rw-r--r--com32/hdt/hdt-cli-memory.c4
-rw-r--r--com32/hdt/hdt-cli.c19
-rw-r--r--com32/hdt/hdt-dump-memory.c12
-rw-r--r--com32/hdt/hdt-dump.c11
-rw-r--r--com32/hdt/hdt-menu-memory.c4
-rw-r--r--com32/hdt/hdt-menu-processor.c178
-rw-r--r--com32/include/libansi.h3
-rw-r--r--com32/include/menu.h2
-rw-r--r--com32/include/sys/elfcommon.h2
-rw-r--r--com32/include/sys/module.h2
-rw-r--r--com32/include/syslinux/pxe_api.h2
-rw-r--r--com32/lib/Makefile3
-rw-r--r--com32/lib/chrreplace.c2
-rw-r--r--com32/lib/pci/scan.c8
-rw-r--r--com32/lib/sys/module/exec.c4
-rw-r--r--com32/lib/syslinux/disk.c16
-rw-r--r--com32/lib/syslinux/initramfs_file.c2
-rw-r--r--com32/lib/syslinux/load_linux.c19
-rw-r--r--com32/lib/syslinux/pxe_dns.c67
-rw-r--r--com32/lib/zlib/zutil.h12
-rw-r--r--com32/libupload/Makefile2
-rw-r--r--com32/libupload/tftp.h12
-rw-r--r--com32/libupload/upload_tftp.c245
-rw-r--r--com32/lua/doc/syslinux.asc336
-rw-r--r--com32/lua/src/syslinux.c291
-rw-r--r--com32/lua/src/vesa.c2
-rw-r--r--com32/lua/test/automenu.lua38
-rw-r--r--com32/mboot/map.c125
-rw-r--r--com32/mboot/mboot.c4
-rw-r--r--com32/mboot/mboot.h1
-rw-r--r--com32/menu/menumain.c5
-rw-r--r--com32/menu/readconfig.c2
-rw-r--r--com32/modules/Makefile23
-rw-r--r--com32/modules/cptime.c2
-rw-r--r--com32/modules/host.c7
-rw-r--r--com32/modules/meminfo.c4
-rw-r--r--com32/modules/pmload.c4
-rw-r--r--com32/rosh/Makefile2
-rw-r--r--com32/samples/resolv.c2
-rw-r--r--com32/sysdump/Makefile4
-rw-r--r--com32/sysdump/dmi.c4
-rw-r--r--com32/tools/Makefile7
-rw-r--r--com32/tools/relocs.c808
-rw-r--r--core/Makefile63
-rw-r--r--core/adv.inc4
-rw-r--r--core/common.inc2
-rw-r--r--core/diskboot.inc2
-rw-r--r--core/elflink/load_env32.c58
-rw-r--r--core/extern.inc22
-rw-r--r--core/fs/btrfs/btrfs.c49
-rw-r--r--core/fs/btrfs/btrfs.h4
-rw-r--r--core/fs/ext2/ext2.c23
-rw-r--r--core/fs/ext2/ext2_fs.h1
-rw-r--r--core/fs/fs.c2
-rw-r--r--core/fs/getfssec.c11
-rw-r--r--core/fs/lib/loadconfig.c5
-rw-r--r--core/fs/pxe/bios.c8
-rw-r--r--core/fs/pxe/dhcp_option.c17
-rw-r--r--core/fs/pxe/dnsresolv.c12
-rw-r--r--core/fs/pxe/gpxeurl.c82
-rw-r--r--core/fs/pxe/http.c19
-rw-r--r--core/fs/pxe/pxe.c20
-rw-r--r--core/fs/pxe/pxe.h8
-rw-r--r--core/fs/pxe/tftp.c181
-rw-r--r--core/fs/pxe/tftp.h13
-rw-r--r--core/fs/pxe/url.h3
-rw-r--r--core/fs/pxe/urlparse.c2
-rw-r--r--core/fs/xfs/xfs.c32
-rw-r--r--core/fs/xfs/xfs.h174
-rw-r--r--core/fs/xfs/xfs_dinode.c2
-rw-r--r--core/fs/xfs/xfs_dir2.c292
-rw-r--r--core/fs/xfs/xfs_dir2.h6
-rw-r--r--core/fs/xfs/xfs_readdir.c151
-rw-r--r--core/head.inc2
-rw-r--r--core/i386/syslinux.ld110
-rw-r--r--core/layout.inc15
-rw-r--r--core/legacynet/core.c101
-rw-r--r--core/legacynet/dnsresolv.c2
-rw-r--r--core/localboot.c5
-rw-r--r--core/lwip/src/netif/undiif.c2
-rw-r--r--core/mem/free.c2
-rw-r--r--core/mem/malloc.c4
-rw-r--r--core/serirq.c2
-rw-r--r--core/sysappend.c2
-rw-r--r--core/syslinux.ld414
-rw-r--r--core/thread/schedule.c4
-rw-r--r--core/x86_64/syslinux.ld428
-rw-r--r--diag/geodsp/Makefile10
-rw-r--r--diag/geodsp/README24
-rw-r--r--diag/geodsp/geodsp1s.asm97
-rw-r--r--diag/geodsp/geodsplib.inc61
-rw-r--r--diag/geodsp/geodspms.asm31
-rwxr-xr-xdiag/geodsp/mk-lba-img.pl2
-rw-r--r--doc/chain.txt15
-rw-r--r--doc/extlinux.txt4
-rw-r--r--doc/menu.txt193
-rw-r--r--doc/syslinux.txt18
-rw-r--r--dos/Makefile2
-rw-r--r--efi/Makefile13
-rw-r--r--efi/adv.c2
-rwxr-xr-xefi/build-gnu-efi.sh4
-rwxr-xr-xefi/check-gnu-efi.sh2
-rwxr-xr-xefi/clean-gnu-efi.sh4
-rw-r--r--efi/efi.h2
-rw-r--r--efi/main.c111
-rw-r--r--efi/pxe.c46
-rw-r--r--efi/tcp.c8
-rw-r--r--efi/udp.c73
-rw-r--r--efi/x86_64/linux.S61
-rw-r--r--extlinux/Makefile1
-rw-r--r--extlinux/main.c192
-rw-r--r--gnu-efi/gnu-efi-3.0/ChangeLog607
-rw-r--r--gnu-efi/gnu-efi-3.0/Make.defaults117
-rw-r--r--gnu-efi/gnu-efi-3.0/Make.rules51
-rw-r--r--gnu-efi/gnu-efi-3.0/Makefile99
-rw-r--r--gnu-efi/gnu-efi-3.0/README.efilib30
-rw-r--r--gnu-efi/gnu-efi-3.0/README.elilo19
-rw-r--r--gnu-efi/gnu-efi-3.0/README.gnuefi398
-rw-r--r--gnu-efi/gnu-efi-3.0/apps/AllocPages.c204
-rw-r--r--gnu-efi/gnu-efi-3.0/apps/FreePages.c164
-rw-r--r--gnu-efi/gnu-efi-3.0/apps/Makefile82
-rw-r--r--gnu-efi/gnu-efi-3.0/apps/drv0.c193
-rw-r--r--gnu-efi/gnu-efi-3.0/apps/drv0.h37
-rw-r--r--gnu-efi/gnu-efi-3.0/apps/drv0_use.c79
-rw-r--r--gnu-efi/gnu-efi-3.0/apps/modelist.c114
-rw-r--r--gnu-efi/gnu-efi-3.0/apps/printenv.c32
-rw-r--r--gnu-efi/gnu-efi-3.0/apps/route80h.c146
-rw-r--r--gnu-efi/gnu-efi-3.0/apps/t.c27
-rw-r--r--gnu-efi/gnu-efi-3.0/apps/t2.c13
-rw-r--r--gnu-efi/gnu-efi-3.0/apps/t3.c95
-rw-r--r--gnu-efi/gnu-efi-3.0/apps/t4.c13
-rw-r--r--gnu-efi/gnu-efi-3.0/apps/t5.c13
-rw-r--r--gnu-efi/gnu-efi-3.0/apps/t6.c43
-rw-r--r--gnu-efi/gnu-efi-3.0/apps/t7.c25
-rw-r--r--gnu-efi/gnu-efi-3.0/apps/tcc.c442
-rw-r--r--gnu-efi/gnu-efi-3.0/apps/tpause.c9
-rw-r--r--gnu-efi/gnu-efi-3.0/apps/trivial.S43
-rw-r--r--gnu-efi/gnu-efi-3.0/gnuefi/Makefile72
-rw-r--r--gnu-efi/gnu-efi-3.0/gnuefi/crt0-efi-ia32.S76
-rw-r--r--gnu-efi/gnu-efi-3.0/gnuefi/crt0-efi-ia64.S87
-rw-r--r--gnu-efi/gnu-efi-3.0/gnuefi/crt0-efi-x86_64.S76
-rw-r--r--gnu-efi/gnu-efi-3.0/gnuefi/elf_ia32_efi.lds75
-rw-r--r--gnu-efi/gnu-efi-3.0/gnuefi/elf_ia32_fbsd_efi.lds75
-rw-r--r--gnu-efi/gnu-efi-3.0/gnuefi/elf_ia64_efi.lds70
-rw-r--r--gnu-efi/gnu-efi-3.0/gnuefi/elf_x86_64_efi.lds65
-rw-r--r--gnu-efi/gnu-efi-3.0/gnuefi/elf_x86_64_fbsd_efi.lds59
-rw-r--r--gnu-efi/gnu-efi-3.0/gnuefi/reloc_ia32.c97
-rw-r--r--gnu-efi/gnu-efi-3.0/gnuefi/reloc_ia64.S227
-rw-r--r--gnu-efi/gnu-efi-3.0/gnuefi/reloc_x86_64.c96
-rw-r--r--gnu-efi/gnu-efi-3.0/gnuefi/setjmp_ia32.S87
-rw-r--r--gnu-efi/gnu-efi-3.0/gnuefi/setjmp_ia64.S2
-rw-r--r--gnu-efi/gnu-efi-3.0/gnuefi/setjmp_x86_64.S56
-rw-r--r--gnu-efi/gnu-efi-3.0/inc/Makefile27
-rw-r--r--gnu-efi/gnu-efi-3.0/inc/argify.h41
-rw-r--r--gnu-efi/gnu-efi-3.0/inc/efi.h53
-rw-r--r--gnu-efi/gnu-efi-3.0/inc/efi_nii.h74
-rw-r--r--gnu-efi/gnu-efi-3.0/inc/efi_pxe.h1743
-rw-r--r--gnu-efi/gnu-efi-3.0/inc/efiapi.h890
-rw-r--r--gnu-efi/gnu-efi-3.0/inc/eficon.h302
-rw-r--r--gnu-efi/gnu-efi-3.0/inc/efidebug.h110
-rw-r--r--gnu-efi/gnu-efi-3.0/inc/efidef.h211
-rw-r--r--gnu-efi/gnu-efi-3.0/inc/efidevp.h402
-rw-r--r--gnu-efi/gnu-efi-3.0/inc/efierr.h67
-rw-r--r--gnu-efi/gnu-efi-3.0/inc/efifs.h116
-rw-r--r--gnu-efi/gnu-efi-3.0/inc/efigpt.h68
-rw-r--r--gnu-efi/gnu-efi-3.0/inc/efiip.h459
-rw-r--r--gnu-efi/gnu-efi-3.0/inc/efilib.h910
-rw-r--r--gnu-efi/gnu-efi-3.0/inc/efilink.h177
-rw-r--r--gnu-efi/gnu-efi-3.0/inc/efinet.h340
-rw-r--r--gnu-efi/gnu-efi-3.0/inc/efipart.h61
-rw-r--r--gnu-efi/gnu-efi-3.0/inc/efipciio.h219
-rw-r--r--gnu-efi/gnu-efi-3.0/inc/efiprot.h757
-rw-r--r--gnu-efi/gnu-efi-3.0/inc/efipxebc.h464
-rw-r--r--gnu-efi/gnu-efi-3.0/inc/efirtlib.h141
-rw-r--r--gnu-efi/gnu-efi-3.0/inc/efiser.h132
-rw-r--r--gnu-efi/gnu-efi-3.0/inc/efistdarg.h33
-rw-r--r--gnu-efi/gnu-efi-3.0/inc/efitcp.h391
-rw-r--r--gnu-efi/gnu-efi-3.0/inc/efiudp.h272
-rw-r--r--gnu-efi/gnu-efi-3.0/inc/efiui.h54
-rw-r--r--gnu-efi/gnu-efi-3.0/inc/ia32/efibind.h284
-rw-r--r--gnu-efi/gnu-efi-3.0/inc/ia32/efilibplat.h26
-rw-r--r--gnu-efi/gnu-efi-3.0/inc/ia32/pe.h595
-rw-r--r--gnu-efi/gnu-efi-3.0/inc/ia64/efibind.h225
-rw-r--r--gnu-efi/gnu-efi-3.0/inc/ia64/efilibplat.h80
-rw-r--r--gnu-efi/gnu-efi-3.0/inc/ia64/pe.h601
-rw-r--r--gnu-efi/gnu-efi-3.0/inc/ia64/salproc.h264
-rw-r--r--gnu-efi/gnu-efi-3.0/inc/inc.mak23
-rw-r--r--gnu-efi/gnu-efi-3.0/inc/libsmbios.h132
-rw-r--r--gnu-efi/gnu-efi-3.0/inc/make.inf33
-rw-r--r--gnu-efi/gnu-efi-3.0/inc/makefile.hdr48
-rw-r--r--gnu-efi/gnu-efi-3.0/inc/pci22.h193
-rw-r--r--gnu-efi/gnu-efi-3.0/inc/protocol/adapterdebug.h32
-rw-r--r--gnu-efi/gnu-efi-3.0/inc/protocol/eficonsplit.h32
-rw-r--r--gnu-efi/gnu-efi-3.0/inc/protocol/efidbg.h210
-rw-r--r--gnu-efi/gnu-efi-3.0/inc/protocol/efivar.h133
-rw-r--r--gnu-efi/gnu-efi-3.0/inc/protocol/ia64/eficontext.h208
-rw-r--r--gnu-efi/gnu-efi-3.0/inc/protocol/intload.h27
-rw-r--r--gnu-efi/gnu-efi-3.0/inc/protocol/legacyboot.h119
-rw-r--r--gnu-efi/gnu-efi-3.0/inc/protocol/make.inf13
-rw-r--r--gnu-efi/gnu-efi-3.0/inc/protocol/makefile.hdr29
-rw-r--r--gnu-efi/gnu-efi-3.0/inc/protocol/piflash64.h121
-rw-r--r--gnu-efi/gnu-efi-3.0/inc/protocol/readme.txt3
-rw-r--r--gnu-efi/gnu-efi-3.0/inc/protocol/vgaclass.h95
-rw-r--r--gnu-efi/gnu-efi-3.0/inc/romload.h41
-rw-r--r--gnu-efi/gnu-efi-3.0/inc/x86_64/efibind.h380
-rw-r--r--gnu-efi/gnu-efi-3.0/inc/x86_64/efilibplat.h26
-rw-r--r--gnu-efi/gnu-efi-3.0/inc/x86_64/pe.h595
-rw-r--r--gnu-efi/gnu-efi-3.0/lib/Makefile80
-rw-r--r--gnu-efi/gnu-efi-3.0/lib/argify.c97
-rw-r--r--gnu-efi/gnu-efi-3.0/lib/boxdraw.c173
-rw-r--r--gnu-efi/gnu-efi-3.0/lib/console.c104
-rw-r--r--gnu-efi/gnu-efi-3.0/lib/crc.c218
-rw-r--r--gnu-efi/gnu-efi-3.0/lib/data.c167
-rw-r--r--gnu-efi/gnu-efi-3.0/lib/debug.c43
-rw-r--r--gnu-efi/gnu-efi-3.0/lib/dpath.c1035
-rw-r--r--gnu-efi/gnu-efi-3.0/lib/error.c76
-rw-r--r--gnu-efi/gnu-efi-3.0/lib/event.c153
-rw-r--r--gnu-efi/gnu-efi-3.0/lib/guid.c175
-rw-r--r--gnu-efi/gnu-efi-3.0/lib/hand.c637
-rw-r--r--gnu-efi/gnu-efi-3.0/lib/hw.c132
-rw-r--r--gnu-efi/gnu-efi-3.0/lib/ia32/efi_stub.S1
-rw-r--r--gnu-efi/gnu-efi-3.0/lib/ia32/initplat.c28
-rw-r--r--gnu-efi/gnu-efi-3.0/lib/ia32/math.c181
-rw-r--r--gnu-efi/gnu-efi-3.0/lib/ia64/initplat.c31
-rw-r--r--gnu-efi/gnu-efi-3.0/lib/ia64/math.c88
-rw-r--r--gnu-efi/gnu-efi-3.0/lib/ia64/palproc.S161
-rw-r--r--gnu-efi/gnu-efi-3.0/lib/ia64/palproc.h51
-rw-r--r--gnu-efi/gnu-efi-3.0/lib/ia64/salpal.c335
-rw-r--r--gnu-efi/gnu-efi-3.0/lib/init.c183
-rw-r--r--gnu-efi/gnu-efi-3.0/lib/lib.h88
-rw-r--r--gnu-efi/gnu-efi-3.0/lib/lock.c107
-rw-r--r--gnu-efi/gnu-efi-3.0/lib/misc.c563
-rw-r--r--gnu-efi/gnu-efi-3.0/lib/print.c1366
-rw-r--r--gnu-efi/gnu-efi-3.0/lib/runtime/efirtlib.c145
-rw-r--r--gnu-efi/gnu-efi-3.0/lib/runtime/rtdata.c65
-rw-r--r--gnu-efi/gnu-efi-3.0/lib/runtime/rtlock.c102
-rw-r--r--gnu-efi/gnu-efi-3.0/lib/runtime/rtstr.c140
-rw-r--r--gnu-efi/gnu-efi-3.0/lib/runtime/vm.c105
-rw-r--r--gnu-efi/gnu-efi-3.0/lib/smbios.c126
-rw-r--r--gnu-efi/gnu-efi-3.0/lib/sread.c358
-rw-r--r--gnu-efi/gnu-efi-3.0/lib/str.c379
-rw-r--r--gnu-efi/gnu-efi-3.0/lib/x86_64/callwrap.c40
-rw-r--r--gnu-efi/gnu-efi-3.0/lib/x86_64/efi_stub.S189
-rw-r--r--gnu-efi/gnu-efi-3.0/lib/x86_64/initplat.c28
-rw-r--r--gnu-efi/gnu-efi-3.0/lib/x86_64/math.c181
-rw-r--r--gpxe/COPYING339
-rw-r--r--gpxe/COPYRIGHTS26
-rw-r--r--gpxe/LOG12
-rw-r--r--gpxe/Makefile56
-rw-r--r--gpxe/README53
-rw-r--r--gpxe/VERSION1
-rw-r--r--gpxe/gpxe.diff73
-rw-r--r--gpxe/pxelinux.gpxe5
-rw-r--r--gpxe/pxelinuxk.gpxe5
-rw-r--r--gpxe/src/Makefile150
-rw-r--r--gpxe/src/Makefile.housekeeping1004
-rw-r--r--gpxe/src/arch/i386/Makefile117
-rw-r--r--gpxe/src/arch/i386/Makefile.efi10
-rw-r--r--gpxe/src/arch/i386/Makefile.pcbios70
-rw-r--r--gpxe/src/arch/i386/README.i386197
-rw-r--r--gpxe/src/arch/i386/core/aout_loader.c144
-rw-r--r--gpxe/src/arch/i386/core/basemem_packet.c32
-rw-r--r--gpxe/src/arch/i386/core/cpu.c73
-rw-r--r--gpxe/src/arch/i386/core/dumpregs.c23
-rw-r--r--gpxe/src/arch/i386/core/freebsd_loader.c377
-rw-r--r--gpxe/src/arch/i386/core/gdbidt.S215
-rw-r--r--gpxe/src/arch/i386/core/gdbmach.c149
-rw-r--r--gpxe/src/arch/i386/core/nulltrap.c51
-rw-r--r--gpxe/src/arch/i386/core/pic8259.c66
-rw-r--r--gpxe/src/arch/i386/core/rdtsc_timer.c89
-rw-r--r--gpxe/src/arch/i386/core/relocate.c170
-rw-r--r--gpxe/src/arch/i386/core/setjmp.S42
-rw-r--r--gpxe/src/arch/i386/core/stack.S15
-rw-r--r--gpxe/src/arch/i386/core/stack16.S15
-rw-r--r--gpxe/src/arch/i386/core/timer2.c87
-rw-r--r--gpxe/src/arch/i386/core/video_subr.c104
-rw-r--r--gpxe/src/arch/i386/core/virtaddr.S103
-rw-r--r--gpxe/src/arch/i386/core/wince_loader.c273
-rw-r--r--gpxe/src/arch/i386/core/x86_io.c96
-rw-r--r--gpxe/src/arch/i386/drivers/net/undi.c148
-rw-r--r--gpxe/src/arch/i386/drivers/net/undiisr.S87
-rw-r--r--gpxe/src/arch/i386/drivers/net/undiload.c171
-rw-r--r--gpxe/src/arch/i386/drivers/net/undinet.c631
-rw-r--r--gpxe/src/arch/i386/drivers/net/undionly.c129
-rw-r--r--gpxe/src/arch/i386/drivers/net/undipreload.c37
-rw-r--r--gpxe/src/arch/i386/drivers/net/undirom.c234
-rw-r--r--gpxe/src/arch/i386/firmware/pcbios/basemem.c46
-rw-r--r--gpxe/src/arch/i386/firmware/pcbios/bios_console.c298
-rw-r--r--gpxe/src/arch/i386/firmware/pcbios/e820mangler.S596
-rw-r--r--gpxe/src/arch/i386/firmware/pcbios/fakee820.c93
-rw-r--r--gpxe/src/arch/i386/firmware/pcbios/gateA20.c176
-rw-r--r--gpxe/src/arch/i386/firmware/pcbios/hidemem.c220
-rw-r--r--gpxe/src/arch/i386/firmware/pcbios/memmap.c312
-rw-r--r--gpxe/src/arch/i386/firmware/pcbios/pnpbios.c109
-rw-r--r--gpxe/src/arch/i386/hci/commands/pxe_cmd.c33
-rw-r--r--gpxe/src/arch/i386/image/bootsector.c114
-rw-r--r--gpxe/src/arch/i386/image/bzimage.c561
-rw-r--r--gpxe/src/arch/i386/image/com32.c285
-rw-r--r--gpxe/src/arch/i386/image/comboot.c322
-rw-r--r--gpxe/src/arch/i386/image/elfboot.c113
-rw-r--r--gpxe/src/arch/i386/image/eltorito.c336
-rw-r--r--gpxe/src/arch/i386/image/multiboot.c466
-rw-r--r--gpxe/src/arch/i386/image/nbi.c442
-rw-r--r--gpxe/src/arch/i386/image/pxe_image.c117
-rw-r--r--gpxe/src/arch/i386/include/basemem.h35
-rw-r--r--gpxe/src/arch/i386/include/basemem_packet.h15
-rw-r--r--gpxe/src/arch/i386/include/bios.h10
-rw-r--r--gpxe/src/arch/i386/include/bios_disks.h69
-rw-r--r--gpxe/src/arch/i386/include/biosint.h33
-rw-r--r--gpxe/src/arch/i386/include/bits/byteswap.h43
-rw-r--r--gpxe/src/arch/i386/include/bits/compiler.h27
-rw-r--r--gpxe/src/arch/i386/include/bits/cpu.h86
-rw-r--r--gpxe/src/arch/i386/include/bits/eltorito.h3
-rw-r--r--gpxe/src/arch/i386/include/bits/endian.h8
-rw-r--r--gpxe/src/arch/i386/include/bits/errfile.h42
-rw-r--r--gpxe/src/arch/i386/include/bits/io.h14
-rw-r--r--gpxe/src/arch/i386/include/bits/nap.h15
-rw-r--r--gpxe/src/arch/i386/include/bits/smbios.h14
-rw-r--r--gpxe/src/arch/i386/include/bits/stdint.h23
-rw-r--r--gpxe/src/arch/i386/include/bits/timer.h15
-rw-r--r--gpxe/src/arch/i386/include/bits/uaccess.h14
-rw-r--r--gpxe/src/arch/i386/include/bits/umalloc.h14
-rw-r--r--gpxe/src/arch/i386/include/bochs.h34
-rw-r--r--gpxe/src/arch/i386/include/bootsector.h14
-rw-r--r--gpxe/src/arch/i386/include/bzimage.h142
-rw-r--r--gpxe/src/arch/i386/include/comboot.h135
-rw-r--r--gpxe/src/arch/i386/include/fakee820.h9
-rw-r--r--gpxe/src/arch/i386/include/gateA20.h7
-rw-r--r--gpxe/src/arch/i386/include/gdbmach.h64
-rw-r--r--gpxe/src/arch/i386/include/gpxe/abft.h37
-rw-r--r--gpxe/src/arch/i386/include/gpxe/bios_nap.h18
-rw-r--r--gpxe/src/arch/i386/include/gpxe/bios_smbios.h18
-rw-r--r--gpxe/src/arch/i386/include/gpxe/bios_timer.h44
-rw-r--r--gpxe/src/arch/i386/include/gpxe/ibft.h302
-rw-r--r--gpxe/src/arch/i386/include/gpxe/memtop_umalloc.h18
-rw-r--r--gpxe/src/arch/i386/include/gpxe/rdtsc_timer.h39
-rw-r--r--gpxe/src/arch/i386/include/gpxe/sbft.h125
-rw-r--r--gpxe/src/arch/i386/include/gpxe/timer2.h14
-rw-r--r--gpxe/src/arch/i386/include/gpxe/x86_io.h153
-rw-r--r--gpxe/src/arch/i386/include/int13.h292
-rw-r--r--gpxe/src/arch/i386/include/kir.h18
-rw-r--r--gpxe/src/arch/i386/include/libkir.h233
-rw-r--r--gpxe/src/arch/i386/include/librm.h206
-rw-r--r--gpxe/src/arch/i386/include/limits.h61
-rw-r--r--gpxe/src/arch/i386/include/memsizes.h19
-rw-r--r--gpxe/src/arch/i386/include/multiboot.h149
-rw-r--r--gpxe/src/arch/i386/include/pic8259.h71
-rw-r--r--gpxe/src/arch/i386/include/pnpbios.h17
-rw-r--r--gpxe/src/arch/i386/include/pxe.h154
-rw-r--r--gpxe/src/arch/i386/include/pxe_api.h1909
-rw-r--r--gpxe/src/arch/i386/include/pxe_call.h57
-rw-r--r--gpxe/src/arch/i386/include/pxe_types.h127
-rw-r--r--gpxe/src/arch/i386/include/pxeparent.h11
-rw-r--r--gpxe/src/arch/i386/include/realmode.h127
-rw-r--r--gpxe/src/arch/i386/include/registers.h198
-rw-r--r--gpxe/src/arch/i386/include/setjmp.h40
-rw-r--r--gpxe/src/arch/i386/include/undi.h106
-rw-r--r--gpxe/src/arch/i386/include/undiload.h35
-rw-r--r--gpxe/src/arch/i386/include/undinet.h17
-rw-r--r--gpxe/src/arch/i386/include/undipreload.h18
-rw-r--r--gpxe/src/arch/i386/include/undirom.h53
-rw-r--r--gpxe/src/arch/i386/include/vga.h228
-rw-r--r--gpxe/src/arch/i386/interface/pcbios/abft.c62
-rw-r--r--gpxe/src/arch/i386/interface/pcbios/aoeboot.c78
-rw-r--r--gpxe/src/arch/i386/interface/pcbios/bios_nap.c16
-rw-r--r--gpxe/src/arch/i386/interface/pcbios/bios_smbios.c86
-rw-r--r--gpxe/src/arch/i386/interface/pcbios/bios_timer.c65
-rw-r--r--gpxe/src/arch/i386/interface/pcbios/biosint.c92
-rw-r--r--gpxe/src/arch/i386/interface/pcbios/ib_srpboot.c73
-rw-r--r--gpxe/src/arch/i386/interface/pcbios/ibft.c451
-rw-r--r--gpxe/src/arch/i386/interface/pcbios/int13.c715
-rw-r--r--gpxe/src/arch/i386/interface/pcbios/iscsiboot.c75
-rw-r--r--gpxe/src/arch/i386/interface/pcbios/keepsan.c26
-rw-r--r--gpxe/src/arch/i386/interface/pcbios/memtop_umalloc.c202
-rw-r--r--gpxe/src/arch/i386/interface/pcbios/pcibios.c115
-rw-r--r--gpxe/src/arch/i386/interface/pcbios/sbft.c105
-rw-r--r--gpxe/src/arch/i386/interface/pxe/pxe_call.c509
-rw-r--r--gpxe/src/arch/i386/interface/pxe/pxe_entry.S216
-rw-r--r--gpxe/src/arch/i386/interface/pxe/pxe_errors.c103
-rw-r--r--gpxe/src/arch/i386/interface/pxe/pxe_file.c306
-rw-r--r--gpxe/src/arch/i386/interface/pxe/pxe_loader.c50
-rw-r--r--gpxe/src/arch/i386/interface/pxe/pxe_preboot.c357
-rw-r--r--gpxe/src/arch/i386/interface/pxe/pxe_tftp.c586
-rw-r--r--gpxe/src/arch/i386/interface/pxe/pxe_udp.c405
-rw-r--r--gpxe/src/arch/i386/interface/pxe/pxe_undi.c791
-rw-r--r--gpxe/src/arch/i386/interface/pxeparent/pxeparent.c201
-rw-r--r--gpxe/src/arch/i386/interface/pxeparent/pxeparent_dhcp.c69
-rw-r--r--gpxe/src/arch/i386/interface/syslinux/com32_call.c190
-rw-r--r--gpxe/src/arch/i386/interface/syslinux/com32_wrapper.S94
-rw-r--r--gpxe/src/arch/i386/interface/syslinux/comboot_call.c716
-rw-r--r--gpxe/src/arch/i386/interface/syslinux/comboot_resolv.c60
-rw-r--r--gpxe/src/arch/i386/kir-Makefile26
-rw-r--r--gpxe/src/arch/i386/prefix/bootpart.S218
-rw-r--r--gpxe/src/arch/i386/prefix/dskprefix.S381
-rw-r--r--gpxe/src/arch/i386/prefix/hdprefix.S109
-rw-r--r--gpxe/src/arch/i386/prefix/hromprefix.S12
-rw-r--r--gpxe/src/arch/i386/prefix/kkpxeprefix.S13
-rw-r--r--gpxe/src/arch/i386/prefix/kpxeprefix.S9
-rw-r--r--gpxe/src/arch/i386/prefix/libprefix.S819
-rw-r--r--gpxe/src/arch/i386/prefix/lkrnprefix.S216
-rw-r--r--gpxe/src/arch/i386/prefix/mbr.S13
-rw-r--r--gpxe/src/arch/i386/prefix/nbiprefix.S77
-rw-r--r--gpxe/src/arch/i386/prefix/nullprefix.S13
-rw-r--r--gpxe/src/arch/i386/prefix/pxeprefix.S761
-rw-r--r--gpxe/src/arch/i386/prefix/romprefix.S1079
-rw-r--r--gpxe/src/arch/i386/prefix/undiloader.S49
-rw-r--r--gpxe/src/arch/i386/prefix/unnrv2b.S184
-rw-r--r--gpxe/src/arch/i386/prefix/unnrv2b16.S9
-rw-r--r--gpxe/src/arch/i386/prefix/usbdisk.S23
-rw-r--r--gpxe/src/arch/i386/prefix/xromprefix.S9
-rw-r--r--gpxe/src/arch/i386/scripts/i386-kir.lds197
-rw-r--r--gpxe/src/arch/i386/scripts/i386.lds202
-rw-r--r--gpxe/src/arch/i386/transitions/libkir.S256
-rw-r--r--gpxe/src/arch/i386/transitions/libpm.S0
-rw-r--r--gpxe/src/arch/i386/transitions/librm.S581
-rw-r--r--gpxe/src/arch/i386/transitions/librm_mgmt.c58
-rw-r--r--gpxe/src/arch/x86/Makefile9
-rw-r--r--gpxe/src/arch/x86/Makefile.efi28
-rw-r--r--gpxe/src/arch/x86/core/pcidirect.c47
-rw-r--r--gpxe/src/arch/x86/core/x86_string.c63
-rw-r--r--gpxe/src/arch/x86/include/bits/pci_io.h15
-rw-r--r--gpxe/src/arch/x86/include/bits/string.h252
-rw-r--r--gpxe/src/arch/x86/include/gpxe/efi/efix86_nap.h18
-rw-r--r--gpxe/src/arch/x86/include/gpxe/pcibios.h135
-rw-r--r--gpxe/src/arch/x86/include/gpxe/pcidirect.h141
-rw-r--r--gpxe/src/arch/x86/interface/efi/efix86_nap.c48
-rw-r--r--gpxe/src/arch/x86/prefix/efidrvprefix.c46
-rw-r--r--gpxe/src/arch/x86/prefix/efiprefix.c41
-rw-r--r--gpxe/src/arch/x86/scripts/efi.lds106
-rw-r--r--gpxe/src/arch/x86_64/Makefile41
-rw-r--r--gpxe/src/arch/x86_64/Makefile.efi14
-rw-r--r--gpxe/src/arch/x86_64/include/bits/byteswap.h22
-rw-r--r--gpxe/src/arch/x86_64/include/bits/compiler.h14
-rw-r--r--gpxe/src/arch/x86_64/include/bits/endian.h6
-rw-r--r--gpxe/src/arch/x86_64/include/bits/errfile.h11
-rw-r--r--gpxe/src/arch/x86_64/include/bits/io.h10
-rw-r--r--gpxe/src/arch/x86_64/include/bits/nap.h12
-rw-r--r--gpxe/src/arch/x86_64/include/bits/smbios.h10
-rw-r--r--gpxe/src/arch/x86_64/include/bits/stdint.h21
-rw-r--r--gpxe/src/arch/x86_64/include/bits/timer.h10
-rw-r--r--gpxe/src/arch/x86_64/include/bits/uaccess.h10
-rw-r--r--gpxe/src/arch/x86_64/include/bits/umalloc.h10
-rw-r--r--gpxe/src/arch/x86_64/include/gdbmach.h51
-rw-r--r--gpxe/src/arch/x86_64/include/limits.h59
-rw-r--r--gpxe/src/config/config.c262
-rw-r--r--gpxe/src/config/config_net80211.c50
-rw-r--r--gpxe/src/config/config_romprefix.c24
-rw-r--r--gpxe/src/config/console.h23
-rw-r--r--gpxe/src/config/defaults.h10
-rw-r--r--gpxe/src/config/defaults/efi.h21
-rw-r--r--gpxe/src/config/defaults/pcbios.h35
-rw-r--r--gpxe/src/config/general.h148
-rw-r--r--gpxe/src/config/ioapi.h17
-rw-r--r--gpxe/src/config/isa.h15
-rw-r--r--gpxe/src/config/nap.h17
-rw-r--r--gpxe/src/config/serial.h35
-rw-r--r--gpxe/src/config/timer.h17
-rw-r--r--gpxe/src/config/umalloc.h14
-rw-r--r--gpxe/src/core/acpi.c42
-rw-r--r--gpxe/src/core/ansiesc.c116
-rw-r--r--gpxe/src/core/asprintf.c49
-rw-r--r--gpxe/src/core/base64.c68
-rw-r--r--gpxe/src/core/basename.c64
-rw-r--r--gpxe/src/core/bitmap.c101
-rw-r--r--gpxe/src/core/bitops.c13
-rw-r--r--gpxe/src/core/btext.c5039
-rw-r--r--gpxe/src/core/console.c130
-rw-r--r--gpxe/src/core/cpio.c42
-rw-r--r--gpxe/src/core/ctype.c48
-rw-r--r--gpxe/src/core/cwuri.c46
-rw-r--r--gpxe/src/core/debug.c196
-rw-r--r--gpxe/src/core/device.c107
-rw-r--r--gpxe/src/core/downloader.c291
-rw-r--r--gpxe/src/core/errno.c18
-rw-r--r--gpxe/src/core/exec.c251
-rw-r--r--gpxe/src/core/filter.c74
-rw-r--r--gpxe/src/core/gdbserial.c46
-rw-r--r--gpxe/src/core/gdbstub.c397
-rw-r--r--gpxe/src/core/gdbudp.c257
-rw-r--r--gpxe/src/core/getkey.c83
-rw-r--r--gpxe/src/core/getopt.c273
-rw-r--r--gpxe/src/core/hw.c74
-rw-r--r--gpxe/src/core/i82365.c656
-rw-r--r--gpxe/src/core/image.c328
-rw-r--r--gpxe/src/core/init.c98
-rw-r--r--gpxe/src/core/interface.c62
-rw-r--r--gpxe/src/core/iobuf.c96
-rw-r--r--gpxe/src/core/job.c97
-rw-r--r--gpxe/src/core/linebuf.c111
-rw-r--r--gpxe/src/core/main.c91
-rw-r--r--gpxe/src/core/malloc.c386
-rw-r--r--gpxe/src/core/misc.c80
-rw-r--r--gpxe/src/core/monojob.c103
-rw-r--r--gpxe/src/core/null_nap.c3
-rw-r--r--gpxe/src/core/nvo.c263
-rw-r--r--gpxe/src/core/open.c197
-rw-r--r--gpxe/src/core/pc_kbd.c112
-rw-r--r--gpxe/src/core/pcmcia.c267
-rw-r--r--gpxe/src/core/posix_io.c355
-rw-r--r--gpxe/src/core/process.c106
-rw-r--r--gpxe/src/core/proto_eth_slow.c406
-rw-r--r--gpxe/src/core/random.c41
-rw-r--r--gpxe/src/core/refcnt.c78
-rw-r--r--gpxe/src/core/resolv.c415
-rw-r--r--gpxe/src/core/serial.c254
-rw-r--r--gpxe/src/core/serial_console.c31
-rw-r--r--gpxe/src/core/settings.c1456
-rw-r--r--gpxe/src/core/string.c355
-rw-r--r--gpxe/src/core/stringextra.c273
-rw-r--r--gpxe/src/core/timer.c42
-rw-r--r--gpxe/src/core/uri.c492
-rw-r--r--gpxe/src/core/uuid.c50
-rw-r--r--gpxe/src/core/vsprintf.c423
-rw-r--r--gpxe/src/core/xfer.c417
-rw-r--r--gpxe/src/crypto/aes_wrap.c123
-rw-r--r--gpxe/src/crypto/arc4.c131
-rw-r--r--gpxe/src/crypto/asn1.c166
-rw-r--r--gpxe/src/crypto/axtls/aes.c476
-rw-r--r--gpxe/src/crypto/axtls/bigint.c1496
-rw-r--r--gpxe/src/crypto/axtls/bigint.h91
-rw-r--r--gpxe/src/crypto/axtls/bigint_impl.h105
-rw-r--r--gpxe/src/crypto/axtls/crypto.h300
-rw-r--r--gpxe/src/crypto/axtls/os_port.h61
-rw-r--r--gpxe/src/crypto/axtls/rsa.c332
-rw-r--r--gpxe/src/crypto/axtls/sha1.c240
-rw-r--r--gpxe/src/crypto/axtls_aes.c158
-rw-r--r--gpxe/src/crypto/axtls_sha1.c25
-rw-r--r--gpxe/src/crypto/cbc.c101
-rw-r--r--gpxe/src/crypto/chap.c124
-rw-r--r--gpxe/src/crypto/crandom.c55
-rw-r--r--gpxe/src/crypto/crc32.c54
-rw-r--r--gpxe/src/crypto/crypto_null.c87
-rw-r--r--gpxe/src/crypto/hmac.c122
-rw-r--r--gpxe/src/crypto/md5.c234
-rw-r--r--gpxe/src/crypto/sha1extra.c165
-rw-r--r--gpxe/src/crypto/x509.c183
-rw-r--r--gpxe/src/doc/build_sys.dox419
-rw-r--r--gpxe/src/doc/pxe_extensions312
-rw-r--r--gpxe/src/doxygen.cfg1487
-rw-r--r--gpxe/src/drivers/bitbash/bitbash.c57
-rw-r--r--gpxe/src/drivers/bitbash/i2c_bit.c393
-rw-r--r--gpxe/src/drivers/bitbash/spi_bit.c225
-rw-r--r--gpxe/src/drivers/block/ata.c188
-rw-r--r--gpxe/src/drivers/block/ramdisk.c97
-rw-r--r--gpxe/src/drivers/block/scsi.c366
-rw-r--r--gpxe/src/drivers/block/srp.c523
-rw-r--r--gpxe/src/drivers/bus/eisa.c182
-rw-r--r--gpxe/src/drivers/bus/isa.c172
-rw-r--r--gpxe/src/drivers/bus/isa_ids.c26
-rw-r--r--gpxe/src/drivers/bus/isapnp.c755
-rw-r--r--gpxe/src/drivers/bus/mca.c177
-rw-r--r--gpxe/src/drivers/bus/pci.c341
-rw-r--r--gpxe/src/drivers/bus/pcibackup.c90
-rw-r--r--gpxe/src/drivers/bus/pciextra.c86
-rw-r--r--gpxe/src/drivers/bus/virtio-pci.c64
-rw-r--r--gpxe/src/drivers/bus/virtio-ring.c134
-rw-r--r--gpxe/src/drivers/infiniband/MT25218_PRM.h3462
-rw-r--r--gpxe/src/drivers/infiniband/MT25408_PRM.h3319
-rw-r--r--gpxe/src/drivers/infiniband/arbel.c2247
-rw-r--r--gpxe/src/drivers/infiniband/arbel.h544
-rw-r--r--gpxe/src/drivers/infiniband/hermon.c2752
-rw-r--r--gpxe/src/drivers/infiniband/hermon.h610
-rw-r--r--gpxe/src/drivers/infiniband/linda.c2432
-rw-r--r--gpxe/src/drivers/infiniband/linda.h276
-rw-r--r--gpxe/src/drivers/infiniband/linda_fw.c1069
-rw-r--r--gpxe/src/drivers/infiniband/mlx_bitops.h223
-rw-r--r--gpxe/src/drivers/infiniband/qib_7220_regs.h1762
-rwxr-xr-xgpxe/src/drivers/infiniband/qib_genbits.pl116
-rw-r--r--gpxe/src/drivers/net/3c503.c5
-rw-r--r--gpxe/src/drivers/net/3c509-eisa.c49
-rw-r--r--gpxe/src/drivers/net/3c509.c432
-rw-r--r--gpxe/src/drivers/net/3c509.h394
-rw-r--r--gpxe/src/drivers/net/3c515.c763
-rw-r--r--gpxe/src/drivers/net/3c515.txt31
-rw-r--r--gpxe/src/drivers/net/3c529.c62
-rw-r--r--gpxe/src/drivers/net/3c595.c553
-rw-r--r--gpxe/src/drivers/net/3c595.h437
-rw-r--r--gpxe/src/drivers/net/3c5x9.c416
-rw-r--r--gpxe/src/drivers/net/3c90x.c994
-rw-r--r--gpxe/src/drivers/net/3c90x.h302
-rw-r--r--gpxe/src/drivers/net/amd8111e.c693
-rw-r--r--gpxe/src/drivers/net/amd8111e.h631
-rw-r--r--gpxe/src/drivers/net/ath5k/ath5k.c1700
-rw-r--r--gpxe/src/drivers/net/ath5k/ath5k.h1279
-rw-r--r--gpxe/src/drivers/net/ath5k/ath5k_attach.c340
-rw-r--r--gpxe/src/drivers/net/ath5k/ath5k_caps.c154
-rw-r--r--gpxe/src/drivers/net/ath5k/ath5k_desc.c544
-rw-r--r--gpxe/src/drivers/net/ath5k/ath5k_dma.c631
-rw-r--r--gpxe/src/drivers/net/ath5k/ath5k_eeprom.c1760
-rw-r--r--gpxe/src/drivers/net/ath5k/ath5k_gpio.c122
-rw-r--r--gpxe/src/drivers/net/ath5k/ath5k_initvals.c1560
-rw-r--r--gpxe/src/drivers/net/ath5k/ath5k_pcu.c534
-rw-r--r--gpxe/src/drivers/net/ath5k/ath5k_phy.c2586
-rw-r--r--gpxe/src/drivers/net/ath5k/ath5k_qcu.c394
-rw-r--r--gpxe/src/drivers/net/ath5k/ath5k_reset.c1176
-rw-r--r--gpxe/src/drivers/net/ath5k/ath5k_rfkill.c107
-rw-r--r--gpxe/src/drivers/net/ath5k/base.h145
-rw-r--r--gpxe/src/drivers/net/ath5k/desc.h332
-rw-r--r--gpxe/src/drivers/net/ath5k/eeprom.h451
-rw-r--r--gpxe/src/drivers/net/ath5k/reg.h2589
-rw-r--r--gpxe/src/drivers/net/ath5k/rfbuffer.h1181
-rw-r--r--gpxe/src/drivers/net/ath5k/rfgain.h516
-rw-r--r--gpxe/src/drivers/net/atl1e.c1758
-rw-r--r--gpxe/src/drivers/net/atl1e.h1031
-rw-r--r--gpxe/src/drivers/net/b44.c951
-rw-r--r--gpxe/src/drivers/net/b44.h470
-rw-r--r--gpxe/src/drivers/net/bnx2.c2697
-rw-r--r--gpxe/src/drivers/net/bnx2.h4598
-rw-r--r--gpxe/src/drivers/net/bnx2_fw.h3494
-rw-r--r--gpxe/src/drivers/net/cs89x0.c739
-rw-r--r--gpxe/src/drivers/net/cs89x0.h481
-rw-r--r--gpxe/src/drivers/net/cs89x0.txt45
-rw-r--r--gpxe/src/drivers/net/davicom.c727
-rw-r--r--gpxe/src/drivers/net/depca.c805
-rw-r--r--gpxe/src/drivers/net/dmfe.c1226
-rw-r--r--gpxe/src/drivers/net/e1000/e1000.c1189
-rw-r--r--gpxe/src/drivers/net/e1000/e1000.h306
-rw-r--r--gpxe/src/drivers/net/e1000/e1000_hw.c9174
-rw-r--r--gpxe/src/drivers/net/e1000/e1000_hw.h3431
-rw-r--r--gpxe/src/drivers/net/e1000/e1000_osdep.h143
-rw-r--r--gpxe/src/drivers/net/eepro.c637
-rw-r--r--gpxe/src/drivers/net/eepro100.c1207
-rw-r--r--gpxe/src/drivers/net/eepro100.h206
-rw-r--r--gpxe/src/drivers/net/epic100.c539
-rw-r--r--gpxe/src/drivers/net/epic100.h190
-rw-r--r--gpxe/src/drivers/net/etherfabric.c4236
-rw-r--r--gpxe/src/drivers/net/etherfabric.h553
-rw-r--r--gpxe/src/drivers/net/etherfabric_nic.h204
-rw-r--r--gpxe/src/drivers/net/forcedeth.c1444
-rw-r--r--gpxe/src/drivers/net/hfa384x.h3069
-rw-r--r--gpxe/src/drivers/net/ipoib.c782
-rw-r--r--gpxe/src/drivers/net/legacy.c157
-rw-r--r--gpxe/src/drivers/net/mtd80x.c1022
-rw-r--r--gpxe/src/drivers/net/mtnic.c1853
-rw-r--r--gpxe/src/drivers/net/mtnic.h722
-rw-r--r--gpxe/src/drivers/net/myri10ge.c1041
-rw-r--r--gpxe/src/drivers/net/myri10ge_mcp.h514
-rw-r--r--gpxe/src/drivers/net/natsemi.c609
-rw-r--r--gpxe/src/drivers/net/natsemi.h232
-rw-r--r--gpxe/src/drivers/net/ne.c6
-rw-r--r--gpxe/src/drivers/net/ne2k_isa.c375
-rw-r--r--gpxe/src/drivers/net/ns83820.c1014
-rw-r--r--gpxe/src/drivers/net/ns8390.c1037
-rw-r--r--gpxe/src/drivers/net/ns8390.h240
-rw-r--r--gpxe/src/drivers/net/p80211hdr.h301
-rw-r--r--gpxe/src/drivers/net/pcnet32.c1021
-rw-r--r--gpxe/src/drivers/net/phantom/nx_bitops.h194
-rw-r--r--gpxe/src/drivers/net/phantom/nxhal_nic_interface.h501
-rw-r--r--gpxe/src/drivers/net/phantom/phantom.c2112
-rw-r--r--gpxe/src/drivers/net/phantom/phantom.h194
-rw-r--r--gpxe/src/drivers/net/phantom/phantom_hw.h184
-rw-r--r--gpxe/src/drivers/net/pnic.c281
-rw-r--r--gpxe/src/drivers/net/pnic_api.h61
-rw-r--r--gpxe/src/drivers/net/prism2.c857
-rw-r--r--gpxe/src/drivers/net/prism2_pci.c58
-rw-r--r--gpxe/src/drivers/net/prism2_plx.c122
-rw-r--r--gpxe/src/drivers/net/r8169.c2285
-rw-r--r--gpxe/src/drivers/net/r8169.h487
-rw-r--r--gpxe/src/drivers/net/rtl8139.c594
-rw-r--r--gpxe/src/drivers/net/rtl818x/rtl8180.c17
-rw-r--r--gpxe/src/drivers/net/rtl818x/rtl8180_grf5101.c186
-rw-r--r--gpxe/src/drivers/net/rtl818x/rtl8180_max2820.c158
-rw-r--r--gpxe/src/drivers/net/rtl818x/rtl8180_sa2400.c217
-rw-r--r--gpxe/src/drivers/net/rtl818x/rtl8185.c14
-rw-r--r--gpxe/src/drivers/net/rtl818x/rtl8185_rtl8225.c804
-rw-r--r--gpxe/src/drivers/net/rtl818x/rtl818x.c855
-rw-r--r--gpxe/src/drivers/net/rtl818x/rtl818x.h359
-rw-r--r--gpxe/src/drivers/net/sis190.c1179
-rw-r--r--gpxe/src/drivers/net/sis190.h311
-rw-r--r--gpxe/src/drivers/net/sis900.c1304
-rw-r--r--gpxe/src/drivers/net/sis900.h375
-rwxr-xr-xgpxe/src/drivers/net/skge.c2472
-rwxr-xr-xgpxe/src/drivers/net/skge.h2623
-rw-r--r--gpxe/src/drivers/net/sky2.c2399
-rw-r--r--gpxe/src/drivers/net/sky2.h2176
-rw-r--r--gpxe/src/drivers/net/smc9000.c955
-rw-r--r--gpxe/src/drivers/net/smc9000.h428
-rw-r--r--gpxe/src/drivers/net/sundance.c897
-rw-r--r--gpxe/src/drivers/net/tg3.c3435
-rw-r--r--gpxe/src/drivers/net/tg3.h2121
-rw-r--r--gpxe/src/drivers/net/tlan.c1723
-rw-r--r--gpxe/src/drivers/net/tlan.h491
-rw-r--r--gpxe/src/drivers/net/tulip.c2099
-rw-r--r--gpxe/src/drivers/net/tulip.txt54
-rw-r--r--gpxe/src/drivers/net/via-rhine.c1447
-rw-r--r--gpxe/src/drivers/net/via-velocity.c1939
-rw-r--r--gpxe/src/drivers/net/via-velocity.h1930
-rw-r--r--gpxe/src/drivers/net/virtio-net.c307
-rw-r--r--gpxe/src/drivers/net/virtio-net.h44
-rw-r--r--gpxe/src/drivers/net/w89c840.c964
-rw-r--r--gpxe/src/drivers/net/wd.c6
-rw-r--r--gpxe/src/drivers/net/wlan_compat.h577
-rw-r--r--gpxe/src/drivers/nvs/nvs.c149
-rw-r--r--gpxe/src/drivers/nvs/spi.c140
-rw-r--r--gpxe/src/drivers/nvs/threewire.c131
-rw-r--r--gpxe/src/hci/commands/autoboot_cmd.c27
-rw-r--r--gpxe/src/hci/commands/config_cmd.c39
-rw-r--r--gpxe/src/hci/commands/dhcp_cmd.c190
-rw-r--r--gpxe/src/hci/commands/digest_cmd.c120
-rw-r--r--gpxe/src/hci/commands/gdbstub_cmd.c105
-rw-r--r--gpxe/src/hci/commands/ifmgmt_cmd.c180
-rw-r--r--gpxe/src/hci/commands/image_cmd.c608
-rw-r--r--gpxe/src/hci/commands/iwmgmt_cmd.c69
-rw-r--r--gpxe/src/hci/commands/login_cmd.c29
-rw-r--r--gpxe/src/hci/commands/nvo_cmd.c79
-rw-r--r--gpxe/src/hci/commands/route_cmd.c87
-rw-r--r--gpxe/src/hci/commands/sanboot_cmd.c70
-rw-r--r--gpxe/src/hci/commands/time_cmd.c84
-rw-r--r--gpxe/src/hci/editstring.c192
-rw-r--r--gpxe/src/hci/mucurses/alert.c18
-rw-r--r--gpxe/src/hci/mucurses/ansi_screen.c74
-rw-r--r--gpxe/src/hci/mucurses/clear.c90
-rw-r--r--gpxe/src/hci/mucurses/colour.c66
-rw-r--r--gpxe/src/hci/mucurses/cursor.h37
-rw-r--r--gpxe/src/hci/mucurses/edging.c111
-rw-r--r--gpxe/src/hci/mucurses/kb.c143
-rw-r--r--gpxe/src/hci/mucurses/mucurses.c147
-rw-r--r--gpxe/src/hci/mucurses/mucurses.h23
-rw-r--r--gpxe/src/hci/mucurses/print.c86
-rw-r--r--gpxe/src/hci/mucurses/print_nadv.c26
-rw-r--r--gpxe/src/hci/mucurses/slk.c363
-rw-r--r--gpxe/src/hci/mucurses/widgets/editbox.c103
-rw-r--r--gpxe/src/hci/mucurses/winattrs.c133
-rw-r--r--gpxe/src/hci/mucurses/windows.c158
-rw-r--r--gpxe/src/hci/mucurses/wininit.c37
-rw-r--r--gpxe/src/hci/readline.c119
-rw-r--r--gpxe/src/hci/shell.c102
-rw-r--r--gpxe/src/hci/shell_banner.c64
-rw-r--r--gpxe/src/hci/strerror.c122
-rw-r--r--gpxe/src/hci/tui/login_ui.c137
-rw-r--r--gpxe/src/hci/tui/settings_ui.c427
-rw-r--r--gpxe/src/hci/wireless_errors.c118
-rw-r--r--gpxe/src/image/efi_image.c108
-rw-r--r--gpxe/src/image/elf.c162
-rw-r--r--gpxe/src/image/embedded.c101
-rw-r--r--gpxe/src/image/script.c126
-rw-r--r--gpxe/src/image/segment.c87
-rw-r--r--gpxe/src/include/alloca.h25
-rw-r--r--gpxe/src/include/assert.h67
-rw-r--r--gpxe/src/include/big_bswap.h33
-rw-r--r--gpxe/src/include/bootp.h230
-rw-r--r--gpxe/src/include/btext.h62
-rw-r--r--gpxe/src/include/byteswap.h59
-rw-r--r--gpxe/src/include/cmdline.h8
-rw-r--r--gpxe/src/include/cmdlinelib.h99
-rw-r--r--gpxe/src/include/cmdlist.h18
-rw-r--r--gpxe/src/include/coff.h73
-rw-r--r--gpxe/src/include/compiler.h650
-rw-r--r--gpxe/src/include/console.h119
-rw-r--r--gpxe/src/include/cpu.h6
-rw-r--r--gpxe/src/include/ctype.h31
-rw-r--r--gpxe/src/include/curses.h755
-rw-r--r--gpxe/src/include/elf.h234
-rw-r--r--gpxe/src/include/endian.h21
-rw-r--r--gpxe/src/include/errno.h510
-rw-r--r--gpxe/src/include/etherboot.h44
-rw-r--r--gpxe/src/include/fs.h41
-rw-r--r--gpxe/src/include/getopt.h94
-rw-r--r--gpxe/src/include/gpxe/acpi.h43
-rw-r--r--gpxe/src/include/gpxe/aes.h30
-rw-r--r--gpxe/src/include/gpxe/ansiesc.h120
-rw-r--r--gpxe/src/include/gpxe/aoe.h150
-rw-r--r--gpxe/src/include/gpxe/api.h84
-rw-r--r--gpxe/src/include/gpxe/arc4.h22
-rw-r--r--gpxe/src/include/gpxe/arp.h46
-rw-r--r--gpxe/src/include/gpxe/asn1.h34
-rw-r--r--gpxe/src/include/gpxe/ata.h209
-rw-r--r--gpxe/src/include/gpxe/base64.h26
-rw-r--r--gpxe/src/include/gpxe/bitbash.h52
-rw-r--r--gpxe/src/include/gpxe/bitmap.h85
-rw-r--r--gpxe/src/include/gpxe/bitops.h230
-rw-r--r--gpxe/src/include/gpxe/blockdev.h53
-rw-r--r--gpxe/src/include/gpxe/cbc.h100
-rw-r--r--gpxe/src/include/gpxe/chap.h53
-rw-r--r--gpxe/src/include/gpxe/command.h26
-rw-r--r--gpxe/src/include/gpxe/cpio.h53
-rw-r--r--gpxe/src/include/gpxe/crc32.h10
-rw-r--r--gpxe/src/include/gpxe/crypto.h156
-rw-r--r--gpxe/src/include/gpxe/device.h113
-rw-r--r--gpxe/src/include/gpxe/dhcp.h637
-rw-r--r--gpxe/src/include/gpxe/dhcpopts.h34
-rw-r--r--gpxe/src/include/gpxe/dhcppkt.h64
-rw-r--r--gpxe/src/include/gpxe/dns.h92
-rw-r--r--gpxe/src/include/gpxe/downloader.h19
-rw-r--r--gpxe/src/include/gpxe/eapol.h112
-rw-r--r--gpxe/src/include/gpxe/editbox.h61
-rw-r--r--gpxe/src/include/gpxe/editstring.h33
-rw-r--r--gpxe/src/include/gpxe/efi/Base.h329
-rw-r--r--gpxe/src/include/gpxe/efi/Guid/PcAnsi.h58
-rw-r--r--gpxe/src/include/gpxe/efi/Guid/SmBios.h34
-rw-r--r--gpxe/src/include/gpxe/efi/Ia32/ProcessorBind.h215
-rw-r--r--gpxe/src/include/gpxe/efi/IndustryStandard/Pci22.h601
-rw-r--r--gpxe/src/include/gpxe/efi/IndustryStandard/PeImage.h752
-rw-r--r--gpxe/src/include/gpxe/efi/LICENCE40
-rw-r--r--gpxe/src/include/gpxe/efi/Pi/PiBootMode.h43
-rw-r--r--gpxe/src/include/gpxe/efi/Pi/PiDependency.h47
-rw-r--r--gpxe/src/include/gpxe/efi/Pi/PiDxeCis.h642
-rw-r--r--gpxe/src/include/gpxe/efi/Pi/PiFirmwareFile.h242
-rw-r--r--gpxe/src/include/gpxe/efi/Pi/PiFirmwareVolume.h154
-rw-r--r--gpxe/src/include/gpxe/efi/Pi/PiHob.h295
-rw-r--r--gpxe/src/include/gpxe/efi/Pi/PiMultiPhase.h104
-rw-r--r--gpxe/src/include/gpxe/efi/PiDxe.h25
-rw-r--r--gpxe/src/include/gpxe/efi/ProcessorBind.h14
-rw-r--r--gpxe/src/include/gpxe/efi/Protocol/ComponentName2.h174
-rw-r--r--gpxe/src/include/gpxe/efi/Protocol/Cpu.h291
-rw-r--r--gpxe/src/include/gpxe/efi/Protocol/CpuIo.h128
-rw-r--r--gpxe/src/include/gpxe/efi/Protocol/DebugSupport.h634
-rw-r--r--gpxe/src/include/gpxe/efi/Protocol/DevicePath.h535
-rw-r--r--gpxe/src/include/gpxe/efi/Protocol/DriverBinding.h153
-rw-r--r--gpxe/src/include/gpxe/efi/Protocol/NetworkInterfaceIdentifier.h74
-rw-r--r--gpxe/src/include/gpxe/efi/Protocol/PciIo.h519
-rw-r--r--gpxe/src/include/gpxe/efi/Protocol/PciRootBridgeIo.h393
-rw-r--r--gpxe/src/include/gpxe/efi/Protocol/SimpleNetwork.h593
-rw-r--r--gpxe/src/include/gpxe/efi/Protocol/SimpleTextIn.h136
-rw-r--r--gpxe/src/include/gpxe/efi/Protocol/SimpleTextOut.h404
-rw-r--r--gpxe/src/include/gpxe/efi/Uefi.h27
-rw-r--r--gpxe/src/include/gpxe/efi/Uefi/UefiBaseType.h200
-rw-r--r--gpxe/src/include/gpxe/efi/Uefi/UefiGpt.h62
-rw-r--r--gpxe/src/include/gpxe/efi/Uefi/UefiInternalFormRepresentation.h1590
-rw-r--r--gpxe/src/include/gpxe/efi/Uefi/UefiMultiPhase.h210
-rw-r--r--gpxe/src/include/gpxe/efi/Uefi/UefiPxe.h1756
-rw-r--r--gpxe/src/include/gpxe/efi/Uefi/UefiSpec.h1916
-rw-r--r--gpxe/src/include/gpxe/efi/X64/ProcessorBind.h247
-rw-r--r--gpxe/src/include/gpxe/efi/efi.h142
-rw-r--r--gpxe/src/include/gpxe/efi/efi_io.h180
-rw-r--r--gpxe/src/include/gpxe/efi/efi_pci.h148
-rw-r--r--gpxe/src/include/gpxe/efi/efi_smbios.h18
-rw-r--r--gpxe/src/include/gpxe/efi/efi_timer.h18
-rw-r--r--gpxe/src/include/gpxe/efi/efi_uaccess.h90
-rw-r--r--gpxe/src/include/gpxe/efi/efi_umalloc.h18
-rwxr-xr-xgpxe/src/include/gpxe/efi/import.pl75
-rw-r--r--gpxe/src/include/gpxe/eisa.h130
-rw-r--r--gpxe/src/include/gpxe/elf.h17
-rw-r--r--gpxe/src/include/gpxe/errfile.h207
-rw-r--r--gpxe/src/include/gpxe/errortab.h23
-rw-r--r--gpxe/src/include/gpxe/ethernet.h21
-rw-r--r--gpxe/src/include/gpxe/fakedhcp.h23
-rw-r--r--gpxe/src/include/gpxe/features.h103
-rw-r--r--gpxe/src/include/gpxe/filter.h75
-rw-r--r--gpxe/src/include/gpxe/ftp.h15
-rw-r--r--gpxe/src/include/gpxe/gdbserial.h21
-rw-r--r--gpxe/src/include/gpxe/gdbstub.h77
-rw-r--r--gpxe/src/include/gpxe/gdbudp.h24
-rw-r--r--gpxe/src/include/gpxe/hidemem.h17
-rw-r--r--gpxe/src/include/gpxe/hmac.h32
-rw-r--r--gpxe/src/include/gpxe/http.h23
-rw-r--r--gpxe/src/include/gpxe/i2c.h171
-rw-r--r--gpxe/src/include/gpxe/ib_cm.h72
-rw-r--r--gpxe/src/include/gpxe/ib_cmrc.h20
-rw-r--r--gpxe/src/include/gpxe/ib_mad.h561
-rw-r--r--gpxe/src/include/gpxe/ib_mcast.h48
-rw-r--r--gpxe/src/include/gpxe/ib_mi.h135
-rw-r--r--gpxe/src/include/gpxe/ib_packet.h147
-rw-r--r--gpxe/src/include/gpxe/ib_pathrec.h76
-rw-r--r--gpxe/src/include/gpxe/ib_sma.h20
-rw-r--r--gpxe/src/include/gpxe/ib_smc.h20
-rw-r--r--gpxe/src/include/gpxe/ib_srp.h79
-rw-r--r--gpxe/src/include/gpxe/icmp.h25
-rw-r--r--gpxe/src/include/gpxe/icmp6.h59
-rw-r--r--gpxe/src/include/gpxe/ieee80211.h1160
-rw-r--r--gpxe/src/include/gpxe/if_arp.h102
-rw-r--r--gpxe/src/include/gpxe/if_ether.h36
-rw-r--r--gpxe/src/include/gpxe/image.h194
-rw-r--r--gpxe/src/include/gpxe/in.h104
-rw-r--r--gpxe/src/include/gpxe/infiniband.h659
-rw-r--r--gpxe/src/include/gpxe/init.h81
-rw-r--r--gpxe/src/include/gpxe/interface.h58
-rw-r--r--gpxe/src/include/gpxe/io.h506
-rw-r--r--gpxe/src/include/gpxe/iobuf.h229
-rw-r--r--gpxe/src/include/gpxe/ip.h97
-rw-r--r--gpxe/src/include/gpxe/ip6.h80
-rw-r--r--gpxe/src/include/gpxe/ipoib.h61
-rw-r--r--gpxe/src/include/gpxe/isa.h97
-rw-r--r--gpxe/src/include/gpxe/isa_ids.h51
-rw-r--r--gpxe/src/include/gpxe/isapnp.h278
-rw-r--r--gpxe/src/include/gpxe/iscsi.h678
-rw-r--r--gpxe/src/include/gpxe/job.h169
-rw-r--r--gpxe/src/include/gpxe/keys.h81
-rw-r--r--gpxe/src/include/gpxe/linebuf.h30
-rw-r--r--gpxe/src/include/gpxe/linux_compat.h27
-rw-r--r--gpxe/src/include/gpxe/list.h180
-rw-r--r--gpxe/src/include/gpxe/login_ui.h14
-rw-r--r--gpxe/src/include/gpxe/malloc.h59
-rw-r--r--gpxe/src/include/gpxe/mca.h108
-rw-r--r--gpxe/src/include/gpxe/md5.h24
-rw-r--r--gpxe/src/include/gpxe/memmap.h36
-rw-r--r--gpxe/src/include/gpxe/monojob.h17
-rw-r--r--gpxe/src/include/gpxe/nap.h56
-rw-r--r--gpxe/src/include/gpxe/ndp.h21
-rw-r--r--gpxe/src/include/gpxe/net80211.h1186
-rw-r--r--gpxe/src/include/gpxe/netdevice.h532
-rw-r--r--gpxe/src/include/gpxe/null_nap.h23
-rw-r--r--gpxe/src/include/gpxe/nvo.h55
-rw-r--r--gpxe/src/include/gpxe/nvs.h68
-rw-r--r--gpxe/src/include/gpxe/open.h105
-rw-r--r--gpxe/src/include/gpxe/pci.h402
-rw-r--r--gpxe/src/include/gpxe/pci_ids.h351
-rw-r--r--gpxe/src/include/gpxe/pci_io.h124
-rw-r--r--gpxe/src/include/gpxe/pcibackup.h33
-rw-r--r--gpxe/src/include/gpxe/posix_io.h87
-rw-r--r--gpxe/src/include/gpxe/process.h80
-rw-r--r--gpxe/src/include/gpxe/profile.h80
-rw-r--r--gpxe/src/include/gpxe/ramdisk.h24
-rw-r--r--gpxe/src/include/gpxe/rarp.h16
-rw-r--r--gpxe/src/include/gpxe/rc80211.h19
-rw-r--r--gpxe/src/include/gpxe/refcnt.h46
-rw-r--r--gpxe/src/include/gpxe/resolv.h170
-rw-r--r--gpxe/src/include/gpxe/retry.h81
-rw-r--r--gpxe/src/include/gpxe/rotate.h29
-rw-r--r--gpxe/src/include/gpxe/rsa.h12
-rw-r--r--gpxe/src/include/gpxe/sanboot.h20
-rw-r--r--gpxe/src/include/gpxe/scsi.h281
-rw-r--r--gpxe/src/include/gpxe/sec80211.h83
-rw-r--r--gpxe/src/include/gpxe/segment.h17
-rw-r--r--gpxe/src/include/gpxe/serial.h16
-rw-r--r--gpxe/src/include/gpxe/settings.h335
-rw-r--r--gpxe/src/include/gpxe/settings_ui.h16
-rw-r--r--gpxe/src/include/gpxe/sha1.h24
-rw-r--r--gpxe/src/include/gpxe/shell.h14
-rw-r--r--gpxe/src/include/gpxe/shell_banner.h14
-rw-r--r--gpxe/src/include/gpxe/smbios.h161
-rw-r--r--gpxe/src/include/gpxe/socket.h101
-rw-r--r--gpxe/src/include/gpxe/spi.h258
-rw-r--r--gpxe/src/include/gpxe/spi_bit.h63
-rw-r--r--gpxe/src/include/gpxe/srp.h868
-rw-r--r--gpxe/src/include/gpxe/tables.h434
-rw-r--r--gpxe/src/include/gpxe/tcp.h318
-rw-r--r--gpxe/src/include/gpxe/tcpip.h128
-rw-r--r--gpxe/src/include/gpxe/tftp.h85
-rw-r--r--gpxe/src/include/gpxe/threewire.h105
-rw-r--r--gpxe/src/include/gpxe/timer.h76
-rw-r--r--gpxe/src/include/gpxe/tls.h187
-rw-r--r--gpxe/src/include/gpxe/uaccess.h344
-rw-r--r--gpxe/src/include/gpxe/udp.h48
-rw-r--r--gpxe/src/include/gpxe/umalloc.h68
-rw-r--r--gpxe/src/include/gpxe/uri.h182
-rw-r--r--gpxe/src/include/gpxe/uuid.h33
-rw-r--r--gpxe/src/include/gpxe/virtio-pci.h97
-rw-r--r--gpxe/src/include/gpxe/virtio-ring.h142
-rw-r--r--gpxe/src/include/gpxe/vsprintf.h74
-rw-r--r--gpxe/src/include/gpxe/wpa.h503
-rw-r--r--gpxe/src/include/gpxe/x509.h41
-rw-r--r--gpxe/src/include/gpxe/xfer.h277
-rw-r--r--gpxe/src/include/hci/ifmgmt_cmd.h30
-rw-r--r--gpxe/src/include/i82365.h450
-rw-r--r--gpxe/src/include/libgen.h9
-rw-r--r--gpxe/src/include/little_bswap.h35
-rw-r--r--gpxe/src/include/mii.h219
-rw-r--r--gpxe/src/include/nic.h273
-rw-r--r--gpxe/src/include/old_tcp.h37
-rw-r--r--gpxe/src/include/pc_kbd.h7
-rw-r--r--gpxe/src/include/pcmcia-opts.h23
-rw-r--r--gpxe/src/include/pcmcia.h156
-rw-r--r--gpxe/src/include/readline/readline.h14
-rw-r--r--gpxe/src/include/stdarg.h12
-rw-r--r--gpxe/src/include/stddef.h26
-rw-r--r--gpxe/src/include/stdint.h36
-rw-r--r--gpxe/src/include/stdio.h47
-rw-r--r--gpxe/src/include/stdlib.h75
-rw-r--r--gpxe/src/include/string.h51
-rw-r--r--gpxe/src/include/strings.h65
-rw-r--r--gpxe/src/include/sys/time.h20
-rw-r--r--gpxe/src/include/sys_info.h33
-rw-r--r--gpxe/src/include/time.h22
-rw-r--r--gpxe/src/include/unistd.h43
-rw-r--r--gpxe/src/include/usr/autoboot.h25
-rw-r--r--gpxe/src/include/usr/dhcpmgmt.h17
-rw-r--r--gpxe/src/include/usr/ifmgmt.h19
-rw-r--r--gpxe/src/include/usr/imgmgmt.h22
-rw-r--r--gpxe/src/include/usr/iwmgmt.h17
-rw-r--r--gpxe/src/include/usr/route.h14
-rw-r--r--gpxe/src/interface/efi/efi_console.c276
-rw-r--r--gpxe/src/interface/efi/efi_init.c112
-rw-r--r--gpxe/src/interface/efi/efi_io.c205
-rw-r--r--gpxe/src/interface/efi/efi_pci.c83
-rw-r--r--gpxe/src/interface/efi/efi_smbios.c64
-rw-r--r--gpxe/src/interface/efi/efi_snp.c1148
-rw-r--r--gpxe/src/interface/efi/efi_strerror.c45
-rw-r--r--gpxe/src/interface/efi/efi_timer.c118
-rw-r--r--gpxe/src/interface/efi/efi_uaccess.c39
-rw-r--r--gpxe/src/interface/efi/efi_umalloc.c98
-rw-r--r--gpxe/src/interface/smbios/smbios.c180
-rw-r--r--gpxe/src/interface/smbios/smbios_settings.c194
-rw-r--r--gpxe/src/libgcc/__divdi3.c26
-rw-r--r--gpxe/src/libgcc/__moddi3.c26
-rw-r--r--gpxe/src/libgcc/__udivdi3.c10
-rw-r--r--gpxe/src/libgcc/__udivmoddi4.c32
-rw-r--r--gpxe/src/libgcc/__umoddi3.c13
-rw-r--r--gpxe/src/libgcc/icc.c8
-rw-r--r--gpxe/src/libgcc/libgcc.h14
-rw-r--r--gpxe/src/libgcc/memcpy.c18
-rw-r--r--gpxe/src/net/80211/net80211.c2829
-rw-r--r--gpxe/src/net/80211/rc80211.c371
-rw-r--r--gpxe/src/net/80211/sec80211.c503
-rw-r--r--gpxe/src/net/80211/wep.c303
-rw-r--r--gpxe/src/net/80211/wpa.c973
-rw-r--r--gpxe/src/net/80211/wpa_ccmp.c528
-rw-r--r--gpxe/src/net/80211/wpa_psk.c125
-rw-r--r--gpxe/src/net/80211/wpa_tkip.c586
-rw-r--r--gpxe/src/net/aoe.c471
-rw-r--r--gpxe/src/net/arp.c289
-rw-r--r--gpxe/src/net/cachedhcp.c76
-rw-r--r--gpxe/src/net/dhcpopts.c447
-rw-r--r--gpxe/src/net/dhcppkt.c283
-rw-r--r--gpxe/src/net/eapol.c85
-rw-r--r--gpxe/src/net/ethernet.c193
-rw-r--r--gpxe/src/net/fakedhcp.c217
-rw-r--r--gpxe/src/net/icmp.c103
-rw-r--r--gpxe/src/net/icmpv6.c128
-rw-r--r--gpxe/src/net/infiniband.c951
-rw-r--r--gpxe/src/net/infiniband/ib_cm.c413
-rw-r--r--gpxe/src/net/infiniband/ib_cmrc.c436
-rw-r--r--gpxe/src/net/infiniband/ib_mcast.c218
-rw-r--r--gpxe/src/net/infiniband/ib_mi.c406
-rw-r--r--gpxe/src/net/infiniband/ib_packet.c244
-rw-r--r--gpxe/src/net/infiniband/ib_pathrec.c296
-rw-r--r--gpxe/src/net/infiniband/ib_sma.c369
-rw-r--r--gpxe/src/net/infiniband/ib_smc.c179
-rw-r--r--gpxe/src/net/infiniband/ib_srp.c406
-rw-r--r--gpxe/src/net/iobpad.c68
-rw-r--r--gpxe/src/net/ipv4.c635
-rw-r--r--gpxe/src/net/ipv6.c381
-rw-r--r--gpxe/src/net/mii.c147
-rw-r--r--gpxe/src/net/ndp.c180
-rw-r--r--gpxe/src/net/netdev_settings.c120
-rw-r--r--gpxe/src/net/netdevice.c633
-rw-r--r--gpxe/src/net/nullnet.c60
-rw-r--r--gpxe/src/net/rarp.c70
-rw-r--r--gpxe/src/net/retry.c192
-rw-r--r--gpxe/src/net/tcp.c1156
-rw-r--r--gpxe/src/net/tcp/ftp.c529
-rw-r--r--gpxe/src/net/tcp/http.c597
-rw-r--r--gpxe/src/net/tcp/https.c51
-rw-r--r--gpxe/src/net/tcp/iscsi.c1934
-rw-r--r--gpxe/src/net/tcpip.c135
-rw-r--r--gpxe/src/net/tls.c1759
-rw-r--r--gpxe/src/net/udp.c463
-rw-r--r--gpxe/src/net/udp/dhcp.c1587
-rw-r--r--gpxe/src/net/udp/dns.c603
-rw-r--r--gpxe/src/net/udp/slam.c812
-rw-r--r--gpxe/src/net/udp/tftp.c1288
-rw-r--r--gpxe/src/usr/autoboot.c233
-rw-r--r--gpxe/src/usr/dhcpmgmt.c78
-rw-r--r--gpxe/src/usr/ifmgmt.c147
-rw-r--r--gpxe/src/usr/imgmgmt.c144
-rw-r--r--gpxe/src/usr/iwmgmt.c244
-rw-r--r--gpxe/src/usr/pxemenu.c383
-rw-r--r--gpxe/src/usr/route.c45
-rw-r--r--gpxe/src/util/Makefile22
-rw-r--r--gpxe/src/util/Option/ROM.pm501
-rwxr-xr-xgpxe/src/util/catrom.pl48
-rwxr-xr-xgpxe/src/util/diffsize.pl101
-rwxr-xr-xgpxe/src/util/disrom.pl81
-rw-r--r--gpxe/src/util/efirom.c280
-rw-r--r--gpxe/src/util/elf2efi.c808
-rwxr-xr-xgpxe/src/util/geniso55
-rwxr-xr-xgpxe/src/util/genliso74
-rwxr-xr-xgpxe/src/util/gensdsk65
-rwxr-xr-xgpxe/src/util/get-pci-ids135
-rw-r--r--gpxe/src/util/hijack.c628
-rw-r--r--gpxe/src/util/iccfix.c156
-rwxr-xr-xgpxe/src/util/licence.pl149
-rwxr-xr-xgpxe/src/util/makerom.pl232
-rwxr-xr-xgpxe/src/util/mergerom.pl98
-rwxr-xr-xgpxe/src/util/modrom.pl226
-rw-r--r--gpxe/src/util/mucurses_test.c63
-rw-r--r--gpxe/src/util/nrv2b.c1501
-rwxr-xr-xgpxe/src/util/padimg.pl44
-rw-r--r--gpxe/src/util/parserom.pl65
-rwxr-xr-xgpxe/src/util/sortobjdump.pl40
-rwxr-xr-xgpxe/src/util/swapdevids.pl49
-rwxr-xr-xgpxe/src/util/symcheck.pl191
-rw-r--r--gpxe/src/util/zbin.c383
-rw-r--r--libinstaller/advio.c6
-rw-r--r--libinstaller/setadv.c2
-rw-r--r--libinstaller/syslxcom.c64
-rw-r--r--libinstaller/syslxcom.h2
-rw-r--r--libinstaller/syslxint.h13
-rw-r--r--libinstaller/syslxmod.c3
-rw-r--r--libinstaller/syslxopt.c2
-rw-r--r--libinstaller/syslxrw.c84
-rw-r--r--libinstaller/syslxrw.h20
-rw-r--r--linux/Makefile1
-rwxr-xr-xlinux/syslinux.c1
-rw-r--r--lzo/Makefile2
-rw-r--r--mbr/isohdpfx.S10
-rw-r--r--memdisk/Makefile2
-rw-r--r--mk/com32.mk15
-rw-r--r--mk/elf.mk6
-rw-r--r--mk/embedded.mk7
-rw-r--r--mk/lib.mk4
-rw-r--r--mk/syslinux.mk4
-rwxr-xr-xmtools/Makefile3
-rwxr-xr-xmtools/syslinux.c60
-rw-r--r--syslinux.spec6
-rw-r--r--txt/syslinux.cfg.txt20
-rw-r--r--txt/syslinux.txt24
-rw-r--r--utils/isohybrid.c2
-rwxr-xr-xutils/keytab-lilo4
-rw-r--r--version2
-rw-r--r--win/ntfssect.c8
-rw-r--r--win/ntfssect.h4
-rw-r--r--win32/Makefile2
-rw-r--r--win64/Makefile2
1141 files changed, 2881 insertions, 308255 deletions
diff --git a/Makefile b/Makefile
index fb387c5..b472945 100644
--- a/Makefile
+++ b/Makefile
@@ -86,9 +86,8 @@ endif
# creating. Which means that we always need a *real* target, such as
# 'all', appended to the make goals.
#
-firmware = $(all_firmware)
-real-target := $(filter-out $(firmware), $(MAKECMDGOALS))
-real-firmware := $(filter $(firmware), $(MAKECMDGOALS))
+real-target := $(filter-out $(all_firmware), $(MAKECMDGOALS))
+real-firmware := $(filter $(all_firmware), $(MAKECMDGOALS))
ifeq ($(real-target),)
real-target = all
@@ -101,7 +100,8 @@ endif
.PHONY: $(filter-out $(private-targets), $(MAKECMDGOALS))
$(filter-out $(private-targets), $(MAKECMDGOALS)):
$(MAKE) -C $(OBJDIR) -f $(CURDIR)/Makefile SRC="$(topdir)" \
- OBJ=$(OBJDIR) objdir=$(OBJDIR) $(MAKECMDGOALS)
+ OBJ=$(OBJDIR) objdir=$(OBJDIR) $(BUILDOPTS) \
+ $(MAKECMDGOALS)
unittest:
printf "Executing unit tests\n"
@@ -110,7 +110,7 @@ unittest:
regression:
$(MAKE) -C tests SRC="$(topdir)/tests" OBJ="$(topdir)/tests" \
- objdir=$(OBJDIR) \
+ objdir=$(OBJDIR) $(BUILDOPTS) \
-f $(topdir)/tests/Makefile all
test: unittest regression
@@ -136,7 +136,7 @@ include $(MAKEDIR)/syslinux.mk
# directories.
#
-ifndef EFI_BUILD
+ifeq ($(FWCLASS),BIOS)
MODULES = memdisk/memdisk \
com32/menu/*.c32 com32/modules/*.c32 com32/mboot/*.c32 \
com32/hdt/*.c32 com32/rosh/*.c32 com32/gfxboot/*.c32 \
@@ -152,6 +152,8 @@ MODULES = com32/menu/*.c32 com32/modules/*.c32 com32/mboot/*.c32 \
com32/cmenu/libmenu/*.c32 com32/elflink/ldlinux/$(LDLINUX)
endif
+export FIRMWARE FWCLASS ARCH BITS
+
# List of module objects that should be installed for all derivatives
INSTALLABLE_MODULES = $(MODULES)
@@ -162,7 +164,7 @@ BOBJECTS = $(BTARGET) \
mbr/*.bin \
core/pxelinux.0 core/lpxelinux.0 \
core/isolinux.bin core/isolinux-debug.bin \
- gpxe/gpxelinux.0 dos/syslinux.com \
+ dos/syslinux.com \
win32/syslinux.exe win64/syslinux64.exe \
dosutil/*.com dosutil/*.sys \
$(MODULES)
@@ -174,7 +176,7 @@ BOBJECTS = $(BTARGET) \
# files that depend only on the B phase, but may have to be regenerated
# for "make installer".
-ifdef EFI_BUILD
+ifeq ($(FWCLASS),EFI)
BSUBDIRS = codepage com32 lzo core mbr sample efi txt
ISUBDIRS =
@@ -185,7 +187,7 @@ NETINSTALLABLE = efi/syslinux.efi $(INSTALLABLE_MODULES)
else
-BSUBDIRS = codepage com32 lzo core memdisk mbr gpxe sample \
+BSUBDIRS = codepage com32 lzo core memdisk mbr sample \
diag libinstaller dos win32 win64 dosutil txt
ITARGET =
@@ -199,7 +201,7 @@ INSTALL_BIN = mtools/syslinux
# Things to install in /sbin
INSTALL_SBIN = extlinux/extlinux
# Things to install in /usr/lib/syslinux
-INSTALL_AUX = core/pxelinux.0 gpxe/gpxelinux.0 gpxe/gpxelinuxk.0 \
+INSTALL_AUX = core/pxelinux.0 \
core/isolinux.bin core/isolinux-debug.bin \
dos/syslinux.com core/lpxelinux.0 \
mbr/*.bin $(INSTALLABLE_MODULES)
@@ -214,14 +216,14 @@ INSTALLSUBDIRS = com32 utils dosutil
EXTBOOTINSTALL = $(INSTALLABLE_MODULES)
# Things to install in /tftpboot
-NETINSTALLABLE = core/pxelinux.0 gpxe/gpxelinux.0 core/lpxelinux.0 \
+NETINSTALLABLE = core/pxelinux.0 core/lpxelinux.0 \
$(INSTALLABLE_MODULES)
-endif # ifdef EFI_BUILD
+endif # ifeq ($(FWCLASS),EFI)
.PHONY: subdirs $(BSUBDIRS) $(ISUBDIRS) test
-ifeq ($(HAVE_FIRMWARE),)
+ifeq ($(FIRMWARE),)
firmware = $(all_firmware)
@@ -253,27 +255,27 @@ endif
bios:
@mkdir -p $(OBJ)/bios
$(MAKE) -C $(OBJ)/bios -f $(SRC)/Makefile SRC="$(SRC)" \
- objdir=$(OBJ)/bios OBJ=$(OBJ)/bios HAVE_FIRMWARE=1 \
- FIRMWARE=BIOS \
+ objdir=$(OBJ)/bios OBJ=$(OBJ)/bios \
+ FIRMWARE=BIOS FWCLASS=BIOS \
ARCH=i386 LDLINUX=ldlinux.c32 $(MAKECMDGOALS)
efi32:
@mkdir -p $(OBJ)/efi32
$(MAKE) -C $(OBJ)/efi32 -f $(SRC)/Makefile SRC="$(SRC)" \
- objdir=$(OBJ)/efi32 OBJ=$(OBJ)/efi32 HAVE_FIRMWARE=1 \
- ARCH=i386 BITS=32 EFI_BUILD=1 LDLINUX=ldlinux.e32 \
- FIRMWARE=EFI32 \
+ objdir=$(OBJ)/efi32 OBJ=$(OBJ)/efi32 \
+ ARCH=i386 BITS=32 LDLINUX=ldlinux.e32 \
+ FIRMWARE=EFI32 FWCLASS=EFI \
$(MAKECMDGOALS)
efi64:
@mkdir -p $(OBJ)/efi64
$(MAKE) -C $(OBJ)/efi64 -f $(SRC)/Makefile SRC="$(SRC)" \
- objdir=$(OBJ)/efi64 OBJ=$(OBJ)/efi64 HAVE_FIRMWARE=1 \
- ARCH=x86_64 BITS=64 EFI_BUILD=1 LDLINUX=ldlinux.e64 \
- FIRMWARE=EFI64 \
+ objdir=$(OBJ)/efi64 OBJ=$(OBJ)/efi64 \
+ ARCH=x86_64 BITS=64 LDLINUX=ldlinux.e64 \
+ FIRMWARE=EFI64 FWCLASS=EFI \
$(MAKECMDGOALS)
-else # ifeq($(HAVE_FIRMWARE),)
+else # FIRMWARE
all: all-local subdirs
@@ -303,7 +305,6 @@ libinstaller: core
utils: mbr
core: com32
efi: core
-gpxe: core
installer: installer-local
set -e; for i in $(ISUBDIRS); \
@@ -341,7 +342,7 @@ local-install: installer
: mkdir -m 755 -p $(INSTALLROOT)$(MANDIR)/man8
: install -m 644 -c man/*.8 $(INSTALLROOT)$(MANDIR)/man8
-ifndef EFI_BUILD
+ifneq ($(FWCLASS),EFI)
install: local-install
set -e ; for i in $(INSTALLSUBDIRS) ; \
do $(MAKE) -C $$i SRC="$(SRC)/$$i" OBJ="$(OBJ)/$$i" \
@@ -357,7 +358,7 @@ install:
install -m 644 com32/elflink/ldlinux/$(LDLINUX) $(INSTALLROOT)$(AUXDIR)/efi$(BITS)
endif
-ifdef EFI_BUILD
+ifeq ($(FWCLASS),EFI)
netinstall:
mkdir -p $(INSTALLROOT)$(TFTPBOOT)/efi$(BITS)
install -m 644 $(NETINSTALLABLE) $(INSTALLROOT)$(TFTPBOOT)/efi$(BITS)
@@ -396,7 +397,7 @@ dist: local-dist local-tidy $(BESUBDIRS) $(IESUBDIRS) $(BSUBDIRS) $(ISUBDIRS)
klibc:
$(MAKE) clean
$(MAKE) CC=klcc ITARGET= ISUBDIRS='linux extlinux' BSUBDIRS=
-endif # ifeq ($(HAVE_FIRMWARE),)
+endif # ifeq ($(FIRMWARE),)
endif # ifeq ($(topdir),)
diff --git a/NEWS b/NEWS
index d1a5b2c..c0846d8 100644
--- a/NEWS
+++ b/NEWS
@@ -768,7 +768,7 @@ Changes in 3.61:
memory regions in the e820 map.
Changes in 3.60:
- * Support for "auxilliary data vector", a small amount of
+ * Support for "auxiliary data vector", a small amount of
writable storage. Currently only supported for EXTLINUX,
but the infrastructure is there for the other derivatives,
assuming a suitable storage location can be found.
diff --git a/codepage/Makefile b/codepage/Makefile
index 18a590f..af5258a 100644
--- a/codepage/Makefile
+++ b/codepage/Makefile
@@ -1,6 +1,6 @@
VPATH = $(SRC)
PERL = perl
-CPSRC = $(wildcard $(SRC)/*.txt)
+CPSRC = $(sort $(wildcard $(SRC)/*.txt))
CPOBJ = $(notdir $(CPSRC))
GENFILES = $(patsubst %.txt,%.cp,$(CPOBJ))
diff --git a/com32/Makefile b/com32/Makefile
index 754c915..5efda1c 100644
--- a/com32/Makefile
+++ b/com32/Makefile
@@ -1,4 +1,4 @@
-SUBDIRS = libupload tools lib elflink/ldlinux gpllib libutil modules mboot \
+SUBDIRS = tools lib libutil gpllib libupload elflink/ldlinux modules mboot \
menu samples elflink rosh cmenu hdt gfxboot sysdump lua/src chain
.PHONY: subdirs $(SUBDIRS)
@@ -11,13 +11,11 @@ $(SUBDIRS):
all tidy dist clean spotless install: subdirs
# Parallel dependencies
-chain mboot menu: lib libutil gpllib
+elflink/ldlinux gpllib libupload libutil: lib
cmenu: lib libutil
-elflink/ldlinux: lib
-gfxboot: lib libutil gpllib
-hdt: lib libupload cmenu gpllib libutil
-modules: lib libutil gpllib
-rosh: lib libutil
-samples: libutil elflink/ldlinux
-sysdump: lib libutil libupload gpllib
-lua/src: cmenu modules
+
+chain gfxboot mboot menu modules rosh: lib libutil gpllib
+hdt: lib libutil gpllib libupload cmenu
+lua/src: lib libutil gpllib cmenu
+samples: lib libutil gpllib elflink/ldlinux
+sysdump: lib libutil gpllib libupload
diff --git a/com32/chain/Makefile b/com32/chain/Makefile
index 4a5af91..d7b5aa8 100644
--- a/com32/chain/Makefile
+++ b/com32/chain/Makefile
@@ -3,7 +3,7 @@
## Copyright 2001-2009 H. Peter Anvin - All Rights Reserved
## Copyright 2009-2010 Intel Corporation; author: H. Peter Anvin
## Copyright 2010 Shao Miller
-## Copyright 2010-2012 Michal Soltys
+## Copyright 2010-2015 Michal Soltys
##
## 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
diff --git a/com32/chain/chain.c b/com32/chain/chain.c
index f86cd7d..4e9e32d 100644
--- a/com32/chain/chain.c
+++ b/com32/chain/chain.c
@@ -3,7 +3,7 @@
* Copyright 2003-2009 H. Peter Anvin - All Rights Reserved
* Copyright 2009-2010 Intel Corporation; author: H. Peter Anvin
* Copyright 2010 Shao Miller
- * Copyright 2010-2012 Michal Soltys
+ * Copyright 2010-2015 Michal Soltys
*
* 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
diff --git a/com32/chain/chain.h b/com32/chain/chain.h
index fb5914b..5e155b3 100644
--- a/com32/chain/chain.h
+++ b/com32/chain/chain.h
@@ -3,7 +3,7 @@
* Copyright 2003-2009 H. Peter Anvin - All Rights Reserved
* Copyright 2009-2010 Intel Corporation; author: H. Peter Anvin
* Copyright 2010 Shao Miller
- * Copyright 2010-2012 Michal Soltys
+ * Copyright 2010-2015 Michal Soltys
*
* 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
diff --git a/com32/chain/mangle.c b/com32/chain/mangle.c
index 3231e51..275d0aa 100644
--- a/com32/chain/mangle.c
+++ b/com32/chain/mangle.c
@@ -3,7 +3,7 @@
* Copyright 2003-2009 H. Peter Anvin - All Rights Reserved
* Copyright 2009-2010 Intel Corporation; author: H. Peter Anvin
* Copyright 2010 Shao Miller
- * Copyright 2010-2012 Michal Soltys
+ * Copyright 2010-2015 Michal Soltys
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
diff --git a/com32/chain/mangle.h b/com32/chain/mangle.h
index d4a5b75..42f6c5b 100644
--- a/com32/chain/mangle.h
+++ b/com32/chain/mangle.h
@@ -3,7 +3,7 @@
* Copyright 2003-2009 H. Peter Anvin - All Rights Reserved
* Copyright 2009-2010 Intel Corporation; author: H. Peter Anvin
* Copyright 2010 Shao Miller
- * Copyright 2010-2012 Michal Soltys
+ * Copyright 2010-2015 Michal Soltys
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
diff --git a/com32/chain/options.c b/com32/chain/options.c
index a99e0d7..45045b4 100644
--- a/com32/chain/options.c
+++ b/com32/chain/options.c
@@ -3,7 +3,7 @@
* Copyright 2003-2009 H. Peter Anvin - All Rights Reserved
* Copyright 2009-2010 Intel Corporation; author: H. Peter Anvin
* Copyright 2010 Shao Miller
- * Copyright 2010-2012 Michal Soltys
+ * Copyright 2010-2015 Michal Soltys
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
@@ -132,10 +132,13 @@ static void usage(void)
" keeppxe Keep the PXE and UNDI stacks in memory (PXELINUX)",
" warn Wait for a keypress to continue chainloading",
" break Don't chainload",
+" gpthcrc Perform gpt header crc check",
+" gptlcrc Perform gpt list crc check",
" strict[=<0|1|2>] Set the level of strictness in sanity checks",
" - strict w/o any value is the same as strict=2",
" relax The same as strict=0",
" prefmbr On hybrid MBR/GPT disks, prefer legacy layout",
+" exit Don't read anything after this keyword",
"",
" file=<file> Load and execute <file>",
" seg=<s[:o[:i]]> Load file at <s:o>, jump to <s:i>",
@@ -174,7 +177,8 @@ void opt_set_defs(void)
opt.maps = true; /* by def. map sector */
opt.hand = true; /* by def. prepare handover */
opt.brkchain = false; /* by def. do chainload */
- opt.piflags = PIF_STRICT; /* by def. be strict, but ignore disk sizes */
+ /* strict but ignore disk size, do all gpt crc checks */
+ opt.piflags = PIF_STRICT | PIF_GPTHCRC | PIF_GPTLCRC;
opt.foff = opt.soff = opt.fip = opt.sip = 0x7C00;
opt.drivename = "boot";
#ifdef DEBUG
@@ -191,6 +195,8 @@ int opt_parse_args(int argc, char *argv[])
for (i = 1; i < argc; i++) {
if (!strncmp(argv[i], "file=", 5)) {
opt.file = argv[i] + 5;
+ } else if (!strncmp(argv[i], "exit", 4)) {
+ break;
} else if (!strcmp(argv[i], "nofile")) {
opt.file = NULL;
} else if (!strncmp(argv[i], "seg=", 4)) {
@@ -218,15 +224,9 @@ int opt_parse_args(int argc, char *argv[])
opt.setbpb = true;
opt.hand = false;
} else if (!strncmp(argv[i], "reactos=", 8)) {
- /*
- * settings based on commit
- * ad4cf1470977f648ee1dd45e97939589ccb0393c
- * note, conflicts with:
- * http://reactos.freedoors.org/Reactos%200.3.13/ReactOS-0.3.13-REL-src/boot/freeldr/notes.txt
- */
- opt.fseg = 0;
- opt.foff = 0x8000;
- opt.fip = 0x8100;
+ opt.fseg = 0x0F80;
+ opt.foff = 0;
+ opt.fip = 0;
opt.file = argv[i] + 8;
opt.setbpb = true;
opt.hand = false;
@@ -359,6 +359,14 @@ int opt_parse_args(int argc, char *argv[])
case '1': opt.piflags |= PIF_STRICT; break;
default:;
}
+ } else if (!strcmp(argv[i], "gpthcrc")) {
+ opt.piflags |= PIF_GPTHCRC;
+ } else if (!strcmp(argv[i], "nogpthcrc")) {
+ opt.piflags &= ~PIF_GPTHCRC;
+ } else if (!strcmp(argv[i], "gptlcrc")) {
+ opt.piflags |= PIF_GPTLCRC;
+ } else if (!strcmp(argv[i], "nogptlcrc")) {
+ opt.piflags &= ~PIF_GPTLCRC;
} else if (!strcmp(argv[i], "warn")) {
opt.warn = true;
} else if (!strcmp(argv[i], "nowarn")) {
diff --git a/com32/chain/options.h b/com32/chain/options.h
index df96e2d..d51d823 100644
--- a/com32/chain/options.h
+++ b/com32/chain/options.h
@@ -3,7 +3,7 @@
* Copyright 2003-2009 H. Peter Anvin - All Rights Reserved
* Copyright 2009-2010 Intel Corporation; author: H. Peter Anvin
* Copyright 2010 Shao Miller
- * Copyright 2010-2012 Michal Soltys
+ * Copyright 2010-2015 Michal Soltys
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
diff --git a/com32/chain/partiter.c b/com32/chain/partiter.c
index d570d93..4937f0c 100644
--- a/com32/chain/partiter.c
+++ b/com32/chain/partiter.c
@@ -3,7 +3,7 @@
* Copyright 2003-2009 H. Peter Anvin - All Rights Reserved
* Copyright 2009-2010 Intel Corporation; author: H. Peter Anvin
* Copyright 2010 Shao Miller
- * Copyright 2010-2012 Michal Soltys
+ * Copyright 2010-2015 Michal Soltys
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
@@ -412,16 +412,29 @@ static inline int valid_crc(uint32_t crc, const uint8_t *buf, unsigned int siz)
return crc == crc32(crc32(0, NULL, 0), buf, siz);
}
-static int valid_crc_hdr(void *buf)
+static int valid_crc_gpth(struct disk_gpt_header *gh, int flags)
{
- struct disk_gpt_header *gh = buf;
- uint32_t crc = gh->chksum;
- int valid;
+ uint32_t crc, crcc;
+ if (!(flags & PIF_GPTHCRC))
+ return 1;
+
+ crc = gh->chksum;
gh->chksum = 0;
- valid = crc == crc32(crc32(0, NULL, 0), buf, gh->hdr_size);
+ crcc = crc32(crc32(0, NULL, 0), (const uint8_t *)gh, gh->hdr_size);
gh->chksum = crc;
- return valid;
+ return crc == crcc;
+}
+
+static int valid_crc_gptl(const struct disk_gpt_header *gh, const struct disk_gpt_part_entry *gl, int flags)
+{
+ uint32_t crcc;
+
+ if (!(flags & PIF_GPTLCRC))
+ return 1;
+
+ crcc = crc32(crc32(0, NULL, 0), (const uint8_t *)gl, gh->part_size * gh->part_count);
+ return gh->table_chksum == crcc;
}
static int pi_next_(struct part_iter *iter)
@@ -528,6 +541,40 @@ void pi_del(struct part_iter **_iter)
*_iter = NULL;
}
+static int notsane_gpt_hdr(const struct disk_info *di, const struct disk_gpt_header *gpth, int flags)
+{
+ uint64_t gpt_loff; /* offset to GPT partition list in sectors */
+ uint64_t gpt_lsiz; /* size of GPT partition list in bytes */
+ uint64_t gpt_lcnt; /* size of GPT partition in sectors */
+ uint64_t gpt_sec; /* secondary gpt header */
+
+ if (!(flags & PIF_STRICT))
+ return 0;
+
+ if (gpth->lba_alt < gpth->lba_cur)
+ gpt_sec = gpth->lba_cur;
+ else
+ gpt_sec = gpth->lba_alt;
+ gpt_loff = gpth->lba_table;
+ gpt_lsiz = (uint64_t)gpth->part_size * gpth->part_count;
+ gpt_lcnt = (gpt_lsiz + di->bps - 1) / di->bps;
+
+ /*
+ * disk_read_sectors allows reading of max 255 sectors, so we use
+ * it as a sanity check base. EFI doesn't specify max (AFAIK).
+ */
+ if (gpt_loff < 2 || !gpt_lsiz || gpt_lcnt > 255u ||
+ gpth->lba_first_usable > gpth->lba_last_usable ||
+ !sane(gpt_loff, gpt_lcnt) ||
+ (gpt_loff + gpt_lcnt > gpth->lba_first_usable && gpt_loff <= gpth->lba_last_usable) ||
+ gpt_loff + gpt_lcnt > gpt_sec ||
+ ((flags & PIF_STRICTER) && (gpt_sec >= di->lbacnt)) ||
+ gpth->part_size < sizeof(struct disk_gpt_part_entry))
+ return -1;
+
+ return 0;
+}
+
static void try_gpt_we(const char *str, int sec)
{
if (sec)
@@ -536,40 +583,43 @@ static void try_gpt_we(const char *str, int sec)
warn(str);
}
-static struct disk_gpt_header *try_gpt_hdr(const struct disk_info *di, int sec)
+static struct disk_gpt_header *try_gpt_hdr(const struct disk_info *di, int sec, int flags)
{
const char *desc = sec ? "backup" : "primary";
uint64_t gpt_cur = sec ? di->lbacnt - 1 : 1;
struct disk_gpt_header *gpth;
- char errbuf[64];
+ char errbuf[96];
gpth = disk_read_sectors(di, gpt_cur, 1);
if (!gpth) {
sprintf(errbuf, "Unable to read %s GPT header.", desc);
- try_gpt_we(errbuf, sec);
- return NULL;
+ goto out;
}
- if(!valid_crc_hdr(gpth)) {
+ if(!valid_crc_gpth(gpth, flags)) {
sprintf(errbuf, "Invalid checksum of %s GPT header.", desc);
- try_gpt_we(errbuf, sec);
- free(gpth);
- return NULL;
+ goto out;
+ }
+ if(notsane_gpt_hdr(di, gpth, flags)) {
+ sprintf(errbuf, "Checksum of %s GPT header is valid, but values fail sanity checks.", desc);
+ goto out;
}
return gpth;
+out:
+ try_gpt_we(errbuf, sec);
+ free(gpth);
+ return NULL;
}
-static struct disk_gpt_part_entry *try_gpt_list(const struct disk_info *di, const struct disk_gpt_header *gpth, int alt)
+static struct disk_gpt_part_entry *try_gpt_list(const struct disk_info *di, const struct disk_gpt_header *gpth, int alt, int flags)
{
int pri = gpth->lba_cur < gpth->lba_alt;
const char *desc = alt ? "alternative" : "main";
struct disk_gpt_part_entry *gptl;
char errbuf[64];
- uint64_t gpt_lsiz; /* size of GPT partition list in bytes */
- uint64_t gpt_lcnt; /* size of GPT partition in sectors */
+ uint32_t gpt_lcnt; /* size of GPT partition in sectors */
uint64_t gpt_loff; /* offset to GPT partition list in sectors */
- gpt_lsiz = (uint64_t)gpth->part_size * gpth->part_count;
- gpt_lcnt = (gpt_lsiz + di->bps - 1) / di->bps;
+ gpt_lcnt = (gpth->part_size * gpth->part_count + di->bps - 1) / di->bps;
if (!alt) {
/* prefer header value for partition table if not asking for alternative */
gpt_loff = gpth->lba_table;
@@ -584,50 +634,17 @@ static struct disk_gpt_part_entry *try_gpt_list(const struct disk_info *di, cons
gptl = disk_read_sectors(di, gpt_loff, gpt_lcnt);
if (!gptl) {
sprintf(errbuf, "Unable to read %s GPT partition list.", desc);
- try_gpt_we(errbuf, alt);
- return NULL;
+ goto out;
}
- if (!valid_crc(gpth->table_chksum, (const uint8_t *)gptl, gpt_lsiz)) {
+ if (!valid_crc_gptl(gpth, gptl, flags)) {
sprintf(errbuf, "Invalid checksum of %s GPT partition list.", desc);
- try_gpt_we(errbuf, alt);
- free(gptl);
- return NULL;
+ goto out;
}
return gptl;
-}
-
-static int notsane_gpt_hdr(const struct disk_info *di, const struct disk_gpt_header *gpth, int flags)
-{
- uint64_t gpt_loff; /* offset to GPT partition list in sectors */
- uint64_t gpt_lsiz; /* size of GPT partition list in bytes */
- uint64_t gpt_lcnt; /* size of GPT partition in sectors */
- uint64_t gpt_sec; /* secondary gpt header */
-
- if (!(flags & PIF_STRICT))
- return 0;
-
- if (gpth->lba_alt < gpth->lba_cur)
- gpt_sec = gpth->lba_cur;
- else
- gpt_sec = gpth->lba_alt;
- gpt_loff = gpth->lba_table;
- gpt_lsiz = (uint64_t)gpth->part_size * gpth->part_count;
- gpt_lcnt = (gpt_lsiz + di->bps - 1) / di->bps;
-
- /*
- * disk_read_sectors allows reading of max 255 sectors, so we use
- * it as a sanity check base. EFI doesn't specify max (AFAIK).
- */
- if (gpt_loff < 2 || !gpt_lsiz || gpt_lcnt > 255u ||
- gpth->lba_first_usable > gpth->lba_last_usable ||
- !sane(gpt_loff, gpt_lcnt) ||
- (gpt_loff + gpt_lcnt > gpth->lba_first_usable && gpt_loff <= gpth->lba_last_usable) ||
- gpt_loff + gpt_lcnt > gpt_sec ||
- ((flags & PIF_STRICTER) && (gpt_sec >= di->lbacnt)) ||
- gpth->part_size < sizeof(struct disk_gpt_part_entry))
- return -1;
-
- return 0;
+out:
+ try_gpt_we(errbuf, alt);
+ free(gptl);
+ return NULL;
}
/* pi_begin() - validate and and get proper iterator for a disk described by di */
@@ -664,13 +681,13 @@ struct part_iter *pi_begin(const struct disk_info *di, int flags)
/* Try to read GPT header */
if (isgpt) {
- gpth = try_gpt_hdr(di, 0);
+ gpth = try_gpt_hdr(di, 0, flags);
if (!gpth)
/*
* this read might fail if bios reports different disk size (different vm/pc)
* not much we can do here to avoid it
*/
- gpth = try_gpt_hdr(di, 1);
+ gpth = try_gpt_hdr(di, 1, flags);
if (!gpth)
goto out;
}
@@ -682,14 +699,9 @@ struct part_iter *pi_begin(const struct disk_info *di, int flags)
dprintf("Looks like a GPT v1.0 disk.\n");
disk_gpt_header_dump(gpth);
#endif
- if (notsane_gpt_hdr(di, gpth, flags)) {
- error("GPT header values are corrupted.");
- goto out;
- }
-
- gptl = try_gpt_list(di, gpth, 0);
+ gptl = try_gpt_list(di, gpth, 0, flags);
if (!gptl)
- gptl = try_gpt_list(di, gpth, 1);
+ gptl = try_gpt_list(di, gpth, 1, flags);
if (!gptl)
goto out;
diff --git a/com32/chain/partiter.h b/com32/chain/partiter.h
index 22c0e42..a48f8d6 100644
--- a/com32/chain/partiter.h
+++ b/com32/chain/partiter.h
@@ -3,7 +3,7 @@
* Copyright 2003-2009 H. Peter Anvin - All Rights Reserved
* Copyright 2009-2010 Intel Corporation; author: H. Peter Anvin
* Copyright 2010 Shao Miller
- * Copyright 2010-2012 Michal Soltys
+ * Copyright 2010-2015 Michal Soltys
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
@@ -46,7 +46,7 @@ enum {PI_ERRLOAD = -31, PI_INSANE, PI_OK = 0, PI_DONE};
/* flags */
-enum {PIF_STEPALL = 1, PIF_PREFMBR = 2, PIF_STRICT = 4, PIF_STRICTER = 8};
+enum {PIF_STEPALL = 1, PIF_PREFMBR = 2, PIF_STRICT = 4, PIF_STRICTER = 8, PIF_GPTHCRC = 16, PIF_GPTLCRC = 32};
struct itertype;
struct part_iter;
diff --git a/com32/chain/utility.c b/com32/chain/utility.c
index b17997f..180749e 100644
--- a/com32/chain/utility.c
+++ b/com32/chain/utility.c
@@ -3,7 +3,7 @@
* Copyright 2003-2009 H. Peter Anvin - All Rights Reserved
* Copyright 2009-2010 Intel Corporation; author: H. Peter Anvin
* Copyright 2010 Shao Miller
- * Copyright 2010-2012 Michal Soltys
+ * Copyright 2010-2015 Michal Soltys
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
diff --git a/com32/chain/utility.h b/com32/chain/utility.h
index 596017b..f8e9c61 100644
--- a/com32/chain/utility.h
+++ b/com32/chain/utility.h
@@ -3,7 +3,7 @@
* Copyright 2003-2009 H. Peter Anvin - All Rights Reserved
* Copyright 2009-2010 Intel Corporation; author: H. Peter Anvin
* Copyright 2010 Shao Miller
- * Copyright 2010-2012 Michal Soltys
+ * Copyright 2010-2015 Michal Soltys
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
diff --git a/com32/cmenu/Makefile b/com32/cmenu/Makefile
index 6bb5231..b81b68e 100644
--- a/com32/cmenu/Makefile
+++ b/com32/cmenu/Makefile
@@ -32,8 +32,8 @@ LIBMENU = libmenu/syslnx.o libmenu/com32io.o libmenu/tui.o \
libmenu/menu.o libmenu/passwords.o libmenu/des.o libmenu/help.o \
$(objdir)/com32/libutil/libutil.c32 $(objdir)/com32/lib/libcom32.c32
-CMENUS = $(patsubst %.c,%.c32,$(wildcard $(SRC)/*.c))
-IMENUS = $(patsubst %.menu,%.c32,$(wildcard $(SRC)/*.menu))
+CMENUS = $(patsubst %.c,%.c32,$(sort $(wildcard $(SRC)/*.c)))
+IMENUS = $(patsubst %.menu,%.c32,$(sort $(wildcard $(SRC)/*.menu)))
MENUS = $(LIBS) $(subst $(SRC)/,,$(CMENUS) $(IMENUS))
@@ -62,7 +62,7 @@ clean: tidy menuclean
rm -f *.lss *.com
menuclean:
- rm -f $(patsubst %.menu,%.c,$(wildcard *.menu))
+ rm -f $(patsubst %.menu,%.c,$(sort $(wildcard *.menu)))
spotless: clean libclean menuclean
rm -f *~ \#* *.c32
diff --git a/com32/elflink/ldlinux/Makefile b/com32/elflink/ldlinux/Makefile
index d948da4..87c0d36 100644
--- a/com32/elflink/ldlinux/Makefile
+++ b/com32/elflink/ldlinux/Makefile
@@ -22,7 +22,7 @@ OBJS = ldlinux.o cli.o readconfig.o refstr.o colors.o getadv.o adv.o \
BTARGET = $(LDLINUX)
-ifdef EFI_BUILD
+ifeq ($(FWCLASS),EFI)
%.e$(BITS): %.elf
$(OBJCOPY) --strip-debug --strip-unneeded $< $@
SONAME = $(patsubst %.elf,%.e$(BITS),$(@F))
diff --git a/com32/elflink/ldlinux/adv.c b/com32/elflink/ldlinux/adv.c
index 0cbbe27..8ce73c3 100644
--- a/com32/elflink/ldlinux/adv.c
+++ b/com32/elflink/ldlinux/adv.c
@@ -28,7 +28,7 @@
/*
* syslinux/adv.c
*
- * Access the syslinux auxilliary data vector
+ * Access the syslinux auxiliary data vector
*/
#include <syslinux/adv.h>
diff --git a/com32/elflink/ldlinux/cli.c b/com32/elflink/ldlinux/cli.c
index 6ff30c6..3119b11 100644
--- a/com32/elflink/ldlinux/cli.c
+++ b/com32/elflink/ldlinux/cli.c
@@ -125,7 +125,7 @@ const char *edit_cmdline(const char *input, int top /*, int width */ ,
int (*pDraw_Menu) (int, int, int),
void (*show_fkey) (int), bool *timedout)
{
- char cmdline[MAX_CMDLINE_LEN] = { };
+ static char cmdline[MAX_CMDLINE_LEN] = { };
int key, len, prev_len, cursor;
int redraw = 0;
int x, y;
diff --git a/com32/elflink/ldlinux/execute.c b/com32/elflink/ldlinux/execute.c
index 653c880..3955571 100644
--- a/com32/elflink/ldlinux/execute.c
+++ b/com32/elflink/ldlinux/execute.c
@@ -44,6 +44,7 @@ const struct image_types image_boot_types[] = {
{ NULL, 0 },
};
+extern jmp_buf __return_to_command_prompt;
extern int create_args_and_load(char *);
__export void execute(const char *cmdline, uint32_t type, bool sysappend)
@@ -136,7 +137,8 @@ __export void execute(const char *cmdline, uint32_t type, bool sysappend)
/* Restore the console */
ldlinux_console_init();
- ldlinux_enter_command();
+ /* Jump back to the main to call ldlinux_enter_command */
+ longjmp(__return_to_command_prompt, 1);
} else if (type == IMAGE_TYPE_CONFIG) {
char *argv[] = { LDLINUX, NULL, NULL };
char *config;
diff --git a/com32/elflink/ldlinux/getadv.c b/com32/elflink/ldlinux/getadv.c
index 1c27f1b..9baeba1 100644
--- a/com32/elflink/ldlinux/getadv.c
+++ b/com32/elflink/ldlinux/getadv.c
@@ -28,7 +28,7 @@
/*
* syslinux/getadv.c
*
- * Get a data item from the auxilliary data vector. Returns a pointer
+ * Get a data item from the auxiliary data vector. Returns a pointer
* and sets *size on success; NULL on failure.
*/
diff --git a/com32/elflink/ldlinux/kernel.c b/com32/elflink/ldlinux/kernel.c
index f3ba37f..942f97c 100644
--- a/com32/elflink/ldlinux/kernel.c
+++ b/com32/elflink/ldlinux/kernel.c
@@ -48,14 +48,6 @@ int new_linux_kernel(char *okernel, char *ocmdline)
sprintf(cmdline, "BOOT_IMAGE=%s %s", kernel_name, args);
- /* "keeppxe" handling */
-#if IS_PXELINUX
- extern char KeepPXE;
-
- if (strstr(cmdline, "keeppxe"))
- KeepPXE |= 1;
-#endif
-
if (strstr(cmdline, "quiet"))
opt_quiet = true;
diff --git a/com32/elflink/ldlinux/ldlinux.c b/com32/elflink/ldlinux/ldlinux.c
index 9b01dd3..0172117 100644
--- a/com32/elflink/ldlinux/ldlinux.c
+++ b/com32/elflink/ldlinux/ldlinux.c
@@ -31,6 +31,8 @@ static const struct file_ext file_extensions[] = {
{ NULL, 0 },
};
+jmp_buf __return_to_command_prompt;
+
/*
* Return a pointer to one byte after the last character of the
* command.
@@ -302,6 +304,7 @@ __export int main(int argc __unused, char **argv)
const void *adv;
const char *cmdline;
size_t count = 0;
+ int retval;
ldlinux_console_init();
@@ -333,16 +336,25 @@ __export int main(int argc __unused, char **argv)
if (!syslinux_setadv(ADV_BOOTONCE, 0, NULL))
syslinux_adv_write();
- load_kernel(cmdline); /* Shouldn't return */
- ldlinux_enter_command();
- }
-
- if (!forceprompt && !shift_is_held())
- ldlinux_auto_boot();
+ /*
+ * The corresponding longjmp is located in the execute function
+ * after a COM32 module has returned.
+ */
+ retval = setjmp(__return_to_command_prompt);
+ if (retval == 0)
+ load_kernel(cmdline); /* Shouldn't return */
+ } else {
+ retval = setjmp(__return_to_command_prompt);
+ if (retval == 0) {
+ if (!forceprompt && !shift_is_held())
+ ldlinux_auto_boot();
- if (defaultlevel > 1)
- ldlinux_auto_boot();
+ if (defaultlevel > 1)
+ ldlinux_auto_boot();
+ }
+ }
+ retval = setjmp(__return_to_command_prompt);
ldlinux_enter_command();
return 0;
}
diff --git a/com32/elflink/ldlinux/readconfig.c b/com32/elflink/ldlinux/readconfig.c
index 347f826..3d6aa27 100644
--- a/com32/elflink/ldlinux/readconfig.c
+++ b/com32/elflink/ldlinux/readconfig.c
@@ -330,7 +330,7 @@ static char *copy_sysappend_string(char *dst, const char *src)
char c;
while ((c = *src++)) {
- if (c <= ' ' && c == '\x7f') {
+ if (my_isspace(c)) {
if (!was_space)
*dst++ = '_';
was_space = true;
@@ -1311,7 +1311,7 @@ static void parse_config_file(FILE * f)
uint32_t baud;
p = skipspace(p + 6);
- port = atoi(p);
+ port = strtoul(p, &p, 0);
while (isalnum(*p))
p++;
@@ -1335,7 +1335,7 @@ static void parse_config_file(FILE * f)
flow = 0;
if (isalnum(*p)) {
/* flow control */
- flow = atoi(p);
+ flow = strtoul(p, NULL, 0);
ignore = ((flow & 0x0F00) >> 4);
}
diff --git a/com32/elflink/ldlinux/setadv.c b/com32/elflink/ldlinux/setadv.c
index 2e38621..ba3be72 100644
--- a/com32/elflink/ldlinux/setadv.c
+++ b/com32/elflink/ldlinux/setadv.c
@@ -29,7 +29,7 @@
/*
* syslinux/setadv.c
*
- * (Over)write a data item in the auxilliary data vector. To
+ * (Over)write a data item in the auxiliary data vector. To
* delete an item, set its length to zero.
*
* Return 0 on success, -1 on error, and set errno.
diff --git a/com32/gplinclude/cpuid.h b/com32/gplinclude/cpuid.h
index 6a33e9c..0eb2826 100644
--- a/com32/gplinclude/cpuid.h
+++ b/com32/gplinclude/cpuid.h
@@ -162,7 +162,7 @@ extern bool get_cpu_flag_value_from_name(s_cpu *cpu, const char * flag);
*/
#define X86_EFLAGS_CF 0x00000001 /* Carry Flag */
#define X86_EFLAGS_PF 0x00000004 /* Parity Flag */
-#define X86_EFLAGS_AF 0x00000010 /* Auxillary carry Flag */
+#define X86_EFLAGS_AF 0x00000010 /* Auxiliary carry Flag */
#define X86_EFLAGS_ZF 0x00000040 /* Zero Flag */
#define X86_EFLAGS_SF 0x00000080 /* Sign Flag */
#define X86_EFLAGS_TF 0x00000100 /* Trap Flag */
diff --git a/com32/gpllib/Makefile b/com32/gpllib/Makefile
index e3e30d7..1fec914 100644
--- a/com32/gpllib/Makefile
+++ b/com32/gpllib/Makefile
@@ -8,7 +8,7 @@ include $(MAKEDIR)/lib.mk
REQFLAGS += -I$(SRC)/../gplinclude -I$(SRC)/../gplinclude/zzjson
GPLDIRS := $(SRC) $(addprefix $(SRC)/,disk dmi vpd acpi zzjson)
-LIBOBJS := $(subst $(SRC)/,,$(foreach dir,$(GPLDIRS),$(patsubst %.c,%.o,$(wildcard $(dir)/*.c))))
+LIBOBJS := $(subst $(SRC)/,,$(foreach dir,$(GPLDIRS),$(patsubst %.c,%.o,$(sort $(wildcard $(dir)/*.c)))))
BINDIR = /usr/bin
LIBDIR = /usr/lib
diff --git a/com32/gpllib/acpi/xsdt.c b/com32/gpllib/acpi/xsdt.c
index 208abc6..976c896 100644
--- a/com32/gpllib/acpi/xsdt.c
+++ b/com32/gpllib/acpi/xsdt.c
@@ -63,7 +63,7 @@ int parse_xsdt(s_acpi * acpi)
/* Let's grab the pointed table header */
char address[16] = { 0 };
- sprintf(address, "%llx", *p);
+ sprintf(address, "%" PRIx64 "x", *p);
uint64_t *pointed_address = (uint64_t *)strtoul(address, NULL, 16);
x->entry[x->entry_count] = pointed_address;
diff --git a/com32/gpllib/disk/write.c b/com32/gpllib/disk/write.c
index d183ade..3c9edff 100644
--- a/com32/gpllib/disk/write.c
+++ b/com32/gpllib/disk/write.c
@@ -40,7 +40,7 @@ int write_sectors(const struct driveinfo *drive_info, const unsigned int lba,
void *buf;
int rv = -1;
- buf = lmalloc(size);
+ buf = lmalloc(SECTOR * size);
if (!buf)
return -1;
@@ -48,7 +48,7 @@ int write_sectors(const struct driveinfo *drive_info, const unsigned int lba,
if (!dapa)
goto out;
- memcpy(buf, data, size);
+ memcpy(buf, data, SECTOR * size);
memset(&inreg, 0, sizeof inreg);
if (drive_info->ebios) {
@@ -123,7 +123,7 @@ int write_verify_sectors(struct driveinfo *drive_info,
const unsigned int lba,
const void *data, const int size)
{
- char *rb = malloc(SECTOR * size * sizeof(char));
+ char *rb = malloc(SECTOR * size);
int status;
if (write_sectors(drive_info, lba, data, size) == -1)
diff --git a/com32/gpllib/dmi/dmi.c b/com32/gpllib/dmi/dmi.c
index ef84e1e..7613383 100644
--- a/com32/gpllib/dmi/dmi.c
+++ b/com32/gpllib/dmi/dmi.c
@@ -100,20 +100,20 @@ static const char *dmi_system_reset_boot_option(uint8_t code)
return out_of_spec;
}
-static void dmi_system_reset_count(uint16_t code, char *array)
+static void dmi_system_reset_count(uint16_t code, char *array, size_t len)
{
if (code == 0xFFFF)
- strlcpy(array, "Unknown", sizeof array);
+ strlcpy(array, "Unknown", len);
else
- snprintf(array, sizeof array, "%u", code);
+ snprintf(array, len, "%u", code);
}
-static void dmi_system_reset_timer(uint16_t code, char *array)
+static void dmi_system_reset_timer(uint16_t code, char *array, size_t len)
{
if (code == 0xFFFF)
- strlcpy(array, "Unknown", sizeof array);
+ strlcpy(array, "Unknown", len);
else
- snprintf(array, sizeof array, "%u min", code);
+ snprintf(array, len, "%u min", code);
}
/*
@@ -231,7 +231,7 @@ void dmi_bios_characteristics_x2(uint8_t code, s_dmi * dmi)
{
int i;
- for (i = 0; i <= 2; i++)
+ for (i = 0; i <= 4; i++)
if (code & (1 << i))
((bool *) (&dmi->bios.characteristics_x2))[i] = true;
}
@@ -947,13 +947,17 @@ void dmi_decode(struct dmi_header *h, uint16_t ver, s_dmi * dmi)
dmi_system_reset_boot_option((data[0x04] >> 3) & 0x3),
sizeof dmi->system.system_reset.boot_option_on_limit);
dmi_system_reset_count(WORD(data + 0x05),
- dmi->system.system_reset.reset_count);
+ dmi->system.system_reset.reset_count,
+ sizeof(dmi->system.system_reset.reset_count));
dmi_system_reset_count(WORD(data + 0x07),
- dmi->system.system_reset.reset_limit);
+ dmi->system.system_reset.reset_limit,
+ sizeof(dmi->system.system_reset.reset_limit));
dmi_system_reset_timer(WORD(data + 0x09),
- dmi->system.system_reset.timer_interval);
+ dmi->system.system_reset.timer_interval,
+ sizeof(dmi->system.system_reset.timer_interval));
dmi_system_reset_timer(WORD(data + 0x0B),
- dmi->system.system_reset.timeout);
+ dmi->system.system_reset.timeout,
+ sizeof(dmi->system.system_reset.timeout));
break;
case 24: /* 3.3.25 Hardware Security */
if (h->length < 0x05)
diff --git a/com32/gpllib/dmi/dmi_bios.c b/com32/gpllib/dmi/dmi_bios.c
index 4a74800..b21caf9 100644
--- a/com32/gpllib/dmi/dmi_bios.c
+++ b/com32/gpllib/dmi/dmi_bios.c
@@ -75,5 +75,7 @@ const char *bios_charac_x1_strings[] = {
const char *bios_charac_x2_strings[] = {
"BIOS boot specification is supported", /* 0 */
"Function key-initiated network boot is supported",
- "Targeted content distribution is supported" /* 2 */
+ "Targeted content distribution is supported",
+ "UEFI is supported",
+ "System is a virtual machine" /* 4 */
};
diff --git a/com32/gpllib/dmi/dmi_cache.c b/com32/gpllib/dmi/dmi_cache.c
index 67a43d0..b52eba1 100644
--- a/com32/gpllib/dmi/dmi_cache.c
+++ b/com32/gpllib/dmi/dmi_cache.c
@@ -130,10 +130,11 @@ const char *dmi_cache_associativity(uint8_t code)
"24-way Set-associative",
"32-way Set-associative",
"48-way Set-associative",
- "64-way Set-associative" /* 0x0D */
+ "64-way Set-associative",
+ "20-way Set-associative" /* 0x0E */
};
- if (code >= 0x01 && code <= 0x0D)
+ if (code >= 0x01 && code <= 0x0E)
return type[code - 0x01];
return out_of_spec;
}
diff --git a/com32/gpllib/dmi/dmi_chassis.c b/com32/gpllib/dmi/dmi_chassis.c
index afca5c2..020c163 100644
--- a/com32/gpllib/dmi/dmi_chassis.c
+++ b/com32/gpllib/dmi/dmi_chassis.c
@@ -57,14 +57,17 @@ const char *dmi_chassis_type(uint8_t code)
"RAID Chassis",
"Rack Mount Chassis",
"Sealed-case PC",
- "Multi-system", /* 0x19 */
+ "Multi-system",
"CompactPCI",
"AdvancedTCA",
"Blade",
- "Blade Enclosing" /* 0x1D */
+ "Blade Enclosing",
+ "Tablet",
+ "Convertible",
+ "Detachable" /* 0x20 */
};
- if (code >= 0x01 && code <= 0x1D)
+ if (code >= 0x01 && code <= 0x20)
return type[code - 0x01];
return out_of_spec;
}
diff --git a/com32/gpllib/dmi/dmi_memory.c b/com32/gpllib/dmi/dmi_memory.c
index 3693753..0647b8f 100644
--- a/com32/gpllib/dmi/dmi_memory.c
+++ b/com32/gpllib/dmi/dmi_memory.c
@@ -124,15 +124,20 @@ const char *dmi_memory_device_type(uint8_t code)
"RDRAM",
"DDR",
"DDR2",
- "DDR2 FB-DIMM", /* 0x14 */
- NULL,
- NULL,
- NULL,
- "DDR3", /* 0x18 */
- "FBD2" /* 0x19 */
+ "DDR2 FB-DIMM",
+ "Reserved",
+ "Reserved",
+ "Reserved",
+ "DDR3",
+ "FBD2",
+ "DDR4",
+ "LPDDR",
+ "LPDDR2",
+ "LPDDR3",
+ "LPDDR4" /* 0x1E */
};
- if (code >= 0x01 && code <= 0x19)
+ if (code >= 0x01 && code <= 0x1E)
return type[code - 0x01];
return out_of_spec;
}
@@ -152,7 +157,10 @@ void dmi_memory_device_type_detail(uint16_t code, char *type_detail, int sizeof_
"EDO",
"Window DRAM",
"Cache DRAM",
- "Non-Volatile" /* 12 */
+ "Non-Volatile",
+ "Registered (Buffered)",
+ "Unbuffered (Unregistered)",
+ "LRDIMM" /* 15 */
};
if ((code & 0x1FFE) == 0)
@@ -160,7 +168,7 @@ void dmi_memory_device_type_detail(uint16_t code, char *type_detail, int sizeof_
else {
int i;
- for (i = 1; i <= 12; i++)
+ for (i = 1; i <= 15; i++)
if (code & (1 << i))
snprintf(type_detail, sizeof_type_detail, "%s", detail[i - 1]);
}
diff --git a/com32/gpllib/dmi/dmi_processor.c b/com32/gpllib/dmi/dmi_processor.c
index fe2ef63..a23e7fe 100644
--- a/com32/gpllib/dmi/dmi_processor.c
+++ b/com32/gpllib/dmi/dmi_processor.c
@@ -256,8 +256,8 @@ const char *dmi_processor_family(uint8_t code, char *manufacturer)
"G5",
"ESA/390 G6", /* 0xCB */
"z/Architectur",
- NULL,
- NULL,
+ "Core i5",
+ "Core i3",
NULL,
NULL, /*0xD0 */
NULL,
@@ -268,29 +268,29 @@ const char *dmi_processor_family(uint8_t code, char *manufacturer)
"Multi-Core Xeon", /*0xD6 */
"Dual-Core Xeon 3xxx",
"Quad-Core Xeon 3xxx", /*0xD8 */
- NULL,
+ "Nano",
"Dual-Core Xeon 5xxx", /*0xDA */
"Quad-Core Xeon 5xxx",
NULL,
"Dual-Core Xeon 7xxx", /*0xDD */
"Quad-Core Xeon 7xxx",
"Multi-Core Xeon 7xxx",
- NULL, /*0xE0 */
- NULL,
- NULL,
+ "Multi-Core Xeon 3400", /*0xE0 */
NULL,
NULL,
NULL,
+ "Opteron 3000",
+ "Sempron II",
"Embedded Opteron Quad-Core", /* 0xE6 */
"Phenom Triple-Core",
"Turion Ultra Dual-Core Mobile",
"Turion Dual-Core Mobile",
"Athlon Dual-Core",
"Sempron SI", /*0xEB */
- NULL,
- NULL,
- NULL,
- NULL,
+ "Phenom II",
+ "Athlon II",
+ "Six-Core Opteron",
+ "Sempron M",
NULL,
NULL,
NULL,
@@ -367,17 +367,40 @@ const char *dmi_processor_upgrade(uint8_t code)
"Socket 478",
"Socket 754",
"Socket 940",
- "Socket 939" /* 0x12 */
+ "Socket 939",
"Socket mPGA604",
"Socket LGA771",
"Socket LGA775",
"Socket S1",
"Socket AM2",
- "Socket F (1207)"
- "Socket LGA1366" /* 0x19 */
+ "Socket F (1207)",
+ "Socket LGA1366",
+ "Socket G34",
+ "Socket AM3",
+ "Socket C32",
+ "Socket LGA1156",
+ "Socket LGA1567",
+ "Socket PGA988A",
+ "Socket BGA1288",
+ "Socket rPGA988B",
+ "Socket BGA1023",
+ "Socket BGA1224",
+ "Socket BGA1155",
+ "Socket LGA1356",
+ "Socket LGA2011",
+ "Socket FS1",
+ "Socket FS2",
+ "Socket FM1",
+ "Socket FM2",
+ "Socket LGA2011-3",
+ "Socket LGA1356-3",
+ "Socket LGA1150",
+ "Socket BGA1168",
+ "Socket BGA1234",
+ "Socket BGA1364" /* 0x30 */
};
- if (code >= 0x01 && code <= 0x19)
+ if (code >= 0x01 && code <= 0x30)
return upgrade[code - 0x01];
return out_of_spec;
}
diff --git a/com32/hdt/Makefile b/com32/hdt/Makefile
index 80f2d0a..61736d0 100644
--- a/com32/hdt/Makefile
+++ b/com32/hdt/Makefile
@@ -25,7 +25,7 @@ CFLAGS += -I$(com32)/cmenu/libmenu -I$(com32)
MODULES = hdt.c32
TESTFILES =
-OBJS = $(subst $(SRC)/,,$(patsubst %.c,%.o,$(wildcard $(SRC)/*.c)))
+OBJS = $(subst $(SRC)/,,$(patsubst %.c,%.o,$(sort $(wildcard $(SRC)/*.c))))
VERSION = $(shell $(SED) -n 's/\#define VERSION \"\(.*\)\"/\1/p' hdt.h)
CODENAME = $(shell $(SED) -n 's/\#define CODENAME \"\(.*\)\"/\1/p' hdt.h)
NODASH_VERSION = $(shell echo $(VERSION) | $(SED) -e 's/-/_/g' | $(SED) -e 's/\./_/g')
diff --git a/com32/hdt/hdt-cli-cpu.c b/com32/hdt/hdt-cli-cpu.c
index 6d764ce..660a90b 100644
--- a/com32/hdt/hdt-cli-cpu.c
+++ b/com32/hdt/hdt-cli-cpu.c
@@ -74,7 +74,7 @@ void main_show_cpu(int argc __unused, char **argv __unused,
/* Let's compute the cpu flags display
* We have to maximize the number of flags per line */
-static void show_flag(char *buffer, bool flag, char *flag_name, bool flush)
+static void show_flag(char *buffer, size_t len, bool flag, char *flag_name, bool flush)
{
char output_buffer[81];
/* Flush is only set when no more flags are present
@@ -86,7 +86,7 @@ static void show_flag(char *buffer, bool flag, char *flag_name, bool flush)
snprintf(output_buffer, sizeof output_buffer, "Flags : %s\n",
buffer);
more_printf("%s", output_buffer);
- memset(buffer, 0, sizeof(buffer));
+ memset(buffer, 0, len);
if (flush)
return;
}
@@ -158,95 +158,95 @@ static void show_cpu(int argc __unused, char **argv __unused,
/* Let's display the supported cpu flags */
memset(buffer, 0, sizeof(buffer));
- show_flag(buffer, hardware->cpu.flags.fpu, "fpu ", false);
- show_flag(buffer, hardware->cpu.flags.vme, "vme ", false);
- show_flag(buffer, hardware->cpu.flags.de, "de ", false);
- show_flag(buffer, hardware->cpu.flags.pse, "pse ", false);
- show_flag(buffer, hardware->cpu.flags.tsc, "tsc ", false);
- show_flag(buffer, hardware->cpu.flags.msr, "msr ", false);
- show_flag(buffer, hardware->cpu.flags.pae, "pae ", false);
- show_flag(buffer, hardware->cpu.flags.mce, "mce ", false);
- show_flag(buffer, hardware->cpu.flags.cx8, "cx8 ", false);
- show_flag(buffer, hardware->cpu.flags.apic, "apic ", false);
- show_flag(buffer, hardware->cpu.flags.sep, "sep ", false);
- show_flag(buffer, hardware->cpu.flags.mtrr, "mtrr ", false);
- show_flag(buffer, hardware->cpu.flags.pge, "pge ", false);
- show_flag(buffer, hardware->cpu.flags.mca, "mca ", false);
- show_flag(buffer, hardware->cpu.flags.cmov, "cmov ", false);
- show_flag(buffer, hardware->cpu.flags.pat, "pat ", false);
- show_flag(buffer, hardware->cpu.flags.pse_36, "pse_36 ", false);
- show_flag(buffer, hardware->cpu.flags.psn, "psn ", false);
- show_flag(buffer, hardware->cpu.flags.clflsh, "clflsh ", false);
- show_flag(buffer, hardware->cpu.flags.dts, "dts ", false);
- show_flag(buffer, hardware->cpu.flags.acpi, "acpi ", false);
- show_flag(buffer, hardware->cpu.flags.mmx, "mmx ", false);
- show_flag(buffer, hardware->cpu.flags.sse, "sse ", false);
- show_flag(buffer, hardware->cpu.flags.sse2, "sse2 ", false);
- show_flag(buffer, hardware->cpu.flags.ss, "ss ", false);
- show_flag(buffer, hardware->cpu.flags.htt, "ht ", false);
- show_flag(buffer, hardware->cpu.flags.acc, "acc ", false);
- show_flag(buffer, hardware->cpu.flags.syscall, "syscall ", false);
- show_flag(buffer, hardware->cpu.flags.mp, "mp ", false);
- show_flag(buffer, hardware->cpu.flags.nx, "nx ", false);
- show_flag(buffer, hardware->cpu.flags.mmxext, "mmxext ", false);
- show_flag(buffer, hardware->cpu.flags.lm, "lm ", false);
- show_flag(buffer, hardware->cpu.flags.nowext, "3dnowext ", false);
- show_flag(buffer, hardware->cpu.flags.now, "3dnow! ", false);
- show_flag(buffer, hardware->cpu.flags.svm, "svm ", false);
- show_flag(buffer, hardware->cpu.flags.vmx, "vmx ", false);
- show_flag(buffer, hardware->cpu.flags.pbe, "pbe ", false);
- show_flag(buffer, hardware->cpu.flags.fxsr_opt, "fxsr_opt ", false);
- show_flag(buffer, hardware->cpu.flags.gbpages, "gbpages ", false);
- show_flag(buffer, hardware->cpu.flags.rdtscp, "rdtscp ", false);
- show_flag(buffer, hardware->cpu.flags.pni, "pni ", false);
- show_flag(buffer, hardware->cpu.flags.pclmulqd, "pclmulqd ", false);
- show_flag(buffer, hardware->cpu.flags.dtes64, "dtes64 ", false);
- show_flag(buffer, hardware->cpu.flags.smx, "smx ", false);
- show_flag(buffer, hardware->cpu.flags.est, "est ", false);
- show_flag(buffer, hardware->cpu.flags.tm2, "tm2 ", false);
- show_flag(buffer, hardware->cpu.flags.sse3, "sse3 ", false);
- show_flag(buffer, hardware->cpu.flags.fma, "fma ", false);
- show_flag(buffer, hardware->cpu.flags.cx16, "cx16 ", false);
- show_flag(buffer, hardware->cpu.flags.xtpr, "xtpr ", false);
- show_flag(buffer, hardware->cpu.flags.pdcm, "pdcm ", false);
- show_flag(buffer, hardware->cpu.flags.dca, "dca ", false);
- show_flag(buffer, hardware->cpu.flags.xmm4_1, "xmm4_1 ", false);
- show_flag(buffer, hardware->cpu.flags.xmm4_2, "xmm4_2 ", false);
- show_flag(buffer, hardware->cpu.flags.x2apic, "x2apic ", false);
- show_flag(buffer, hardware->cpu.flags.movbe, "movbe ", false);
- show_flag(buffer, hardware->cpu.flags.popcnt, "popcnt ", false);
- show_flag(buffer, hardware->cpu.flags.aes, "aes ", false);
- show_flag(buffer, hardware->cpu.flags.xsave, "xsave ", false);
- show_flag(buffer, hardware->cpu.flags.osxsave, "osxsave ", false);
- show_flag(buffer, hardware->cpu.flags.avx, "avx ", false);
- show_flag(buffer, hardware->cpu.flags.hypervisor, "hypervisor ", false);
- show_flag(buffer, hardware->cpu.flags.ace2, "ace2 ", false);
- show_flag(buffer, hardware->cpu.flags.ace2_en, "ace2_en ", false);
- show_flag(buffer, hardware->cpu.flags.phe, "phe ", false);
- show_flag(buffer, hardware->cpu.flags.phe_en, "phe_en ", false);
- show_flag(buffer, hardware->cpu.flags.pmm, "pmm ", false);
- show_flag(buffer, hardware->cpu.flags.pmm_en, "pmm_en ", false);
- show_flag(buffer, hardware->cpu.flags.extapic, "extapic ", false);
- show_flag(buffer, hardware->cpu.flags.cr8_legacy, "cr8_legacy ", false);
- show_flag(buffer, hardware->cpu.flags.abm, "abm ", false);
- show_flag(buffer, hardware->cpu.flags.sse4a, "sse4a ", false);
- show_flag(buffer, hardware->cpu.flags.misalignsse, "misalignsse ", false);
- show_flag(buffer, hardware->cpu.flags.nowprefetch, "3dnowprefetch ", false);
- show_flag(buffer, hardware->cpu.flags.osvw, "osvw ", false);
- show_flag(buffer, hardware->cpu.flags.ibs, "ibs ", false);
- show_flag(buffer, hardware->cpu.flags.sse5, "sse5 ", false);
- show_flag(buffer, hardware->cpu.flags.skinit, "skinit ", false);
- show_flag(buffer, hardware->cpu.flags.wdt, "wdt ", false);
- show_flag(buffer, hardware->cpu.flags.ida, "ida ", false);
- show_flag(buffer, hardware->cpu.flags.arat, "arat ", false);
- show_flag(buffer, hardware->cpu.flags.tpr_shadow, "tpr_shadow ", false);
- show_flag(buffer, hardware->cpu.flags.vnmi, "vnmi ", false);
- show_flag(buffer, hardware->cpu.flags.flexpriority, "flexpriority ", false);
- show_flag(buffer, hardware->cpu.flags.ept, "ept ", false);
- show_flag(buffer, hardware->cpu.flags.vpid, "vpid ", false);
+ show_flag(buffer, sizeof(buffer), hardware->cpu.flags.fpu, "fpu ", false);
+ show_flag(buffer, sizeof(buffer), hardware->cpu.flags.vme, "vme ", false);
+ show_flag(buffer, sizeof(buffer), hardware->cpu.flags.de, "de ", false);
+ show_flag(buffer, sizeof(buffer), hardware->cpu.flags.pse, "pse ", false);
+ show_flag(buffer, sizeof(buffer), hardware->cpu.flags.tsc, "tsc ", false);
+ show_flag(buffer, sizeof(buffer), hardware->cpu.flags.msr, "msr ", false);
+ show_flag(buffer, sizeof(buffer), hardware->cpu.flags.pae, "pae ", false);
+ show_flag(buffer, sizeof(buffer), hardware->cpu.flags.mce, "mce ", false);
+ show_flag(buffer, sizeof(buffer), hardware->cpu.flags.cx8, "cx8 ", false);
+ show_flag(buffer, sizeof(buffer), hardware->cpu.flags.apic, "apic ", false);
+ show_flag(buffer, sizeof(buffer), hardware->cpu.flags.sep, "sep ", false);
+ show_flag(buffer, sizeof(buffer), hardware->cpu.flags.mtrr, "mtrr ", false);
+ show_flag(buffer, sizeof(buffer), hardware->cpu.flags.pge, "pge ", false);
+ show_flag(buffer, sizeof(buffer), hardware->cpu.flags.mca, "mca ", false);
+ show_flag(buffer, sizeof(buffer), hardware->cpu.flags.cmov, "cmov ", false);
+ show_flag(buffer, sizeof(buffer), hardware->cpu.flags.pat, "pat ", false);
+ show_flag(buffer, sizeof(buffer), hardware->cpu.flags.pse_36, "pse_36 ", false);
+ show_flag(buffer, sizeof(buffer), hardware->cpu.flags.psn, "psn ", false);
+ show_flag(buffer, sizeof(buffer), hardware->cpu.flags.clflsh, "clflsh ", false);
+ show_flag(buffer, sizeof(buffer), hardware->cpu.flags.dts, "dts ", false);
+ show_flag(buffer, sizeof(buffer), hardware->cpu.flags.acpi, "acpi ", false);
+ show_flag(buffer, sizeof(buffer), hardware->cpu.flags.mmx, "mmx ", false);
+ show_flag(buffer, sizeof(buffer), hardware->cpu.flags.sse, "sse ", false);
+ show_flag(buffer, sizeof(buffer), hardware->cpu.flags.sse2, "sse2 ", false);
+ show_flag(buffer, sizeof(buffer), hardware->cpu.flags.ss, "ss ", false);
+ show_flag(buffer, sizeof(buffer), hardware->cpu.flags.htt, "ht ", false);
+ show_flag(buffer, sizeof(buffer), hardware->cpu.flags.acc, "acc ", false);
+ show_flag(buffer, sizeof(buffer), hardware->cpu.flags.syscall, "syscall ", false);
+ show_flag(buffer, sizeof(buffer), hardware->cpu.flags.mp, "mp ", false);
+ show_flag(buffer, sizeof(buffer), hardware->cpu.flags.nx, "nx ", false);
+ show_flag(buffer, sizeof(buffer), hardware->cpu.flags.mmxext, "mmxext ", false);
+ show_flag(buffer, sizeof(buffer), hardware->cpu.flags.lm, "lm ", false);
+ show_flag(buffer, sizeof(buffer), hardware->cpu.flags.nowext, "3dnowext ", false);
+ show_flag(buffer, sizeof(buffer), hardware->cpu.flags.now, "3dnow! ", false);
+ show_flag(buffer, sizeof(buffer), hardware->cpu.flags.svm, "svm ", false);
+ show_flag(buffer, sizeof(buffer), hardware->cpu.flags.vmx, "vmx ", false);
+ show_flag(buffer, sizeof(buffer), hardware->cpu.flags.pbe, "pbe ", false);
+ show_flag(buffer, sizeof(buffer), hardware->cpu.flags.fxsr_opt, "fxsr_opt ", false);
+ show_flag(buffer, sizeof(buffer), hardware->cpu.flags.gbpages, "gbpages ", false);
+ show_flag(buffer, sizeof(buffer), hardware->cpu.flags.rdtscp, "rdtscp ", false);
+ show_flag(buffer, sizeof(buffer), hardware->cpu.flags.pni, "pni ", false);
+ show_flag(buffer, sizeof(buffer), hardware->cpu.flags.pclmulqd, "pclmulqd ", false);
+ show_flag(buffer, sizeof(buffer), hardware->cpu.flags.dtes64, "dtes64 ", false);
+ show_flag(buffer, sizeof(buffer), hardware->cpu.flags.smx, "smx ", false);
+ show_flag(buffer, sizeof(buffer), hardware->cpu.flags.est, "est ", false);
+ show_flag(buffer, sizeof(buffer), hardware->cpu.flags.tm2, "tm2 ", false);
+ show_flag(buffer, sizeof(buffer), hardware->cpu.flags.sse3, "sse3 ", false);
+ show_flag(buffer, sizeof(buffer), hardware->cpu.flags.fma, "fma ", false);
+ show_flag(buffer, sizeof(buffer), hardware->cpu.flags.cx16, "cx16 ", false);
+ show_flag(buffer, sizeof(buffer), hardware->cpu.flags.xtpr, "xtpr ", false);
+ show_flag(buffer, sizeof(buffer), hardware->cpu.flags.pdcm, "pdcm ", false);
+ show_flag(buffer, sizeof(buffer), hardware->cpu.flags.dca, "dca ", false);
+ show_flag(buffer, sizeof(buffer), hardware->cpu.flags.xmm4_1, "xmm4_1 ", false);
+ show_flag(buffer, sizeof(buffer), hardware->cpu.flags.xmm4_2, "xmm4_2 ", false);
+ show_flag(buffer, sizeof(buffer), hardware->cpu.flags.x2apic, "x2apic ", false);
+ show_flag(buffer, sizeof(buffer), hardware->cpu.flags.movbe, "movbe ", false);
+ show_flag(buffer, sizeof(buffer), hardware->cpu.flags.popcnt, "popcnt ", false);
+ show_flag(buffer, sizeof(buffer), hardware->cpu.flags.aes, "aes ", false);
+ show_flag(buffer, sizeof(buffer), hardware->cpu.flags.xsave, "xsave ", false);
+ show_flag(buffer, sizeof(buffer), hardware->cpu.flags.osxsave, "osxsave ", false);
+ show_flag(buffer, sizeof(buffer), hardware->cpu.flags.avx, "avx ", false);
+ show_flag(buffer, sizeof(buffer), hardware->cpu.flags.hypervisor, "hypervisor ", false);
+ show_flag(buffer, sizeof(buffer), hardware->cpu.flags.ace2, "ace2 ", false);
+ show_flag(buffer, sizeof(buffer), hardware->cpu.flags.ace2_en, "ace2_en ", false);
+ show_flag(buffer, sizeof(buffer), hardware->cpu.flags.phe, "phe ", false);
+ show_flag(buffer, sizeof(buffer), hardware->cpu.flags.phe_en, "phe_en ", false);
+ show_flag(buffer, sizeof(buffer), hardware->cpu.flags.pmm, "pmm ", false);
+ show_flag(buffer, sizeof(buffer), hardware->cpu.flags.pmm_en, "pmm_en ", false);
+ show_flag(buffer, sizeof(buffer), hardware->cpu.flags.extapic, "extapic ", false);
+ show_flag(buffer, sizeof(buffer), hardware->cpu.flags.cr8_legacy, "cr8_legacy ", false);
+ show_flag(buffer, sizeof(buffer), hardware->cpu.flags.abm, "abm ", false);
+ show_flag(buffer, sizeof(buffer), hardware->cpu.flags.sse4a, "sse4a ", false);
+ show_flag(buffer, sizeof(buffer), hardware->cpu.flags.misalignsse, "misalignsse ", false);
+ show_flag(buffer, sizeof(buffer), hardware->cpu.flags.nowprefetch, "3dnowprefetch ", false);
+ show_flag(buffer, sizeof(buffer), hardware->cpu.flags.osvw, "osvw ", false);
+ show_flag(buffer, sizeof(buffer), hardware->cpu.flags.ibs, "ibs ", false);
+ show_flag(buffer, sizeof(buffer), hardware->cpu.flags.sse5, "sse5 ", false);
+ show_flag(buffer, sizeof(buffer), hardware->cpu.flags.skinit, "skinit ", false);
+ show_flag(buffer, sizeof(buffer), hardware->cpu.flags.wdt, "wdt ", false);
+ show_flag(buffer, sizeof(buffer), hardware->cpu.flags.ida, "ida ", false);
+ show_flag(buffer, sizeof(buffer), hardware->cpu.flags.arat, "arat ", false);
+ show_flag(buffer, sizeof(buffer), hardware->cpu.flags.tpr_shadow, "tpr_shadow ", false);
+ show_flag(buffer, sizeof(buffer), hardware->cpu.flags.vnmi, "vnmi ", false);
+ show_flag(buffer, sizeof(buffer), hardware->cpu.flags.flexpriority, "flexpriority ", false);
+ show_flag(buffer, sizeof(buffer), hardware->cpu.flags.ept, "ept ", false);
+ show_flag(buffer, sizeof(buffer), hardware->cpu.flags.vpid, "vpid ", false);
/* No more flags, let's display the remaining flags */
- show_flag(buffer, false, "", true);
+ show_flag(buffer, sizeof(buffer), false, "", true);
}
struct cli_module_descr cpu_show_modules = {
diff --git a/com32/hdt/hdt-cli-memory.c b/com32/hdt/hdt-cli-memory.c
index c05b7cd..a614292 100644
--- a/com32/hdt/hdt-cli-memory.c
+++ b/com32/hdt/hdt-cli-memory.c
@@ -47,7 +47,7 @@ static void show_memory_e820(int argc __unused, char **argv __unused,
more_printf("BIOS-provided physical RAM e820 map:\n");
for (int i = 0; i < count; i++) {
get_type(map[i].type, type, 14);
- more_printf("%016llx - %016llx %016llx (%s)\n",
+ more_printf("%016" PRIx64 "x - %016" PRIx64 "x %016" PRIx64 "x (%s)\n",
map[i].addr, map[i].size, map[i].addr + map[i].size,
remove_spaces(type));
}
@@ -60,7 +60,7 @@ static void show_memory_e820(int argc __unused, char **argv __unused,
more_printf("Sanitized e820 map:\n");
for (int i = 0; i < nr; i++) {
get_type(nm[i].type, type, 14);
- more_printf("%016llx - %016llx %016llx (%s)\n",
+ more_printf("%016" PRIx64 "x - %016" PRIx64 "x %016" PRIx64 "x (%s)\n",
nm[i].addr, nm[i].size, nm[i].addr + nm[i].size,
remove_spaces(type));
}
diff --git a/com32/hdt/hdt-cli.c b/com32/hdt/hdt-cli.c
index 2895b13..9d3c2a0 100644
--- a/com32/hdt/hdt-cli.c
+++ b/com32/hdt/hdt-cli.c
@@ -211,7 +211,7 @@ cli_mode_t mode_s_to_mode_t(char *name)
int i = 0;
while (list_modes[i]) {
- if (!strncmp(name, list_modes[i]->name, sizeof(list_modes[i]->name)))
+ if (!strcmp(name, list_modes[i]->name))
break;
i++;
}
@@ -288,8 +288,7 @@ static void expand_aliases(char *line __unused, char **command, char **module,
/* Simple aliases mapping a single command to another one */
for (i = 0; i < MAX_ALIASES; i++) {
for (j = 0; j < hdt_aliases[i].nb_aliases; j++) {
- if (!strncmp(*command, hdt_aliases[i].aliases[j],
- sizeof(hdt_aliases[i].aliases[j]))) {
+ if (!strcmp(*command, hdt_aliases[i].aliases[j])) {
dprintf("CLI DEBUG: ALIAS %s ", *command);
strlcpy(*command, hdt_aliases[i].command,
sizeof(hdt_aliases[i].command) + 1);
@@ -323,7 +322,7 @@ out:
* command is always malloc'ed (even for an empty line)
**/
static void parse_command_line(char *line, char **command, char **module,
- int *argc, char **argv)
+ int *argc, char ***argv)
{
int argc_iter = 0, args_pos = 0, token_found = 0, token_len = 0;
int args_len = 0;
@@ -391,8 +390,8 @@ static void parse_command_line(char *line, char **command, char **module,
pch = strtok(line + args_pos, CLI_SPACE);
while (pch != NULL) {
dprintf("CLI DEBUG parse: argv[%d] = %s\n", argc_iter, pch);
- argv[argc_iter] = malloc(strlen(pch) * sizeof(char));
- strlcpy(argv[argc_iter], pch, strlen(pch));
+ *argv[argc_iter] = malloc(strlen(pch) * sizeof(char));
+ strlcpy(*argv[argc_iter], pch, strlen(pch));
argc_iter++;
pch = strtok(NULL, CLI_SPACE);
/*
@@ -583,7 +582,7 @@ static void autocomplete(char *line)
char *command = NULL, *module = NULL;
char **argv = NULL;
- parse_command_line(line, &command, &module, &argc, argv);
+ parse_command_line(line, &command, &module, &argc, &argv);
dprintf("CLI DEBUG autocomplete: before checking args\n");
/* If the user specified arguments, there is nothing we can complete */
@@ -624,7 +623,7 @@ static void exec_command(char *line, struct s_hardware *hardware)
struct cli_callback_descr *current_module = NULL;
/* This will allocate memory for command and module */
- parse_command_line(line, &command, &module, &argc, argv);
+ parse_command_line(line, &command, &module, &argc, &argv);
dprintf("CLI DEBUG exec: Checking for aliases\n");
/*
@@ -636,7 +635,7 @@ static void exec_command(char *line, struct s_hardware *hardware)
find_cli_callback_descr(command, current_mode->default_modules,
&current_module);
- if ((module == NULL) || (current_module->nomodule == true)) {
+ if ((module == NULL) || ((current_module != NULL) && current_module->nomodule == true)) {
dprintf("CLI DEBUG exec : single command detected\n");
/*
* A single word was specified: look at the list of default
@@ -646,7 +645,7 @@ static void exec_command(char *line, struct s_hardware *hardware)
*/
/* First of all it the command doesn't need module, let's rework the arguments */
- if ((current_module->nomodule == true) && ( module != NULL)) {
+ if (((current_module != NULL) && (current_module->nomodule == true)) && ( module != NULL)) {
dprintf("CLI_DEBUG exec: Reworking arguments with argc=%d\n",argc);
char **new_argv=NULL;
new_argv=malloc((argc + 2)*sizeof(char *));
diff --git a/com32/hdt/hdt-dump-memory.c b/com32/hdt/hdt-dump-memory.c
index 5095d3c..224ea24 100644
--- a/com32/hdt/hdt-dump-memory.c
+++ b/com32/hdt/hdt-dump-memory.c
@@ -91,9 +91,9 @@ void dump_e820(struct s_hardware *hardware, ZZJSON_CONFIG *config, ZZJSON **item
char begin[24]={0};
char size[24]={0};
char end[24]={0};
- snprintf(begin,sizeof(begin),"0x%016llx",map[i].addr);
- snprintf(size,sizeof(size),"0x%016llx",map[i].size);
- snprintf(end,sizeof(end),"0x%016llx",map[i].addr+map[i].size);
+ snprintf(begin,sizeof(begin),"0x%016" PRIx64 "x",map[i].addr);
+ snprintf(size,sizeof(size),"0x%016" PRIx64 "x",map[i].size);
+ snprintf(end,sizeof(end),"0x%016" PRIx64 "x",map[i].addr+map[i].size);
CREATE_NEW_OBJECT;
add_s("memory.segment.start",begin);
add_s("memory.segment.size ",size);
@@ -108,9 +108,9 @@ void dump_e820(struct s_hardware *hardware, ZZJSON_CONFIG *config, ZZJSON **item
char begin[24]={0};
char size[24]={0};
char end[24]={0};
- snprintf(begin,sizeof(begin),"0x%016llx",nm[i].addr);
- snprintf(size,sizeof(size),"0x%016llx",nm[i].size);
- snprintf(end,sizeof(end),"0x%016llx",nm[i].addr+nm[i].size);
+ snprintf(begin,sizeof(begin),"0x%016" PRIx64 "x",nm[i].addr);
+ snprintf(size,sizeof(size),"0x%016" PRIx64 "x",nm[i].size);
+ snprintf(end,sizeof(end),"0x%016" PRIx64 "x",nm[i].addr+nm[i].size);
CREATE_NEW_OBJECT;
add_s("sanitized_memory.segment.start",begin);
add_s("sanitized_memory.segment.size ",size);
diff --git a/com32/hdt/hdt-dump.c b/com32/hdt/hdt-dump.c
index b1748c8..17bcc25 100644
--- a/com32/hdt/hdt-dump.c
+++ b/com32/hdt/hdt-dump.c
@@ -116,6 +116,12 @@ char *compute_filename(struct s_hardware *hardware)
/* Avoid space to make filename easier to manipulate */
chrreplace(filename, ' ', '_');
+ /* Avoid commas to make filename easier to manipulate */
+ chrreplace(filename, ',', '_');
+
+ /* Avoid pluses to make filename easier to manipulate */
+ chrreplace(filename, '+', '_');
+
return filename;
}
@@ -218,11 +224,12 @@ void dump(struct s_hardware *hardware)
/* We close & flush the file to send */
cpio_close(upload);
- if ((err = flush_data(upload)) != TFTP_OK) {
+ if ((err = flush_data(upload)) != TFTP_ERR_OK) {
/* As we manage a tftp connection, let's display the associated error message */
more_printf("Dump failed !\n");
more_printf("TFTP ERROR on : %s:/%s \n", hardware->tftp_ip, filename);
- more_printf("TFTP ERROR msg : %s \n", tftp_string_error_message[-err]);
+ more_printf("TFTP ERROR num : %d \n", err);
+ more_printf("TFTP ERROR msg : %s \n", tftp_string_error_message[err]);
} else {
more_printf("Dump file sent at %s:/%s\n", hardware->tftp_ip, filename);
}
diff --git a/com32/hdt/hdt-menu-memory.c b/com32/hdt/hdt-menu-memory.c
index 60d741d..ae6fc67 100644
--- a/com32/hdt/hdt-menu-memory.c
+++ b/com32/hdt/hdt-menu-memory.c
@@ -57,10 +57,10 @@ static void compute_e820(struct s_my_menu *menu)
for (int j = 0; j < count; j++) {
get_type(map[j].type, type, 14);
snprintf(buffer, sizeof buffer,
- "%016llx - %016llx (%s)",
+ "%016" PRIx64 "x - %016" PRIx64 "x (%s)",
map[j].addr, map[j].size, remove_spaces(type));
snprintf(statbuffer, sizeof statbuffer,
- "%016llx - %016llx (%s)",
+ "%016" PRIx64 "x - %016" PRIx64 "x (%s)",
map[j].addr, map[j].size, remove_spaces(type));
add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
menu->items_count++;
diff --git a/com32/hdt/hdt-menu-processor.c b/com32/hdt/hdt-menu-processor.c
index f28833b..623c3c8 100644
--- a/com32/hdt/hdt-menu-processor.c
+++ b/com32/hdt/hdt-menu-processor.c
@@ -28,7 +28,7 @@
#include "hdt-menu.h"
-static void show_flag(struct s_my_menu *menu, char *buffer, bool flag,
+static void show_flag(struct s_my_menu *menu, char *buffer, size_t len, bool flag,
char *flag_name, bool flush)
{
char output_buffer[SUBMENULEN + 1];
@@ -39,7 +39,7 @@ static void show_flag(struct s_my_menu *menu, char *buffer, bool flag,
add_item(output_buffer, statbuffer, OPT_INACTIVE, NULL, 0);
menu->items_count++;
- memset(buffer, 0, sizeof(buffer));
+ memset(buffer, 0, len);
if (flush)
return;
}
@@ -213,101 +213,101 @@ void compute_processor(struct s_my_menu *menu, struct s_hardware *hardware)
menu->items_count++;
memset(buffer1, 0, sizeof(buffer1));
- show_flag(menu, buffer1, hardware->cpu.flags.fpu, "fpu ", false);
- show_flag(menu, buffer1, hardware->cpu.flags.vme, "vme ", false);
- show_flag(menu, buffer1, hardware->cpu.flags.de, "de ", false);
- show_flag(menu, buffer1, hardware->cpu.flags.pse, "pse ", false);
- show_flag(menu, buffer1, hardware->cpu.flags.tsc, "tsc ", false);
- show_flag(menu, buffer1, hardware->cpu.flags.msr, "msr ", false);
- show_flag(menu, buffer1, hardware->cpu.flags.pae, "pae ", false);
- show_flag(menu, buffer1, hardware->cpu.flags.mce, "mce ", false);
- show_flag(menu, buffer1, hardware->cpu.flags.cx8, "cx8 ", false);
- show_flag(menu, buffer1, hardware->cpu.flags.apic, "apic ", false);
- show_flag(menu, buffer1, hardware->cpu.flags.sep, "sep ", false);
- show_flag(menu, buffer1, hardware->cpu.flags.mtrr, "mtrr ", false);
- show_flag(menu, buffer1, hardware->cpu.flags.pge, "pge ", false);
- show_flag(menu, buffer1, hardware->cpu.flags.mca, "mca ", false);
- show_flag(menu, buffer1, hardware->cpu.flags.cmov, "cmov ", false);
- show_flag(menu, buffer1, hardware->cpu.flags.pat, "pat ", false);
- show_flag(menu, buffer1, hardware->cpu.flags.pse_36, "pse_36 ", false);
- show_flag(menu, buffer1, hardware->cpu.flags.psn, "psn ", false);
- show_flag(menu, buffer1, hardware->cpu.flags.clflsh, "clflsh ", false);
- show_flag(menu, buffer1, hardware->cpu.flags.dts, "dts ", false);
- show_flag(menu, buffer1, hardware->cpu.flags.acpi, "acpi ", false);
- show_flag(menu, buffer1, hardware->cpu.flags.mmx, "mmx ", false);
- show_flag(menu, buffer1, hardware->cpu.flags.sse, "sse ", false);
- show_flag(menu, buffer1, hardware->cpu.flags.sse2, "sse2 ", false);
- show_flag(menu, buffer1, hardware->cpu.flags.ss, "ss ", false);
- show_flag(menu, buffer1, hardware->cpu.flags.htt, "ht ", false);
- show_flag(menu, buffer1, hardware->cpu.flags.acc, "acc ", false);
- show_flag(menu, buffer1, hardware->cpu.flags.syscall, "syscall ", false);
- show_flag(menu, buffer1, hardware->cpu.flags.mp, "mp ", false);
- show_flag(menu, buffer1, hardware->cpu.flags.nx, "nx ", false);
- show_flag(menu, buffer1, hardware->cpu.flags.mmxext, "mmxext ", false);
- show_flag(menu, buffer1, hardware->cpu.flags.lm, "lm ", false);
- show_flag(menu, buffer1, hardware->cpu.flags.nowext, "3dnowext ", false);
- show_flag(menu, buffer1, hardware->cpu.flags.now, "3dnow! ", false);
- show_flag(menu, buffer1, hardware->cpu.flags.svm, "svm ", false);
- show_flag(menu, buffer1, hardware->cpu.flags.vmx, "vmx ", false);
- show_flag(menu, buffer1, hardware->cpu.flags.pbe, "pbe ", false);
- show_flag(menu, buffer1, hardware->cpu.flags.fxsr_opt, "fxsr_opt ", false);
- show_flag(menu, buffer1, hardware->cpu.flags.gbpages, "gbpages ", false);
- show_flag(menu, buffer1, hardware->cpu.flags.rdtscp, "rdtscp ", false);
- show_flag(menu, buffer1, hardware->cpu.flags.pni, "pni ", false);
- show_flag(menu, buffer1, hardware->cpu.flags.pclmulqd, "pclmulqd ", false);
- show_flag(menu, buffer1, hardware->cpu.flags.dtes64, "dtes64 ", false);
- show_flag(menu, buffer1, hardware->cpu.flags.smx, "smx ", false);
- show_flag(menu, buffer1, hardware->cpu.flags.est, "est ", false);
- show_flag(menu, buffer1, hardware->cpu.flags.tm2, "tm2 ", false);
- show_flag(menu, buffer1, hardware->cpu.flags.sse3, "sse3 ", false);
- show_flag(menu, buffer1, hardware->cpu.flags.fma, "fma ", false);
- show_flag(menu, buffer1, hardware->cpu.flags.cx16, "cx16 ", false);
- show_flag(menu, buffer1, hardware->cpu.flags.xtpr, "xtpr ", false);
- show_flag(menu, buffer1, hardware->cpu.flags.pdcm, "pdcm ", false);
- show_flag(menu, buffer1, hardware->cpu.flags.dca, "dca ", false);
- show_flag(menu, buffer1, hardware->cpu.flags.xmm4_1, "xmm4_1 ", false);
- show_flag(menu, buffer1, hardware->cpu.flags.xmm4_2, "xmm4_2 ", false);
- show_flag(menu, buffer1, hardware->cpu.flags.x2apic, "x2apic ", false);
- show_flag(menu, buffer1, hardware->cpu.flags.movbe, "movbe ", false);
- show_flag(menu, buffer1, hardware->cpu.flags.popcnt, "popcnt ", false);
- show_flag(menu, buffer1, hardware->cpu.flags.aes, "aes ", false);
- show_flag(menu, buffer1, hardware->cpu.flags.xsave, "xsave ", false);
- show_flag(menu, buffer1, hardware->cpu.flags.osxsave, "osxsave ", false);
- show_flag(menu, buffer1, hardware->cpu.flags.avx, "avx ", false);
- show_flag(menu, buffer1, hardware->cpu.flags.hypervisor, "hypervisor ",
+ show_flag(menu, buffer1, sizeof(buffer1), hardware->cpu.flags.fpu, "fpu ", false);
+ show_flag(menu, buffer1, sizeof(buffer1), hardware->cpu.flags.vme, "vme ", false);
+ show_flag(menu, buffer1, sizeof(buffer1), hardware->cpu.flags.de, "de ", false);
+ show_flag(menu, buffer1, sizeof(buffer1), hardware->cpu.flags.pse, "pse ", false);
+ show_flag(menu, buffer1, sizeof(buffer1), hardware->cpu.flags.tsc, "tsc ", false);
+ show_flag(menu, buffer1, sizeof(buffer1), hardware->cpu.flags.msr, "msr ", false);
+ show_flag(menu, buffer1, sizeof(buffer1), hardware->cpu.flags.pae, "pae ", false);
+ show_flag(menu, buffer1, sizeof(buffer1), hardware->cpu.flags.mce, "mce ", false);
+ show_flag(menu, buffer1, sizeof(buffer1), hardware->cpu.flags.cx8, "cx8 ", false);
+ show_flag(menu, buffer1, sizeof(buffer1), hardware->cpu.flags.apic, "apic ", false);
+ show_flag(menu, buffer1, sizeof(buffer1), hardware->cpu.flags.sep, "sep ", false);
+ show_flag(menu, buffer1, sizeof(buffer1), hardware->cpu.flags.mtrr, "mtrr ", false);
+ show_flag(menu, buffer1, sizeof(buffer1), hardware->cpu.flags.pge, "pge ", false);
+ show_flag(menu, buffer1, sizeof(buffer1), hardware->cpu.flags.mca, "mca ", false);
+ show_flag(menu, buffer1, sizeof(buffer1), hardware->cpu.flags.cmov, "cmov ", false);
+ show_flag(menu, buffer1, sizeof(buffer1), hardware->cpu.flags.pat, "pat ", false);
+ show_flag(menu, buffer1, sizeof(buffer1), hardware->cpu.flags.pse_36, "pse_36 ", false);
+ show_flag(menu, buffer1, sizeof(buffer1), hardware->cpu.flags.psn, "psn ", false);
+ show_flag(menu, buffer1, sizeof(buffer1), hardware->cpu.flags.clflsh, "clflsh ", false);
+ show_flag(menu, buffer1, sizeof(buffer1), hardware->cpu.flags.dts, "dts ", false);
+ show_flag(menu, buffer1, sizeof(buffer1), hardware->cpu.flags.acpi, "acpi ", false);
+ show_flag(menu, buffer1, sizeof(buffer1), hardware->cpu.flags.mmx, "mmx ", false);
+ show_flag(menu, buffer1, sizeof(buffer1), hardware->cpu.flags.sse, "sse ", false);
+ show_flag(menu, buffer1, sizeof(buffer1), hardware->cpu.flags.sse2, "sse2 ", false);
+ show_flag(menu, buffer1, sizeof(buffer1), hardware->cpu.flags.ss, "ss ", false);
+ show_flag(menu, buffer1, sizeof(buffer1), hardware->cpu.flags.htt, "ht ", false);
+ show_flag(menu, buffer1, sizeof(buffer1), hardware->cpu.flags.acc, "acc ", false);
+ show_flag(menu, buffer1, sizeof(buffer1), hardware->cpu.flags.syscall, "syscall ", false);
+ show_flag(menu, buffer1, sizeof(buffer1), hardware->cpu.flags.mp, "mp ", false);
+ show_flag(menu, buffer1, sizeof(buffer1), hardware->cpu.flags.nx, "nx ", false);
+ show_flag(menu, buffer1, sizeof(buffer1), hardware->cpu.flags.mmxext, "mmxext ", false);
+ show_flag(menu, buffer1, sizeof(buffer1), hardware->cpu.flags.lm, "lm ", false);
+ show_flag(menu, buffer1, sizeof(buffer1), hardware->cpu.flags.nowext, "3dnowext ", false);
+ show_flag(menu, buffer1, sizeof(buffer1), hardware->cpu.flags.now, "3dnow! ", false);
+ show_flag(menu, buffer1, sizeof(buffer1), hardware->cpu.flags.svm, "svm ", false);
+ show_flag(menu, buffer1, sizeof(buffer1), hardware->cpu.flags.vmx, "vmx ", false);
+ show_flag(menu, buffer1, sizeof(buffer1), hardware->cpu.flags.pbe, "pbe ", false);
+ show_flag(menu, buffer1, sizeof(buffer1), hardware->cpu.flags.fxsr_opt, "fxsr_opt ", false);
+ show_flag(menu, buffer1, sizeof(buffer1), hardware->cpu.flags.gbpages, "gbpages ", false);
+ show_flag(menu, buffer1, sizeof(buffer1), hardware->cpu.flags.rdtscp, "rdtscp ", false);
+ show_flag(menu, buffer1, sizeof(buffer1), hardware->cpu.flags.pni, "pni ", false);
+ show_flag(menu, buffer1, sizeof(buffer1), hardware->cpu.flags.pclmulqd, "pclmulqd ", false);
+ show_flag(menu, buffer1, sizeof(buffer1), hardware->cpu.flags.dtes64, "dtes64 ", false);
+ show_flag(menu, buffer1, sizeof(buffer1), hardware->cpu.flags.smx, "smx ", false);
+ show_flag(menu, buffer1, sizeof(buffer1), hardware->cpu.flags.est, "est ", false);
+ show_flag(menu, buffer1, sizeof(buffer1), hardware->cpu.flags.tm2, "tm2 ", false);
+ show_flag(menu, buffer1, sizeof(buffer1), hardware->cpu.flags.sse3, "sse3 ", false);
+ show_flag(menu, buffer1, sizeof(buffer1), hardware->cpu.flags.fma, "fma ", false);
+ show_flag(menu, buffer1, sizeof(buffer1), hardware->cpu.flags.cx16, "cx16 ", false);
+ show_flag(menu, buffer1, sizeof(buffer1), hardware->cpu.flags.xtpr, "xtpr ", false);
+ show_flag(menu, buffer1, sizeof(buffer1), hardware->cpu.flags.pdcm, "pdcm ", false);
+ show_flag(menu, buffer1, sizeof(buffer1), hardware->cpu.flags.dca, "dca ", false);
+ show_flag(menu, buffer1, sizeof(buffer1), hardware->cpu.flags.xmm4_1, "xmm4_1 ", false);
+ show_flag(menu, buffer1, sizeof(buffer1), hardware->cpu.flags.xmm4_2, "xmm4_2 ", false);
+ show_flag(menu, buffer1, sizeof(buffer1), hardware->cpu.flags.x2apic, "x2apic ", false);
+ show_flag(menu, buffer1, sizeof(buffer1), hardware->cpu.flags.movbe, "movbe ", false);
+ show_flag(menu, buffer1, sizeof(buffer1), hardware->cpu.flags.popcnt, "popcnt ", false);
+ show_flag(menu, buffer1, sizeof(buffer1), hardware->cpu.flags.aes, "aes ", false);
+ show_flag(menu, buffer1, sizeof(buffer1), hardware->cpu.flags.xsave, "xsave ", false);
+ show_flag(menu, buffer1, sizeof(buffer1), hardware->cpu.flags.osxsave, "osxsave ", false);
+ show_flag(menu, buffer1, sizeof(buffer1), hardware->cpu.flags.avx, "avx ", false);
+ show_flag(menu, buffer1, sizeof(buffer1), hardware->cpu.flags.hypervisor, "hypervisor ",
false);
- show_flag(menu, buffer1, hardware->cpu.flags.ace2, "ace2 ", false);
- show_flag(menu, buffer1, hardware->cpu.flags.ace2_en, "ace2_en ", false);
- show_flag(menu, buffer1, hardware->cpu.flags.phe, "phe ", false);
- show_flag(menu, buffer1, hardware->cpu.flags.phe_en, "phe_en ", false);
- show_flag(menu, buffer1, hardware->cpu.flags.pmm, "pmm ", false);
- show_flag(menu, buffer1, hardware->cpu.flags.pmm_en, "pmm_en ", false);
- show_flag(menu, buffer1, hardware->cpu.flags.extapic, "extapic ", false);
- show_flag(menu, buffer1, hardware->cpu.flags.cr8_legacy, "cr8_legacy ",
+ show_flag(menu, buffer1, sizeof(buffer1), hardware->cpu.flags.ace2, "ace2 ", false);
+ show_flag(menu, buffer1, sizeof(buffer1), hardware->cpu.flags.ace2_en, "ace2_en ", false);
+ show_flag(menu, buffer1, sizeof(buffer1), hardware->cpu.flags.phe, "phe ", false);
+ show_flag(menu, buffer1, sizeof(buffer1), hardware->cpu.flags.phe_en, "phe_en ", false);
+ show_flag(menu, buffer1, sizeof(buffer1), hardware->cpu.flags.pmm, "pmm ", false);
+ show_flag(menu, buffer1, sizeof(buffer1), hardware->cpu.flags.pmm_en, "pmm_en ", false);
+ show_flag(menu, buffer1, sizeof(buffer1), hardware->cpu.flags.extapic, "extapic ", false);
+ show_flag(menu, buffer1, sizeof(buffer1), hardware->cpu.flags.cr8_legacy, "cr8_legacy ",
false);
- show_flag(menu, buffer1, hardware->cpu.flags.abm, "abm ", false);
- show_flag(menu, buffer1, hardware->cpu.flags.sse4a, "sse4a ", false);
- show_flag(menu, buffer1, hardware->cpu.flags.misalignsse, "misalignsse ",
+ show_flag(menu, buffer1, sizeof(buffer1), hardware->cpu.flags.abm, "abm ", false);
+ show_flag(menu, buffer1, sizeof(buffer1), hardware->cpu.flags.sse4a, "sse4a ", false);
+ show_flag(menu, buffer1, sizeof(buffer1), hardware->cpu.flags.misalignsse, "misalignsse ",
false);
- show_flag(menu, buffer1, hardware->cpu.flags.nowprefetch, "3dnowprefetch ",
+ show_flag(menu, buffer1, sizeof(buffer1), hardware->cpu.flags.nowprefetch, "3dnowprefetch ",
false);
- show_flag(menu, buffer1, hardware->cpu.flags.osvw, "osvw ", false);
- show_flag(menu, buffer1, hardware->cpu.flags.ibs, "ibs ", false);
- show_flag(menu, buffer1, hardware->cpu.flags.sse5, "sse5 ", false);
- show_flag(menu, buffer1, hardware->cpu.flags.skinit, "skinit ", false);
- show_flag(menu, buffer1, hardware->cpu.flags.wdt, "wdt ", false);
- show_flag(menu, buffer1, hardware->cpu.flags.ida, "ida ", false);
- show_flag(menu, buffer1, hardware->cpu.flags.arat, "arat ", false);
- show_flag(menu, buffer1, hardware->cpu.flags.tpr_shadow, "tpr_shadow ",
+ show_flag(menu, buffer1, sizeof(buffer1), hardware->cpu.flags.osvw, "osvw ", false);
+ show_flag(menu, buffer1, sizeof(buffer1), hardware->cpu.flags.ibs, "ibs ", false);
+ show_flag(menu, buffer1, sizeof(buffer1), hardware->cpu.flags.sse5, "sse5 ", false);
+ show_flag(menu, buffer1, sizeof(buffer1), hardware->cpu.flags.skinit, "skinit ", false);
+ show_flag(menu, buffer1, sizeof(buffer1), hardware->cpu.flags.wdt, "wdt ", false);
+ show_flag(menu, buffer1, sizeof(buffer1), hardware->cpu.flags.ida, "ida ", false);
+ show_flag(menu, buffer1, sizeof(buffer1), hardware->cpu.flags.arat, "arat ", false);
+ show_flag(menu, buffer1, sizeof(buffer1), hardware->cpu.flags.tpr_shadow, "tpr_shadow ",
false);
- show_flag(menu, buffer1, hardware->cpu.flags.vnmi, "vnmi ", false);
- show_flag(menu, buffer1, hardware->cpu.flags.flexpriority, "flexpriority ",
+ show_flag(menu, buffer1, sizeof(buffer1), hardware->cpu.flags.vnmi, "vnmi ", false);
+ show_flag(menu, buffer1, sizeof(buffer1), hardware->cpu.flags.flexpriority, "flexpriority ",
false);
- show_flag(menu, buffer1, hardware->cpu.flags.ept, "ept ", false);
- show_flag(menu, buffer1, hardware->cpu.flags.vpid, "vpid ", false);
+ show_flag(menu, buffer1, sizeof(buffer1), hardware->cpu.flags.ept, "ept ", false);
+ show_flag(menu, buffer1, sizeof(buffer1), hardware->cpu.flags.vpid, "vpid ", false);
/* Let's flush the remaining flags */
- show_flag(menu, buffer1, false, "", true);
+ show_flag(menu, buffer1, sizeof(buffer1), false, "", true);
printf("MENU: Processor menu done (%d items)\n", menu->items_count);
}
diff --git a/com32/include/libansi.h b/com32/include/libansi.h
index d813f9f..030fd0d 100644
--- a/com32/include/libansi.h
+++ b/com32/include/libansi.h
@@ -29,6 +29,9 @@
#ifndef DEFINE_LIB_ANSI_H
#define DEFINE_LIB_ANSI_H
+#include <stdbool.h>
+#include <stdio.h>
+
#define CSI "\e["
void display_cursor(bool status);
diff --git a/com32/include/menu.h b/com32/include/menu.h
index bc0182f..b0251e4 100644
--- a/com32/include/menu.h
+++ b/com32/include/menu.h
@@ -195,7 +195,7 @@ void local_cursor_enable(bool);
static inline int my_isspace(char c)
{
- return (unsigned char)c <= ' ';
+ return (unsigned char)c <= ' ' || (unsigned char)c == '\x7f';
}
int my_isxdigit(char c);
diff --git a/com32/include/sys/elfcommon.h b/com32/include/sys/elfcommon.h
index 99b5ad1..29f2094 100644
--- a/com32/include/sys/elfcommon.h
+++ b/com32/include/sys/elfcommon.h
@@ -162,7 +162,7 @@
#define DT_EXTRATAGIDX(tag) ((Elf32_Word)-((Elf32_Sword) (tag) <<1>>1)-1)
#define DT_EXTRANUM 3
-/* Auxilliary table entries */
+/* Auxiliary table entries */
#define AT_NULL 0 /* end of vector */
#define AT_IGNORE 1 /* entry should be ignored */
#define AT_EXECFD 2 /* file descriptor of program */
diff --git a/com32/include/sys/module.h b/com32/include/sys/module.h
index 3e5a8d9..48d65b2 100644
--- a/com32/include/sys/module.h
+++ b/com32/include/sys/module.h
@@ -263,7 +263,7 @@ extern int _module_unload(struct elf_module *module);
*
* This function returns the type of module we're dealing with
* either a library module ( LIB_MODULE ), executable module ( EXEC_MODULE ),
- * or an error ( UNKNOWN_MODULE ). The way it checks teh type is by checking to see
+ * or an error ( UNKNOWN_MODULE ). The way it checks the type is by checking to see
* if the module has its main_func set ( in which case it's an executable ). In case
* it doesn't it then checks to see if init_func is set ( in which case it's a
* library module. If this isn't the case either we don't know what it is so bail out
diff --git a/com32/include/syslinux/pxe_api.h b/com32/include/syslinux/pxe_api.h
index 3e994c0..37c9cfb 100644
--- a/com32/include/syslinux/pxe_api.h
+++ b/com32/include/syslinux/pxe_api.h
@@ -587,7 +587,7 @@ typedef struct s_PXENV_UNLOAD_STACK {
int __weak pxe_call(int, void *);
void __weak unload_pxe(uint16_t flags);
-uint32_t __weak dns_resolv(const char *);
+uint32_t __weak pxe_dns(const char *);
extern uint32_t __weak SendCookies;
void __weak http_bake_cookies(void);
diff --git a/com32/lib/Makefile b/com32/lib/Makefile
index 1624ae7..74fff14 100644
--- a/com32/lib/Makefile
+++ b/com32/lib/Makefile
@@ -22,7 +22,7 @@ LIBJPG_OBJS = \
jpeg/rgb24.o jpeg/bgr24.o jpeg/yuv420p.o jpeg/grey.o \
jpeg/rgba32.o jpeg/bgra32.o
-ifdef EFI_BUILD
+ifeq ($(FWCLASS),EFI)
I915VESA_OBJ =
else
I915VESA_OBJ = sys/vesa/i915resolution.o
@@ -46,7 +46,6 @@ LIBSYSLINUX_OBJS = \
syslinux/reboot.o syslinux/keyboard.o \
syslinux/version.o \
syslinux/pxe_get_cached.o syslinux/pxe_get_nic.o \
- syslinux/pxe_dns.o \
syslinux/video/fontquery.o syslinux/video/reportmode.o
DYNENTRY_OBJS = \
diff --git a/com32/lib/chrreplace.c b/com32/lib/chrreplace.c
index 65786f9..cfbf5d4 100644
--- a/com32/lib/chrreplace.c
+++ b/com32/lib/chrreplace.c
@@ -4,8 +4,8 @@
void chrreplace(char *source, char old, char new)
{
while (*source) {
- source++;
if (source[0] == old) source[0]=new;
+ source++;
}
}
diff --git a/com32/lib/pci/scan.c b/com32/lib/pci/scan.c
index fe00fc2..20a3e2a 100644
--- a/com32/lib/pci/scan.c
+++ b/com32/lib/pci/scan.c
@@ -603,6 +603,7 @@ int get_module_name_from_alias(struct pci_domain *domain, char *modules_alias_pa
char sub_product_id[16];
FILE *f;
struct pci_device *dev=NULL;
+ int valid_lines=0;
/* Intializing the linux_kernel_module for each pci device to "unknown" */
/* adding a dev_info member if needed */
@@ -630,6 +631,7 @@ int get_module_name_from_alias(struct pci_domain *domain, char *modules_alias_pa
if ((line[0] == '#') || (strstr(line,"alias pci:v")==NULL))
continue;
+ valid_lines++;
/* Resetting temp buffer*/
memset(module_name,0,sizeof(module_name));
memset(vendor_id,0,sizeof(vendor_id));
@@ -725,5 +727,11 @@ int get_module_name_from_alias(struct pci_domain *domain, char *modules_alias_pa
}
}
fclose(f);
+ /* If no valid line was found in the module.alias,
+ * we shall report it as broken/empty/non-existing */
+ if (valid_lines == 0) {
+ return -ENOMODULESALIAS;
+ }
+
return 0;
}
diff --git a/com32/lib/sys/module/exec.c b/com32/lib/sys/module/exec.c
index 84b96e0..3bf1eff 100644
--- a/com32/lib/sys/module/exec.c
+++ b/com32/lib/sys/module/exec.c
@@ -162,7 +162,7 @@ int spawn_load(const char *name, int argc, char **argv)
struct elf_module *cur_module;
int type;
- dprintf("enter: name = %s", name);
+ dprintf("enter: name = %s\n", name);
if (module == NULL)
return -1;
@@ -190,7 +190,7 @@ int spawn_load(const char *name, int argc, char **argv)
type = get_module_type(module);
- dprintf("type = %d, prev = %s, cur = %s",
+ dprintf("type = %d, prev = %s, cur = %s\n",
type, cur_module->name, module->name);
if(type==EXEC_MODULE)
diff --git a/com32/lib/syslinux/disk.c b/com32/lib/syslinux/disk.c
index 5a99bb4..afbfc84 100644
--- a/com32/lib/syslinux/disk.c
+++ b/com32/lib/syslinux/disk.c
@@ -528,9 +528,9 @@ void disk_gpt_part_dump(const struct disk_gpt_part_entry *const gpt_part)
char guid_text[37];
dprintf("----------------------------------\n"
- "GPT part. LBA first __ : 0x%.16llx\n"
- "GPT part. LBA last ___ : 0x%.16llx\n"
- "GPT part. attribs ____ : 0x%.16llx\n"
+ "GPT part. LBA first __ : 0x%.16" PRIx64 "x\n"
+ "GPT part. LBA last ___ : 0x%.16" PRIx64 "x\n"
+ "GPT part. attribs ____ : 0x%.16" PRIx64 "x\n"
"GPT part. name _______ : '",
gpt_part->lba_first, gpt_part->lba_last, gpt_part->attribs);
for (i = 0; i < sizeof(gpt_part->name); i++) {
@@ -559,11 +559,11 @@ void disk_gpt_header_dump(const struct disk_gpt_header *const gpt)
"GPT header size ______ : 0x%.8x\n"
"GPT header checksum __ : 0x%.8x\n"
"GPT reserved _________ : '%4.4s'\n"
- "GPT LBA current ______ : 0x%.16llx\n"
- "GPT LBA alternative __ : 0x%.16llx\n"
- "GPT LBA first usable _ : 0x%.16llx\n"
- "GPT LBA last usable __ : 0x%.16llx\n"
- "GPT LBA part. table __ : 0x%.16llx\n"
+ "GPT LBA current ______ : 0x%.16" PRIx64 "x\n"
+ "GPT LBA alternative __ : 0x%.16" PRIx64 "x\n"
+ "GPT LBA first usable _ : 0x%.16" PRIx64 "x\n"
+ "GPT LBA last usable __ : 0x%.16" PRIx64 "x\n"
+ "GPT LBA part. table __ : 0x%.16" PRIx64 "x\n"
"GPT partition count __ : 0x%.8x\n"
"GPT partition size ___ : 0x%.8x\n"
"GPT part. table chksum : 0x%.8x\n",
diff --git a/com32/lib/syslinux/initramfs_file.c b/com32/lib/syslinux/initramfs_file.c
index 7eb55b5..9f9fa75 100644
--- a/com32/lib/syslinux/initramfs_file.c
+++ b/com32/lib/syslinux/initramfs_file.c
@@ -126,7 +126,7 @@ int initramfs_mknod(struct initramfs *ihead, const char *filename,
if (do_mkdir)
bp += initramfs_mkdirs(filename, bp, bytes);
- bp += sprintf(bp, "070701%08x%08x%08x%08x%08x%08x%08x%08x%08x"
+ bp += sprintf(bp, "070701%08x%08x%08x%08x%08x%08x%08zx%08x%08x"
"%08x%08x%08x%08x", next_ino++, mode,
0, 0, 1, 0, len, 0, 1, major, minor, namelen + 1, 0);
memcpy(bp, filename, namelen);
diff --git a/com32/lib/syslinux/load_linux.c b/com32/lib/syslinux/load_linux.c
index 06ae2a9..0edb771 100644
--- a/com32/lib/syslinux/load_linux.c
+++ b/com32/lib/syslinux/load_linux.c
@@ -48,6 +48,7 @@
#include <syslinux/movebits.h>
#include <syslinux/firmware.h>
#include <syslinux/video.h>
+#include <syslinux/config.h>
#define BOOT_MAGIC 0xAA55
#define LINUX_MAGIC ('H' + ('d' << 8) + ('r' << 16) + ('S' << 24))
@@ -155,8 +156,8 @@ int bios_boot_linux(void *kernel_buf, size_t kernel_size,
char *cmdline)
{
struct linux_header hdr, *whdr;
- size_t real_mode_size, prot_mode_size, base;
- addr_t real_mode_base, prot_mode_base, prot_mode_max;
+ size_t real_mode_size, prot_mode_size;
+ addr_t real_mode_base, prot_mode_base, prot_mode_max, base;
addr_t irf_size;
size_t cmdline_size, cmdline_offset;
struct setup_data *sdp;
@@ -166,6 +167,7 @@ int bios_boot_linux(void *kernel_buf, size_t kernel_size,
struct syslinux_memmap *amap = NULL;
uint32_t memlimit = 0;
uint16_t video_mode = 0;
+ uint16_t bootflags = 0;
const char *arg;
cmdline_size = strlen(cmdline) + 1;
@@ -200,6 +202,14 @@ int bios_boot_linux(void *kernel_buf, size_t kernel_size,
}
}
+ if (syslinux_filesystem() == SYSLINUX_FS_PXELINUX &&
+ strstr(cmdline, "keeppxe")) {
+ extern __weak char KeepPXE;
+
+ KeepPXE |= 1; /* for pxelinux_scan_memory */
+ bootflags = 3; /* for unload_pxe */
+ }
+
/* Copy the header into private storage */
/* Use whdr to modify the actual kernel header */
memcpy(&hdr, kernel_buf, sizeof hdr);
@@ -254,7 +264,7 @@ int bios_boot_linux(void *kernel_buf, size_t kernel_size,
cmdline_offset = calc_cmdline_offset(mmap, &hdr, cmdline_size,
real_mode_base,
real_mode_base + real_mode_size);
- dprintf("cmdline_offset at 0x%x\n", real_mode_base + cmdline_offset);
+ dprintf("cmdline_offset at 0x%zx\n", real_mode_base + cmdline_offset);
if (hdr.version < 0x020a) {
/*
@@ -323,6 +333,7 @@ int bios_boot_linux(void *kernel_buf, size_t kernel_size,
}
whdr->code32_start += base - prot_mode_base;
+ prot_mode_base = base;
/* Real mode code */
if (syslinux_memmap_find(amap, &real_mode_base,
@@ -494,7 +505,7 @@ int bios_boot_linux(void *kernel_buf, size_t kernel_size,
dprintf("*** vga=current, not calling syslinux_force_text_mode()...\n");
}
- syslinux_shuffle_boot_rm(fraglist, mmap, 0, &regs);
+ syslinux_shuffle_boot_rm(fraglist, mmap, bootflags, &regs);
dprintf("shuffle_boot_rm failed\n");
bail:
diff --git a/com32/lib/syslinux/pxe_dns.c b/com32/lib/syslinux/pxe_dns.c
deleted file mode 100644
index b813b54..0000000
--- a/com32/lib/syslinux/pxe_dns.c
+++ /dev/null
@@ -1,67 +0,0 @@
-/* ----------------------------------------------------------------------- *
- *
- * Copyright 2010 Intel Corporation; author: H. Peter Anvin
- *
- * 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.
- *
- * ----------------------------------------------------------------------- */
-
-/*
- * pxe_dns.c
- *
- * Resolve a hostname via DNS
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <stdint.h>
-#include <string.h>
-#include <com32.h>
-
-#include <syslinux/pxe.h>
-
-/* Returns the status code from PXE (0 on success),
- or -1 on invocation failure */
-uint32_t pxe_dns(const char *hostname)
-{
- union {
- unsigned char b[4];
- uint32_t ip;
- } q;
- char *lm_hostname;
- uint32_t status;
-
- /* Is this a dot-quad? */
- if (sscanf(hostname, "%hhu.%hhu.%hhu.%hhu",
- &q.b[0], &q.b[1], &q.b[2], &q.b[3]) == 4)
- return q.ip;
-
- lm_hostname = lstrdup(hostname);
- if (!lm_hostname)
- return 0;
-
- status = dns_resolv(lm_hostname);
-
- lfree(lm_hostname);
-
- return status;
-}
diff --git a/com32/lib/zlib/zutil.h b/com32/lib/zlib/zutil.h
index ac2d73e..ed6bd83 100644
--- a/com32/lib/zlib/zutil.h
+++ b/com32/lib/zlib/zutil.h
@@ -253,12 +253,12 @@ extern const char * const z_errmsg[10]; /* indexed by 2-zlib_error */
# define Tracec(c,x) {if (z_verbose>0 && (c)) fprintf x ;}
# define Tracecv(c,x) {if (z_verbose>1 && (c)) fprintf x ;}
#else
-# define Assert(cond,msg)
-# define Trace(x)
-# define Tracev(x)
-# define Tracevv(x)
-# define Tracec(c,x)
-# define Tracecv(c,x)
+# define Assert(cond,msg) ((void)0)
+# define Trace(x) ((void)0)
+# define Tracev(x) ((void)0)
+# define Tracevv(x) ((void)0)
+# define Tracec(c,x) ((void)0)
+# define Tracecv(c,x) ((void)0)
#endif
diff --git a/com32/libupload/Makefile b/com32/libupload/Makefile
index f9440c5..a779913 100644
--- a/com32/libupload/Makefile
+++ b/com32/libupload/Makefile
@@ -4,7 +4,7 @@ include $(MAKEDIR)/com32.mk
REQFLAGS += -I$(SRC)
-LIBOBJS := $(notdir $(patsubst %.c,%.o,$(wildcard $(SRC)/*.c)))
+LIBOBJS := $(notdir $(patsubst %.c,%.o,$(sort $(wildcard $(SRC)/*.c))))
BINDIR = /usr/bin
LIBDIR = /usr/lib
diff --git a/com32/libupload/tftp.h b/com32/libupload/tftp.h
index 323dc16..209d975 100644
--- a/com32/libupload/tftp.h
+++ b/com32/libupload/tftp.h
@@ -2,7 +2,8 @@
#ifndef UPLOAD_TFTP
#define UPLOAD_TFTP
-/* TFTP Error codes */
+
+/* TFTP Error codes in host byte order */
enum tftp_error_codes {
TFTP_ERR_UNKNOWN_ERROR = 0, // We have to use the message from the server
TFTP_ERR_FILE_NOT_FOUND = 1, /**< File not found */
@@ -13,9 +14,12 @@ TFTP_ERR_UNKNOWN_TID = 5, /**< Unknown transfer ID */
TFTP_ERR_FILE_EXISTS = 6, /**< File already exists */
TFTP_ERR_UNKNOWN_USER = 7, /**< No such user */
TFTP_ERR_BAD_OPTS = 8, /**< Option negotiation failed */
-TFTP_ERR_UNABLE_TO_RESOLVE = 9, // Not in RFC, internal usage
-TFTP_ERR_UNABLE_TO_CONNECT = 10, // Not in RFC, internal usage
-TFTP_OK = 11, /* Not in RFC */
+
+/* The following are not defined in RFC, for internal usage only */
+TFTP_ERR_UNABLE_TO_RESOLVE = 9,
+TFTP_ERR_UNABLE_TO_CONNECT = 10,
+TFTP_ERR_OK = 11,
+TFTP_ERR_NO_NETWORK = 12,
};
extern const char *tftp_string_error_message[];
diff --git a/com32/libupload/upload_tftp.c b/com32/libupload/upload_tftp.c
index 6a0dacb..1e0b070 100644
--- a/com32/libupload/upload_tftp.c
+++ b/com32/libupload/upload_tftp.c
@@ -8,180 +8,62 @@
#include <syslinux/config.h>
#include <netinet/in.h>
#include <sys/times.h>
+#include <fs/pxe/pxe.h>
+#include <fs/pxe/url.h>
+#include <fs/pxe/tftp.h>
#include "upload_backend.h"
-enum tftp_opcode {
- TFTP_RRQ = 1,
- TFTP_WRQ = 2,
- TFTP_DATA = 3,
- TFTP_ACK = 4,
- TFTP_ERROR = 5,
-};
-
-struct tftp_error {
- uint16_t opcode;
- uint16_t errcode;
- char errmsg[0];
-} __attribute__ (( packed ));
-
-struct tftp_state {
- uint32_t my_ip;
- uint32_t srv_ip;
- uint32_t srv_gw;
- uint16_t my_port;
- uint16_t srv_port;
- uint16_t seq;
-};
-
const char *tftp_string_error_message[]={
-"",
-"File not found",
-"Access Denied",
-"Disk Full",
-"Illegal Operation",
-"Unknown Transfert ID",
-"File already exists",
-"Unknown User",
-"Negociation failed",
-"Unable to resolve hostname", // not in RFC
-"Unable to connect", // not in RFC
-"No Error",
+ "Unknown error",
+ "File not found",
+ "Access Denied",
+ "Disk Full",
+ "Illegal Operation",
+ "Unknown Transfer ID",
+ "File already exists",
+ "Unknown User",
+ "Negotiation failed",
+
+ /* These are not in any RFC, defined internally */
+ "Unable to resolve hostname",
+ "Unable to connect",
+ "No Error",
+ "Network unavailable",
};
-#define RCV_BUF 2048
-
-static int send_ack_packet(struct tftp_state *tftp,
- const void *pkt, size_t len)
-{
- t_PXENV_UDP_WRITE *uw;
- t_PXENV_UDP_READ *ur;
- clock_t start;
- static const clock_t timeouts[] = {
- 2, 2, 3, 3, 4, 5, 6, 7, 9, 10, 12, 15, 18, 21, 26, 31,
- 37, 44, 53, 64, 77, 92, 110, 132, 159, 191, 229, 0
- };
- const clock_t *timeout;
- int err = -1;
-
- uw = lmalloc(sizeof *uw + len);
- ur = lmalloc(sizeof *ur + RCV_BUF);
-
- for (timeout = timeouts ; *timeout ; timeout++) {
- memset(uw, 0, sizeof *uw);
- memcpy(uw+1, pkt, len);
- uw->ip = tftp->srv_ip;
- uw->gw = tftp->srv_gw;
- uw->src_port = tftp->my_port;
- uw->dst_port = tftp->srv_port ? tftp->srv_port : htons(69);
- uw->buffer_size = len;
- uw->buffer = FAR_PTR(uw+1);
-
- pxe_call(PXENV_UDP_WRITE, uw);
-
- start = times(NULL);
-
- do {
- memset(ur, 0, sizeof *ur);
- ur->src_ip = tftp->srv_ip;
- ur->dest_ip = tftp->my_ip;
- ur->s_port = tftp->srv_port;
- ur->d_port = tftp->my_port;
- ur->buffer_size = RCV_BUF;
- ur->buffer = FAR_PTR(ur+1);
-
- err = pxe_call(PXENV_UDP_READ, ur);
-
- if (!err && ur->status == PXENV_STATUS_SUCCESS &&
- tftp->srv_ip == ur->src_ip &&
- (tftp->srv_port == 0 ||
- tftp->srv_port == ur->s_port)) {
- uint16_t *xb = (uint16_t *)(ur+1);
- if (ntohs(xb[0]) == TFTP_ACK &&
- ntohs(xb[1]) == tftp->seq) {
- tftp->srv_port = ur->s_port;
- err = TFTP_OK; /* All good! */
- goto done;
- } else if (ntohs(xb[0]) == TFTP_ERROR) {
- struct tftp_error *te = (struct tftp_error *)(ur+1);
- if (te->errcode == TFTP_ERR_UNKNOWN_ERROR) {
- tftp_string_error_message[TFTP_ERR_UNKNOWN_ERROR]=strdup(te->errmsg);
- }
- err=-ntohs(te->errcode); // Return the associated error code
- goto done;
- }
- }
- } while ((clock_t)(times(NULL) - start) < *timeout);
- }
-
-done:
- lfree(ur);
- lfree(uw);
+static bool have_real_network(void);
- return err;
-}
+static int upload_tftp_write(struct upload_backend *be) {
+ struct url_info url;
+ struct inode inode;
+ char url_path[255];
+ int err;
-static int upload_tftp_write(struct upload_backend *be)
-{
- static uint16_t local_port = 0x4000;
- struct tftp_state tftp;
- char buffer[512+4+6];
- int nlen;
- int err=TFTP_OK;
- const union syslinux_derivative_info *sdi =
- syslinux_derivative_info();
- const char *data = be->outbuf;
- size_t len = be->zbytes;
- size_t chunk;
-
- tftp.my_ip = sdi->pxe.myip;
- tftp.my_port = htons(local_port++);
- tftp.srv_gw = ((tftp.srv_ip ^ tftp.my_ip) & sdi->pxe.ipinfo->netmask)
- ? sdi->pxe.ipinfo->gateway : 0;
- tftp.srv_port = 0;
- tftp.seq = 0;
-
- if (be->argv[1]) {
- tftp.srv_ip = pxe_dns(be->argv[1]);
- if (!tftp.srv_ip) {
-// printf("\nUnable to resolve hostname: %s\n", be->argv[1]);
- return -TFTP_ERR_UNABLE_TO_RESOLVE;
- }
- } else {
- tftp.srv_ip = sdi->pxe.ipinfo->serverip;
- if (!tftp.srv_ip) {
-// printf("\nNo server IP address\n");
- return -TFTP_ERR_UNABLE_TO_CONNECT;
- }
+ if (!have_real_network()) {
+ dprintf("\nNot running from the network\n");
+ return -TFTP_ERR_NO_NETWORK;
}
-/* printf("server %u.%u.%u.%u... ",
- ((uint8_t *)&tftp.srv_ip)[0],
- ((uint8_t *)&tftp.srv_ip)[1],
- ((uint8_t *)&tftp.srv_ip)[2],
- ((uint8_t *)&tftp.srv_ip)[3]);*/
-
- buffer[0] = 0;
- buffer[1] = TFTP_WRQ;
- nlen = strlcpy(buffer+2, be->argv[0], 512);
- memcpy(buffer+3+nlen, "octet", 6);
+ if (!strncmp(be->argv[0], "tftp://", 7))
+ strlcpy(url_path, be->argv[0], sizeof(url_path));
+ else
+ snprintf(url_path, sizeof(url_path), "tftp://%s/%s",
+ be->argv[1] ? be->argv[1] : "", be->argv[0]);
- if ((err=send_ack_packet(&tftp, buffer, 2+nlen+1+6))!=TFTP_OK)
+ parse_url(&url, url_path);
+ err = -url_set_ip(&url);
+ if (err != TFTP_ERR_OK)
return err;
- do {
- chunk = len >= 512 ? 512 : len;
+ dprintf("Connecting to %s to send %s\n", url.host, url.path);
+ err = -tftp_put(&url, 0, &inode, NULL, be->outbuf, be->zbytes);
- buffer[1] = TFTP_DATA;
- *((uint16_t *)(buffer+2)) = htons(++tftp.seq);
- memcpy(buffer+4, data, chunk);
- data += chunk;
- len -= chunk;
-
- if ((err=send_ack_packet(&tftp, buffer, chunk+4))!=TFTP_OK)
- return err;
- } while (chunk == 512);
+ if (err != TFTP_ERR_OK) {
+ printf("upload_tftp_write: TFTP server returned error %d : %s\n",
+ err, tftp_string_error_message[err]);
+ }
- return TFTP_OK;
+ return err;
}
struct upload_backend upload_tftp = {
@@ -190,3 +72,46 @@ struct upload_backend upload_tftp = {
.minargs = 1,
.write = upload_tftp_write,
};
+
+/*
+ * Dummy functions to prevent link failure for non-network cores
+ */
+static int _dummy_tftp_put(struct url_info *url, int flags,
+ struct inode *inode, const char **redir,
+ char *data, int data_length)
+{
+ (void)url;
+ (void)flags;
+ (void)inode;
+ (void)redir;
+ (void)data;
+ (void)data_length;
+
+ return -TFTP_ERR_NO_NETWORK;
+}
+
+__weak int __attribute__((alias("_dummy_tftp_put")))
+tftp_put(struct url_info *url, int flags, struct inode *inode,
+ const char **redir, char *data, int data_length);
+
+static int _dummy_tftp_put(struct url_info *url, int flags,
+ struct inode *inode, const char **redir,
+ char *data, int data_length);
+
+static bool have_real_network(void)
+{
+ return tftp_put != _dummy_tftp_put;
+}
+
+__weak int url_set_ip(struct url_info *ui)
+{
+ (void)ui;
+
+ return -TFTP_ERR_NO_NETWORK;
+}
+
+__weak void parse_url(struct url_info *ui, char *url)
+{
+ (void)ui;
+ (void)url;
+}
diff --git a/com32/lua/doc/syslinux.asc b/com32/lua/doc/syslinux.asc
index 424c51f..6475d42 100644
--- a/com32/lua/doc/syslinux.asc
+++ b/com32/lua/doc/syslinux.asc
@@ -23,270 +23,232 @@ Modules
Modules must be explicitly loaded into the namespace
before use, for example:
......................................................
-syslinux = require ("syslinux")
+local sl = require "syslinux"
......................................................
+Using +local+, as above, is good practice in scripts, but it must be
+omitted when working interactively.
SYSLINUX
~~~~~~~~
-.syslinux.version()
+version()::
+Return the Syslinux version string.
-Returns version string
+derivative()::
+Return the running Syslinux derivative
+(the string +ISOLINUX+, +PXELINUX+ or +SYSLINUX+).
-.syslinux.derivative()
+sleep(s)::
+Sleep for +s+ seconds.
-Returns running Syslinux's derivative (ISOLINUX, PXELINUX or SYSLINUX).
-See com32/lua/test/syslinux-derivative.lua for an example.
-
-.syslinux.sleep(s)
-
-Sleep for +s+ seconds
-
-.syslinux.msleep(ms)
-
-Sleep for +ms+ milliseconds
-
-.run_command(command)
+msleep(ms)::
+Sleep for +ms+ milliseconds.
+run_command(command)::
Execute syslinux command line +command+.
-
++
_Example_:
......................................................
- syslinux.run_command("memdisk initrd=/dos/BIOS/FSC-P7935-108.img raw")
+local sl = require "syslinux"
+sl.run_command "memdisk initrd=/dos/BIOS/FSC-P7935-108.img raw"
......................................................
-.run_default()
+run_default()::
+Execute the default command in the configuration.
-FIXME
+local_boot(type)::
+Do a local boot. The +type+ values are described in the documentation
+of the LOCALBOOT configuration item.
-.local_boot()
+final_cleanup(flags)::
+Restore sane hardware and software status before booting. If +flags+
+is 3, keep the PXE and UNDI stacks in memory (see the _keeppxe_ option).
+Only needed in special circumstances.
-FIXME
+boot_linux(kernel[,cmdline])::
+Load and boot the Linux kernel at path +kernel+. Initramfs images are
+loaded according to the +initrd+ option in +cmdline+. The
++BOOT_IMAGE+ parameter is added to the command line with the value of
++kernel+.
-.final_cleanup()
+IMAGE_TYPE::
+A table mapping the various kernel type strings to the integer +type+
+parameter of +run_kernel_image()+.
-FIXME
+run_kernel_image(kernel, cmdline, ipappend_flags, type)::
+Load the specified +kernel+ and run it with +cmdline+. See also the
+documentation of the IPAPPEND configuration item; +type+ is one of
+the values of the +IMAGE_TYPE+ table.
-.boot_linux(kernel, cmdline, [mem_limit], [videomode])
+loadfile(filename)::
+Return a _file_ object with the contents of file +filename+ loaded.
+Its methods are:
-FIXME
+size():::
+Return the size of a loaded _file_.
-.run_kernel_image(kernel, cmdline, ipappend_flags, type)
+name():::
+Return the name of a loaded _file_.
-FIXME
+initramfs()::
+Return an empty _initramfs_ object. Its methods are:
-.loadfile(filname)
+load(filename):::
+Load contents of +filename+ into an _initramfs_ and return the
+extended object.
-Load file +filename+ (via TFTP)
+add_file(filename[,data[,do_mkdir[,mode]]]):::
+Add +filename+ of +mode+ containing +data+ to an _initramfs_ and
+return the extended object.
+If +do_mkdir+, create parent directories, too. +mode+ defaults
+to 7*64+5*8+5 (which is 0755 in octal).
-.filesize(file)
+size():::
+Returns the current size of an _initramfs_.
-Return size of +file+ (loaded by loadfile())
+boot_it(kernel[,initramfs,[cmdline]])::
+Boot the loaded +kernel+ (a _file_ object) with an optional
++initramfs+ (an _initramfs_ object or +nil+) and +cmdline+.
-.filename(file)
+_Example_:
+......................................................
+local sl = require "syslinux"
-Return name of +file+ (loaded by loadfile())
+kernel = sl.loadfile "/SuSE-11.1/x86_64/linux"
+print("File name: " .. kernel:name() .. " size: " .. kernel:size())
-.in itramfs_init()
+initrd1 = "/SuSE-11.1/x86_64/initrd"
-Return empty initramfs object
+initrd = sl.initramfs()
+initrd:load(initrd1)
+print ("File name: " .. initrd1 .. " size: " .. initrd:size())
-.initramfs_load_archive(initramfs, filename)
+sl.boot_it(kernel, initrd, "init=/bin/bash")
+......................................................
-Load contents of +filename+ into +initramfs+. Initialize
-+initramfs+ with initramfs_init() before use.
+KEY::
+Table containing the return values of +get_key()+ for special (eg. function)
+keys.
-.initramfs_add_file(initramfs, file)
+KEY_CTRL(key)::
+Return the code for the Ctrl-modified version of the given ASCII code.
-Adds +file+ to +initramfs+. +initramfs+ needs to be
-initialized, +file+ has been loaded by loadfile().
+get_key(timeout)::
+Wait at most +timeout+ ms for a key press.
+Return the ASCII code of the pressed key, some other value of the +KEY+
+table, or +KEY.NONE+ on timeout.
-_Example_:
-......................................................
- -- get nice output
- printf = function(s,...)
- return io.write(s:format(...))
- end -- function
-
- kernel = syslinux.loadfile("/SuSE-11.1/x86_64/linux")
-
- printf("Filename/size: %s %d\n", syslinux.filename(kernel), syslinux.filesize(kernel))
-
- initrd = syslinux.loadfile("/SuSE-11.1/x86_64/initrd")
-
- printf("Filename/size: %s %d\n", syslinux.filename(initrd), syslinux.filesize(initrd))
-
- initrd = syslinux.initramfs_init()
- syslinux.initramfs_load_archive(initrd, "/SuSE-11.1/x86_64/initrd");
-
- syslinux.boot_it(kernel, initrd, "init=/bin/bash")
-
- syslinux.sleep(20)
-
-......................................................
+config_file()::
+Return the path of the current config file.
+ipappend_strs()::
+Return the table of SYSAPPEND (formerly IPAPPEND) strings. See also
+the documentation of those configuration items.
+
+reboot([warm_boot])::
+Reboot. If +warm_boot+ is nonzero, perform a warm reboot.
DMI
~~~
-.dmi_supported()
-
-Returns +true+ if DMI is supported on machine, +false+ otherwise.
-
-.dmi_gettable()
+supported()::
+Return true if DMI is supported on machine, false otherwise.
-Returns a list if key-value pairs. The key is one of the DMI property strings:
-FIXME list
+gettable()::
+Return DMI info as a nested table.
_Example_:
......................................................
- if (dmi.supported()) then
-
- dmitable = dmi.gettable()
-
- for k,v in pairs(dmitable) do
- print(k, v)
- end
-
- print(dmitable["system.manufacturer"])
- print(dmitable["system.product_name"])
- print(dmitable["bios.bios_revision"])
-
- if ( string.match(dmitable["system.product_name"], "ESPRIMO P7935") ) then
- print("Matches")
- syslinux.run_command("memdisk initrd=/dos/BIOS/FSC-P7935-108.img raw")
- else
- print("Does not match")
- syslinux.run_command("memdisk initrd=/dos/BIOS/FSC-P7935-108.img raw")
- end
-
- end
+local sl = require "syslinux"
+local dmi = require "dmi"
+
+if (dmi.supported()) then
+
+ dmitable = dmi.gettable()
+
+ for k,v in pairs(dmitable) do
+ print(k, v)
+ end
+
+ print(dmitable.system.manufacturer)
+ print(dmitable.system.product_name)
+ print(dmitable.bios.bios_revision)
+
+ if ( string.match(dmitable.system.product_name, "ESPRIMO P7935") ) then
+ print("Matches")
+ sl.run_command("memdisk initrd=/dos/BIOS/FSC-P7935-108.img raw")
+ else
+ print("Does not match")
+ sl.run_command("memdisk initrd=/dos/BIOS/FSC-P7935-108.img raw")
+ end
+end
......................................................
PCI
~~~
-.pci_getinfo()
-
-Return list of value pairs (device_index, device) of all PCI devices.
-
-.pci_getidlist(filename)
+getinfo()::
+Return the table of all PCI devices, keyed by the device index.
+Each device is described by a table of its properties.
+getidlist(filename)::
Load a tab separated list of PCI IDs and their description.
Sample files can be found here: http://pciids.sourceforge.net/
-
_Example_:
......................................................
--- get nice output
-printf = function(s,...)
- return io.write(s:format(...))
- end
-
--- get device info
-pciinfo = pci.getinfo()
+local pci = require "pci"
--- get plain text device description
pciids = pci.getidlist("/pci.ids")
--- list all pci busses
-for dind,device in pairs(pciinfo) do
-
- -- search for device description
- search = string.format("%04x%04x", device['vendor'], device['product'])
-
- printf(" %04x:%04x:%04x:%04x = ", device['vendor'], device['product'],
- device['sub_vendor'], device['sub_product'])
-
- if ( pciids[search] ) then
- printf("%s\n", pciids[search])
- else
- printf("Unknown\n")
- end
+for dind, device in pairs (pci.getinfo()) do
+ local vendor = string.format ("%04x", device.vendor)
+ local main_id = vendor .. string.format ("%04x", device.product)
+ local sub_id = string.format ("%04x%04x", device.sub_vendor, device.sub_product)
+ io.write (string.format ("%s:%s = %s %s (%s)\n", main_id, sub_id, pciids[vendor],
+ pciids[main_id], pciids[main_id .. sub_id] or "unknown subdevice"))
end
-
--- print(pciids["8086"])
--- print(pciids["10543009"])
--- print(pciids["00700003"])
--- print(pciids["0070e817"])
--- print(pciids["1002437a1002437a"])
......................................................
VESA
~~~~
-.getmodes()
-
+getmodes()::
Return list of available VESA modes.
-
++
_Example_:
......................................................
- -- get nice output
- printf = function(s,...)
- return io.write(s:format(...))
- end
-
- -- list available vesa modes
- -- only one supported right now, not of much use
- modes = vesa.getmodes()
-
- for mind,mode in pairs(modes) do
- printf("%04x: %dx%dx%d\n", mode['mode'], mode['hres'], mode['vres'], mode['bpp'])
- end
-......................................................
+local vesa = require "vesa"
+for mind,mode in pairs(vesa.getmodes()) do
+ print (string.format ("%04x: %dx%dx%d", mode.mode, mode.hres, mode.vres, mode.bpp))
+end
+......................................................
-.setmode()
-
-Set (only currently supported) VESA mode.
-
-.load_background(filename)
+setmode()::
+Set the 640x480 VESA mode.
-Load +filename+ from TFTP, and use it as background image.
+load_background(filename)::
+Load +filename+ (a PNG, JPEG or LSS-16 format image), and tile it as
+background image. The text already present is not erased.
_Example_:
......................................................
- -- get nice output
- printf = function(s,...)
- return io.write(s:format(...))
- end
-
- -- lets go to graphics land
- vesa.setmode()
-
- printf("Hello World! - VESA mode")
-
- -- some text to display "typing style"
- textline=[[
- From syslinux GSOC 2009 home page:
-
- Finish the Lua engine
-
- We already have a Lua interpreter integrated with the Syslinux build. However, right now it is not very useful. We need to create a set of bindings to the Syslinux functionality, and have an array of documentation and examples so users can use them.
-
- This is not a documentation project, but the documentation deliverable will be particularly important for this one, since the intended target is system administrators, not developers.
- ]]
-
-
- -- do display loop
- -- keep in mind: background change will not erase text!
- while ( true ) do
-
- vesa.load_background("/background1.jpg")
-
- syslinux.sleep(1)
-
- for i = 1, #textline do
- local c = textline:sub(i,i)
- printf("%s", c)
- syslinux.msleep(200)
- end
-
- syslinux.sleep(10)
+local sl = require "syslinux"
+local vesa = require "vesa"
-......................................................
+vesa.setmode()
+vesa.load_background "sample2.jpg"
+for c in string.gmatch ("Hello World! - VESA mode", ".") do
+ io.write (c)
+ sl.msleep(200)
+end
+
+vesa.load_background "PXE-RRZE_small.jpg"
+sl.sleep(3)
+......................................................
diff --git a/com32/lua/src/syslinux.c b/com32/lua/src/syslinux.c
index ea702fa..9a2998b 100644
--- a/com32/lua/src/syslinux.c
+++ b/com32/lua/src/syslinux.c
@@ -44,10 +44,11 @@
int __parse_argv(char ***argv, const char *str);
-#define SYSLINUX_FILE "syslinux_file"
+static const char SYSLINUX_FILE[] = "syslinux_file";
+static const char SYSLINUX_INITRAMFS[] = "syslinux_initramfs";
typedef struct syslinux_file {
- char *data;
+ void *data;
char *name;
size_t size;
} syslinux_file;
@@ -73,48 +74,6 @@ static char *find_argument(char **argv, const char *argument)
return ptr;
}
-/* Get a value with a potential suffix (k/m/g/t/p/e) */
-static unsigned long long suffix_number(const char *str)
-{
- char *ep;
- unsigned long long v;
- int shift;
-
- v = strtoull(str, &ep, 0);
- switch (*ep | 0x20) {
- case 'k':
- shift = 10;
- break;
- case 'm':
- shift = 20;
- break;
- case 'g':
- shift = 30;
- break;
- case 't':
- shift = 40;
- break;
- case 'p':
- shift = 50;
- break;
- case 'e':
- shift = 60;
- break;
- default:
- shift = 0;
- break;
- }
- v <<= shift;
-
- return v;
-}
-
-/* Truncate to 32 bits, with saturate */
-static inline uint32_t saturate32(unsigned long long v)
-{
- return (v > 0xffffffff) ? 0xffffffff : (uint32_t) v;
-}
-
/* Stitch together the command line from a set of argv's */
static char *make_cmdline(char **argv)
{
@@ -171,8 +130,7 @@ static int sl_local_boot(lua_State * L)
static int sl_final_cleanup(lua_State * L)
{
- uint16_t flags = luaL_checkint(L, 1);
- syslinux_local_boot(flags);
+ syslinux_final_cleanup (luaL_checkint (L, 1));
return 0;
}
@@ -182,18 +140,13 @@ static int sl_boot_linux(lua_State * L)
const char *kernel = luaL_checkstring(L, 1);
const char *cmdline = luaL_optstring(L, 2, "");
char *initrd;
- void *kernel_data, *file_data;
- size_t kernel_len, file_len;
+ void *kernel_data;
+ size_t kernel_len;
struct initramfs *initramfs;
char *newcmdline;
- uint32_t mem_limit = luaL_optint(L, 3, 0);
- uint16_t video_mode = luaL_optint(L, 4, 0);
int ret;
char **argv, **argp, *arg, *p;
- (void)mem_limit;
- (void)video_mode;
-
ret = __parse_argv(&argv, cmdline);
newcmdline = malloc(strlen(kernel) + 12);
@@ -219,7 +172,7 @@ static int sl_boot_linux(lua_State * L)
msleep(1000);
*/
- printf("Loading kernel %s...\n", kernel);
+ printf("Loading kernel %s... ", kernel);
if (loadfile(kernel, &kernel_data, &kernel_len))
printf("failed!\n");
else
@@ -237,10 +190,10 @@ static int sl_boot_linux(lua_State * L)
initrd = arg;
printf("Loading initrd %s... ", initrd);
- if (initramfs_load_archive(initramfs, initrd)) {
+ if (initramfs_load_archive(initramfs, initrd))
printf("failed!\n");
- }
- printf("ok\n");
+ else
+ printf("ok\n");
if (p)
*p++ = ',';
@@ -283,27 +236,30 @@ static int sl_run_kernel_image(lua_State * L)
static int sl_loadfile(lua_State * L)
{
- const char *filename = luaL_checkstring(L, 1);
- syslinux_file *file;
-
- void *file_data;
- size_t file_len;
-
- if (loadfile(filename, &file_data, &file_len)) {
- lua_pushstring(L, "Could not load file");
- lua_error(L);
+ size_t name_len;
+ const char *filename = luaL_checklstring (L, 1, &name_len);
+ syslinux_file *file = lua_newuserdata (L, sizeof (syslinux_file));
+
+ file->name = malloc (name_len+1);
+ if (!file->name) return luaL_error (L, "Out of memory");
+ memcpy (file->name, filename, name_len+1);
+ if (loadfile (file->name, &file->data, &file->size)) {
+ free (file->name);
+ return luaL_error (L, "Could not load file");
}
+ luaL_setmetatable (L, SYSLINUX_FILE);
+ return 1;
+}
- file = malloc(sizeof(syslinux_file));
- strlcpy(file->name,filename,sizeof(syslinux_file));
- file->size = file_len;
- file->data = file_data;
-
- lua_pushlightuserdata(L, file);
- luaL_getmetatable(L, SYSLINUX_FILE);
- lua_setmetatable(L, -2);
+static int sl_unloadfile (lua_State *L)
+{
+ syslinux_file *file = luaL_checkudata (L, 1, SYSLINUX_FILE);
- return 1;
+ free (file->name);
+ free (file->data);
+ /* the __gc method may also be (repeatedly) called before garbage collection, so: */
+ file->name = file->data = NULL;
+ return 0;
}
static int sl_filesize(lua_State * L)
@@ -326,55 +282,80 @@ static int sl_filename(lua_State * L)
static int sl_initramfs_init(lua_State * L)
{
- struct initramfs *initramfs;
+ struct initramfs *ir = lua_newuserdata (L, sizeof (*ir));
- initramfs = initramfs_init();
- if (!initramfs)
- printf("Initializing initrd failed!\n");
+ memset (ir, 0, sizeof (*ir)); /* adapted from initramfs_init() */
+ ir->prev = ir->next = ir;
+ luaL_setmetatable (L, SYSLINUX_INITRAMFS);
+ return 1;
+}
- lua_pushlightuserdata(L, initramfs);
- luaL_getmetatable(L, SYSLINUX_FILE);
- lua_setmetatable(L, -2);
+static int sl_initramfs_load_archive(lua_State * L)
+{
+ const char *filename = luaL_checkstring(L, 2);
+ if (initramfs_load_archive (luaL_checkudata(L, 1, SYSLINUX_INITRAMFS), filename))
+ return luaL_error (L, "Loading initramfs %s failed", filename);
+ lua_settop (L, 1);
return 1;
}
-static int sl_initramfs_load_archive(lua_State * L)
+static int sl_initramfs_add_file(lua_State * L)
{
- struct initramfs *initramfs = luaL_checkudata(L, 1, SYSLINUX_FILE);
const char *filename = luaL_checkstring(L, 2);
+ size_t file_len;
+ const char *file_data = luaL_optlstring (L, 3, NULL, &file_len);
+ void *data = NULL;
- if (initramfs_load_archive(initramfs, filename)) {
- printf("failed!\n");
+ if (file_len) {
+ data = malloc (file_len);
+ if (!data) return luaL_error (L, "Out of memory");
+ memcpy (data, file_data, file_len);
}
+ if (initramfs_add_file(luaL_checkudata(L, 1, SYSLINUX_INITRAMFS),
+ data, file_len, file_len, filename,
+ luaL_optint (L, 4, 0), luaL_optint (L, 5, 0755)))
+ return luaL_error (L, "Adding file %s to initramfs failed", filename);
+ lua_settop (L, 1);
+ return 1;
+}
- return 0;
+static int sl_initramfs_size (lua_State *L)
+{
+ lua_pushinteger (L, initramfs_size (luaL_checkudata(L, 1, SYSLINUX_INITRAMFS)));
+ return 1;
}
-static int sl_initramfs_add_file(lua_State * L)
+static int sl_initramfs_purge (lua_State *L)
{
- struct initramfs *initramfs = luaL_checkudata(L, 1, SYSLINUX_FILE);
- const char *filename = luaL_checkstring(L, 2);
- void *file_data = NULL;
- size_t file_len = 0;
+ struct initramfs *ir = luaL_checkudata(L, 1, SYSLINUX_INITRAMFS);
- return initramfs_add_file(initramfs, file_data, file_len, file_len,
- filename, 0, 0755);
+ ir = ir->next;
+ while (ir->len) {
+ free ((void *)ir->data);
+ ir = ir->next;
+ free (ir->prev);
+ }
+ /* the __gc method may also be (repeatedly) called before garbage collection, so: */
+ ir->next = ir->prev = ir;
+ return 0;
}
static int sl_boot_it(lua_State * L)
{
const syslinux_file *kernel = luaL_checkudata(L, 1, SYSLINUX_FILE);
- struct initramfs *initramfs = luaL_checkudata(L, 2, SYSLINUX_FILE);
- const char *cmdline = luaL_optstring(L, 3, "");
- uint32_t mem_limit = luaL_optint(L, 4, 0);
- uint16_t video_mode = luaL_optint(L, 5, 0);
- /* Preventing gcc to complain about unused variables */
- (void)video_mode;
- (void)mem_limit;
-
- return syslinux_boot_linux(kernel->data, kernel->size,
- initramfs, NULL, (char *)cmdline);
+ struct initramfs *ir = luaL_testudata(L, 2, SYSLINUX_INITRAMFS);
+ size_t len;
+ const char *cmdline_param = luaL_optlstring(L, 3, "", &len);
+ char *cmdline = malloc (len+1); /* syslinux_boot_linux needs non-const cmdline */
+ int err;
+
+ if (!cmdline) return luaL_error (L, "Out of memory");
+ memcpy (cmdline, cmdline_param, len+1);
+ err = syslinux_boot_linux (kernel->data, kernel->size, ir, NULL, cmdline);
+ free (cmdline);
+ if (err) return luaL_error (L, "Booting failed");
+ return 0; /* unexpected */
}
static int sl_config_file(lua_State * L)
@@ -464,11 +445,7 @@ static const luaL_Reg syslinuxlib[] = {
{"sleep", sl_sleep},
{"msleep", sl_msleep},
{"loadfile", sl_loadfile},
- {"filesize", sl_filesize},
- {"filename", sl_filename},
- {"initramfs_init", sl_initramfs_init},
- {"initramfs_load_archive", sl_initramfs_load_archive},
- {"initramfs_add_file", sl_initramfs_add_file},
+ {"initramfs", sl_initramfs_init},
{"boot_it", sl_boot_it},
{"config_file", sl_config_file},
{"ipappend_strs", sl_ipappend_strs},
@@ -480,46 +457,84 @@ static const luaL_Reg syslinuxlib[] = {
{NULL, NULL}
};
+static const luaL_Reg file_methods[] = {
+ {"__gc", sl_unloadfile},
+ {"name", sl_filename},
+ {"size", sl_filesize},
+ {NULL, NULL}
+};
+
+static const luaL_Reg initramfs_methods[] = {
+ {"__gc", sl_initramfs_purge},
+ {"load", sl_initramfs_load_archive},
+ {"add_file", sl_initramfs_add_file},
+ {"size", sl_initramfs_size},
+ {NULL, NULL}
+};
+
/* This defines a function that opens up your library. */
LUALIB_API int luaopen_syslinux(lua_State * L)
{
luaL_newmetatable(L, SYSLINUX_FILE);
+ lua_pushstring (L, "__index");
+ lua_pushvalue (L, -2);
+ lua_settable (L, -3);
+ luaL_setfuncs (L, file_methods, 0);
+
+ luaL_newmetatable (L, SYSLINUX_INITRAMFS);
+ lua_pushstring (L, "__index");
+ lua_pushvalue (L, -2);
+ lua_settable (L, -3);
+ luaL_setfuncs (L, initramfs_methods, 0);
luaL_newlib(L, syslinuxlib);
+#define export(c,x) lua_pushinteger (L,c##_##x); lua_setfield (L, -2, #x);
+
lua_newtable (L);
-#define export_key(x) lua_pushinteger (L, KEY_##x); lua_setfield (L, -2, #x);
- export_key (NONE);
- export_key (BACKSPACE);
- export_key (TAB);
- export_key (ENTER);
- export_key (ESC);
- export_key (DEL);
- export_key (F1);
- export_key (F2);
- export_key (F3);
- export_key (F4);
- export_key (F5);
- export_key (F6);
- export_key (F7);
- export_key (F8);
- export_key (F9);
- export_key (F10);
- export_key (F11);
- export_key (F12);
- export_key (UP);
- export_key (DOWN);
- export_key (LEFT);
- export_key (RIGHT);
- export_key (PGUP);
- export_key (PGDN);
- export_key (HOME);
- export_key (END);
- export_key (INSERT);
- export_key (DELETE);
+ export (KEY, NONE);
+ export (KEY, BACKSPACE);
+ export (KEY, TAB);
+ export (KEY, ENTER);
+ export (KEY, ESC);
+ export (KEY, DEL);
+ export (KEY, F1);
+ export (KEY, F2);
+ export (KEY, F3);
+ export (KEY, F4);
+ export (KEY, F5);
+ export (KEY, F6);
+ export (KEY, F7);
+ export (KEY, F8);
+ export (KEY, F9);
+ export (KEY, F10);
+ export (KEY, F11);
+ export (KEY, F12);
+ export (KEY, UP);
+ export (KEY, DOWN);
+ export (KEY, LEFT);
+ export (KEY, RIGHT);
+ export (KEY, PGUP);
+ export (KEY, PGDN);
+ export (KEY, HOME);
+ export (KEY, END);
+ export (KEY, INSERT);
+ export (KEY, DELETE);
lua_setfield (L, -2, "KEY");
+ lua_newtable (L);
+ export (IMAGE_TYPE, KERNEL);
+ export (IMAGE_TYPE, LINUX);
+ export (IMAGE_TYPE, BOOT);
+ export (IMAGE_TYPE, BSS);
+ export (IMAGE_TYPE, PXE);
+ export (IMAGE_TYPE, FDIMAGE);
+ export (IMAGE_TYPE, COM32);
+ export (IMAGE_TYPE, CONFIG);
+ export (IMAGE_TYPE, LOCALBOOT);
+ lua_setfield (L, -2, "IMAGE_TYPE");
+
return 1;
}
diff --git a/com32/lua/src/vesa.c b/com32/lua/src/vesa.c
index 28e0124..119f6fc 100644
--- a/com32/lua/src/vesa.c
+++ b/com32/lua/src/vesa.c
@@ -59,8 +59,6 @@ static int vesa_getmodes(lua_State *L)
while ((mode = *mode_ptr++) != 0xFFFF) {
mode &= 0x1FF; /* The rest are attributes of sorts */
- printf("Found mode: 0x%04x (%dx%dx%d)\n", mode, mi->h_res, mi->v_res, mi->bpp);
-
memset(&rm, 0, sizeof(rm));
memset(mi, 0, sizeof *mi);
rm.eax.w[0] = 0x4F01; /* Get SVGA mode information */
diff --git a/com32/lua/test/automenu.lua b/com32/lua/test/automenu.lua
index 1e66cca..002fb09 100644
--- a/com32/lua/test/automenu.lua
+++ b/com32/lua/test/automenu.lua
@@ -26,6 +26,17 @@ local function modifiers ()
return (single and " single" or "") .. ({" quiet",""," debug"})[verbosity]
end
+local function boot (kernel_path, initrd_path, cmdline)
+ print ("Loading " .. kernel_path .. " ...")
+ local kernel = sl.loadfile (kernel_path)
+ local initrd
+ if (initrd_path) then
+ print ("Loading " .. initrd_path .. " ...")
+ initrd = sl.initramfs():load (initrd_path)
+ end
+ sl.boot_it (kernel, initrd, cmdline)
+end
+
local function scan (params)
local sep = string.sub (params.dir, -1) == "/" and "" or "/"
if not params.items then params.items = {} end
@@ -35,14 +46,16 @@ local function scan (params)
local from,to,version = string.find (name, "^vmlinuz%-(.*)")
if from then
local initrd = params.dir .. sep .. "initrd.img-" .. version
- local initrd_param = ""
- if lfs.attributes (initrd, "size") then
- initrd_param = "initrd=" .. initrd .. " "
+ if not lfs.attributes (initrd, "size") then
+ initrd = nil
end
table.insert (params.items, {
- show = function () return name end,
+ show = name .. (initrd and " +initrd" or ""),
version = version,
- execute = function () sl.boot_linux (path, initrd_param .. params.append .. modifiers ()) end
+ execute = function ()
+ boot (path, initrd,
+ params.append .. modifiers ())
+ end
})
end
end
@@ -81,21 +94,18 @@ local function kernel_gt (k1, k2)
return version_gt (k1.version, k2.version)
end
-local function print_or_call (x, def)
- local t = type (x)
- if t == "nil" then
- if def then print (def) end
- elseif t == "function" then
- x ()
+local function get (x)
+ if type (x) == "function" then
+ return x ()
else
- print (x)
+ return x
end
end
local function draw (params)
- print_or_call (params.title, "\n=== Boot menu ===")
+ print (get (params.title) or "\n=== Boot menu ===")
for i, item in ipairs (params.items) do
- print ((i == params.default and " > " or " ") .. i .. " " .. item.show ())
+ print ((i == params.default and " > " or " ") .. i .. " " .. get (item.show))
end
print ("\nKernel arguments:\n " .. params.append .. modifiers ())
print ("\nHit a number to select from the menu,\n ENTER to accept default,\n ESC to exit\n or any other key to print menu again")
diff --git a/com32/mboot/map.c b/com32/mboot/map.c
index 84f3b20..97b5b5d 100644
--- a/com32/mboot/map.c
+++ b/com32/mboot/map.c
@@ -61,7 +61,7 @@ addr_t map_data(const void *data, size_t len, size_t align, int flags)
return 0;
}
- dprintf("Mapping 0x%08x bytes (%#x pad) at 0x%08x\n", len, pad, start);
+ dprintf("Mapping 0x%08zx bytes (%#x pad) at 0x%08x\n", len, pad, start);
if (start + len + pad > mboot_high_water_mark)
mboot_high_water_mark = start + len + pad;
@@ -106,6 +106,11 @@ struct multiboot_header *map_image(void *ptr, size_t len)
Elf32_Ehdr *eh = ptr;
Elf32_Phdr *ph;
Elf32_Shdr *sh;
+
+ Elf64_Ehdr *eh64 = ptr;
+ Elf64_Phdr *ph64;
+ Elf64_Shdr *sh64;
+
unsigned int i, mbh_offset;
uint32_t bad_flags;
@@ -150,6 +155,18 @@ struct multiboot_header *map_image(void *ptr, size_t len)
!eh->e_phnum || eh->e_phoff + eh->e_phentsize * eh->e_phnum > len)
eh = NULL; /* No valid ELF header found */
+ /* Determine 64-bit images */
+ if ((eh != NULL) ||
+ len < sizeof(Elf64_Ehdr) ||
+ memcmp(eh64->e_ident, "\x7f" "ELF\2\1\1", 6) ||
+ (eh64->e_machine != EM_X86_64) ||
+ eh64->e_version != EV_CURRENT ||
+ eh64->e_ehsize < sizeof(Elf64_Ehdr) || eh64->e_ehsize >= len ||
+ eh64->e_phentsize < sizeof(Elf64_Phdr) ||
+ !eh64->e_phnum ||
+ eh64->e_phoff + eh64->e_phentsize * eh64->e_phnum > len)
+ eh64 = NULL; /* No valid ELF64 header found */
+
/* Is this a Solaris kernel? */
if (!set.solaris && eh && kernel_is_solaris(eh))
opt.solaris = true;
@@ -265,6 +282,112 @@ struct multiboot_header *map_image(void *ptr, size_t len)
sh[i].sh_addr = addr;
}
}
+ } else if (eh64 && !(opt.aout && mbh_len &&
+ (mbh->flags & MULTIBOOT_AOUT_KLUDGE))) {
+ /* Load 64-bit ELF */
+ regs.eip = eh64->e_entry; /* Can be overridden further down... */
+
+ ph64 = (Elf64_Phdr *) (cptr + eh64->e_phoff);
+
+ for (i = 0; i < eh64->e_phnum; i++) {
+ if (ph64->p_type == PT_LOAD || ph64->p_type == PT_PHDR) {
+ /*
+ * This loads at p_paddr, which matches Grub. However, if
+ * e_entry falls within the p_vaddr range of this PHDR, then
+ * adjust it to match the p_paddr range... this is how Grub
+ * behaves, so it's by definition correct (it doesn't have to
+ * make sense...)
+ */
+ addr_t addr = ph64->p_paddr;
+ addr_t msize = ph64->p_memsz;
+ addr_t dsize = min(msize, ph64->p_filesz);
+
+ if (eh64->e_entry >= ph64->p_vaddr
+ && eh64->e_entry < ph64->p_vaddr + msize)
+ regs.eip = eh64->e_entry + (ph64->p_paddr - ph64->p_vaddr);
+
+ dprintf("Segment at 0x%08x data 0x%08x len 0x%08x\n",
+ addr, dsize, msize);
+
+ if (syslinux_memmap_type(amap, addr, msize) != SMT_FREE) {
+ printf
+ ("Memory segment at 0x%08x (len 0x%08x) is unavailable\n",
+ addr, msize);
+ return NULL; /* Memory region unavailable */
+ }
+
+ /* Mark this region as allocated in the available map */
+ if (syslinux_add_memmap(&amap, addr, msize, SMT_ALLOC)) {
+ error("Overlapping segments found in ELF header\n");
+ return NULL;
+ }
+
+ if (ph64->p_filesz) {
+ /* Data present region. Create a move entry for it. */
+ if (syslinux_add_movelist
+ (&ml, addr, (addr_t) cptr + ph64->p_offset, dsize)) {
+ error("Failed to map PHDR data\n");
+ return NULL;
+ }
+ }
+ if (msize > dsize) {
+ /* Zero-filled region. Mark as a zero region in the memory map. */
+ if (syslinux_add_memmap
+ (&mmap, addr + dsize, msize - dsize, SMT_ZERO)) {
+ error("Failed to map PHDR zero region\n");
+ return NULL;
+ }
+ }
+ if (addr + msize > mboot_high_water_mark)
+ mboot_high_water_mark = addr + msize;
+ } else {
+ /* Ignore this program header */
+ }
+
+ ph64 = (Elf64_Phdr *) ((char *)ph64 + eh64->e_phentsize);
+ }
+
+ /* Load the ELF symbol table */
+ if (eh64->e_shoff) {
+ addr_t addr, len;
+
+ sh64 = (Elf64_Shdr *) ((char *)eh64 + eh64->e_shoff);
+
+ len = eh64->e_shentsize * eh64->e_shnum;
+ /*
+ * Align this, but don't pad -- in general this means a bunch of
+ * smaller sections gets packed into a single page.
+ */
+ addr = map_data(sh64, len, 4096, MAP_HIGH | MAP_NOPAD);
+ if (!addr) {
+ error("Failed to map symbol table\n");
+ return NULL;
+ }
+
+ mbinfo.flags |= MB_INFO_ELF_SHDR;
+ mbinfo.syms.e.addr = addr;
+ mbinfo.syms.e.num = eh64->e_shnum;
+ mbinfo.syms.e.size = eh64->e_shentsize;
+ mbinfo.syms.e.shndx = eh64->e_shstrndx;
+
+ for (i = 0; i < eh64->e_shnum; i++) {
+ addr_t align;
+
+ if (!sh64[i].sh_size)
+ continue; /* Empty section */
+ if (sh64[i].sh_flags & SHF_ALLOC)
+ continue; /* SHF_ALLOC sections should have PHDRs */
+
+ align = sh64[i].sh_addralign ? sh64[i].sh_addralign : 0;
+ addr = map_data((char *)ptr + sh64[i].sh_offset,
+ sh64[i].sh_size, align, MAP_HIGH);
+ if (!addr) {
+ error("Failed to map symbol section\n");
+ return NULL;
+ }
+ sh64[i].sh_addr = addr;
+ }
+ }
} else if (mbh_len && (mbh->flags & MULTIBOOT_AOUT_KLUDGE)) {
/*
* a.out kludge thing...
diff --git a/com32/mboot/mboot.c b/com32/mboot/mboot.c
index 10e6701..4e6b4e1 100644
--- a/com32/mboot/mboot.c
+++ b/com32/mboot/mboot.c
@@ -223,13 +223,13 @@ int main(int argc, char *argv[])
mbinfo.flags |= MB_INFO_CMDLINE;
}
- /* Map auxilliary images */
+ /* Map auxiliary images */
if (nmodules > 1) {
if (map_modules(modules + 1, nmodules - 1))
return 1;
}
- /* Add auxilliary information */
+ /* Add auxiliary information */
mboot_make_memmap();
mboot_apm();
mboot_syslinux_info();
diff --git a/com32/mboot/mboot.h b/com32/mboot/mboot.h
index da6ca2f..9f9e510 100644
--- a/com32/mboot/mboot.h
+++ b/com32/mboot/mboot.h
@@ -46,6 +46,7 @@
#include <minmax.h>
#include <sys/stat.h>
#include <elf.h>
+#include <sys/elf64.h>
#include <console.h>
#include <syslinux/loadfile.h>
diff --git a/com32/menu/menumain.c b/com32/menu/menumain.c
index b8cb06f..330bbc4 100644
--- a/com32/menu/menumain.c
+++ b/com32/menu/menumain.c
@@ -230,7 +230,7 @@ static int ask_passwd(const char *menu_entry)
for (x = 2; x <= WIDTH - 2 * PASSWD_MARGIN - 1; x++)
putchar('q');
- printf("j\017\033[%d;%dH\2#12 %s \033[%d;%dH\2#13",
+ printf("j\017\033[%d;%zdH\2#12 %s \033[%d;%dH\2#13",
PASSWD_ROW, (WIDTH - (strlen(cm->messages[MSG_PASSPROMPT]) + 2)) / 2,
cm->messages[MSG_PASSPROMPT], PASSWD_ROW + 1, PASSWD_MARGIN + 3);
@@ -306,7 +306,8 @@ static void draw_menu(int sel, int top, int edit_line)
if (cm->nentries > MENU_ROWS) {
int sblen = max(MENU_ROWS * MENU_ROWS / cm->nentries, 1);
- sbtop = (MENU_ROWS - sblen + 1) * top / (cm->nentries - MENU_ROWS + 1);
+ sbtop = ((MENU_ROWS - sblen + 1) * top /
+ (cm->nentries - MENU_ROWS + 1)) + VSHIFT;
sbbot = sbtop + sblen - 1;
sbtop += 4;
sbbot += 4; /* Starting row of scrollbar */
diff --git a/com32/menu/readconfig.c b/com32/menu/readconfig.c
index b7814be..a433fad 100644
--- a/com32/menu/readconfig.c
+++ b/com32/menu/readconfig.c
@@ -299,7 +299,7 @@ static char *copy_sysappend_string(char *dst, const char *src)
char c;
while ((c = *src++)) {
- if (c <= ' ' && c == '\x7f') {
+ if (my_isspace(c)) {
if (!was_space)
*dst++ = '_';
was_space = true;
diff --git a/com32/modules/Makefile b/com32/modules/Makefile
index 13cc63b..c01d633 100644
--- a/com32/modules/Makefile
+++ b/com32/modules/Makefile
@@ -18,13 +18,22 @@
VPATH = $(SRC)
include $(MAKEDIR)/elf.mk
-MODULES = config.c32 ethersel.c32 dmitest.c32 cpuidtest.c32 \
- disk.c32 pcitest.c32 elf.c32 linux.c32 reboot.c32 pmload.c32 \
- meminfo.c32 sdi.c32 sanboot.c32 ifcpu64.c32 vesainfo.c32 \
- kbdmap.c32 cmd.c32 vpdtest.c32 host.c32 ls.c32 gpxecmd.c32 \
- ifcpu.c32 cpuid.c32 cat.c32 pwd.c32 ifplop.c32 zzjson.c32 \
- whichsys.c32 prdhcp.c32 pxechn.c32 kontron_wdt.c32 ifmemdsk.c32 \
- hexdump.c32 poweroff.c32 cptime.c32 debug.c32
+# BIOS-specific modules
+MOD_BIOS = disk.c32 elf.c32 ethersel.c32 gpxecmd.c32 ifmemdsk.c32 ifplop.c32 \
+ kbdmap.c32 kontron_wdt.c32 pcitest.c32 pmload.c32 poweroff.c32 \
+ prdhcp.c32 pxechn.c32 sanboot.c32 sdi.c32 vesainfo.c32
+
+# All-architecture modules
+MOD_ALL = cat.c32 cmd.c32 config.c32 cptime.c32 cpuid.c32 cpuidtest.c32 \
+ debug.c32 dir.c32 dmitest.c32 hexdump.c32 host.c32 ifcpu.c32 \
+ ifcpu64.c32 linux.c32 ls.c32 meminfo.c32 pwd.c32 reboot.c32 \
+ vpdtest.c32 whichsys.c32 zzjson.c32
+
+ifeq ($(FIRMWARE),BIOS)
+MODULES = $(MOD_ALL) $(MOD_BIOS)
+else
+MODULES = $(MOD_ALL)
+endif
TESTFILES =
diff --git a/com32/modules/cptime.c b/com32/modules/cptime.c
index 0f5ffe6..315b9f9 100644
--- a/com32/modules/cptime.c
+++ b/com32/modules/cptime.c
@@ -216,7 +216,7 @@ int time_copy(char *fn, char do_simple, char do_verbose, size_t ibufsz, off_t ma
print_cp_result_long(fn, bcnt, bc, ec, ibufsz, do_verbose);
}
if (do_verbose)
- printf(" numrd %d bcnt %d bufsz %d i %d\n", numrd, bcnt, bufsz, i);
+ printf(" numrd %d bcnt %zd bufsz %zd i %d\n", numrd, bcnt, bufsz, i);
}
return rv;
} /* int time_copy(char *fn, char do_simple, int bufsz, off_t maxlen) */
diff --git a/com32/modules/host.c b/com32/modules/host.c
index d70efff..be7f6ce 100644
--- a/com32/modules/host.c
+++ b/com32/modules/host.c
@@ -6,11 +6,6 @@
#include <com32.h>
#include <syslinux/pxe.h>
-static inline uint32_t dns_resolve(const char *hostname)
-{
- return pxe_dns(hostname);
-}
-
static inline void usage(const char *s)
{
fprintf(stderr, "Usage: %s hostname [, hostname_1, hostname_2, ...]\n", s);
@@ -29,7 +24,7 @@ int main(int argc, char *argv[])
}
for (i = 1; i < argc; i++) {
- ip = dns_resolve(argv[i]);
+ ip = pxe_dns(argv[i]);
if (!ip) {
printf("%s not found.\n", argv[i]);
} else {
diff --git a/com32/modules/meminfo.c b/com32/modules/meminfo.c
index fc04792..c8f953b 100644
--- a/com32/modules/meminfo.c
+++ b/com32/modules/meminfo.c
@@ -71,12 +71,12 @@ static void dump_e820(void)
if (oreg.ecx.l >= 24) {
/* ebx base length end type */
- printf("%8x %016llx %016llx %016llx %d [%x]",
+ printf("%8x %016" PRIx64 "x %016" PRIx64 "x %016" PRIx64 "x %d [%x]",
ireg.ebx.l, ed.base, ed.len, ed.base + ed.len, ed.type,
ed.extattr);
} else {
/* ebx base length end */
- printf("%8x %016llx %016llx %016llx %d [-]",
+ printf("%8x %016" PRIx64 "x %016" PRIx64 "x %016" PRIx64 "x %d [-]",
ireg.ebx.l, ed.base, ed.len, ed.base + ed.len, ed.type);
ed.extattr = 1;
}
diff --git a/com32/modules/pmload.c b/com32/modules/pmload.c
index 6808d38..d6239ec 100644
--- a/com32/modules/pmload.c
+++ b/com32/modules/pmload.c
@@ -84,10 +84,10 @@ int boot_raw(void *ptr, size_t len, addr_t where, char **argv)
dprintf("Initial memory map:\n");
syslinux_dump_memmap(mmap);
- dprintf("Segment at 0x%08x len 0x%08x\n", where, len);
+ dprintf("Segment at 0x%08x len 0x%08zx\n", where, len);
if (syslinux_memmap_type(amap, where, len) != SMT_FREE) {
- printf("Memory segment at 0x%08x (len 0x%08x) is unavailable\n",
+ printf("Memory segment at 0x%08x (len 0x%08zx) is unavailable\n",
where, len);
goto bail; /* Memory region unavailable */
}
diff --git a/com32/rosh/Makefile b/com32/rosh/Makefile
index 4d900f4..0d49eec 100644
--- a/com32/rosh/Makefile
+++ b/com32/rosh/Makefile
@@ -27,7 +27,7 @@ include $(MAKEDIR)/rosh.mk
# official release. Otherwise, substitute a hex string that is pretty much
# guaranteed to be unique to be unique from build to build.
ifndef HEXDATE
-HEXDATE := $(shell $(PERL) $(topdir)/now.pl $(SRCS) $(wildcard *.h))
+HEXDATE := $(shell $(PERL) $(topdir)/now.pl $(SRCS) $(sort $(wildcard *.h)))
endif
ifndef DATE
DATE := $(shell sh $(topdir)/gen-id.sh $(VERSION) $(HEXDATE))
diff --git a/com32/samples/resolv.c b/com32/samples/resolv.c
index 8f062d1..a6757b7 100644
--- a/com32/samples/resolv.c
+++ b/com32/samples/resolv.c
@@ -25,7 +25,7 @@
uint32_t resolv(const char *name)
{
- return dns_resolv(name);
+ return pxe_dns(name);
}
int main(int argc, char *argv[])
diff --git a/com32/sysdump/Makefile b/com32/sysdump/Makefile
index 240edaa..ba9bcae 100644
--- a/com32/sysdump/Makefile
+++ b/com32/sysdump/Makefile
@@ -27,14 +27,14 @@ CFLAGS += -I$(com32) -I$(topdir)
MODULES = sysdump.c32
TESTFILES =
-SRCS = $(wildcard $(SRC)/*.c)
+SRCS = $(sort $(wildcard $(SRC)/*.c))
OBJS = $(subst $(SRC)/,,$(patsubst %.c,%.o,$(SRCS)))
# The DATE is set on the make command line when building binaries for
# official release. Otherwise, substitute a hex string that is pretty much
# guaranteed to be unique to be unique from build to build.
ifndef HEXDATE
-HEXDATE := $(shell $(PERL) $(topdir)/now.pl $(SRCS) $(wildcard *.h))
+HEXDATE := $(shell $(PERL) $(topdir)/now.pl $(SRCS) $(sort $(wildcard *.h)))
endif
ifndef DATE
DATE := $(shell sh $(topdir)/gen-id.sh $(VERSION) $(HEXDATE))
diff --git a/com32/sysdump/dmi.c b/com32/sysdump/dmi.c
index ce25efa..7c39b7b 100644
--- a/com32/sysdump/dmi.c
+++ b/com32/sysdump/dmi.c
@@ -65,7 +65,7 @@ static void dump_smbios(struct upload_backend *be, size_t dptr)
struct smbios_header smx = *smb;
char filename[32];
- snprintf(filename, sizeof filename, "dmi/%05x.%08x",
+ snprintf(filename, sizeof filename, "dmi/%05zx.%08x",
dptr, smb->dmi.tbladdr);
cpio_hdr(be, MODE_FILE, smb->dmi.tbllen + 32, filename);
@@ -90,7 +90,7 @@ static void dump_old_dmi(struct upload_backend *be, size_t dptr)
} fake;
char filename[32];
- snprintf(filename, sizeof filename, "dmi/%05x.%08x",
+ snprintf(filename, sizeof filename, "dmi/%05zx.%08x",
dptr, dmi->tbladdr);
cpio_hdr(be, MODE_FILE, dmi->tbllen + 32, filename);
diff --git a/com32/tools/Makefile b/com32/tools/Makefile
index 9c0ea70..d64fc1d 100644
--- a/com32/tools/Makefile
+++ b/com32/tools/Makefile
@@ -1,6 +1,6 @@
## -*- makefile -*- ------------------------------------------------------
##
-## Copyright 2001-2008 H. Peter Anvin - All Rights Reserved
+## Copyright 2001-2016 H. Peter Anvin - All Rights Reserved
##
## 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
@@ -13,15 +13,12 @@
VPATH = $(SRC)
include $(MAKEDIR)/build.mk
-BINS = relocs
+BINS =
INCLUDES += -I$(SRC)/include
all : $(BINS)
-relocs : relocs.o
- $(CC) $(LDFLAGS) -o $@ $^ $(LIBS)
-
tidy dist clean spotless:
rm -f $(BINS)
rm -f *.o *.a .*.d
diff --git a/com32/tools/relocs.c b/com32/tools/relocs.c
deleted file mode 100644
index 86fc7c5..0000000
--- a/com32/tools/relocs.c
+++ /dev/null
@@ -1,808 +0,0 @@
-/*
- * This file is taken from the Linux kernel and is distributed under GPL v2.
- */
-#include <stdio.h>
-#include <stdarg.h>
-#include <stdlib.h>
-#include <stdint.h>
-#include <string.h>
-#include <errno.h>
-#include <unistd.h>
-#include <elf.h>
-#include <byteswap.h>
-#define USE_BSD
-#include <endian.h>
-#include <regex.h>
-#include <tools/le_byteshift.h>
-
-static void die(char *fmt, ...);
-
-#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
-static Elf32_Ehdr ehdr;
-static unsigned long reloc_count, reloc_idx;
-static unsigned long *relocs;
-static unsigned long reloc16_count, reloc16_idx;
-static unsigned long *relocs16;
-
-struct section {
- Elf32_Shdr shdr;
- struct section *link;
- Elf32_Sym *symtab;
- Elf32_Rel *reltab;
- char *strtab;
-};
-static struct section *secs;
-
-enum symtype {
- S_ABS,
- S_REL,
- S_SEG,
- S_LIN,
- S_NSYMTYPES
-};
-
-static const char * const sym_regex_kernel[S_NSYMTYPES] = {
-/*
- * Following symbols have been audited. Don't warn user about
- * absolute relocations present w.r.t these symbols.
- */
- [S_ABS] =
- "^(__.*_len|__.*_dwords)$",
-
-/*
- * These symbols are known to be relative, even if the linker marks them
- * as absolute (typically defined outside any section in the linker script.)
- */
- [S_REL] =
- "^(__.*_start|__.*_end|_end|_[se](text|data))$",
-};
-
-
-static const char * const sym_regex_realmode[S_NSYMTYPES] = {
-/*
- * These are 16-bit segment symbols when compiling 16-bit code.
- */
- [S_SEG] =
- "^real_mode_seg$",
-
-/*
- * These are offsets belonging to segments, as opposed to linear addresses,
- * when compiling 16-bit code.
- */
- [S_LIN] =
- "^pa_",
-};
-
-static const char * const *sym_regex;
-
-static regex_t sym_regex_c[S_NSYMTYPES];
-static int is_reloc(enum symtype type, const char *sym_name)
-{
- return sym_regex[type] &&
- !regexec(&sym_regex_c[type], sym_name, 0, NULL, 0);
-}
-
-static void regex_init(int use_real_mode)
-{
- char errbuf[128];
- int err;
- int i;
-
- if (use_real_mode)
- sym_regex = sym_regex_realmode;
- else
- sym_regex = sym_regex_kernel;
-
- for (i = 0; i < S_NSYMTYPES; i++) {
- if (!sym_regex[i])
- continue;
-
- err = regcomp(&sym_regex_c[i], sym_regex[i],
- REG_EXTENDED|REG_NOSUB);
-
- if (err) {
- regerror(err, &sym_regex_c[i], errbuf, sizeof errbuf);
- die("%s", errbuf);
- }
- }
-}
-
-static void die(char *fmt, ...)
-{
- va_list ap;
- va_start(ap, fmt);
- vfprintf(stderr, fmt, ap);
- va_end(ap);
- exit(1);
-}
-
-static const char *sym_type(unsigned type)
-{
- static const char *type_name[] = {
-#define SYM_TYPE(X) [X] = #X
- SYM_TYPE(STT_NOTYPE),
- SYM_TYPE(STT_OBJECT),
- SYM_TYPE(STT_FUNC),
- SYM_TYPE(STT_SECTION),
- SYM_TYPE(STT_FILE),
- SYM_TYPE(STT_COMMON),
- SYM_TYPE(STT_TLS),
-#undef SYM_TYPE
- };
- const char *name = "unknown sym type name";
- if (type < ARRAY_SIZE(type_name)) {
- name = type_name[type];
- }
- return name;
-}
-
-static const char *sym_bind(unsigned bind)
-{
- static const char *bind_name[] = {
-#define SYM_BIND(X) [X] = #X
- SYM_BIND(STB_LOCAL),
- SYM_BIND(STB_GLOBAL),
- SYM_BIND(STB_WEAK),
-#undef SYM_BIND
- };
- const char *name = "unknown sym bind name";
- if (bind < ARRAY_SIZE(bind_name)) {
- name = bind_name[bind];
- }
- return name;
-}
-
-static const char *sym_visibility(unsigned visibility)
-{
- static const char *visibility_name[] = {
-#define SYM_VISIBILITY(X) [X] = #X
- SYM_VISIBILITY(STV_DEFAULT),
- SYM_VISIBILITY(STV_INTERNAL),
- SYM_VISIBILITY(STV_HIDDEN),
- SYM_VISIBILITY(STV_PROTECTED),
-#undef SYM_VISIBILITY
- };
- const char *name = "unknown sym visibility name";
- if (visibility < ARRAY_SIZE(visibility_name)) {
- name = visibility_name[visibility];
- }
- return name;
-}
-
-static const char *rel_type(unsigned type)
-{
- static const char *type_name[] = {
-#define REL_TYPE(X) [X] = #X
- REL_TYPE(R_386_NONE),
- REL_TYPE(R_386_32),
- REL_TYPE(R_386_PC32),
- REL_TYPE(R_386_GOT32),
- REL_TYPE(R_386_PLT32),
- REL_TYPE(R_386_COPY),
- REL_TYPE(R_386_GLOB_DAT),
- REL_TYPE(R_386_JMP_SLOT),
- REL_TYPE(R_386_RELATIVE),
- REL_TYPE(R_386_GOTOFF),
- REL_TYPE(R_386_GOTPC),
- REL_TYPE(R_386_8),
- REL_TYPE(R_386_PC8),
- REL_TYPE(R_386_16),
- REL_TYPE(R_386_PC16),
-#undef REL_TYPE
- };
- const char *name = "unknown type rel type name";
- if (type < ARRAY_SIZE(type_name) && type_name[type]) {
- name = type_name[type];
- }
- return name;
-}
-
-static const char *sec_name(unsigned shndx)
-{
- const char *sec_strtab;
- const char *name;
- sec_strtab = secs[ehdr.e_shstrndx].strtab;
- name = "<noname>";
- if (shndx < ehdr.e_shnum) {
- name = sec_strtab + secs[shndx].shdr.sh_name;
- }
- else if (shndx == SHN_ABS) {
- name = "ABSOLUTE";
- }
- else if (shndx == SHN_COMMON) {
- name = "COMMON";
- }
- return name;
-}
-
-static const char *sym_name(const char *sym_strtab, Elf32_Sym *sym)
-{
- const char *name;
- name = "<noname>";
- if (sym->st_name) {
- name = sym_strtab + sym->st_name;
- }
- else {
- name = sec_name(sym->st_shndx);
- }
- return name;
-}
-
-
-
-#if BYTE_ORDER == LITTLE_ENDIAN
-#define le16_to_cpu(val) (val)
-#define le32_to_cpu(val) (val)
-#endif
-#if BYTE_ORDER == BIG_ENDIAN
-#define le16_to_cpu(val) bswap_16(val)
-#define le32_to_cpu(val) bswap_32(val)
-#endif
-
-static uint16_t elf16_to_cpu(uint16_t val)
-{
- return le16_to_cpu(val);
-}
-
-static uint32_t elf32_to_cpu(uint32_t val)
-{
- return le32_to_cpu(val);
-}
-
-static void read_ehdr(FILE *fp)
-{
- if (fread(&ehdr, sizeof(ehdr), 1, fp) != 1) {
- die("Cannot read ELF header: %s\n",
- strerror(errno));
- }
- if (memcmp(ehdr.e_ident, ELFMAG, SELFMAG) != 0) {
- die("No ELF magic\n");
- }
- if (ehdr.e_ident[EI_CLASS] != ELFCLASS32) {
- die("Not a 32 bit executable\n");
- }
- if (ehdr.e_ident[EI_DATA] != ELFDATA2LSB) {
- die("Not a LSB ELF executable\n");
- }
- if (ehdr.e_ident[EI_VERSION] != EV_CURRENT) {
- die("Unknown ELF version\n");
- }
- /* Convert the fields to native endian */
- ehdr.e_type = elf16_to_cpu(ehdr.e_type);
- ehdr.e_machine = elf16_to_cpu(ehdr.e_machine);
- ehdr.e_version = elf32_to_cpu(ehdr.e_version);
- ehdr.e_entry = elf32_to_cpu(ehdr.e_entry);
- ehdr.e_phoff = elf32_to_cpu(ehdr.e_phoff);
- ehdr.e_shoff = elf32_to_cpu(ehdr.e_shoff);
- ehdr.e_flags = elf32_to_cpu(ehdr.e_flags);
- ehdr.e_ehsize = elf16_to_cpu(ehdr.e_ehsize);
- ehdr.e_phentsize = elf16_to_cpu(ehdr.e_phentsize);
- ehdr.e_phnum = elf16_to_cpu(ehdr.e_phnum);
- ehdr.e_shentsize = elf16_to_cpu(ehdr.e_shentsize);
- ehdr.e_shnum = elf16_to_cpu(ehdr.e_shnum);
- ehdr.e_shstrndx = elf16_to_cpu(ehdr.e_shstrndx);
-
- if ((ehdr.e_type != ET_EXEC) && (ehdr.e_type != ET_DYN)) {
- die("Unsupported ELF header type\n");
- }
- if (ehdr.e_machine != EM_386) {
- die("Not for x86\n");
- }
- if (ehdr.e_version != EV_CURRENT) {
- die("Unknown ELF version\n");
- }
- if (ehdr.e_ehsize != sizeof(Elf32_Ehdr)) {
- die("Bad Elf header size\n");
- }
- if (ehdr.e_phentsize != sizeof(Elf32_Phdr)) {
- die("Bad program header entry\n");
- }
- if (ehdr.e_shentsize != sizeof(Elf32_Shdr)) {
- die("Bad section header entry\n");
- }
- if (ehdr.e_shstrndx >= ehdr.e_shnum) {
- die("String table index out of bounds\n");
- }
-}
-
-static void read_shdrs(FILE *fp)
-{
- int i;
- Elf32_Shdr shdr;
-
- secs = calloc(ehdr.e_shnum, sizeof(struct section));
- if (!secs) {
- die("Unable to allocate %d section headers\n",
- ehdr.e_shnum);
- }
- if (fseek(fp, ehdr.e_shoff, SEEK_SET) < 0) {
- die("Seek to %d failed: %s\n",
- ehdr.e_shoff, strerror(errno));
- }
- for (i = 0; i < ehdr.e_shnum; i++) {
- struct section *sec = &secs[i];
- if (fread(&shdr, sizeof shdr, 1, fp) != 1)
- die("Cannot read ELF section headers %d/%d: %s\n",
- i, ehdr.e_shnum, strerror(errno));
- sec->shdr.sh_name = elf32_to_cpu(shdr.sh_name);
- sec->shdr.sh_type = elf32_to_cpu(shdr.sh_type);
- sec->shdr.sh_flags = elf32_to_cpu(shdr.sh_flags);
- sec->shdr.sh_addr = elf32_to_cpu(shdr.sh_addr);
- sec->shdr.sh_offset = elf32_to_cpu(shdr.sh_offset);
- sec->shdr.sh_size = elf32_to_cpu(shdr.sh_size);
- sec->shdr.sh_link = elf32_to_cpu(shdr.sh_link);
- sec->shdr.sh_info = elf32_to_cpu(shdr.sh_info);
- sec->shdr.sh_addralign = elf32_to_cpu(shdr.sh_addralign);
- sec->shdr.sh_entsize = elf32_to_cpu(shdr.sh_entsize);
- if (sec->shdr.sh_link < ehdr.e_shnum)
- sec->link = &secs[sec->shdr.sh_link];
- }
-
-}
-
-static void read_strtabs(FILE *fp)
-{
- int i;
- for (i = 0; i < ehdr.e_shnum; i++) {
- struct section *sec = &secs[i];
- if (sec->shdr.sh_type != SHT_STRTAB) {
- continue;
- }
- sec->strtab = malloc(sec->shdr.sh_size);
- if (!sec->strtab) {
- die("malloc of %d bytes for strtab failed\n",
- sec->shdr.sh_size);
- }
- if (fseek(fp, sec->shdr.sh_offset, SEEK_SET) < 0) {
- die("Seek to %d failed: %s\n",
- sec->shdr.sh_offset, strerror(errno));
- }
- if (fread(sec->strtab, 1, sec->shdr.sh_size, fp)
- != sec->shdr.sh_size) {
- die("Cannot read symbol table: %s\n",
- strerror(errno));
- }
- }
-}
-
-static void read_symtabs(FILE *fp)
-{
- int i,j;
- for (i = 0; i < ehdr.e_shnum; i++) {
- struct section *sec = &secs[i];
- if (sec->shdr.sh_type != SHT_SYMTAB) {
- continue;
- }
- sec->symtab = malloc(sec->shdr.sh_size);
- if (!sec->symtab) {
- die("malloc of %d bytes for symtab failed\n",
- sec->shdr.sh_size);
- }
- if (fseek(fp, sec->shdr.sh_offset, SEEK_SET) < 0) {
- die("Seek to %d failed: %s\n",
- sec->shdr.sh_offset, strerror(errno));
- }
- if (fread(sec->symtab, 1, sec->shdr.sh_size, fp)
- != sec->shdr.sh_size) {
- die("Cannot read symbol table: %s\n",
- strerror(errno));
- }
- for (j = 0; j < sec->shdr.sh_size/sizeof(Elf32_Sym); j++) {
- Elf32_Sym *sym = &sec->symtab[j];
- sym->st_name = elf32_to_cpu(sym->st_name);
- sym->st_value = elf32_to_cpu(sym->st_value);
- sym->st_size = elf32_to_cpu(sym->st_size);
- sym->st_shndx = elf16_to_cpu(sym->st_shndx);
- }
- }
-}
-
-
-static void read_relocs(FILE *fp)
-{
- int i,j;
- for (i = 0; i < ehdr.e_shnum; i++) {
- struct section *sec = &secs[i];
- if (sec->shdr.sh_type != SHT_REL) {
- continue;
- }
- sec->reltab = malloc(sec->shdr.sh_size);
- if (!sec->reltab) {
- die("malloc of %d bytes for relocs failed\n",
- sec->shdr.sh_size);
- }
- if (fseek(fp, sec->shdr.sh_offset, SEEK_SET) < 0) {
- die("Seek to %d failed: %s\n",
- sec->shdr.sh_offset, strerror(errno));
- }
- if (fread(sec->reltab, 1, sec->shdr.sh_size, fp)
- != sec->shdr.sh_size) {
- die("Cannot read symbol table: %s\n",
- strerror(errno));
- }
- for (j = 0; j < sec->shdr.sh_size/sizeof(Elf32_Rel); j++) {
- Elf32_Rel *rel = &sec->reltab[j];
- rel->r_offset = elf32_to_cpu(rel->r_offset);
- rel->r_info = elf32_to_cpu(rel->r_info);
- }
- }
-}
-
-
-static void print_absolute_symbols(void)
-{
- int i;
- printf("Absolute symbols\n");
- printf(" Num: Value Size Type Bind Visibility Name\n");
- for (i = 0; i < ehdr.e_shnum; i++) {
- struct section *sec = &secs[i];
- char *sym_strtab;
- int j;
-
- if (sec->shdr.sh_type != SHT_SYMTAB) {
- continue;
- }
- sym_strtab = sec->link->strtab;
- for (j = 0; j < sec->shdr.sh_size/sizeof(Elf32_Sym); j++) {
- Elf32_Sym *sym;
- const char *name;
- sym = &sec->symtab[j];
- name = sym_name(sym_strtab, sym);
- if (sym->st_shndx != SHN_ABS) {
- continue;
- }
- printf("%5d %08x %5d %10s %10s %12s %s\n",
- j, sym->st_value, sym->st_size,
- sym_type(ELF32_ST_TYPE(sym->st_info)),
- sym_bind(ELF32_ST_BIND(sym->st_info)),
- sym_visibility(ELF32_ST_VISIBILITY(sym->st_other)),
- name);
- }
- }
- printf("\n");
-}
-
-static void print_absolute_relocs(void)
-{
- int i, printed = 0;
-
- for (i = 0; i < ehdr.e_shnum; i++) {
- struct section *sec = &secs[i];
- struct section *sec_applies, *sec_symtab;
- char *sym_strtab;
- Elf32_Sym *sh_symtab;
- int j;
- if (sec->shdr.sh_type != SHT_REL) {
- continue;
- }
- sec_symtab = sec->link;
- sec_applies = &secs[sec->shdr.sh_info];
- if (!(sec_applies->shdr.sh_flags & SHF_ALLOC)) {
- continue;
- }
- sh_symtab = sec_symtab->symtab;
- sym_strtab = sec_symtab->link->strtab;
- for (j = 0; j < sec->shdr.sh_size/sizeof(Elf32_Rel); j++) {
- Elf32_Rel *rel;
- Elf32_Sym *sym;
- const char *name;
- rel = &sec->reltab[j];
- sym = &sh_symtab[ELF32_R_SYM(rel->r_info)];
- name = sym_name(sym_strtab, sym);
- if (sym->st_shndx != SHN_ABS) {
- continue;
- }
-
- /* Absolute symbols are not relocated if bzImage is
- * loaded at a non-compiled address. Display a warning
- * to user at compile time about the absolute
- * relocations present.
- *
- * User need to audit the code to make sure
- * some symbols which should have been section
- * relative have not become absolute because of some
- * linker optimization or wrong programming usage.
- *
- * Before warning check if this absolute symbol
- * relocation is harmless.
- */
- if (is_reloc(S_ABS, name) || is_reloc(S_REL, name))
- continue;
-
- if (!printed) {
- printf("WARNING: Absolute relocations"
- " present\n");
- printf("Offset Info Type Sym.Value "
- "Sym.Name\n");
- printed = 1;
- }
-
- printf("%08x %08x %10s %08x %s\n",
- rel->r_offset,
- rel->r_info,
- rel_type(ELF32_R_TYPE(rel->r_info)),
- sym->st_value,
- name);
- }
- }
-
- if (printed)
- printf("\n");
-}
-
-static void walk_relocs(void (*visit)(Elf32_Rel *rel, Elf32_Sym *sym),
- int use_real_mode)
-{
- int i;
- /* Walk through the relocations */
- for (i = 0; i < ehdr.e_shnum; i++) {
- char *sym_strtab;
- Elf32_Sym *sh_symtab;
- struct section *sec_applies, *sec_symtab;
- int j;
- struct section *sec = &secs[i];
-
- if (sec->shdr.sh_type != SHT_REL) {
- continue;
- }
- sec_symtab = sec->link;
- sec_applies = &secs[sec->shdr.sh_info];
- if (!(sec_applies->shdr.sh_flags & SHF_ALLOC)) {
- continue;
- }
- sh_symtab = sec_symtab->symtab;
- sym_strtab = sec_symtab->link->strtab;
- for (j = 0; j < sec->shdr.sh_size/sizeof(Elf32_Rel); j++) {
- Elf32_Rel *rel;
- Elf32_Sym *sym;
- unsigned r_type;
- const char *symname;
- int shn_abs;
-
- rel = &sec->reltab[j];
- sym = &sh_symtab[ELF32_R_SYM(rel->r_info)];
- r_type = ELF32_R_TYPE(rel->r_info);
-
- shn_abs = sym->st_shndx == SHN_ABS;
-
- switch (r_type) {
- case R_386_NONE:
- case R_386_PC32:
- case R_386_PC16:
- case R_386_PC8:
- case R_386_GOTPC:
- case R_386_GOTOFF:
- case R_386_GOT32:
- case R_386_PLT32:
- /*
- * NONE can be ignored and and PC relative
- * relocations don't need to be adjusted.
- */
- break;
-
- case R_386_16:
- symname = sym_name(sym_strtab, sym);
- if (!use_real_mode)
- goto bad;
- if (shn_abs) {
- if (is_reloc(S_ABS, symname))
- break;
- else if (!is_reloc(S_SEG, symname))
- goto bad;
- } else {
- if (is_reloc(S_LIN, symname))
- goto bad;
- else
- break;
- }
- visit(rel, sym);
- break;
-
- case R_386_32:
- symname = sym_name(sym_strtab, sym);
- if (shn_abs) {
- if (is_reloc(S_ABS, symname))
- break;
- else if (!is_reloc(S_REL, symname))
- goto bad;
- } else {
- if (use_real_mode &&
- !is_reloc(S_LIN, symname))
- break;
- }
- visit(rel, sym);
- break;
- default:
- die("Unsupported relocation type: %s (%d)\n",
- rel_type(r_type), r_type);
- break;
- bad:
- symname = sym_name(sym_strtab, sym);
- die("Invalid %s %s relocation: %s\n",
- shn_abs ? "absolute" : "relative",
- rel_type(r_type), symname);
- }
- }
- }
-}
-
-static void count_reloc(Elf32_Rel *rel, Elf32_Sym *sym)
-{
- (void)sym;
-
- if (ELF32_R_TYPE(rel->r_info) == R_386_16)
- reloc16_count++;
- else
- reloc_count++;
-}
-
-static void collect_reloc(Elf32_Rel *rel, Elf32_Sym *sym)
-{
- (void)sym;
-
- /* Remember the address that needs to be adjusted. */
- if (ELF32_R_TYPE(rel->r_info) == R_386_16)
- relocs16[reloc16_idx++] = rel->r_offset;
- else
- relocs[reloc_idx++] = rel->r_offset;
-}
-
-static int cmp_relocs(const void *va, const void *vb)
-{
- const unsigned long *a, *b;
- a = va; b = vb;
- return (*a == *b)? 0 : (*a > *b)? 1 : -1;
-}
-
-static int write32(unsigned int v, FILE *f)
-{
- unsigned char buf[4];
-
- put_unaligned_le32(v, buf);
- return fwrite(buf, 1, 4, f) == 4 ? 0 : -1;
-}
-
-static void emit_relocs(int as_text, int use_real_mode)
-{
- int i;
- /* Count how many relocations I have and allocate space for them. */
- reloc_count = 0;
- walk_relocs(count_reloc, use_real_mode);
- relocs = malloc(reloc_count * sizeof(relocs[0]));
- if (!relocs) {
- die("malloc of %d entries for relocs failed\n",
- reloc_count);
- }
-
- relocs16 = malloc(reloc16_count * sizeof(relocs[0]));
- if (!relocs16) {
- die("malloc of %d entries for relocs16 failed\n",
- reloc16_count);
- }
- /* Collect up the relocations */
- reloc_idx = 0;
- walk_relocs(collect_reloc, use_real_mode);
-
- if (reloc16_count && !use_real_mode)
- die("Segment relocations found but --realmode not specified\n");
-
- /* Order the relocations for more efficient processing */
- qsort(relocs, reloc_count, sizeof(relocs[0]), cmp_relocs);
- qsort(relocs16, reloc16_count, sizeof(relocs16[0]), cmp_relocs);
-
- /* Print the relocations */
- if (as_text) {
- /* Print the relocations in a form suitable that
- * gas will like.
- */
- printf(".section \".data.reloc\",\"a\"\n");
- printf(".balign 4\n");
- if (use_real_mode) {
- printf("\t.long %lu\n", reloc16_count);
- for (i = 0; i < reloc16_count; i++)
- printf("\t.long 0x%08lx\n", relocs16[i]);
- printf("\t.long %lu\n", reloc_count);
- for (i = 0; i < reloc_count; i++) {
- printf("\t.long 0x%08lx\n", relocs[i]);
- }
- } else {
- for (i = 0; i < reloc_count; i++) {
- printf("\t.long 0x%08lx\n", relocs[i]);
- }
- /* Print a stop */
- printf("\t.long 0x%08lx\n", (unsigned long)0);
- }
-
- printf("\n");
- }
- else {
- if (use_real_mode) {
- write32(reloc16_count, stdout);
- for (i = 0; i < reloc16_count; i++)
- write32(relocs16[i], stdout);
- write32(reloc_count, stdout);
-
- /* Now print each relocation */
- for (i = 0; i < reloc_count; i++)
- write32(relocs[i], stdout);
- } else {
- /* Now print each relocation */
- for (i = 0; i < reloc_count; i++) {
- write32(relocs[i], stdout);
- }
-
- /* Print a stop */
- write32(0, stdout);
- }
- }
-}
-
-static void usage(void)
-{
- die("relocs [--abs-syms|--abs-relocs|--text|--realmode] vmlinux\n");
-}
-
-int main(int argc, char **argv)
-{
- int show_absolute_syms, show_absolute_relocs;
- int as_text, use_real_mode;
- const char *fname;
- FILE *fp;
- int i;
-
- show_absolute_syms = 0;
- show_absolute_relocs = 0;
- as_text = 0;
- use_real_mode = 0;
- fname = NULL;
- for (i = 1; i < argc; i++) {
- char *arg = argv[i];
- if (*arg == '-') {
- if (strcmp(arg, "--abs-syms") == 0) {
- show_absolute_syms = 1;
- continue;
- }
- if (strcmp(arg, "--abs-relocs") == 0) {
- show_absolute_relocs = 1;
- continue;
- }
- if (strcmp(arg, "--text") == 0) {
- as_text = 1;
- continue;
- }
- if (strcmp(arg, "--realmode") == 0) {
- use_real_mode = 1;
- continue;
- }
- }
- else if (!fname) {
- fname = arg;
- continue;
- }
- usage();
- }
- if (!fname) {
- usage();
- }
- regex_init(use_real_mode);
- fp = fopen(fname, "r");
- if (!fp) {
- die("Cannot open %s: %s\n",
- fname, strerror(errno));
- }
- read_ehdr(fp);
- read_shdrs(fp);
- read_strtabs(fp);
- read_symtabs(fp);
- read_relocs(fp);
- if (show_absolute_syms) {
- print_absolute_symbols();
- return 0;
- }
- if (show_absolute_relocs) {
- print_absolute_relocs();
- return 0;
- }
- emit_relocs(as_text, use_real_mode);
- return 0;
-}
diff --git a/core/Makefile b/core/Makefile
index ad0acb5..46cb037 100644
--- a/core/Makefile
+++ b/core/Makefile
@@ -1,7 +1,7 @@
## -----------------------------------------------------------------------
##
## Copyright 1998-2009 H. Peter Anvin - All Rights Reserved
-## Copyright 2009-2014 Intel Corporation; author: H. Peter Anvin
+## Copyright 2009-2016 Intel Corporation; author: H. Peter Anvin
##
## 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
@@ -39,8 +39,8 @@ BTARGET = kwdhash.gen \
isolinux.bin isolinux-debug.bin pxelinux.0 lpxelinux.0
# All primary source files for the main syslinux files
-NASMSRC := $(wildcard $(SRC)/*.asm)
-NASMHDR := $(wildcard $(SRC)/*.inc)
+NASMSRC := $(sort $(wildcard $(SRC)/*.asm))
+NASMHDR := $(sort $(wildcard $(SRC)/*.inc))
CSRC := $(shell find $(SRC) -name '*.c' -print)
SSRC := $(shell find $(SRC) -name '*.S' -print)
CHDR := $(shell find $(SRC) -name '*.h' -print)
@@ -77,18 +77,20 @@ FILTER_OBJS = %rawcon.o %plaincon.o %pxelinux-c.o %ldlinux-c.o \
$(subst $(OBJ)/,,$(LPXELINUX_OBJS)) \
$(subst $(OBJ)/,,$(PXELINUX_OBJS))
-ifdef EFI_BUILD
+ifeq ($(FWCLASS),EFI)
# EFI is single-threaded, and doesn't use the LZO assembly decoder
FILTER_OBJS += $(subst $(SRC)/,, \
- $(patsubst %.S,%.o, $(wildcard $(SRC)/lzo/*.S)) \
- $(patsubst %.c,%.o, $(wildcard $(SRC)/thread/*.c)) \
- $(patsubst %.S,%.o, $(wildcard $(SRC)/thread/*.S)))
+ $(patsubst %.S,%.o, $(sort $(wildcard $(SRC)/lzo/*.S))) \
+ $(patsubst %.c,%.o, $(sort $(wildcard $(SRC)/thread/*.c))) \
+ $(patsubst %.S,%.o, $(sort $(wildcard $(SRC)/thread/*.S)))) \
+ $(patsubst %.asm,%.o, $(sort $(wildcard $(SRC)/*.asm))) \
+ $(patsubst %.c,%.o, $(sort $(wildcard $(SRC)/bios*.c)))
endif
COBJS = $(filter-out $(FILTER_OBJS),$(COBJ))
SOBJS = $(filter-out $(FILTER_OBJS),$(SOBJ))
-ifdef EFI_BUILD
+ifeq ($(FWCLASS),EFI)
COBJS += $(subst $(SRC)/,,$(CORE_PXE_CSRC:%.c=%.o) fs/pxe/ftp.o fs/pxe/ftp_readdir.o \
fs/pxe/http.o fs/pxe/http_readdir.o)
endif
@@ -116,20 +118,7 @@ ifndef DATE
DATE := $(shell sh $(SRC)/../gen-id.sh $(VERSION) $(HEXDATE))
endif
-# Set up the NASM and LD options for the architecture
-NASM_ELF = "unknown"
-LD_PIE = "unknown"
-ifeq ($(ARCH),i386)
- NASM_ELF = elf
- LD_PIE = -pie
-endif
-ifeq ($(ARCH),x86_64)
- NASM_ELF = elf64
- #LD_PIE = --pic-executable
- LD_PIE =
-endif
-
-ifdef EFI_BUILD
+ifeq ($(FWCLASS),EFI)
all: makeoutputdirs $(filter-out %bios.o,$(COBJS) $(SOBJS)) codepage.o
else
all: makeoutputdirs $(BTARGET)
@@ -141,14 +130,14 @@ makeoutputdirs:
kwdhash.gen: keywords genhash.pl
$(PERL) $(SRC)/genhash.pl < $(SRC)/keywords > $(OBJ)/kwdhash.gen
-.PRECIOUS: %.elf
+ifeq ($(FWCLASS),BIOS)
+.PRECIOUS: %.elf
%.raw: %.elf
$(OBJCOPY) -O binary -S $< $(@:.bin=.raw)
-# GNU make 3.82 gets confused by the first form
-.PRECIOUS: $(OBJ)/%.raw
-
+# GNU make 3.82 gets confused by plain %.raw; make 4.0 requires it
+.PRECIOUS: $(OBJ)/%.raw %.raw
%.bin: %.raw $(PREPCORE)
$(PREPCORE) $< $@
@@ -161,12 +150,20 @@ kwdhash.gen: keywords genhash.pl
AUXLIBS = libisolinux.a libisolinux-debug.a libldlinux.a \
libpxelinux.a liblpxelinux.a
+
LDSCRIPT = $(SRC)/$(ARCH)/syslinux.ld
+NASM_ELF = elf
+
%.elf: %.o $(LIBDEP) $(LDSCRIPT) $(AUXLIBS)
- $(LD) $(LDFLAGS) -Bsymbolic $(LD_PIE) -E --hash-style=gnu -T $(LDSCRIPT) -M -o $@ $< \
+ $(LD) $(LDFLAGS) -pie -Bsymbolic \
+ -T $(LDSCRIPT) \
+ --unresolved-symbols=report-all \
+ -E --hash-style=gnu -M -o $@ $< \
--start-group $(LIBS) $(subst $(*F).elf,lib$(*F).a,$@) --end-group \
> $(@:.elf=.map)
+ if [ `$(NM) -D -u $@ | wc -l` -ne 0 ]; then \
+ $(NM) -D -u $@ 1>&2; rm -f $@; false; fi
$(OBJDUMP) -h $@ > $(@:.elf=.sec)
$(PERL) $(SRC)/lstadjust.pl $(@:.elf=.lsr) $(@:.elf=.sec) $(@:.elf=.lst)
@@ -195,11 +192,6 @@ libldlinux.a: plaincon.o localboot.o ldlinux-c.o
$(AR) cq $@ $^
$(RANLIB) $@
-$(LIB): $(LIBOBJS)
- rm -f $@
- $(AR) cq $@ $^
- $(RANLIB) $@
-
pxelinux.o: pxelinux.asm kwdhash.gen ../version.gen
$(NASM) -f $(NASM_ELF) $(NASMOPT) -DDATE_STR="'$(DATE)'" \
-DHEXDATE="$(HEXDATE)" \
@@ -228,6 +220,13 @@ ldlinux.bss: ldlinux.bin
ldlinux.sys: ldlinux.bin
dd if=$< of=$@ bs=512 skip=2
+endif # BIOS
+
+$(LIB): $(LIBOBJS)
+ rm -f $@
+ $(AR) cq $@ $^
+ $(RANLIB) $@
+
codepage.cp: $(OBJ)/../codepage/$(CODEPAGE).cp
cp -f $< $@
diff --git a/core/adv.inc b/core/adv.inc
index 288bf03..a18020c 100644
--- a/core/adv.inc
+++ b/core/adv.inc
@@ -13,9 +13,9 @@
;;
;; adv.inc
;;
-;; The auxillary data vector and its routines
+;; The auxiliary data vector and its routines
;;
-;; The auxillary data vector is a 512-byte aligned block that on the
+;; The auxiliary data vector is a 512-byte aligned block that on the
;; disk-based derivatives can be part of the syslinux file itself. It
;; exists in two copies; when written, both copies are written (with a
;; sync in between, if from the operating system.) The first two
diff --git a/core/common.inc b/core/common.inc
index fd75dfe..c42fc56 100644
--- a/core/common.inc
+++ b/core/common.inc
@@ -7,7 +7,7 @@
%include "pm.inc" ; Protected mode
%include "bcopy32.inc" ; 32-bit bcopy
%include "strcpy.inc" ; strcpy()
-%include "adv.inc" ; Auxillary Data Vector
+%include "adv.inc" ; Auxiliary Data Vector
%include "timer.inc" ; Timer handling
; Note: the prefix section is included late, to avoid problems with some
diff --git a/core/diskboot.inc b/core/diskboot.inc
index 9dea6f9..19d6bcf 100644
--- a/core/diskboot.inc
+++ b/core/diskboot.inc
@@ -431,7 +431,7 @@ xint13:
;
bailmsg: db 'Boot error', 0Dh, 0Ah, 0
- ; This fails if the boot sector overflowsg
+ ; This fails if the boot sector overflows
zb 1F8h-($-$$)
bs_magic dd LDLINUX_MAGIC
diff --git a/core/elflink/load_env32.c b/core/elflink/load_env32.c
index 492cc09..db19c7a 100644
--- a/core/elflink/load_env32.c
+++ b/core/elflink/load_env32.c
@@ -55,7 +55,7 @@ void init_module_subsystem(struct elf_module *module)
list_add(&module->list, &modules_head);
}
-__export int start_ldlinux(int argc, char **argv)
+static int _start_ldlinux(int argc, char **argv)
{
int rv;
@@ -96,6 +96,62 @@ again:
return rv;
}
+__export int start_ldlinux(int argc, char **argv)
+{
+ /* These variables are static to survive the longjmp. */
+ static int has_jmpbuf = 0;
+ static jmp_buf restart;
+ static int savedargc;
+ static char *heapargs;
+ static size_t argsmem = 0;
+ char **stackargv;
+ char *stackargs;
+ char *p, *q;
+ int i;
+
+
+ /* 1. Save the arguments on the heap */
+ for (i = 0; i < argc; i++)
+ argsmem += strlen(argv[i]) + 1;
+
+ savedargc = argc;
+ heapargs = malloc(argsmem);
+
+ p = heapargs;
+ for (i = 0; i < savedargc; i++) {
+ q = argv[i];
+ while (*q)
+ *p++ = *q++;
+
+ *p++ = '\0';
+ }
+
+ /* 2. Undo the stack if we're restarting ldlinux */
+ if (has_jmpbuf)
+ longjmp(restart, 1);
+
+ setjmp(restart);
+ has_jmpbuf = 1;
+
+ /* 3. Convert the heap memory to stack memory to avoid memory leaks */
+ stackargs = alloca(argsmem);
+ stackargv = alloca(savedargc * (sizeof(char *) + 1));
+
+ memcpy(stackargs, heapargs, argsmem);
+
+ p = stackargs;
+ for (i = 0; i < savedargc; i++) {
+ stackargv[i] = p;
+ p += strlen(p) + 1;
+ }
+
+ stackargv[savedargc] = NULL;
+
+ free(heapargs);
+
+ return _start_ldlinux(savedargc, stackargv);
+}
+
/* note to self: do _*NOT*_ use static key word on this function */
void load_env32(com32sys_t * regs __unused)
{
diff --git a/core/extern.inc b/core/extern.inc
index af8eb04..f546023 100644
--- a/core/extern.inc
+++ b/core/extern.inc
@@ -12,27 +12,17 @@
; hello.c
extern hello
- ;abort.c
- extern abort_load_new
-
; elflink/load_env32.c
extern load_env32, pm_env32_run
- ; memscan.c
- extern highmem_init
-
- extern linux_kernel
-
extern mp1, mp2, mp3, mp4, mp5
- extern hexdump, mydump
+ extern hexdump
extern mem_init
; fs.c
- extern pm_fs_init, pm_searchdir, getfssec, getfsbytes
- extern pm_mangle_name, pm_load_config
- extern pm_open_file, pm_close_file
+ extern pm_fs_init
extern SectorSize, SectorShift
; chdir.c
@@ -41,9 +31,6 @@
; readdir.c
extern opendir, readdir, closedir
- ; newconfig.c
- extern pm_is_config_file
-
; idle.c
extern __idle
@@ -67,7 +54,7 @@
%if IS_PXELINUX
; pxe.c
- extern unload_pxe, reset_pxe, http_bake_cookies
+ extern unload_pxe, reset_pxe
%endif
; plaincon.c
@@ -91,7 +78,4 @@
; font.c
extern pm_getchar, pm_adjust_screen, pm_userfont
- ; localboot.c
- extern pm_local_boot
-
%endif ; EXTERN_INC
diff --git a/core/fs/btrfs/btrfs.c b/core/fs/btrfs/btrfs.c
index 53e1105..58e1fe6 100644
--- a/core/fs/btrfs/btrfs.c
+++ b/core/fs/btrfs/btrfs.c
@@ -81,7 +81,8 @@ static int btrfs_comp_chunk_map(struct btrfs_chunk_map_item *m1,
}
/* insert a new chunk mapping item */
-static void insert_map(struct fs_info *fs, struct btrfs_chunk_map_item *item)
+static void insert_chunk_item(struct fs_info *fs,
+ struct btrfs_chunk_map_item *item)
{
struct btrfs_info * const bfs = fs->fs_info;
struct btrfs_chunk_map *chunk_map = &bfs->chunk_map;
@@ -113,6 +114,22 @@ static void insert_map(struct fs_info *fs, struct btrfs_chunk_map_item *item)
chunk_map->cur_length++;
}
+static inline void insert_map(struct fs_info *fs, struct btrfs_disk_key *key,
+ struct btrfs_chunk *chunk)
+{
+ struct btrfs_stripe *stripe = &chunk->stripe;
+ struct btrfs_stripe *stripe_end = stripe + chunk->num_stripes;
+ struct btrfs_chunk_map_item item;
+
+ item.logical = key->offset;
+ item.length = chunk->length;
+ for ( ; stripe < stripe_end; stripe++) {
+ item.devid = stripe->devid;
+ item.physical = stripe->offset;
+ insert_chunk_item(fs, &item);
+ }
+}
+
/*
* from sys_chunk_array or chunk_tree, we can convert a logical address to
* a physical address we can not support multi device case yet
@@ -330,7 +347,6 @@ static int next_slot(struct fs_info *fs, struct btrfs_disk_key *key,
static void btrfs_read_sys_chunk_array(struct fs_info *fs)
{
struct btrfs_info * const bfs = fs->fs_info;
- struct btrfs_chunk_map_item item;
struct btrfs_disk_key *key;
struct btrfs_chunk *chunk;
int cur;
@@ -342,12 +358,7 @@ static void btrfs_read_sys_chunk_array(struct fs_info *fs)
cur += sizeof(*key);
chunk = (struct btrfs_chunk *)(bfs->sb.sys_chunk_array + cur);
cur += btrfs_chunk_item_size(chunk->num_stripes);
- /* insert to mapping table, ignore multi stripes */
- item.logical = key->offset;
- item.length = chunk->length;
- item.devid = chunk->stripe.devid;
- item.physical = chunk->stripe.offset;/*ignore other stripes */
- insert_map(fs, &item);
+ insert_map(fs, key, chunk);
}
}
@@ -355,14 +366,18 @@ static void btrfs_read_sys_chunk_array(struct fs_info *fs)
static void btrfs_read_chunk_tree(struct fs_info *fs)
{
struct btrfs_info * const bfs = fs->fs_info;
+ struct btrfs_disk_key ignore_key;
struct btrfs_disk_key search_key;
struct btrfs_chunk *chunk;
- struct btrfs_chunk_map_item item;
struct btrfs_path path;
if (!(bfs->sb.flags & BTRFS_SUPER_FLAG_METADUMP)) {
if (bfs->sb.num_devices > 1)
printf("warning: only support single device btrfs\n");
+
+ ignore_key.objectid = BTRFS_DEV_ITEMS_OBJECTID;
+ ignore_key.type = BTRFS_DEV_ITEM_KEY;
+
/* read chunk from chunk_tree */
search_key.objectid = BTRFS_FIRST_CHUNK_TREE_OBJECTID;
search_key.type = BTRFS_CHUNK_ITEM_KEY;
@@ -371,16 +386,18 @@ static void btrfs_read_chunk_tree(struct fs_info *fs)
search_tree(fs, bfs->sb.chunk_root, &search_key, &path);
do {
do {
+ /* skip information about underlying block
+ * devices.
+ */
+ if (!btrfs_comp_keys_type(&ignore_key,
+ &path.item.key))
+ continue;
if (btrfs_comp_keys_type(&search_key,
- &path.item.key))
+ &path.item.key))
break;
+
chunk = (struct btrfs_chunk *)(path.data);
- /* insert to mapping table, ignore stripes */
- item.logical = path.item.key.offset;
- item.length = chunk->length;
- item.devid = chunk->stripe.devid;
- item.physical = chunk->stripe.offset;
- insert_map(fs, &item);
+ insert_map(fs, &path.item.key, chunk);
} while (!next_slot(fs, &search_key, &path));
if (btrfs_comp_keys_type(&search_key, &path.item.key))
break;
diff --git a/core/fs/btrfs/btrfs.h b/core/fs/btrfs/btrfs.h
index 1568e4d..32e7c70 100644
--- a/core/fs/btrfs/btrfs.h
+++ b/core/fs/btrfs/btrfs.h
@@ -32,7 +32,7 @@ typedef u64 __le64;
#define BTRFS_MAGIC "_BHRfS_M"
#define BTRFS_MAGIC_L 8
-#define BTRFS_MAGIC_N 0x4d5f53665248425f
+#define BTRFS_MAGIC_N 0x4d5f53665248425fULL
#define BTRFS_SUPER_FLAG_METADUMP (1ULL << 33)
@@ -56,6 +56,8 @@ typedef u64 __le64;
#define BTRFS_MAX_LEVEL 8
#define BTRFS_MAX_CHUNK_ENTRIES 256
+#define BTRFS_DEV_ITEMS_OBJECTID 1ULL
+
#define BTRFS_FT_REG_FILE 1
#define BTRFS_FT_DIR 2
#define BTRFS_FT_SYMLINK 7
diff --git a/core/fs/ext2/ext2.c b/core/fs/ext2/ext2.c
index 76bd1d5..4bc0a53 100644
--- a/core/fs/ext2/ext2.c
+++ b/core/fs/ext2/ext2.c
@@ -25,22 +25,17 @@ static enum dirent_type ext2_cvt_type(unsigned int d_file_type)
return inode_type[d_file_type];
}
-/*
- * get the group's descriptor of group_num
- */
-static const struct ext2_group_desc *
-ext2_get_group_desc(struct fs_info *fs, uint32_t group_num)
+static const void *__ext2_get_group_desc(struct fs_info *fs, uint32_t group_num)
{
struct ext2_sb_info *sbi = EXT2_SB(fs);
uint32_t desc_block, desc_index;
- const struct ext2_group_desc *desc_data_block;
+ uint8_t *p;
if (group_num >= sbi->s_groups_count) {
printf ("ext2_get_group_desc"
"block_group >= groups_count - "
"block_group = %d, groups_count = %d",
group_num, sbi->s_groups_count);
-
return NULL;
}
@@ -49,8 +44,17 @@ ext2_get_group_desc(struct fs_info *fs, uint32_t group_num)
desc_block += sbi->s_first_data_block + 1;
- desc_data_block = get_cache(fs->fs_dev, desc_block);
- return &desc_data_block[desc_index];
+ p = get_cache(fs->fs_dev, desc_block);
+ return p + sbi->s_desc_size * desc_index;
+}
+
+/*
+ * get the group's descriptor of group_num
+ */
+static inline const struct ext2_group_desc *
+ext2_get_group_desc(struct fs_info *fs, uint32_t group_num)
+{
+ return __ext2_get_group_desc(fs, group_num);
}
/*
@@ -306,6 +310,7 @@ static int ext2_fs_init(struct fs_info *fs)
if (sb.s_desc_size < sizeof(struct ext2_group_desc))
sb.s_desc_size = sizeof(struct ext2_group_desc);
sbi->s_desc_per_block = BLOCK_SIZE(fs) / sb.s_desc_size;
+ sbi->s_desc_size = sb.s_desc_size;
sbi->s_groups_count = (sb.s_blocks_count - sb.s_first_data_block
+ EXT2_BLOCKS_PER_GROUP(fs) - 1)
/ EXT2_BLOCKS_PER_GROUP(fs);
diff --git a/core/fs/ext2/ext2_fs.h b/core/fs/ext2/ext2_fs.h
index 803a995..d8d07eb 100644
--- a/core/fs/ext2/ext2_fs.h
+++ b/core/fs/ext2/ext2_fs.h
@@ -278,6 +278,7 @@ struct ext2_sb_info {
uint32_t s_first_data_block; /* First Data Block */
int s_inode_size;
uint8_t s_uuid[16]; /* 128-bit uuid for volume */
+ int s_desc_size; /* size of group descriptor */
};
static inline struct ext2_sb_info *EXT2_SB(struct fs_info *fs)
diff --git a/core/fs/fs.c b/core/fs/fs.c
index 0846c88..4161848 100644
--- a/core/fs/fs.c
+++ b/core/fs/fs.c
@@ -331,7 +331,7 @@ err_path:
return file_to_handle(file);
err:
- dprintf("serachdir: error seraching file %s\n", name);
+ dprintf("searchdir: error searching file %s\n", name);
_close_file(file);
err_no_close:
return -1;
diff --git a/core/fs/getfssec.c b/core/fs/getfssec.c
index e099b64..2ea122d 100644
--- a/core/fs/getfssec.c
+++ b/core/fs/getfssec.c
@@ -39,18 +39,23 @@
* will store the initial sector number into inode->next_extent.lstart
* on return.)
*
+ * If inode->next_extent.pstart is EXTENT_ZERO, then no disk I/O is
+ * performed, and the data in the extent is all zero.
+ *
* If inode->next_extent.len != 0 on entry then the routine is allowed
* to assume inode->next_extent contains valid data from the previous
* usage, which can be used for optimization purposes.
*
* If the filesystem can map the entire file as a single extent
* (e.g. iso9660), then the filesystem can simply insert the extent
- * information into inode->next_extent at searchdir/iget time, and leave
- * next_extent() as NULL.
+ * information into inode->next_extent at searchdir/iget time, and point
+ * next_extent() to the generic function no_next_extent().
*
* Note: the filesystem driver is not required to do extent coalescing,
* if that is difficult to do; this routine will perform extent lookahead
- * and coalescing.
+ * and coalescing. However, if the filesystem can do extent coalescing
+ * very cheaply by using filesystem-specific knowledge, then that is
+ * preferred (e.g. FAT).
*/
#include <dprintf.h>
diff --git a/core/fs/lib/loadconfig.c b/core/fs/lib/loadconfig.c
index 95e6f3f..d164ae1 100644
--- a/core/fs/lib/loadconfig.c
+++ b/core/fs/lib/loadconfig.c
@@ -22,6 +22,11 @@ int generic_open_config(struct com32_filedata *filedata)
};
static const char *filenames[] = {
"extlinux.conf",
+#if defined(__FIRMWARE_EFI64__)
+ "syslx64.cfg",
+#elif defined(__FIRMWARE_EFI32__)
+ "syslia32.cfg",
+#endif
"syslinux.cfg",
NULL
};
diff --git a/core/fs/pxe/bios.c b/core/fs/pxe/bios.c
index 6eb3762..ddf9982 100644
--- a/core/fs/pxe/bios.c
+++ b/core/fs/pxe/bios.c
@@ -361,7 +361,7 @@ __export void unload_pxe(uint16_t flags)
api = 0xff00;
if (real_base_mem <= bios_fbm()) { /* Sanity check */
- dprintf("FBM %d < real_base_mem %d\n", bios_fbm(), real_base_mem);
+ dprintf("FBM %d > real_base_mem %d\n", bios_fbm(), real_base_mem);
goto cant_free;
}
api++;
@@ -414,7 +414,7 @@ void net_parse_dhcp(void)
*/
ddprintf("Getting cached packet ");
pkt_len = pxe_get_cached_info(1, bp, dhcp_max_packet);
- parse_dhcp(bp, pkt_len);
+ parse_dhcp(bp, pkt_len, 1);
/*
* We don't use flags from the request packet, so
@@ -432,7 +432,7 @@ void net_parse_dhcp(void)
* address). This lives in the DHCPACK packet (query info 2)
*/
pkt_len = pxe_get_cached_info(2, bp, dhcp_max_packet);
- parse_dhcp(bp, pkt_len);
+ parse_dhcp(bp, pkt_len, 2);
/*
* Save away MAC address (assume this is in query info 2. If this
* turns out to be problematic it might be better getting it from
@@ -447,7 +447,7 @@ void net_parse_dhcp(void)
* packet (query info 3)
*/
pkt_len = pxe_get_cached_info(3, bp, dhcp_max_packet);
- parse_dhcp(bp, pkt_len);
+ parse_dhcp(bp, pkt_len, 3);
ddprintf("\n");
/*
diff --git a/core/fs/pxe/dhcp_option.c b/core/fs/pxe/dhcp_option.c
index 1fdcc70..17f8034 100644
--- a/core/fs/pxe/dhcp_option.c
+++ b/core/fs/pxe/dhcp_option.c
@@ -73,11 +73,11 @@ static void server(const void *data, int opt_len)
return;
if (IPInfo.serverip)
- return;
+ return;
ip = *(uint32_t *)data;
if (ip_ok(ip))
- IPInfo.serverip = ip;
+ IPInfo.serverip = ip;
}
static void client_identifier(const void *data, int opt_len)
@@ -183,7 +183,7 @@ void parse_dhcp_options(const void *option, int size, uint8_t opt_filter)
break;
/* Anything else will have a length field */
- opt_len = *p++; /* c <- option lenght */
+ opt_len = *p++; /* c <- option length */
size -= opt_len + 1;
if (size < 0)
break;
@@ -212,6 +212,8 @@ void parse_dhcp_options(const void *option, int size, uint8_t opt_filter)
* Parse a DHCP packet. This includes dealing with "overloaded"
* option fields (see RFC 2132, section 9.3)
*
+ * pkt_type 1 for Discover, 2 for Ack, 3 for ProxyDHCP, 0 for everything
+ *
* This should fill in the following global variables, if the
* information is present:
*
@@ -225,18 +227,21 @@ void parse_dhcp_options(const void *option, int size, uint8_t opt_filter)
* MAC_len, MAC - Client identifier, if MAC_len == 0
*
*/
-void parse_dhcp(const void *pkt, size_t pkt_len)
+void parse_dhcp(const void *pkt, size_t pkt_len, int pkt_type)
{
const struct bootp_t *dhcp = (const struct bootp_t *)pkt;
int opt_len;
+ int min_opt = 0;
IPInfo.ipver = 4; /* This is IPv4 only for now... */
over_load = 0;
- if (ip_ok(dhcp->yip))
+ if (pkt_type == 1 || pkt_type == 3)
+ min_opt = 43;
+ if ((pkt_type == 2) && ip_ok(dhcp->yip))
IPInfo.myip = dhcp->yip;
- if (ip_ok(dhcp->sip))
+ if (ip_ok(dhcp->sip) || pkt_type == 3)
IPInfo.serverip = dhcp->sip;
opt_len = (char *)dhcp + pkt_len - (char *)&dhcp->options;
diff --git a/core/fs/pxe/dnsresolv.c b/core/fs/pxe/dnsresolv.c
index afb9e21..26c5b34 100644
--- a/core/fs/pxe/dnsresolv.c
+++ b/core/fs/pxe/dnsresolv.c
@@ -88,7 +88,7 @@ static bool parse_dotquad(const char *ip_str, uint32_t *res)
* _ip_ if it exists and can be found. If _ip_ = 0 on exit, the
* lookup failed. _name_ will be updated
*/
-__export uint32_t dns_resolv(const char *name)
+__export uint32_t pxe_dns(const char *name)
{
err_t err;
struct ip_addr ip;
@@ -122,13 +122,3 @@ __export uint32_t dns_resolv(const char *name)
return ip.addr;
}
-
-/*
- * the one should be called from ASM file
- */
-void pm_pxe_dns_resolv(com32sys_t *regs)
-{
- const char *name = MK_PTR(regs->ds, regs->esi.w[0]);
-
- regs->eax.l = dns_resolv(name);
-}
diff --git a/core/fs/pxe/gpxeurl.c b/core/fs/pxe/gpxeurl.c
index 6bbae3c..d030a80 100644
--- a/core/fs/pxe/gpxeurl.c
+++ b/core/fs/pxe/gpxeurl.c
@@ -1,88 +1,10 @@
#include "pxe.h"
#if GPXE
-static void gpxe_close_file(struct inode *inode)
-{
- struct pxe_pvt_inode *socket = PVT(inode);
- static __lowmem struct s_PXENV_FILE_CLOSE file_close;
-
- file_close.FileHandle = socket->tftp_remoteport;
- pxe_call(PXENV_FILE_CLOSE, &file_close);
-}
-
-/**
- * Get a fresh packet from a gPXE socket
- * @param: inode -> Inode pointer
- *
- */
-static void gpxe_get_packet(struct inode *inode)
-{
- struct pxe_pvt_inode *socket = PVT(inode);
- static __lowmem struct s_PXENV_FILE_READ file_read;
- int err;
-
- while (1) {
- file_read.FileHandle = socket->tftp_remoteport;
- file_read.Buffer = FAR_PTR(packet_buf);
- file_read.BufferSize = PKTBUF_SIZE;
- err = pxe_call(PXENV_FILE_READ, &file_read);
- if (!err) /* successed */
- break;
-
- if (file_read.Status != PXENV_STATUS_TFTP_OPEN)
- kaboom();
- }
-
- memcpy(socket->tftp_pktbuf, packet_buf, file_read.BufferSize);
-
- socket->tftp_dataptr = socket->tftp_pktbuf;
- socket->tftp_bytesleft = file_read.BufferSize;
- socket->tftp_filepos += file_read.BufferSize;
-
- if (socket->tftp_bytesleft == 0)
- inode->size = socket->tftp_filepos;
-
- /* if we're done here, close the file */
- if (inode->size > socket->tftp_filepos)
- return;
-
- /* Got EOF, close it */
- socket->tftp_goteof = 1;
- gpxe_close_file(inode);
-}
-
-/**
- * Open a url using gpxe
- *
- * @param:inode, the inode to store our state in
- * @param:url, the url we want to open
- *
- * @out: open_file_t structure, stores in file->open_file
- * @out: the lenght of this file, stores in file->file_len
- *
- */
void gpxe_open(struct inode *inode, const char *url)
{
- static __lowmem struct s_PXENV_FILE_OPEN file_open;
- static char lowurl[2*FILENAME_MAX];
- struct pxe_pvt_inode *socket = PVT(inode);
- int err;
-
- socket->tftp_pktbuf = malloc(PKTBUF_SIZE);
- if (!socket->tftp_pktbuf)
- return;
-
- snprintf(lowurl, sizeof lowurl, "%s", url);
- file_open.Status = PXENV_STATUS_BAD_FUNC;
- file_open.FileName = FAR_PTR(lowurl);
- err = pxe_call(PXENV_FILE_OPEN, &file_open);
- if (err)
- return;
-
- socket->fill_buffer = gpxe_get_packet;
- socket->close = gpxe_close_file;
- socket->tftp_remoteport = file_open.FileHandle;
- inode->size = -1; /* This is not an error */
+ (void)inode;
+ (void)url;
}
#endif /* GPXE */
diff --git a/core/fs/pxe/http.c b/core/fs/pxe/http.c
index 0768c10..f5f49e2 100644
--- a/core/fs/pxe/http.c
+++ b/core/fs/pxe/http.c
@@ -50,7 +50,7 @@ static bool append_ch(char *str, size_t size, size_t *pos, int ch)
static size_t cookie_len, header_len;
static char *cookie_buf, *header_buf;
-__export uint32_t SendCookies = -1UL; /* Send all cookies */
+__export uint32_t SendCookies = UINT_MAX; /* Send all cookies */
static size_t http_do_bake_cookies(char *q)
{
@@ -211,12 +211,25 @@ void http_open(struct url_info *url, int flags, struct inode *inode,
header_bytes += snprintf(header_buf + header_bytes,
header_len - header_bytes,
" HTTP/1.0\r\n"
- "Host: %s\r\n"
+ "Host: %s",
+ url->host);
+ if (header_bytes >= header_len)
+ goto fail; /* Buffer overflow */
+ if (url->port != HTTP_PORT) {
+ header_bytes += snprintf(header_buf + header_bytes,
+ header_len - header_bytes,
+ ":%d", url->port);
+ if (header_bytes >= header_len)
+ goto fail; /* Buffer overflow */
+ }
+ header_bytes += snprintf(header_buf + header_bytes,
+ header_len - header_bytes,
+ "\r\n"
"User-Agent: Syslinux/" VERSION_STR "\r\n"
"Connection: close\r\n"
"%s"
"\r\n",
- url->host, cookie_buf ? cookie_buf : "");
+ cookie_buf ? cookie_buf : "");
if (header_bytes >= header_len)
goto fail; /* Buffer overflow */
diff --git a/core/fs/pxe/pxe.c b/core/fs/pxe/pxe.c
index 5efcd9c..761a171 100644
--- a/core/fs/pxe/pxe.c
+++ b/core/fs/pxe/pxe.c
@@ -237,13 +237,25 @@ static uint32_t pxe_getfssec(struct file *file, char *buf,
/*
* Assign an IP address to a URL
*/
-static void url_set_ip(struct url_info *url)
+__export int url_set_ip(struct url_info *url)
{
+ int err = -ntohs(TFTP_OK);
+
url->ip = 0;
- if (url->host)
- url->ip = dns_resolv(url->host);
- if (!url->ip)
+ if (url->host && url->host[0]) {
+ url->ip = pxe_dns(url->host);
+ if (!url->ip)
+ err = -ntohs(TFTP_ERESOLVE);
+ }
+
+ /* Note: default to the server IP on resolve failure */
+ if (!url->ip) {
url->ip = IPInfo.serverip;
+ if (!url->ip)
+ err = -ntohs(TFTP_NONETWORK);
+ }
+
+ return err;
}
/**
diff --git a/core/fs/pxe/pxe.h b/core/fs/pxe/pxe.h
index 15252ff..19664f9 100644
--- a/core/fs/pxe/pxe.h
+++ b/core/fs/pxe/pxe.h
@@ -232,7 +232,7 @@ void undiif_input(t_PXENV_UNDI_ISR *isr);
/* dhcp_options.c */
void parse_dhcp_options(const void *, int, uint8_t);
-void parse_dhcp(const void *, size_t);
+void parse_dhcp(const void *, size_t, int);
/* idle.c */
void pxe_idle_init(void);
@@ -244,7 +244,11 @@ void tftp_open(struct url_info *url, int flags, struct inode *inode,
/* gpxeurl.c */
void gpxe_open(struct inode *inode, const char *url);
-#define GPXE 0
+#ifdef __FIRMWARE_BIOS__
+# define GPXE 1
+#else
+# define GPXE 0
+#endif
/* http.c */
void http_open(struct url_info *url, int flags, struct inode *inode,
diff --git a/core/fs/pxe/tftp.c b/core/fs/pxe/tftp.c
index 446da63..594152b 100644
--- a/core/fs/pxe/tftp.c
+++ b/core/fs/pxe/tftp.c
@@ -259,7 +259,16 @@ wait_pkt:
} else {
/* Make sure the packet actually came from the server and
is long enough for a TFTP opcode */
- dprintf("tftp_open: got packet buflen=%d\n", buf_len);
+ dprintf("tftp_open: got packet buflen=%d from server %u.%u.%u.%u(%u.%u.%u.%u)\n",
+ buf_len,
+ ((uint8_t *)&src_ip)[0],
+ ((uint8_t *)&src_ip)[1],
+ ((uint8_t *)&src_ip)[2],
+ ((uint8_t *)&src_ip)[3],
+ ((uint8_t *)&url->ip)[0],
+ ((uint8_t *)&url->ip)[1],
+ ((uint8_t *)&url->ip)[2],
+ ((uint8_t *)&url->ip)[3]);
if ((src_ip == url->ip) && (buf_len >= 2))
break;
}
@@ -414,3 +423,173 @@ done:
return;
}
+
+
+/**
+ * Send a file to a TFTP server
+ *
+ * @param:inode, the inode to store our state in
+ * @param:ip, the ip to contact to get the file
+ * @param:filename, the file we wanna push
+ *
+ * @out: open_file_t structure, stores in file->open_file
+ * @out: the lenght of this file, stores in file->file_len
+ *
+ */
+__export int tftp_put(struct url_info *url, int flags, struct inode *inode,
+ const char **redir, char *data, int data_length)
+{
+ struct pxe_pvt_inode *socket = PVT(inode);
+ char *buf;
+ uint16_t buf_len;
+ static const char wrq_tail[] = "octet";
+ char wrq_packet_buf[512+4+6];
+ char reply_packet_buf[PKTBUF_SIZE];
+ int err;
+ int wrq_len;
+ const uint8_t *timeout_ptr;
+ jiffies_t timeout;
+ jiffies_t oldtime;
+ uint16_t opcode;
+ uint16_t src_port = url->port;
+ uint32_t src_ip;
+ uint16_t seq = 0;
+ size_t chunk = 0;
+ int len = data_length;
+ int return_code = -ntohs(TFTP_EUNDEF);
+
+ (void)redir; /* TFTP does not redirect */
+ (void)flags;
+
+ if (url->type != URL_OLD_TFTP) {
+ /*
+ * The TFTP URL specification allows the TFTP to end with a
+ * ;mode= which we just ignore.
+ */
+ url_unescape(url->path, ';');
+ }
+
+ if (!src_port)
+ src_port = TFTP_PORT;
+
+// socket->ops = &tftp_conn_ops;
+ if (core_udp_open(socket))
+ return return_code;
+
+ buf = wrq_packet_buf;
+ *(uint16_t *)buf = TFTP_WRQ; /* TFTP opcode */
+ buf += 2;
+
+ buf += strlcpy(buf, url->path, 512);
+
+ buf++; /* Point *past* the final NULL */
+ memcpy(buf, wrq_tail, sizeof wrq_tail);
+ buf += sizeof wrq_tail;
+
+ wrq_len = buf - wrq_packet_buf;
+
+ timeout_ptr = TimeoutTable; /* Reset timeout */
+sendreq:
+ timeout = *timeout_ptr++;
+ if (!timeout)
+ return return_code; /* No file available... */
+ oldtime = jiffies();
+
+ core_udp_sendto(socket, wrq_packet_buf, wrq_len, url->ip, src_port);
+
+ /* If the WRITE call fails, we let the timeout take care of it... */
+ for (;;) {
+ buf_len = sizeof(reply_packet_buf);
+
+ err = core_udp_recv(socket, reply_packet_buf, &buf_len,
+ &src_ip, &src_port);
+ if (err) {
+ jiffies_t now = jiffies();
+ if (now - oldtime >= timeout)
+ goto sendreq;
+ } else {
+ /* Make sure the packet actually came from the server and
+ is long enough for a TFTP opcode */
+ dprintf("tftp_put: got packet buflen=%d from server %u.%u.%u.%u(%u.%u.%u.%u)\n",
+ buf_len,
+ ((uint8_t *)&src_ip)[0],
+ ((uint8_t *)&src_ip)[1],
+ ((uint8_t *)&src_ip)[2],
+ ((uint8_t *)&src_ip)[3],
+ ((uint8_t *)&url->ip)[0],
+ ((uint8_t *)&url->ip)[1],
+ ((uint8_t *)&url->ip)[2],
+ ((uint8_t *)&url->ip)[3]);
+ if ((src_ip == url->ip) && (buf_len >= 2))
+ break;
+ }
+ }
+
+ core_udp_disconnect(socket);
+ core_udp_connect(socket, src_ip, src_port);
+
+ /* filesize <- -1 == unknown */
+ inode->size = -1;
+ socket->tftp_blksize = TFTP_BLOCKSIZE;
+
+ /*
+ * Get the opcode type, and parse it
+ */
+ opcode = *(uint16_t *)reply_packet_buf;
+ switch (opcode) {
+ case TFTP_ERROR:
+ dprintf("tftp_push: received a TFTP_ERROR\n");
+ struct tftp_error *te = (struct tftp_error *)(reply_packet_buf+1);
+ return_code = -ntohs(te->errcode);
+ inode->size = 0;
+ goto done; /* ERROR reply; don't try again */
+
+ case TFTP_ACK:
+ dprintf("tftp_push: received a TFTP_ACK\n");
+ /* We received a ACK packet, sending the associated data packet */
+
+ /* If data was completly sent, we can stop here */
+ if (len == 0) {
+ return_code = -ntohs(TFTP_OK);
+ goto done;
+ }
+
+ /* If the server sequence is not aligned with our, we have an issue
+ * Let's break the transmission for now but could be improved later */
+ uint16_t srv_seq = ntohs(*(uint16_t *)(reply_packet_buf+2));
+ if (srv_seq != seq) {
+ printf("tftp_push: server sequence (%"PRIu16") is not aligned with our sequence (%"PRIu16"\n", srv_seq, seq);
+ return_code = -ntohs(TFTP_EBADOP);
+ goto done;
+ }
+
+ /* Let's transmit the data block */
+ chunk = len >= 512 ? 512 : len;
+ buf = wrq_packet_buf;
+ *(uint16_t *)buf = TFTP_DATA; /* TFTP opcode */
+ *((uint16_t *)(buf+2)) = htons(++seq);
+ memcpy(buf+4, data, chunk);
+ wrq_len = chunk + 4;
+ data += chunk;
+ len -= chunk;
+ timeout_ptr = TimeoutTable; /* Reset timeout */
+ goto sendreq;
+
+ default:
+ dprintf("tftp_push: unknown opcode %d\n", ntohs(opcode));
+ return_code = -ntohs(TFTP_EOPTNEG);
+ goto err_reply;
+ }
+
+err_reply:
+ /* Build the TFTP error packet */
+ dprintf("tftp_push: Failure\n");
+ tftp_error(inode, TFTP_EOPTNEG, "TFTP protocol error");
+ inode->size = 0;
+
+done:
+ if (!inode->size)
+ core_udp_close(socket);
+
+ return return_code;
+}
diff --git a/core/fs/pxe/tftp.h b/core/fs/pxe/tftp.h
index 114c221..82ef64a 100644
--- a/core/fs/pxe/tftp.h
+++ b/core/fs/pxe/tftp.h
@@ -50,5 +50,18 @@
#define TFTP_EEXISTS htons(6) // File exists
#define TFTP_ENOUSER htons(7) // No such user
#define TFTP_EOPTNEG htons(8) // Option negotiation failure
+#define TFTP_ERESOLVE htons(9) // Not in RFC, internal usage
+#define TFTP_ECONNECT htons(10) // Not in RFC, internal usage
+#define TFTP_OK htons(11) // Not in RFC, internal usage
+#define TFTP_NONETWORK htons(12) // Not in RFC, internal usage
+
+struct tftp_error {
+ uint16_t opcode;
+ uint16_t errcode;
+ char errmsg[0];
+} __attribute__ (( packed ));
+
+int tftp_put(struct url_info *url, int flags, struct inode *inode,
+ const char **redir, char *data, int data_length);
#endif /* PXE_TFTP_H */
diff --git a/core/fs/pxe/url.h b/core/fs/pxe/url.h
index 53984f3..9346200 100644
--- a/core/fs/pxe/url.h
+++ b/core/fs/pxe/url.h
@@ -19,7 +19,7 @@ struct url_info {
char *user;
char *passwd;
char *host;
- uint32_t ip; /* Placeholder field not set by parse_url() */
+ uint32_t ip; /* Not set by parse_url(), use url_set_ip() */
unsigned int port;
char *path; /* Includes query */
enum url_type type;
@@ -29,5 +29,6 @@ enum url_type url_type(const char *url);
void parse_url(struct url_info *ui, char *url);
size_t url_escape_unsafe(char *output, const char *input, size_t bufsize);
char *url_unescape(char *buffer, char terminator);
+int url_set_ip(struct url_info *ui);
#endif /* CORE_PXE_URL_H */
diff --git a/core/fs/pxe/urlparse.c b/core/fs/pxe/urlparse.c
index 6b73ddb..8b604dc 100644
--- a/core/fs/pxe/urlparse.c
+++ b/core/fs/pxe/urlparse.c
@@ -59,7 +59,7 @@ enum url_type url_type(const char *url)
* this routine does not allocate any additional storage. Freeing the
* original buffer frees all storage used.
*/
-void parse_url(struct url_info *ui, char *url)
+__export void parse_url(struct url_info *ui, char *url)
{
char *p = url;
char *q, *r, *s;
diff --git a/core/fs/xfs/xfs.c b/core/fs/xfs/xfs.c
index e42e952..6f45973 100644
--- a/core/fs/xfs/xfs.c
+++ b/core/fs/xfs/xfs.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2012-2013 Paulo Alcantara <pcacjr@zytor.com>
+ * Copyright (c) 2012-2015 Paulo Alcantara <pcacjr@zytor.com>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
@@ -74,10 +74,13 @@ static int xfs_readdir(struct file *file, struct dirent *dirent)
return -1;
}
- if (core->di_format == XFS_DINODE_FMT_LOCAL)
+ switch (core->di_format) {
+ case XFS_DINODE_FMT_LOCAL:
return xfs_fmt_local_readdir(file, dirent, core);
- else if (core->di_format == XFS_DINODE_FMT_EXTENTS)
+ case XFS_DINODE_FMT_EXTENTS:
+ case XFS_DINODE_FMT_BTREE:
return xfs_fmt_extents_readdir(file, dirent, core);
+ }
return -1;
}
@@ -117,8 +120,10 @@ static int xfs_next_extent(struct inode *inode, uint32_t lstart)
goto out;
if (core->di_format == XFS_DINODE_FMT_EXTENTS) {
- bmbt_irec_get(&rec, (xfs_bmbt_rec_t *)&core->di_literal_area[0] +
- XFS_PVT(inode)->i_cur_extent++);
+ bmbt_irec_get(&rec, (xfs_bmbt_rec_t *)XFS_DFORK_PTR(core,
+ XFS_DATA_FORK) +
+ XFS_PVT(inode)->i_cur_extent);
+ XFS_PVT(inode)->i_cur_extent++;
bno = fsblock_to_bytes(fs, rec.br_startblock) >> BLOCK_SHIFT(fs);
@@ -130,7 +135,7 @@ static int xfs_next_extent(struct inode *inode, uint32_t lstart)
} else if (core->di_format == XFS_DINODE_FMT_BTREE) {
xfs_debug("XFS_DINODE_FMT_BTREE");
index = XFS_PVT(inode)->i_cur_extent++;
- rblock = (xfs_bmdr_block_t *)&core->di_literal_area[0];
+ rblock = XFS_DFORK_PTR(core, XFS_DATA_FORK);
fsize = XFS_DFORK_SIZE(core, fs, XFS_DATA_FORK);
pp = XFS_BMDR_PTR_ADDR(rblock, 1, xfs_bmdr_maxrecs(fsize, 0));
bno = fsblock_to_bytes(fs, be64_to_cpu(pp[0])) >> BLOCK_SHIFT(fs);
@@ -278,9 +283,9 @@ static int xfs_readlink(struct inode *inode, char *buf)
}
if (core->di_format == XFS_DINODE_FMT_LOCAL) {
- memcpy(buf, (char *)&core->di_literal_area[0], pathlen);
+ memcpy(buf, XFS_DFORK_PTR(core, XFS_DATA_FORK), pathlen);
} else if (core->di_format == XFS_DINODE_FMT_EXTENTS) {
- bmbt_irec_get(&rec, (xfs_bmbt_rec_t *)&core->di_literal_area[0]);
+ bmbt_irec_get(&rec, XFS_DFORK_PTR(core, XFS_DATA_FORK));
db = fsblock_to_bytes(fs, rec.br_startblock) >> BLOCK_SHIFT(fs);
dir_buf = xfs_dir2_dirblks_get_cached(fs, db, rec.br_blockcount);
@@ -331,7 +336,7 @@ out:
return NULL;
}
-static inline int xfs_read_superblock(struct fs_info *fs, xfs_sb_t *sb)
+static inline int xfs_read_sb(struct fs_info *fs, xfs_sb_t *sb)
{
struct disk *disk = fs->fs_dev->disk;
@@ -376,24 +381,21 @@ static int xfs_fs_init(struct fs_info *fs)
SECTOR_SHIFT(fs) = disk->sector_shift;
SECTOR_SIZE(fs) = 1 << SECTOR_SHIFT(fs);
- if (xfs_read_superblock(fs, &sb)) {
+ if (xfs_read_sb(fs, &sb)) {
xfs_error("Superblock read failed");
goto out;
}
-
- if (!xfs_is_valid_magicnum(&sb)) {
+ if (!xfs_is_valid_sb(&sb)) {
xfs_error("Invalid superblock");
goto out;
}
-
- xfs_debug("magicnum 0x%lX", be32_to_cpu(sb.sb_magicnum));
+ xfs_debug("sb magic: 0x%lX", be32_to_cpu(sb.sb_magicnum));
info = xfs_new_sb_info(&sb);
if (!info) {
xfs_error("Failed to fill in filesystem-specific info structure");
goto out;
}
-
fs->fs_info = info;
xfs_debug("block_shift %u blocksize 0x%lX (%lu)", info->block_shift,
diff --git a/core/fs/xfs/xfs.h b/core/fs/xfs/xfs.h
index 0d953d8..65acd17 100644
--- a/core/fs/xfs/xfs.h
+++ b/core/fs/xfs/xfs.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2012-2013 Paulo Alcantara <pcacjr@zytor.com>
+ * Copyright (c) 2012-2015 Paulo Alcantara <pcacjr@zytor.com>
*
* Some parts borrowed from Linux kernel tree (linux/fs/xfs):
*
@@ -30,15 +30,16 @@
#include "xfs_types.h"
#include "xfs_ag.h"
-#define xfs_error(fmt, args...) \
- ({ \
- printf("%s:%u: xfs - [ERROR] " fmt "\n", __func__, __LINE__, ## args); \
+#define xfs_error(fmt, args...) \
+ ({ \
+ dprintf("%s:%u: xfs - [error] " fmt "\n", __func__, __LINE__, \
+ ## args); \
})
-#define xfs_debug(fmt, args...) \
- ({ \
- dprintf("%s:%u: xfs - [DEBUG] " fmt "\n", __func__, __LINE__, \
- ## args); \
+#define xfs_debug(fmt, args...) \
+ ({ \
+ dprintf("%s:%u: xfs - [debug] " fmt "\n", __func__, __LINE__, \
+ ## args); \
})
struct xfs_fs_info;
@@ -115,6 +116,9 @@ struct xfs_fs_info;
#define XFS_DIR2_NULL_DATAPTR ((uint32_t)0)
+#define XFS_DIR3_BLOCK_MAGIC 0x58444233 /* XDB3: single block dirs */
+#define XFS_DIR3_DATA_MAGIC 0x58444433 /* XDD3: multiblock dirs */
+
/* File types and modes */
#define S_IFMT 00170000
#define S_IFSOCK 0140000
@@ -345,8 +349,19 @@ typedef struct xfs_dinode {
/* di_next_unlinked is the only non-core field in the old dinode */
uint32_t di_next_unlinked;/* agi unlinked list ptr */
- uint8_t di_literal_area[1];
-} __attribute__((packed)) xfs_dinode_t;
+
+ /* start of the extended dinode, writable fields */
+ uint32_t di_crc; /* CRC of the inode */
+ uint64_t di_changecount; /* number of attribute changes */
+ uint64_t di_lsn; /* flush sequence */
+ uint64_t di_flags2; /* more random flags */
+ uint8_t di_pad2[16];
+
+ /* fields only written to during inode creation */
+ xfs_timestamp_t di_crtime; /* time created */
+ uint64_t di_ino; /* inode number */
+ uuid_t di_uuid; /* UUID of the filesystem */
+} __attribute__((__packed__)) xfs_dinode_t;
/*
* Inode size for given fs.
@@ -358,23 +373,41 @@ typedef struct xfs_dinode {
(XFS_BTREE_LBLOCK_LEN - sizeof(xfs_bmdr_block_t))
/*
+ * Size of the core inode on disk. Version 1 and 2 inodes have
+ * the same size, but version 3 has grown a few additional fields.
+ */
+static inline unsigned int xfs_dinode_size(int version)
+{
+ if (version == 3)
+ return sizeof(struct xfs_dinode);
+ return offsetof(struct xfs_dinode, di_crc);
+}
+
+/*
* Inode data & attribute fork sizes, per inode.
*/
#define XFS_DFORK_Q(dip) ((dip)->di_forkoff != 0)
#define XFS_DFORK_BOFF(dip) ((int)((dip)->di_forkoff << 3))
-#define XFS_DFORK_DSIZE(dip, fs) \
- (XFS_DFORK_Q(dip) ? \
- XFS_DFORK_BOFF(dip) : \
- XFS_LITINO(fs))
-#define XFS_DFORK_ASIZE(dip, fs) \
- (XFS_DFORK_Q(dip) ? \
- XFS_LITINO(fs) - XFS_DFORK_BOFF(dip) : \
- 0)
-#define XFS_DFORK_SIZE(dip, fs, w) \
- ((w) == XFS_DATA_FORK ? \
- XFS_DFORK_DSIZE(dip, fs) : \
- XFS_DFORK_ASIZE(dip, fs))
+#define XFS_DFORK_DSIZE(dip, fs) \
+ (XFS_DFORK_Q(dip) ? \
+ XFS_DFORK_BOFF(dip) : \
+ XFS_LITINO(fs))
+#define XFS_DFORK_ASIZE(dip, fs) \
+ (XFS_DFORK_Q(dip) ? \
+ XFS_LITINO(fs) - XFS_DFORK_BOFF(dip) : \
+ 0)
+#define XFS_DFORK_SIZE(dip, fs, w) \
+ ((w) == XFS_DATA_FORK ? \
+ XFS_DFORK_DSIZE(dip, fs) : \
+ XFS_DFORK_ASIZE(dip, fs))
+
+#define XFS_DFORK_DPTR(dip) \
+ ((void *)((uint8_t *)dip + xfs_dinode_size(dip->di_version)))
+#define XFS_DFORK_APTR(dip) \
+ ((void *)((uint8_t *)XFS_DFORK_DPTR(dip) + XFS_DFORK_BOFF(dip)))
+#define XFS_DFORK_PTR(dip,w) \
+ ((w) == XFS_DATA_FORK ? XFS_DFORK_DPTR(dip) : XFS_DFORK_APTR(dip))
struct xfs_inode {
xfs_agblock_t i_agblock;
@@ -405,13 +438,12 @@ typedef struct xfs_dir2_sf_hdr {
typedef struct xfs_dir2_sf_entry {
uint8_t namelen; /* actual name length */
xfs_dir2_sf_off_t offset; /* saved offset */
- uint8_t name[1]; /* name, variable size */
- xfs_dir2_inou_t inumber; /* inode number, var. offset */
+ uint8_t name[]; /* name, variable size */
} __attribute__((__packed__)) xfs_dir2_sf_entry_t;
typedef struct xfs_dir2_sf {
- xfs_dir2_sf_hdr_t hdr; /* shortform header */
- xfs_dir2_sf_entry_t list[1]; /* shortform entries */
+ xfs_dir2_sf_hdr_t hdr; /* shortform header */
+ xfs_dir2_sf_entry_t list[]; /* shortform entries */
} __attribute__((__packed__)) xfs_dir2_sf_t;
typedef xfs_ino_t xfs_intino_t;
@@ -482,6 +514,21 @@ typedef struct xfs_dir2_data_unused {
/* uint16_t tag; */ /* starting offset of us */
} __attribute__((__packed__)) xfs_dir2_data_unused_t;
+struct xfs_dir3_blk_hdr {
+ uint32_t magic; /* magic number */
+ uint32_t crc; /* CRC of block */
+ uint64_t blkno; /* first block of the buffer */
+ uint64_t lsn; /* sequence number of last write */
+ uuid_t uuid; /* filesystem we belong to */
+ uint64_t owner; /* inode that owns the block */
+} __attribute__((__packed__));
+
+struct xfs_dir3_data_hdr {
+ struct xfs_dir3_blk_hdr hdr;
+ xfs_dir2_data_free_t best_free[XFS_DIR2_DATA_FD_COUNT];
+ uint32_t pad; /* 64 bit alignment */
+} __attribute__((__packed__));
+
/**
* rol32 - rotate a 32-bit value left
* @word: value to rotate
@@ -501,10 +548,17 @@ static inline uint32_t rol32(uint32_t word, signed int shift)
static inline int xfs_dir2_data_entsize(int n)
{
- return (int)roundup(offsetof(struct xfs_dir2_data_entry, name[0]) + n +
+ return (int)roundup(offsetof(struct xfs_dir2_data_entry, name[0]) + n +
(unsigned int)sizeof(uint16_t), XFS_DIR2_DATA_ALIGN);
}
+static inline int xfs_dir3_data_entsize(int n)
+{
+ return (int)roundup(offsetof(struct xfs_dir2_data_entry, name[0]) + n +
+ (unsigned int)sizeof(uint16_t) + sizeof(uint8_t),
+ XFS_DIR2_DATA_ALIGN);
+}
+
static inline uint16_t *
xfs_dir2_data_entry_tag_p(struct xfs_dir2_data_entry *dep)
{
@@ -597,27 +651,69 @@ typedef struct xfs_dir2_leaf {
xfs_dir2_leaf_entry_t ents[]; /* entries */
} __attribute__((__packed__)) xfs_dir2_leaf_t;
+typedef struct xfs_da3_blkinfo {
+ /*
+ * the node link manipulation code relies on the fact that the first
+ * element of this structure is the struct xfs_da_blkinfo so it can
+ * ignore the differences in the rest of the structures.
+ */
+ xfs_da_blkinfo_t hdr;
+ uint32_t crc; /* CRC of block */
+ uint64_t blkno; /* first block of the buffer */
+ uint64_t lsn; /* sequence number of last write */
+ uuid_t uuid; /* filesystem we belong to */
+ uint64_t owner; /* inode that owns the block */
+} __attribute__((__packed__)) xfs_da3_blkinfo_t;
+
+typedef struct xfs_dir3_leaf_hdr {
+ xfs_da3_blkinfo_t info; /* header for da routines */
+ uint16_t count; /* count of entries */
+ uint16_t stale; /* count of stale entries */
+ uint32_t pad; /* 64 bit alignment */
+} __attribute__((__packed__)) xfs_dir3_leaf_hdr_t;
+
+typedef struct xfs_dir3_leaf {
+ xfs_dir3_leaf_hdr_t hdr; /* leaf header */
+ xfs_dir2_leaf_entry_t ents[]; /* entries */
+} __attribute__((__packed__)) xfs_dir3_leaf_t;
+
#define XFS_DA_NODE_MAGIC 0xfebeU /* magic number: non-leaf blocks */
#define XFS_ATTR_LEAF_MAGIC 0xfbeeU /* magic number: attribute leaf blks */
#define XFS_DIR2_LEAF1_MAGIC 0xd2f1U /* magic number: v2 dirlf single blks */
#define XFS_DIR2_LEAFN_MAGIC 0xd2ffU /* magic number: V2 dirlf multi blks */
+#define XFS_DA3_NODE_MAGIC 0x3ebe /* magic number: non-leaf blocks */
+#define XFS_ATTR3_LEAF_MAGIC 0x3bee /* magic number: attribute leaf blks */
+#define XFS_DIR3_LEAF1_MAGIC 0x3df1 /* magic number: v2 dirlf single blks */
+#define XFS_DIR3_LEAFN_MAGIC 0x3dff /* magic number: v2 dirlf multi blks */
+
+#define XFS_DIR3_LEAF1_MAGIC 0x3df1 /* magic number: v2 dirlf single blks */
+#define XFS_DIR3_LEAFN_MAGIC 0x3dff /* magic number: v2 dirlf multi blks */
+
+typedef struct xfs_da_node_hdr {
+ xfs_da_blkinfo_t info; /* block type, links, etc. */
+ uint16_t count; /* count of active entries */
+ uint16_t level; /* level above leaves (leaf == 0) */
+} __attribute__((__packed__)) xfs_da_node_hdr_t;
+
+typedef struct xfs_da_node_entry {
+ uint32_t hashval; /* hash value for this descendant */
+ uint32_t before; /* Btree block before this key */
+} __attribute__((__packed__)) xfs_da_node_entry_t;
+
typedef struct xfs_da_intnode {
- struct xfs_da_node_hdr { /* constant-structure header block */
- xfs_da_blkinfo_t info; /* block type, links, etc. */
- uint16_t count; /* count of active entries */
- uint16_t level; /* level above leaves (leaf == 0) */
- } hdr;
- struct xfs_da_node_entry {
- uint32_t hashval; /* hash value for this descendant */
- uint32_t before; /* Btree block before this key */
- } btree[1];
+ xfs_da_node_hdr_t hdr;
+ xfs_da_node_entry_t btree[];
} __attribute__((__packed__)) xfs_da_intnode_t;
-typedef struct xfs_da_node_hdr xfs_da_node_hdr_t;
-typedef struct xfs_da_node_entry xfs_da_node_entry_t;
+typedef struct xfs_da3_node_hdr {
+ xfs_da3_blkinfo_t info; /* block type, links, etc. */
+ uint16_t count; /* count of active entries */
+ uint16_t level; /* level above leaves (leaf == 0) */
+ uint32_t pad32;
+} __attribute__((__packed__)) xfs_da3_node_hdr_t;
-static inline bool xfs_is_valid_magicnum(const xfs_sb_t *sb)
+static inline bool xfs_is_valid_sb(const xfs_sb_t *sb)
{
return sb->sb_magicnum == *(uint32_t *)XFS_SB_MAGIC;
}
diff --git a/core/fs/xfs/xfs_dinode.c b/core/fs/xfs/xfs_dinode.c
index 55be6e2..dff7382 100644
--- a/core/fs/xfs/xfs_dinode.c
+++ b/core/fs/xfs/xfs_dinode.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2012-2013 Paulo Alcantara <pcacjr@zytor.com>
+ * Copyright (c) 2012-2015 Paulo Alcantara <pcacjr@zytor.com>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
diff --git a/core/fs/xfs/xfs_dir2.c b/core/fs/xfs/xfs_dir2.c
index de37ef7..2f5928a 100644
--- a/core/fs/xfs/xfs_dir2.c
+++ b/core/fs/xfs/xfs_dir2.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2012-2013 Paulo Alcantara <pcacjr@zytor.com>
+ * Copyright (c) 2012-2015 Paulo Alcantara <pcacjr@zytor.com>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
@@ -67,30 +67,29 @@ uint32_t xfs_dir2_da_hashname(const uint8_t *name, int namelen)
}
static void *get_dirblks(struct fs_info *fs, block_t startblock,
- xfs_filblks_t c)
+ xfs_filblks_t c)
{
- int count = c << XFS_INFO(fs)->dirblklog;
- uint8_t *p;
- uint8_t *buf;
- off_t offset = 0;
+ const size_t len = c * XFS_INFO(fs)->dirblksize;
+ uint64_t offs = startblock << BLOCK_SHIFT(fs);
+ void *buf;
+ size_t ret;
- buf = malloc(c * XFS_INFO(fs)->dirblksize);
+ buf = malloc(len);
if (!buf)
malloc_error("buffer memory");
+ memset(buf, 0, len);
- memset(buf, 0, XFS_INFO(fs)->dirblksize);
-
- while (count--) {
- p = (uint8_t *)get_cache(fs->fs_dev, startblock++);
- memcpy(buf + offset, p, BLOCK_SIZE(fs));
- offset += BLOCK_SIZE(fs);
+ ret = cache_read(fs, buf, offs, len);
+ if (ret != len) {
+ xfs_error("failed to read contiguous directory blocks\n");
+ free(buf);
+ return NULL;
}
-
return buf;
}
-const void *xfs_dir2_dirblks_get_cached(struct fs_info *fs, block_t startblock,
- xfs_filblks_t c)
+void *xfs_dir2_dirblks_get_cached(struct fs_info *fs, block_t startblock,
+ xfs_filblks_t c)
{
unsigned char i;
void *buf;
@@ -100,6 +99,8 @@ const void *xfs_dir2_dirblks_get_cached(struct fs_info *fs, block_t startblock,
if (!dirblks_cached_count) {
buf = get_dirblks(fs, startblock, c);
+ if (!buf)
+ return NULL;
dirblks_cache[dirblks_cached_count].dc_startblock = startblock;
dirblks_cache[dirblks_cached_count].dc_blkscount = c;
@@ -116,6 +117,8 @@ const void *xfs_dir2_dirblks_get_cached(struct fs_info *fs, block_t startblock,
}
buf = get_dirblks(fs, startblock, c);
+ if (!buf)
+ return NULL;
dirblks_cache[XFS_DIR2_DIRBLKS_CACHE_SIZE / 2].dc_startblock =
startblock;
@@ -144,6 +147,8 @@ const void *xfs_dir2_dirblks_get_cached(struct fs_info *fs, block_t startblock,
}
buf = get_dirblks(fs, startblock, c);
+ if (!buf)
+ return NULL;
dirblks_cache[dirblks_cached_count].dc_startblock = startblock;
dirblks_cache[dirblks_cached_count].dc_blkscount = c;
@@ -152,7 +157,6 @@ const void *xfs_dir2_dirblks_get_cached(struct fs_info *fs, block_t startblock,
return dirblks_cache[dirblks_cached_count++].dc_area;
}
}
-
return NULL;
}
@@ -171,23 +175,27 @@ void xfs_dir2_dirblks_flush_cache(void)
struct inode *xfs_dir2_local_find_entry(const char *dname, struct inode *parent,
xfs_dinode_t *core)
{
- xfs_dir2_sf_t *sf = (xfs_dir2_sf_t *)&core->di_literal_area[0];
+ xfs_dir2_sf_t *sf = XFS_DFORK_PTR(core, XFS_DATA_FORK);
xfs_dir2_sf_entry_t *sf_entry;
+ uint8_t ftypelen = core->di_version == 3 ? 1 : 0;
uint8_t count = sf->hdr.i8count ? sf->hdr.i8count : sf->hdr.count;
struct fs_info *fs = parent->fs;
struct inode *inode;
+ xfs_dir2_inou_t *inou;
xfs_intino_t ino;
xfs_dinode_t *ncore = NULL;
xfs_debug("dname %s parent %p core %p", dname, parent, core);
xfs_debug("count %hhu i8count %hhu", sf->hdr.count, sf->hdr.i8count);
- sf_entry = (xfs_dir2_sf_entry_t *)((uint8_t *)&sf->list[0] -
+ sf_entry = (xfs_dir2_sf_entry_t *)((uint8_t *)sf->list -
(!sf->hdr.i8count ? 4 : 0));
while (count--) {
- uint8_t *start_name = &sf_entry->name[0];
+ uint8_t *start_name = sf_entry->name;
uint8_t *end_name = start_name + sf_entry->namelen;
+ xfs_debug("namelen %u", sf_entry->namelen);
+
if (!xfs_dir2_entry_name_cmp(start_name, end_name, dname)) {
xfs_debug("Found entry %s", dname);
goto found;
@@ -195,8 +203,9 @@ struct inode *xfs_dir2_local_find_entry(const char *dname, struct inode *parent,
sf_entry = (xfs_dir2_sf_entry_t *)((uint8_t *)sf_entry +
offsetof(struct xfs_dir2_sf_entry,
- name[0]) +
+ name) +
sf_entry->namelen +
+ ftypelen +
(sf->hdr.i8count ? 8 : 4));
}
@@ -205,11 +214,12 @@ struct inode *xfs_dir2_local_find_entry(const char *dname, struct inode *parent,
found:
inode = xfs_new_inode(fs);
- ino = xfs_dir2_sf_get_inumber(sf, (xfs_dir2_inou_t *)(
- (uint8_t *)sf_entry +
- offsetof(struct xfs_dir2_sf_entry,
- name[0]) +
- sf_entry->namelen));
+ inou = (xfs_dir2_inou_t *)((uint8_t *)sf_entry +
+ offsetof(struct xfs_dir2_sf_entry,
+ name) +
+ sf_entry->namelen +
+ ftypelen);
+ ino = xfs_dir2_sf_get_inumber(sf, inou);
xfs_debug("entry inode's number %lu", ino);
@@ -251,6 +261,7 @@ struct inode *xfs_dir2_block_find_entry(const char *dname, struct inode *parent,
block_t dir_blk;
struct fs_info *fs = parent->fs;
const uint8_t *dirblk_buf;
+ bool isdir3;
uint8_t *p, *endp;
xfs_dir2_data_hdr_t *hdr;
struct inode *inode = NULL;
@@ -262,18 +273,26 @@ struct inode *xfs_dir2_block_find_entry(const char *dname, struct inode *parent,
xfs_debug("dname %s parent %p core %p", dname, parent, core);
- bmbt_irec_get(&r, (xfs_bmbt_rec_t *)&core->di_literal_area[0]);
+ bmbt_irec_get(&r, XFS_DFORK_PTR(core, XFS_DATA_FORK));
dir_blk = fsblock_to_bytes(fs, r.br_startblock) >> BLOCK_SHIFT(fs);
dirblk_buf = xfs_dir2_dirblks_get_cached(fs, dir_blk, r.br_blockcount);
+ if (!dirblk_buf)
+ return NULL;
+
hdr = (xfs_dir2_data_hdr_t *)dirblk_buf;
- if (be32_to_cpu(hdr->magic) != XFS_DIR2_BLOCK_MAGIC) {
+ if (be32_to_cpu(hdr->magic) == XFS_DIR2_BLOCK_MAGIC) {
+ isdir3 = false;
+ } else if (be32_to_cpu(hdr->magic) == XFS_DIR3_BLOCK_MAGIC) {
+ isdir3 = true;
+ } else {
xfs_error("Block directory header's magic number does not match!");
xfs_debug("hdr->magic: 0x%lx", be32_to_cpu(hdr->magic));
goto out;
}
- p = (uint8_t *)(hdr + 1);
+ p = (uint8_t *)dirblk_buf + (isdir3 ? sizeof(struct xfs_dir3_data_hdr) :
+ sizeof(struct xfs_dir2_data_hdr));
btp = xfs_dir2_block_tail_p(XFS_INFO(fs), hdr);
endp = (uint8_t *)((xfs_dir2_leaf_entry_t *)btp - be32_to_cpu(btp->count));
@@ -290,7 +309,7 @@ struct inode *xfs_dir2_block_find_entry(const char *dname, struct inode *parent,
dep = (xfs_dir2_data_entry_t *)p;
- start_name = &dep->name[0];
+ start_name = dep->name;
end_name = start_name + dep->namelen;
if (!xfs_dir2_entry_name_cmp(start_name, end_name, dname)) {
@@ -298,7 +317,8 @@ struct inode *xfs_dir2_block_find_entry(const char *dname, struct inode *parent,
goto found;
}
- p += xfs_dir2_data_entsize(dep->namelen);
+ p += (isdir3 ? xfs_dir3_data_entsize(dep->namelen) :
+ xfs_dir2_data_entsize(dep->namelen));
}
out:
@@ -348,7 +368,9 @@ failed:
struct inode *xfs_dir2_leaf_find_entry(const char *dname, struct inode *parent,
xfs_dinode_t *core)
{
- xfs_dir2_leaf_t *leaf;
+ xfs_dir2_leaf_hdr_t *hdr;
+ xfs_dir2_leaf_entry_t *ents;
+ uint16_t count;
xfs_bmbt_irec_t irec;
block_t leaf_blk, dir_blk;
xfs_dir2_leaf_entry_t *lep;
@@ -358,37 +380,47 @@ struct inode *xfs_dir2_leaf_find_entry(const char *dname, struct inode *parent,
uint32_t hash = 0;
uint32_t hashwant;
uint32_t newdb, curdb = -1;
- xfs_dir2_data_entry_t *dep;
+ xfs_dir2_data_entry_t *dep = NULL;
struct inode *ip;
xfs_dir2_data_hdr_t *data_hdr;
uint8_t *start_name;
uint8_t *end_name;
xfs_intino_t ino;
xfs_dinode_t *ncore;
- const uint8_t *buf = NULL;
+ uint8_t *buf = NULL;
xfs_debug("dname %s parent %p core %p", dname, parent, core);
- bmbt_irec_get(&irec, ((xfs_bmbt_rec_t *)&core->di_literal_area[0]) +
+ bmbt_irec_get(&irec, (xfs_bmbt_rec_t *)XFS_DFORK_PTR(core, XFS_DATA_FORK) +
be32_to_cpu(core->di_nextents) - 1);
leaf_blk = fsblock_to_bytes(parent->fs, irec.br_startblock) >>
BLOCK_SHIFT(parent->fs);
- leaf = (xfs_dir2_leaf_t *)xfs_dir2_dirblks_get_cached(parent->fs, leaf_blk,
- irec.br_blockcount);
- if (be16_to_cpu(leaf->hdr.info.magic) != XFS_DIR2_LEAF1_MAGIC) {
+ hdr = xfs_dir2_dirblks_get_cached(parent->fs, leaf_blk,
+ irec.br_blockcount);
+ if (!hdr)
+ return NULL;
+
+ if (be16_to_cpu(hdr->info.magic) == XFS_DIR2_LEAF1_MAGIC) {
+ count = be16_to_cpu(hdr->count);
+ ents = (xfs_dir2_leaf_entry_t *)((uint8_t *)hdr +
+ sizeof(struct xfs_dir2_leaf_hdr));
+ } else if (be16_to_cpu(hdr->info.magic) == XFS_DIR3_LEAF1_MAGIC) {
+ count = be16_to_cpu(((xfs_dir3_leaf_hdr_t *)hdr)->count);
+ ents = (xfs_dir2_leaf_entry_t *)((uint8_t *)hdr +
+ sizeof(struct xfs_dir3_leaf_hdr));
+ } else {
xfs_error("Single leaf block header's magic number does not match!");
goto out;
}
- if (!leaf->hdr.count)
+ if (!count)
goto out;
hashwant = xfs_dir2_da_hashname((uint8_t *)dname, strlen(dname));
/* Binary search */
- for (lep = leaf->ents, low = 0, high = be16_to_cpu(leaf->hdr.count) - 1;
- low <= high; ) {
+ for (lep = ents, low = 0, high = count - 1; low <= high; ) {
mid = (low + high) >> 1;
if ((hash = be32_to_cpu(lep[mid].hashval)) == hashwant)
break;
@@ -407,10 +439,8 @@ struct inode *xfs_dir2_leaf_find_entry(const char *dname, struct inode *parent,
while (mid > 0 && be32_to_cpu(lep[mid - 1].hashval) == hashwant)
mid--;
- for (lep = &leaf->ents[mid];
- mid < be16_to_cpu(leaf->hdr.count) &&
- be32_to_cpu(lep->hashval) == hashwant;
- lep++, mid++) {
+ for (lep = &ents[mid];
+ mid < count && be32_to_cpu(lep->hashval) == hashwant; lep++, mid++) {
/* Skip over stale leaf entries. */
if (be32_to_cpu(lep->address) == XFS_DIR2_NULL_DATAPTR)
continue;
@@ -418,13 +448,17 @@ struct inode *xfs_dir2_leaf_find_entry(const char *dname, struct inode *parent,
newdb = xfs_dir2_dataptr_to_db(parent->fs, be32_to_cpu(lep->address));
if (newdb != curdb) {
bmbt_irec_get(&irec,
- ((xfs_bmbt_rec_t *)&core->di_literal_area[0]) + newdb);
+ (xfs_bmbt_rec_t *)XFS_DFORK_PTR(core,
+ XFS_DATA_FORK) +
+ newdb);
dir_blk = fsblock_to_bytes(parent->fs, irec.br_startblock) >>
BLOCK_SHIFT(parent->fs);
- buf = xfs_dir2_dirblks_get_cached(parent->fs, dir_blk, irec.br_blockcount);
+ buf = xfs_dir2_dirblks_get_cached(parent->fs, dir_blk,
+ irec.br_blockcount);
data_hdr = (xfs_dir2_data_hdr_t *)buf;
- if (be32_to_cpu(data_hdr->magic) != XFS_DIR2_DATA_MAGIC) {
+ if (be32_to_cpu(data_hdr->magic) != XFS_DIR2_DATA_MAGIC &&
+ be32_to_cpu(data_hdr->magic) != XFS_DIR3_DATA_MAGIC) {
xfs_error("Leaf directory's data magic No. does not match!");
goto out;
}
@@ -432,10 +466,10 @@ struct inode *xfs_dir2_leaf_find_entry(const char *dname, struct inode *parent,
curdb = newdb;
}
- dep = (xfs_dir2_data_entry_t *)((char *)buf +
- xfs_dir2_dataptr_to_off(parent->fs, be32_to_cpu(lep->address)));
-
- start_name = &dep->name[0];
+ dep = (xfs_dir2_data_entry_t *)(
+ buf + xfs_dir2_dataptr_to_off(parent->fs,
+ be32_to_cpu(lep->address)));
+ start_name = dep->name;
end_name = start_name + dep->namelen;
if (!xfs_dir2_entry_name_cmp(start_name, end_name, dname)) {
@@ -523,7 +557,7 @@ block_t xfs_dir2_get_right_blk(struct fs_info *fs, xfs_dinode_t *core,
int nextents;
xfs_bmbt_ptr_t *pp;
xfs_bmbt_key_t *kp;
- xfs_btree_block_t *blk;
+ const xfs_btree_block_t *blk;
xfs_bmbt_rec_t *xp;
*error = 0;
@@ -531,7 +565,8 @@ block_t xfs_dir2_get_right_blk(struct fs_info *fs, xfs_dinode_t *core,
xfs_debug("XFS_DINODE_FMT_EXTENTS");
for (idx = 0; idx < be32_to_cpu(core->di_nextents); idx++) {
bmbt_irec_get(&irec,
- ((xfs_bmbt_rec_t *)&core->di_literal_area[0]) + idx);
+ (xfs_bmbt_rec_t *)
+ XFS_DFORK_PTR(core, XFS_DATA_FORK) + idx);
if (fsblkno >= irec.br_startoff &&
fsblkno < irec.br_startoff + irec.br_blockcount)
break;
@@ -539,7 +574,7 @@ block_t xfs_dir2_get_right_blk(struct fs_info *fs, xfs_dinode_t *core,
} else if (core->di_format == XFS_DINODE_FMT_BTREE) {
xfs_debug("XFS_DINODE_FMT_BTREE");
bno = NULLFSBLOCK;
- rblock = (xfs_bmdr_block_t *)&core->di_literal_area[0];
+ rblock = XFS_DFORK_PTR(core, XFS_DATA_FORK);
fsize = XFS_DFORK_SIZE(core, fs, XFS_DATA_FORK);
pp = XFS_BMDR_PTR_ADDR(rblock, 1, xfs_bmdr_maxrecs(fsize, 0));
kp = XFS_BMDR_KEY_ADDR(rblock, 1);
@@ -549,7 +584,7 @@ block_t xfs_dir2_get_right_blk(struct fs_info *fs, xfs_dinode_t *core,
/* Find the leaf */
for (;;) {
- blk = (xfs_btree_block_t *)get_cache(fs->fs_dev, bno);
+ blk = get_cache(fs->fs_dev, bno);
if (be16_to_cpu(blk->bb_level) == 0)
break;
pp = XFS_BMBT_PTR_ADDR(fs, blk, 1,
@@ -576,7 +611,7 @@ block_t xfs_dir2_get_right_blk(struct fs_info *fs, xfs_dinode_t *core,
if (nextbno == NULLFSBLOCK)
break;
bno = fsblock_to_bytes(fs, nextbno) >> BLOCK_SHIFT(fs);
- blk = (xfs_btree_block_t *)get_cache(fs->fs_dev, bno);
+ blk = get_cache(fs->fs_dev, bno);
}
}
@@ -593,110 +628,99 @@ struct inode *xfs_dir2_node_find_entry(const char *dname, struct inode *parent,
xfs_dinode_t *core)
{
block_t fsblkno;
- xfs_da_intnode_t *node = NULL;
+ xfs_da_node_hdr_t *nhdr;
uint32_t hashwant;
uint32_t hash = 0;
+ uint16_t i;
+ uint16_t count;
xfs_da_node_entry_t *btree;
- uint16_t max;
- uint16_t span;
- uint16_t probe;
int error;
+ xfs_dir2_leaf_hdr_t *lhdr;
xfs_dir2_data_hdr_t *data_hdr;
- xfs_dir2_leaf_t *leaf;
xfs_dir2_leaf_entry_t *lep;
xfs_dir2_data_entry_t *dep;
+ xfs_dir2_leaf_entry_t *ents;
struct inode *ip;
uint8_t *start_name;
uint8_t *end_name;
int low;
int high;
int mid = 0;
- uint32_t newdb, curdb = -1;
+ uint32_t newdb;
+ uint32_t curdb;
xfs_intino_t ino;
xfs_dinode_t *ncore;
- const uint8_t *buf = NULL;
+ uint8_t *buf = NULL;
xfs_debug("dname %s parent %p core %p", dname, parent, core);
- hashwant = xfs_dir2_da_hashname((uint8_t *)dname, strlen(dname));
-
- fsblkno = xfs_dir2_get_right_blk(parent->fs, core,
- xfs_dir2_byte_to_db(parent->fs, XFS_DIR2_LEAF_OFFSET),
- &error);
+ curdb = xfs_dir2_byte_to_db(parent->fs, XFS_DIR2_LEAF_OFFSET);
+ fsblkno = xfs_dir2_get_right_blk(parent->fs, core, curdb, &error);
if (error) {
xfs_error("Cannot find right rec!");
return NULL;
}
- node = (xfs_da_intnode_t *)xfs_dir2_dirblks_get_cached(parent->fs, fsblkno,
- 1);
- if (be16_to_cpu(node->hdr.info.magic) != XFS_DA_NODE_MAGIC) {
- xfs_error("Node's magic number does not match!");
+ nhdr = xfs_dir2_dirblks_get_cached(parent->fs, fsblkno, 1);
+ if (be16_to_cpu(nhdr->info.magic) == XFS_DA_NODE_MAGIC) {
+ count = be16_to_cpu(nhdr->count);
+ btree = (xfs_da_node_entry_t *)((uint8_t *)nhdr +
+ sizeof(struct xfs_da_node_hdr));
+ } else if (be16_to_cpu(nhdr->info.magic) == XFS_DA3_NODE_MAGIC) {
+ count = be16_to_cpu(((xfs_da3_node_hdr_t *)nhdr)->count);
+ btree = (xfs_da_node_entry_t *)((uint8_t *)nhdr +
+ sizeof(struct xfs_da3_node_hdr));
+ } else {
+ xfs_error("Node's magic number (0x%04x) does not match!");
goto out;
}
- do {
- if (!node->hdr.count)
- goto out;
-
- /* Given a hash to lookup, you read the node's btree array and first
- * "hashval" in the array that exceeds the given hash and it can then
- * be found in the block pointed by the "before" value.
- */
- max = be16_to_cpu(node->hdr.count);
-
- probe = span = max/2;
- for (btree = &node->btree[probe];
- span > 4; btree = &node->btree[probe]) {
- span /= 2;
- hash = be32_to_cpu(btree->hashval);
-
- if (hash < hashwant)
- probe += span;
- else if (hash > hashwant)
- probe -= span;
- else
- break;
- }
-
- while ((probe > 0) && (be32_to_cpu(btree->hashval) >= hashwant)) {
- btree--;
- probe--;
- }
-
- while ((probe < max) && (be32_to_cpu(btree->hashval) < hashwant)) {
- btree++;
- probe++;
- }
+ hashwant = xfs_dir2_da_hashname((uint8_t *)dname, strlen(dname));
- if (probe == max)
- fsblkno = be32_to_cpu(node->btree[max-1].before);
- else
- fsblkno = be32_to_cpu(node->btree[probe].before);
+ /* Given a hash to lookup, you read the node's btree array and first
+ * "hashval" in the array that exceeds the given hash and it can then
+ * be found in the block pointed by the "before" value.
+ */
+ fsblkno = 0;
+ for (i = 0; i < count; i++) {
+ if (hashwant < be32_to_cpu(btree[i].hashval)) {
+ fsblkno = be32_to_cpu(btree[i].before);
+ break;
+ }
+ }
- fsblkno = xfs_dir2_get_right_blk(parent->fs, core, fsblkno, &error);
- if (error) {
- xfs_error("Cannot find right rec!");
- goto out;
- }
+ if (!fsblkno)
+ goto out;
- node = (xfs_da_intnode_t *)xfs_dir2_dirblks_get_cached(parent->fs,
- fsblkno, 1);
- } while(be16_to_cpu(node->hdr.info.magic) == XFS_DA_NODE_MAGIC);
+ fsblkno = xfs_dir2_get_right_blk(parent->fs, core, fsblkno, &error);
+ if (error) {
+ xfs_error("Cannot find leaf record");
+ goto out;
+ }
- leaf = (xfs_dir2_leaf_t*)node;
- if (be16_to_cpu(leaf->hdr.info.magic) != XFS_DIR2_LEAFN_MAGIC) {
- xfs_error("Leaf's magic number does not match!");
+ lhdr = xfs_dir2_dirblks_get_cached(parent->fs, fsblkno, 1);
+ if (be16_to_cpu(lhdr->info.magic) == XFS_DIR2_LEAFN_MAGIC) {
+ count = be16_to_cpu(lhdr->count);
+ ents = (xfs_dir2_leaf_entry_t *)((uint8_t *)lhdr +
+ sizeof(struct xfs_dir2_leaf_hdr));
+ } else if (be16_to_cpu(lhdr->info.magic) == XFS_DIR3_LEAFN_MAGIC) {
+ count = be16_to_cpu(((xfs_dir3_leaf_hdr_t *)lhdr)->count);
+ ents = (xfs_dir2_leaf_entry_t *)((uint8_t *)lhdr +
+ sizeof(struct xfs_dir3_leaf_hdr));
+ } else {
+ xfs_error("Leaf's magic number does not match (0x%04x)!",
+ be16_to_cpu(lhdr->info.magic));
goto out;
}
- if (!leaf->hdr.count)
- goto out;
+ if (!count)
+ goto out;
- for (lep = leaf->ents, low = 0, high = be16_to_cpu(leaf->hdr.count) - 1;
- low <= high; ) {
+ lep = ents;
+ low = 0;
+ high = count - 1;
+ while (low <= high) {
mid = (low + high) >> 1;
-
if ((hash = be32_to_cpu(lep[mid].hashval)) == hashwant)
break;
if (hash < hashwant)
@@ -714,9 +738,8 @@ struct inode *xfs_dir2_node_find_entry(const char *dname, struct inode *parent,
while (mid > 0 && be32_to_cpu(lep[mid - 1].hashval) == hashwant)
mid--;
- for (lep = &leaf->ents[mid];
- mid < be16_to_cpu(leaf->hdr.count) &&
- be32_to_cpu(lep->hashval) == hashwant;
+ curdb = -1;
+ for (lep = &ents[mid]; mid < count && be32_to_cpu(lep->hashval) == hashwant;
lep++, mid++) {
/* Skip over stale leaf entries. */
if (be32_to_cpu(lep->address) == XFS_DIR2_NULL_DATAPTR)
@@ -732,7 +755,8 @@ struct inode *xfs_dir2_node_find_entry(const char *dname, struct inode *parent,
buf = xfs_dir2_dirblks_get_cached(parent->fs, fsblkno, 1);
data_hdr = (xfs_dir2_data_hdr_t *)buf;
- if (be32_to_cpu(data_hdr->magic) != XFS_DIR2_DATA_MAGIC) {
+ if (be32_to_cpu(data_hdr->magic) != XFS_DIR2_DATA_MAGIC &&
+ be32_to_cpu(data_hdr->magic) != XFS_DIR3_DATA_MAGIC) {
xfs_error("Leaf directory's data magic No. does not match!");
goto out;
}
@@ -740,10 +764,10 @@ struct inode *xfs_dir2_node_find_entry(const char *dname, struct inode *parent,
curdb = newdb;
}
- dep = (xfs_dir2_data_entry_t *)((char *)buf +
- xfs_dir2_dataptr_to_off(parent->fs, be32_to_cpu(lep->address)));
-
- start_name = &dep->name[0];
+ dep = (xfs_dir2_data_entry_t *)(
+ buf + xfs_dir2_dataptr_to_off(parent->fs,
+ be32_to_cpu(lep->address)));
+ start_name = dep->name;
end_name = start_name + dep->namelen;
if (!xfs_dir2_entry_name_cmp(start_name, end_name, dname)) {
diff --git a/core/fs/xfs/xfs_dir2.h b/core/fs/xfs/xfs_dir2.h
index 158cf44..1e1fb57 100644
--- a/core/fs/xfs/xfs_dir2.h
+++ b/core/fs/xfs/xfs_dir2.h
@@ -23,8 +23,8 @@
#include "xfs.h"
-const void *xfs_dir2_dirblks_get_cached(struct fs_info *fs, block_t startblock,
- xfs_filblks_t c);
+void *xfs_dir2_dirblks_get_cached(struct fs_info *fs, block_t startblock,
+ xfs_filblks_t c);
void xfs_dir2_dirblks_flush_cache(void);
uint32_t xfs_dir2_da_hashname(const uint8_t *name, int namelen);
@@ -46,7 +46,7 @@ static inline bool xfs_dir2_isleaf(struct fs_info *fs, xfs_dinode_t *dip)
uint64_t last = 0;
xfs_bmbt_irec_t irec;
- bmbt_irec_get(&irec, ((xfs_bmbt_rec_t *)&dip->di_literal_area[0]) +
+ bmbt_irec_get(&irec, (xfs_bmbt_rec_t *)XFS_DFORK_PTR(dip, XFS_DATA_FORK) +
be32_to_cpu(dip->di_nextents) - 1);
last = irec.br_startoff + irec.br_blockcount;
diff --git a/core/fs/xfs/xfs_readdir.c b/core/fs/xfs/xfs_readdir.c
index 86c8a77..51518ef 100644
--- a/core/fs/xfs/xfs_readdir.c
+++ b/core/fs/xfs/xfs_readdir.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2012-2013 Paulo Alcantara <pcacjr@zytor.com>
+ * Copyright (c) 2012-2015 Paulo Alcantara <pcacjr@zytor.com>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
@@ -64,10 +64,12 @@ static int fill_dirent(struct fs_info *fs, struct dirent *dirent,
int xfs_readdir_dir2_local(struct file *file, struct dirent *dirent,
xfs_dinode_t *core)
{
- xfs_dir2_sf_t *sf = (xfs_dir2_sf_t *)&core->di_literal_area[0];
+ xfs_dir2_sf_t *sf = XFS_DFORK_PTR(core, XFS_DATA_FORK);
xfs_dir2_sf_entry_t *sf_entry;
+ uint8_t ftypelen = core->di_version == 3 ? 1 : 0;
uint8_t count = sf->hdr.i8count ? sf->hdr.i8count : sf->hdr.count;
uint32_t offset = file->offset;
+ xfs_dir2_inou_t *inou;
uint8_t *start_name;
uint8_t *end_name;
xfs_ino_t ino;
@@ -82,7 +84,7 @@ int xfs_readdir_dir2_local(struct file *file, struct dirent *dirent,
file->offset++;
- sf_entry = (xfs_dir2_sf_entry_t *)((uint8_t *)&sf->list[0] -
+ sf_entry = (xfs_dir2_sf_entry_t *)((uint8_t *)sf->list -
(!sf->hdr.i8count ? 4 : 0));
if (file->offset - 1) {
@@ -91,20 +93,22 @@ int xfs_readdir_dir2_local(struct file *file, struct dirent *dirent,
sf_entry = (xfs_dir2_sf_entry_t *)(
(uint8_t *)sf_entry +
offsetof(struct xfs_dir2_sf_entry,
- name[0]) +
+ name) +
sf_entry->namelen +
+ ftypelen +
(sf->hdr.i8count ? 8 : 4));
}
}
- start_name = &sf_entry->name[0];
+ start_name = sf_entry->name;
end_name = start_name + sf_entry->namelen;
- ino = xfs_dir2_sf_get_inumber(sf, (xfs_dir2_inou_t *)(
- (uint8_t *)sf_entry +
- offsetof(struct xfs_dir2_sf_entry,
- name[0]) +
- sf_entry->namelen));
+ inou = (xfs_dir2_inou_t *)((uint8_t *)sf_entry +
+ offsetof(struct xfs_dir2_sf_entry,
+ name) +
+ sf_entry->namelen +
+ ftypelen);
+ ino = xfs_dir2_sf_get_inumber(sf, inou);
retval = fill_dirent(fs, dirent, file->offset, ino, (char *)start_name,
end_name - start_name);
@@ -126,6 +130,7 @@ int xfs_readdir_dir2_block(struct file *file, struct dirent *dirent,
block_t dir_blk;
struct fs_info *fs = file->fs;
const uint8_t *dirblk_buf;
+ bool isdir3;
uint8_t *p;
uint32_t offset;
xfs_dir2_data_hdr_t *hdr;
@@ -139,12 +144,16 @@ int xfs_readdir_dir2_block(struct file *file, struct dirent *dirent,
xfs_debug("file %p dirent %p core %p", file, dirent, core);
- bmbt_irec_get(&r, (xfs_bmbt_rec_t *)&core->di_literal_area[0]);
+ bmbt_irec_get(&r, XFS_DFORK_PTR(core, XFS_DATA_FORK));
dir_blk = fsblock_to_bytes(fs, r.br_startblock) >> BLOCK_SHIFT(fs);
dirblk_buf = xfs_dir2_dirblks_get_cached(fs, dir_blk, r.br_blockcount);
hdr = (xfs_dir2_data_hdr_t *)dirblk_buf;
- if (be32_to_cpu(hdr->magic) != XFS_DIR2_BLOCK_MAGIC) {
+ if (be32_to_cpu(hdr->magic) == XFS_DIR2_BLOCK_MAGIC) {
+ isdir3 = false;
+ } else if (be32_to_cpu(hdr->magic) == XFS_DIR3_BLOCK_MAGIC) {
+ isdir3 = true;
+ } else {
xfs_error("Block directory header's magic number does not match!");
xfs_debug("hdr->magic: 0x%lx", be32_to_cpu(hdr->magic));
goto out;
@@ -157,7 +166,8 @@ int xfs_readdir_dir2_block(struct file *file, struct dirent *dirent,
file->offset++;
- p = (uint8_t *)(hdr + 1);
+ p = (uint8_t *)dirblk_buf + (isdir3 ? sizeof(struct xfs_dir3_data_hdr) :
+ sizeof(struct xfs_dir2_data_hdr));
if (file->offset - 1) {
offset = file->offset;
@@ -170,7 +180,8 @@ int xfs_readdir_dir2_block(struct file *file, struct dirent *dirent,
continue;
}
- p += xfs_dir2_data_entsize(dep->namelen);
+ p += (isdir3 ? xfs_dir3_data_entsize(dep->namelen) :
+ xfs_dir2_data_entsize(dep->namelen));
}
}
@@ -197,9 +208,11 @@ out:
int xfs_readdir_dir2_leaf(struct file *file, struct dirent *dirent,
xfs_dinode_t *core)
{
+ xfs_dir2_leaf_hdr_t *hdr;
+ xfs_dir2_leaf_entry_t *ents;
+ uint16_t count;
xfs_bmbt_irec_t irec;
struct fs_info *fs = file->fs;
- xfs_dir2_leaf_t *leaf;
block_t leaf_blk, dir_blk;
xfs_dir2_leaf_entry_t *lep;
uint32_t db;
@@ -214,39 +227,49 @@ int xfs_readdir_dir2_leaf(struct file *file, struct dirent *dirent,
xfs_debug("file %p dirent %p core %p", file, dirent, core);
- bmbt_irec_get(&irec, ((xfs_bmbt_rec_t *)&core->di_literal_area[0]) +
+ bmbt_irec_get(&irec, (xfs_bmbt_rec_t *)XFS_DFORK_PTR(core, XFS_DATA_FORK) +
be32_to_cpu(core->di_nextents) - 1);
leaf_blk = fsblock_to_bytes(fs, irec.br_startblock) >>
BLOCK_SHIFT(file->fs);
- leaf = (xfs_dir2_leaf_t *)xfs_dir2_dirblks_get_cached(fs, leaf_blk,
- irec.br_blockcount);
- if (be16_to_cpu(leaf->hdr.info.magic) != XFS_DIR2_LEAF1_MAGIC) {
+ hdr = xfs_dir2_dirblks_get_cached(fs, leaf_blk, irec.br_blockcount);
+ if (!hdr)
+ return -1;
+
+ if (be16_to_cpu(hdr->info.magic) == XFS_DIR2_LEAF1_MAGIC) {
+ count = be16_to_cpu(hdr->count);
+ ents = (xfs_dir2_leaf_entry_t *)((uint8_t *)hdr +
+ sizeof(struct xfs_dir2_leaf_hdr));
+ } else if (be16_to_cpu(hdr->info.magic) == XFS_DIR3_LEAF1_MAGIC) {
+ count = be16_to_cpu(((xfs_dir3_leaf_hdr_t *)hdr)->count);
+ ents = (xfs_dir2_leaf_entry_t *)((uint8_t *)hdr +
+ sizeof(struct xfs_dir3_leaf_hdr));
+ } else {
xfs_error("Single leaf block header's magic number does not match!");
goto out;
}
- if (!leaf->hdr.count)
- goto out;
-
- if (file->offset + 1 > be16_to_cpu(leaf->hdr.count))
+ if (!count || file->offset + 1 > count)
goto out;
- lep = &leaf->ents[file->offset++];
+ lep = &ents[file->offset++];
/* Skip over stale leaf entries */
for ( ; be32_to_cpu(lep->address) == XFS_DIR2_NULL_DATAPTR;
- lep++, file->offset++);
+ lep++, file->offset++)
+ ;
db = xfs_dir2_dataptr_to_db(fs, be32_to_cpu(lep->address));
- bmbt_irec_get(&irec, (xfs_bmbt_rec_t *)&core->di_literal_area[0] + db);
+ bmbt_irec_get(&irec, (xfs_bmbt_rec_t *)XFS_DFORK_PTR(core,
+ XFS_DATA_FORK) + db);
dir_blk = fsblock_to_bytes(fs, irec.br_startblock) >> BLOCK_SHIFT(fs);
buf = xfs_dir2_dirblks_get_cached(fs, dir_blk, irec.br_blockcount);
data_hdr = (xfs_dir2_data_hdr_t *)buf;
- if (be32_to_cpu(data_hdr->magic) != XFS_DIR2_DATA_MAGIC) {
+ if (be32_to_cpu(data_hdr->magic) != XFS_DIR2_DATA_MAGIC &&
+ be32_to_cpu(data_hdr->magic) != XFS_DIR3_DATA_MAGIC) {
xfs_error("Leaf directory's data magic number does not match!");
goto out;
}
@@ -277,14 +300,16 @@ int xfs_readdir_dir2_node(struct file *file, struct dirent *dirent,
xfs_dinode_t *core)
{
struct fs_info *fs = file->fs;
- xfs_bmbt_irec_t irec;
- uint32_t node_off = 0;
block_t fsblkno;
- xfs_da_intnode_t *node = NULL;
+ xfs_da_node_hdr_t *nhdr;
+ xfs_da_node_entry_t *btree;
+ uint16_t btcount;
+ uint16_t lfcount;
+ xfs_dir2_leaf_hdr_t *lhdr;
+ xfs_dir2_leaf_entry_t *ents;
struct inode *inode = file->inode;
int error;
xfs_dir2_data_hdr_t *data_hdr;
- xfs_dir2_leaf_t *leaf;
xfs_dir2_leaf_entry_t *lep;
unsigned int offset;
xfs_dir2_data_entry_t *dep;
@@ -296,52 +321,71 @@ int xfs_readdir_dir2_node(struct file *file, struct dirent *dirent,
xfs_debug("file %p dirent %p core %p", file, dirent, core);
- do {
- bmbt_irec_get(&irec, (xfs_bmbt_rec_t *)&core->di_literal_area[0] +
- ++node_off);
- } while (irec.br_startoff < xfs_dir2_byte_to_db(fs, XFS_DIR2_LEAF_OFFSET));
-
- fsblkno = fsblock_to_bytes(fs, irec.br_startblock) >> BLOCK_SHIFT(fs);
+ db = xfs_dir2_byte_to_db(fs, XFS_DIR2_LEAF_OFFSET);
+ fsblkno = xfs_dir2_get_right_blk(fs, core, db, &error);
+ if (error) {
+ xfs_error("Cannot find fs block");
+ return -1;
+ }
- node = (xfs_da_intnode_t *)xfs_dir2_dirblks_get_cached(fs, fsblkno, 1);
- if (be16_to_cpu(node->hdr.info.magic) != XFS_DA_NODE_MAGIC) {
- xfs_error("Node's magic number does not match!");
+ nhdr = xfs_dir2_dirblks_get_cached(fs, fsblkno, 1);
+ if (be16_to_cpu(nhdr->info.magic) == XFS_DA_NODE_MAGIC) {
+ btcount = be16_to_cpu(nhdr->count);
+ btree = (xfs_da_node_entry_t *)((uint8_t *)nhdr +
+ sizeof(struct xfs_da_node_hdr));
+ } else if (be16_to_cpu(nhdr->info.magic) == XFS_DA3_NODE_MAGIC) {
+ btcount = be16_to_cpu(((xfs_da3_node_hdr_t *)nhdr)->count);
+ btree = (xfs_da_node_entry_t *)((uint8_t *)nhdr +
+ sizeof(struct xfs_da3_node_hdr));
+ } else {
+ xfs_error("Node's magic number (0x%04x) does not match!",
+ be16_to_cpu(nhdr->info.magic));
goto out;
}
try_next_btree:
- if (!node->hdr.count ||
- XFS_PVT(inode)->i_btree_offset >= be16_to_cpu(node->hdr.count))
+ if (!btcount ||
+ XFS_PVT(inode)->i_btree_offset >= btcount)
goto out;
- fsblkno = be32_to_cpu(node->btree[XFS_PVT(inode)->i_btree_offset].before);
+ fsblkno = be32_to_cpu(btree[XFS_PVT(inode)->i_btree_offset].before);
fsblkno = xfs_dir2_get_right_blk(fs, core, fsblkno, &error);
if (error) {
xfs_error("Cannot find leaf rec!");
goto out;
}
- leaf = (xfs_dir2_leaf_t*)xfs_dir2_dirblks_get_cached(fs, fsblkno, 1);
- if (be16_to_cpu(leaf->hdr.info.magic) != XFS_DIR2_LEAFN_MAGIC) {
- xfs_error("Leaf's magic number does not match!");
+ lhdr = xfs_dir2_dirblks_get_cached(fs, fsblkno, 1);
+ if (be16_to_cpu(lhdr->info.magic) == XFS_DIR2_LEAFN_MAGIC) {
+ lfcount = be16_to_cpu(lhdr->count);
+ ents = (xfs_dir2_leaf_entry_t *)((uint8_t *)lhdr +
+ sizeof(struct xfs_dir2_leaf_hdr));
+ } else if (be16_to_cpu(lhdr->info.magic) == XFS_DIR3_LEAFN_MAGIC) {
+ lfcount = be16_to_cpu(((xfs_dir3_leaf_hdr_t *)lhdr)->count);
+ ents = (xfs_dir2_leaf_entry_t *)((uint8_t *)lhdr +
+ sizeof(struct xfs_dir3_leaf_hdr));
+ } else {
+ xfs_error("Leaf's magic number does not match (0x%04x)!",
+ be16_to_cpu(lhdr->info.magic));
goto out;
}
- if (!leaf->hdr.count ||
- XFS_PVT(inode)->i_leaf_ent_offset >= be16_to_cpu(leaf->hdr.count)) {
+ if (!lfcount ||
+ XFS_PVT(inode)->i_leaf_ent_offset >= lfcount) {
XFS_PVT(inode)->i_btree_offset++;
XFS_PVT(inode)->i_leaf_ent_offset = 0;
goto try_next_btree;
}
- lep = &leaf->ents[XFS_PVT(inode)->i_leaf_ent_offset];
+ lep = &ents[XFS_PVT(inode)->i_leaf_ent_offset];
/* Skip over stale leaf entries */
- for ( ; XFS_PVT(inode)->i_leaf_ent_offset < be16_to_cpu(leaf->hdr.count) &&
+ for ( ; XFS_PVT(inode)->i_leaf_ent_offset < lfcount &&
be32_to_cpu(lep->address) == XFS_DIR2_NULL_DATAPTR;
- lep++, XFS_PVT(inode)->i_leaf_ent_offset++);
+ lep++, XFS_PVT(inode)->i_leaf_ent_offset++)
+ ;
- if (XFS_PVT(inode)->i_leaf_ent_offset == be16_to_cpu(leaf->hdr.count)) {
+ if (XFS_PVT(inode)->i_leaf_ent_offset == lfcount) {
XFS_PVT(inode)->i_btree_offset++;
XFS_PVT(inode)->i_leaf_ent_offset = 0;
goto try_next_btree;
@@ -359,7 +403,8 @@ try_next_btree:
buf = xfs_dir2_dirblks_get_cached(fs, fsblkno, 1);
data_hdr = (xfs_dir2_data_hdr_t *)buf;
- if (be32_to_cpu(data_hdr->magic) != XFS_DIR2_DATA_MAGIC) {
+ if (be32_to_cpu(data_hdr->magic) != XFS_DIR2_DATA_MAGIC &&
+ be32_to_cpu(data_hdr->magic) != XFS_DIR3_DATA_MAGIC) {
xfs_error("Leaf directory's data magic No. does not match!");
goto out;
}
diff --git a/core/head.inc b/core/head.inc
index 71eb574..b97db35 100644
--- a/core/head.inc
+++ b/core/head.inc
@@ -22,6 +22,8 @@
%if __NASM_MAJOR__ < 2 || (__NASM_MAJOR__ == 2 && __NASM_MINOR__ < 3)
%error "NASM 2.03 or later required to compile correctly"
+%elif __NASM_VERSION_ID__ == 0x020b0600
+ %fatal "NASM 2.11.06 is known to miscompile Syslinux"
%endif
%include "macros.inc"
diff --git a/core/i386/syslinux.ld b/core/i386/syslinux.ld
index 7b4e012..e8d32dd 100644
--- a/core/i386/syslinux.ld
+++ b/core/i386/syslinux.ld
@@ -1,7 +1,7 @@
/* -----------------------------------------------------------------------
*
* Copyright 2008-2009 H. Peter Anvin - All Rights Reserved
- * Copyright 2009 Intel Corporation; author: H. Peter Anvin
+ * Copyright 2009-2016 Intel Corporation; author: H. Peter Anvin
*
* 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
@@ -12,7 +12,7 @@
* ----------------------------------------------------------------------- */
/*
- * Linker script for the SYSLINUX core
+ * Linker script for the SYSLINUX core when built for i386-bios
*/
OUTPUT_FORMAT("elf32-i386", "elf32-i386", "elf32-i386")
@@ -26,7 +26,7 @@ SECTIONS
{
/* Prefix structure for the compression program */
. = 0;
- __module_start = .;
+ __module_start = ABSOLUTE(.);
.prefix : {
*(.prefix)
}
@@ -102,6 +102,7 @@ SECTIONS
__init_len = ABSOLUTE(__init_end) - ABSOLUTE(__init_start);
__init_dwords = (__init_len + 3) >> 2;
+ . = ALIGN(4);
.text16 : {
FILL(0x90909090)
__text16_start = .;
@@ -159,17 +160,17 @@ SECTIONS
__data16_dwords = (__data16_len + 3) >> 2;
. = ALIGN(4);
- __config_lma = .;
+ __config_lma = ABSOLUTE(.);
. += SIZEOF(.config);
. = ALIGN(4);
- __replacestub_lma = .;
+ __replacestub_lma = ABSOLUTE(.);
. += SIZEOF(.replacestub);
/* The 32-bit code loads above the non-progbits sections */
. = ALIGN(16);
- __pm_code_lma = .;
+ __pm_code_lma = ABSOLUTE(.);
__high_clear_start = .;
@@ -199,13 +200,6 @@ SECTIONS
/*
* Special 16-bit segments
*/
-
- . = ALIGN(65536);
- .real_mode (NOLOAD) : {
- *(.real_mode)
- }
- real_mode_seg = core_real_mode >> 4;
-
. = ALIGN(65536);
.xfer_buf (NOLOAD) : {
*(.xfer_buf)
@@ -213,7 +207,7 @@ SECTIONS
xfer_buf_seg = core_xfer_buf >> 4;
/*
- * The auxilliary data segment is used by the 16-bit code
+ * The auxiliary data segment is used by the 16-bit code
* for items that don't need to live in the bottom 64K.
*/
@@ -255,10 +249,9 @@ SECTIONS
. = 0x100000;
__pm_code_start = .;
+ __vma_to_lma = ABSOLUTE(__pm_code_lma - __pm_code_start);
- __text_vma = .;
- __text_lma = __pm_code_lma;
- .text : AT(__text_lma) {
+ .text : AT(ADDR(.text) + __vma_to_lma) {
FILL(0x90909090)
__text_start = .;
*(.text)
@@ -266,106 +259,68 @@ SECTIONS
__text_end = .;
}
- . = ALIGN(16);
-
- __rodata_vma = .;
- __rodata_lma = __rodata_vma + __text_lma - __text_vma;
- .rodata : AT(__rodata_lma) {
+ .rodata : AT(ADDR(.rodata) + __vma_to_lma) {
__rodata_start = .;
*(.rodata)
*(.rodata.*)
__rodata_end = .;
}
- . = ALIGN(4);
-
- __ctors_vma = .;
- __ctors_lma = __ctors_vma + __text_lma - __text_vma;
- .ctors : AT(__ctors_lma) {
+ .ctors : AT(ADDR(.ctors) + __vma_to_lma) {
__ctors_start = .;
KEEP (*(SORT(.ctors.*)))
KEEP (*(.ctors))
__ctors_end = .;
}
- __dtors_vma = .;
- __dtors_lma = __dtors_vma + __text_lma - __text_vma;
- .dtors : AT(__dtors_lma) {
+ .dtors : AT(ADDR(.dtors) + __vma_to_lma) {
__dtors_start = .;
KEEP (*(SORT(.dtors.*)))
KEEP (*(.dtors))
__dtors_end = .;
}
- . = ALIGN(4);
-
- __dynsym_vma = .;
- __dynsym_lma = __dynsym_vma + __text_lma - __text_vma;
- .dynsym : AT(__dynsym_lma) {
+ .dynsym : AT(ADDR(.dynsym) + __vma_to_lma) {
__dynsym_start = .;
- *(.dynsym)
+ KEEP (*(.dynsym))
__dynsym_end = .;
}
__dynsym_len = __dynsym_end - __dynsym_start;
- . = ALIGN(4);
-
- __dynstr_vma = .;
- __dynstr_lma = __dynstr_vma + __text_lma - __text_vma;
- .dynstr : AT(__dynstr_lma) {
+ .dynstr : AT(ADDR(.dynstr) + __vma_to_lma) {
__dynstr_start = .;
- *(.dynstr)
+ KEEP (*(.dynstr))
__dynstr_end = .;
}
__dynstr_len = __dynstr_end - __dynstr_start;
- . = ALIGN(4);
-
- __gnu_hash_vma = .;
- __gnu_hash_lma = __gnu_hash_vma + __text_lma - __text_vma;
- .gnu.hash : AT(__gnu_hash_lma) {
+ .gnu.hash : AT(ADDR(.gnu.hash) + __vma_to_lma) {
__gnu_hash_start = .;
- *(.gnu.hash)
+ KEEP (*(.gnu.hash))
__gnu_hash_end = .;
}
- . = ALIGN(4);
-
- __dynlink_vma = .;
- __dynlink_lma = __dynlink_vma + __text_lma - __text_vma;
- .dynlink : AT(__dynlink_lma) {
+ .dynlink : AT(ADDR(.dynlink) + __vma_to_lma) {
__dynlink_start = .;
- *(.dynlink)
+ KEEP (*(.dynlink))
__dynlink_end = .;
}
- . = ALIGN(4);
-
- __got_vma = .;
- __got_lma = __got_vma + __text_lma - __text_vma;
- .got : AT(__got_lma) {
+ .got : AT(ADDR(.got) + __vma_to_lma) {
__got_start = .;
- KEEP (*(.got.plt))
KEEP (*(.got))
+ KEEP (*(.got.plt))
__got_end = .;
}
- . = ALIGN(4);
-
- __dynamic_vma = .;
- __dynamic_lma = __dynamic_vma + __text_lma - __text_vma;
- .dynamic : AT(__dynamic_lma) {
+ .dynamic : AT(ADDR(.dynamic) + __vma_to_lma) {
__dynamic_start = .;
- *(.dynamic)
+ KEEP (*(.dynamic))
__dynamic_end = .;
}
- . = ALIGN(16);
-
- __data_vma = .;
- __data_lma = __data_vma + __text_lma - __text_vma;
- .data : AT(__data_lma) {
+ .data : AT(ADDR(.data) + __vma_to_lma) {
__data_start = .;
*(.data)
*(.data.*)
@@ -377,9 +332,9 @@ SECTIONS
__pm_code_dwords = (__pm_code_len + 3) >> 2;
. = ALIGN(128);
-
+
__bss_vma = .;
- __bss_lma = .; /* Dummy */
+ __bss_lma = ABSOLUTE(.); /* Dummy */
.bss (NOLOAD) : AT (__bss_lma) {
__bss_start = .;
*(.bss)
@@ -393,7 +348,7 @@ SECTIONS
/* Very large objects which don't need to be zeroed */
__hugebss_vma = .;
- __hugebss_lma = .; /* Dummy */
+ __hugebss_lma = ABSOLUTE(.); /* Dummy */
.hugebss (NOLOAD) : AT (__hugebss_lma) {
__hugebss_start = .;
*(.hugebss)
@@ -406,7 +361,7 @@ SECTIONS
/* XXX: This stack should be unified with the COM32 stack */
__stack_vma = .;
- __stack_lma = .; /* Dummy */
+ __stack_lma = ABSOLUTE(.); /* Dummy */
.stack (NOLOAD) : AT(__stack_lma) {
__stack_start = .;
*(.stack)
@@ -417,12 +372,13 @@ SECTIONS
_end = .;
- /* COM32R and kernels are loaded after our own PM code */
- . = ALIGN(65536);
+ /* The first block of the heap is here */
+ . = ALIGN(4096);
free_high_memory = .;
/* Stuff we don't need... */
/DISCARD/ : {
*(.eh_frame)
+ *(.interp)
}
}
diff --git a/core/layout.inc b/core/layout.inc
index 53ca783..bb7cb33 100644
--- a/core/layout.inc
+++ b/core/layout.inc
@@ -101,9 +101,10 @@ RBFG_brainfuck: resb 2048 ; Bigger than an Ethernet packet...
; Symbols from linker script
%macro SECINFO 1
- extern __%1_start, __%1_lma, __%1_end
+ extern __%1_start, __%1_end
extern __%1_len, __%1_dwords
%endmacro
+
SECINFO bss16
SECINFO uibss
SECINFO config
@@ -112,6 +113,7 @@ RBFG_brainfuck: resb 2048 ; Bigger than an Ethernet packet...
SECINFO pm_code
SECINFO high_clear
+ extern __pm_code_lma
SECINFO bss
@@ -139,17 +141,6 @@ serial_buf_size equ 4096 ; Should be a power of 2
core_xfer_buf resb 65536
;
-; Segment for the real mode code (needed as long as we have a in-kernel
-; loader and/or COM16 support.
-; One symbol for the segment number, one for the absolute address
-;
- extern real_mode_seg
- section .real_mode write nobits align=65536
- global core_real_mode:data hidden
-core_real_mode resb 65536
-comboot_seg equ real_mode_seg ; COMBOOT image loading zone
-
-;
; At the very end, the lowmem heap
;
extern __lowmem_heap
diff --git a/core/legacynet/core.c b/core/legacynet/core.c
index eacb492..24a670e 100644
--- a/core/legacynet/core.c
+++ b/core/legacynet/core.c
@@ -220,3 +220,104 @@ int reset_pxe(void)
return err;
}
+
+#if GPXE
+
+static void gpxe_close_file(struct inode *inode)
+{
+ struct pxe_pvt_inode *socket = PVT(inode);
+ static __lowmem struct s_PXENV_FILE_CLOSE file_close;
+
+ file_close.FileHandle = socket->tftp_remoteport;
+ pxe_call(PXENV_FILE_CLOSE, &file_close);
+}
+
+/**
+ * Get a fresh packet from a gPXE socket
+ * @param: inode -> Inode pointer
+ *
+ */
+static void gpxe_get_packet(struct inode *inode)
+{
+ struct pxe_pvt_inode *socket = PVT(inode);
+ static __lowmem struct s_PXENV_FILE_READ file_read;
+ int err;
+
+ while (1) {
+ file_read.FileHandle = socket->tftp_remoteport;
+ file_read.Buffer = FAR_PTR(packet_buf);
+ file_read.BufferSize = PKTBUF_SIZE;
+ err = pxe_call(PXENV_FILE_READ, &file_read);
+ if (!err) /* successed */
+ break;
+
+ if (file_read.Status != PXENV_STATUS_TFTP_OPEN)
+ kaboom();
+ }
+
+ memcpy(socket->tftp_pktbuf, packet_buf, file_read.BufferSize);
+
+ socket->tftp_dataptr = socket->tftp_pktbuf;
+ socket->tftp_bytesleft = file_read.BufferSize;
+ socket->tftp_filepos += file_read.BufferSize;
+
+ if (socket->tftp_bytesleft == 0)
+ inode->size = socket->tftp_filepos;
+
+ /* if we're done here, close the file */
+ if (inode->size > socket->tftp_filepos)
+ return;
+
+ /* Got EOF, close it */
+ socket->tftp_goteof = 1;
+ gpxe_close_file(inode);
+}
+
+const struct pxe_conn_ops gpxe_conn_ops = {
+ .fill_buffer = gpxe_get_packet,
+ .close = gpxe_close_file,
+};
+
+/**
+ * Open a url using gpxe
+ *
+ * @param:inode, the inode to store our state in
+ * @param:url, the url we want to open
+ *
+ * @out: open_file_t structure, stores in file->open_file
+ * @out: the lenght of this file, stores in file->file_len
+ *
+ */
+void gpxe_open(struct inode *inode, const char *url)
+{
+ static __lowmem struct s_PXENV_FILE_OPEN file_open;
+ static __lowmem struct s_PXENV_GET_FILE_SIZE file_size;
+ static __lowmem char lowurl[2*FILENAME_MAX];
+ struct pxe_pvt_inode *socket = PVT(inode);
+ int err;
+
+ socket->tftp_pktbuf = malloc(PKTBUF_SIZE);
+ if (!socket->tftp_pktbuf)
+ return;
+
+ snprintf(lowurl, sizeof lowurl, "%s", url);
+ file_open.Status = PXENV_STATUS_BAD_FUNC;
+ file_open.FileName = FAR_PTR(lowurl);
+ err = pxe_call(PXENV_FILE_OPEN, &file_open);
+ if (err)
+ return;
+
+
+ socket->ops = &gpxe_conn_ops;
+ socket->tftp_remoteport = file_open.FileHandle;
+ file_size.Status = PXENV_STATUS_BAD_FUNC;
+ file_size.FileHandle = file_open.FileHandle;
+ err = pxe_call(PXENV_GET_FILE_SIZE, &file_size);
+ if (err) {
+ inode->size = -1; /* fallback size; this shouldn't be an error */
+ } else {
+ inode->size = file_size.FileSize;
+ }
+}
+
+#endif /* GPXE */
diff --git a/core/legacynet/dnsresolv.c b/core/legacynet/dnsresolv.c
index fdbe795..9be0a43 100644
--- a/core/legacynet/dnsresolv.c
+++ b/core/legacynet/dnsresolv.c
@@ -208,7 +208,7 @@ static bool parse_dotquad(const char *ip_str, uint32_t *res)
*
* XXX: probably need some caching here.
*/
-__export uint32_t dns_resolv(const char *name)
+__export uint32_t __weak pxe_dns(const char *name)
{
static char __lowmem DNSSendBuf[PKTBUF_SIZE];
static char __lowmem DNSRecvBuf[PKTBUF_SIZE];
diff --git a/core/localboot.c b/core/localboot.c
index 04635d4..0b8769e 100644
--- a/core/localboot.c
+++ b/core/localboot.c
@@ -87,8 +87,3 @@ __export void local_boot(int16_t ax)
ireg.edx.w[0] = ax;
call16(local_boot16, &ireg, NULL);
}
-
-void pm_local_boot(com32sys_t *regs)
-{
- local_boot(regs->eax.w[0]);
-}
diff --git a/core/lwip/src/netif/undiif.c b/core/lwip/src/netif/undiif.c
index e62a984..d68edef 100644
--- a/core/lwip/src/netif/undiif.c
+++ b/core/lwip/src/netif/undiif.c
@@ -45,7 +45,7 @@
* something that better describes your network interface.
*/
-/* other headers include deprintf.h too early */
+/* other headers include dprintf.h too early */
#define UNDIIF_ID_FULL_DEBUG (UNDIIF_ID_DEBUG | UNDIIF_DEBUG)
#if UNDIIF_ID_FULL_DEBUG
diff --git a/core/mem/free.c b/core/mem/free.c
index 2d16cd1..21f9b59 100644
--- a/core/mem/free.c
+++ b/core/mem/free.c
@@ -87,7 +87,9 @@ void bios_free(void *ptr)
__export void free(void *ptr)
{
+#ifdef DEBUG_MALLOC
dprintf("free(%p) @ %p\n", ptr, __builtin_return_address(0));
+#endif
if ( !ptr )
return;
diff --git a/core/mem/malloc.c b/core/mem/malloc.c
index b40c2f2..836c2fe 100644
--- a/core/mem/malloc.c
+++ b/core/mem/malloc.c
@@ -93,14 +93,18 @@ static void *_malloc(size_t size, enum heap heap, malloc_tag_t tag)
{
void *p;
+#ifdef DEBUG_MALLOC
dprintf("_malloc(%zu, %u, %u) @ %p = ",
size, heap, tag, __builtin_return_address(0));
+#endif
sem_down(&__malloc_semaphore, 0);
p = firmware->mem->malloc(size, heap, tag);
sem_up(&__malloc_semaphore);
+#ifdef DEBUG_MALLOC
dprintf("%p\n", p);
+#endif
return p;
}
diff --git a/core/serirq.c b/core/serirq.c
index e230b98..22370b9 100644
--- a/core/serirq.c
+++ b/core/serirq.c
@@ -200,5 +200,5 @@ __export void sirq_cleanup_nowipe(void)
void sirq_cleanup(void)
{
sirq_cleanup_nowipe();
- memcpy(SerialHead, 0x0, serial_buf_size);
+ memset(SerialHead, 0x0, serial_buf_size);
}
diff --git a/core/sysappend.c b/core/sysappend.c
index 5c3f650..758703e 100644
--- a/core/sysappend.c
+++ b/core/sysappend.c
@@ -35,7 +35,7 @@ static char *copy_and_mangle(char *dst, const char *src)
char c;
while ((c = *src++)) {
- if (c <= ' ' && c == '\x7f') {
+ if (c <= ' ' || c == '\x7f') {
if (!was_space)
*dst++ = '_';
was_space = true;
diff --git a/core/syslinux.ld b/core/syslinux.ld
deleted file mode 100644
index fa8c8c9..0000000
--- a/core/syslinux.ld
+++ /dev/null
@@ -1,414 +0,0 @@
-/* -----------------------------------------------------------------------
- *
- * Copyright 2008-2009 H. Peter Anvin - All Rights Reserved
- * Copyright 2009 Intel Corporation; author: H. Peter Anvin
- *
- * 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, Inc., 51 Franklin St, Fifth Floor,
- * Boston MA 02110-1301, USA; either version 2 of the License, or
- * (at your option) any later version; incorporated herein by reference.
- *
- * ----------------------------------------------------------------------- */
-
-/*
- * Linker script for the SYSLINUX core
- */
-
-OUTPUT_FORMAT("elf32-i386", "elf32-i386", "elf32-i386")
-OUTPUT_ARCH(i386)
-EXTERN(_start)
-ENTRY(_start)
-
-STACK32_LEN = 65536;
-
-SECTIONS
-{
- /* Prefix structure for the compression program */
- . = 0;
- HIDDEN(__module_start = .);
- .prefix : {
- *(.prefix)
- }
-
- /* "Early" sections (before the load) */
- . = 0x1000;
-
- .earlybss (NOLOAD) : {
- HIDDEN(__earlybss_start = .);
- *(.earlybss)
- HIDDEN(__earlybss_end = .);
- }
- HIDDEN(__earlybss_len = ABSOLUTE(__earlybss_end) - ABSOLUTE(__earlybss_start));
- HIDDEN(__earlybss_dwords = (__earlybss_len + 3) >> 2);
-
- . = ALIGN(4);
- .bss16 (NOLOAD) : {
- HIDDEN(__bss16_start = .);
- *(.bss16)
- HIDDEN(__bss16_end = .);
- }
- HIDDEN(__bss16_len = ABSOLUTE(__bss16_end) - ABSOLUTE(__bss16_start));
- HIDDEN(__bss16_dwords = (__bss16_len + 3) >> 2);
-
- . = ALIGN(4);
- .config : AT (__config_lma) {
- HIDDEN(__config_start = .);
- *(.config)
- HIDDEN(__config_end = .);
- }
- HIDDEN(__config_len = ABSOLUTE(__config_end) - ABSOLUTE(__config_start));
- HIDDEN(__config_dwords = (__config_len + 3) >> 2);
-
- /* Generated and/or copied code */
-
- . = ALIGN(128); /* Minimum separation from mutable data */
- .replacestub : AT (__replacestub_lma) {
- HIDDEN(__replacestub_start = .);
- *(.replacestub)
- HIDDEN(__replacestub_end = .);
- }
- HIDDEN(__replacestub_len = ABSOLUTE(__replacestub_end) - ABSOLUTE(__replacestub_start));
- HIDDEN(__replacestub_dwords = (__replacestub_len + 3) >> 2);
-
- . = ALIGN(16);
- HIDDEN(__gentextnr_lma = .);
- .gentextnr : AT(__gentextnr_lma) {
- HIDDEN(__gentextnr_start = .);
- *(.gentextnr)
- HIDDEN(__gentextnr_end = .);
- }
- HIDDEN(__gentextnr_len = ABSOLUTE(__gentextnr_end) - ABSOLUTE(__gentextnr_start));
- HIDDEN(__gentextnr_dwords = (__gentextnr_len + 3) >> 2);
-
- . = STACK_BASE;
- .stack16 : AT(STACK_BASE) {
- HIDDEN(__stack16_start = .);
- . += STACK_LEN;
- HIDDEN(__stack16_end = .);
- }
- HIDDEN(__stack16_len = ABSOLUTE(__stack16_end) - ABSOLUTE(__stack16_start));
- HIDDEN(__stack16_dwords = (__stack16_len + 3) >> 2);
-
- /* Initialized sections */
-
- . = 0x7c00;
- .init : {
- FILL(0x90909090)
- HIDDEN(__init_start = .);
- *(.init)
- HIDDEN(__init_end = .);
- }
- HIDDEN(__init_len = ABSOLUTE(__init_end) - ABSOLUTE(__init_start));
- HIDDEN(__init_dwords = (__init_len + 3) >> 2);
-
- .text16 : {
- FILL(0x90909090)
- HIDDEN(__text16_start = .);
- *(.text16)
- HIDDEN(__text16_end = .);
- }
- HIDDEN(__text16_len = ABSOLUTE(__text16_end) - ABSOLUTE(__text16_start));
- HIDDEN(__text16_dwords = (__text16_len + 3) >> 2);
-
- /*
- * .textnr is used for 32-bit code that is used on the code
- * path to initialize the .text segment
- */
- . = ALIGN(16);
- .textnr : {
- FILL(0x90909090)
- HIDDEN(__textnr_start = .);
- *(.textnr)
- HIDDEN(__textnr_end = .);
- }
- HIDDEN(__textnr_len = ABSOLUTE(__textnr_end) - ABSOLUTE(__textnr_start));
- HIDDEN(__textnr_dwords = (__textnr_len + 3) >> 2);
-
- . = ALIGN(16);
- HIDDEN(__bcopyxx_start = .);
-
- .bcopyxx.text : {
- FILL(0x90909090)
- HIDDEN(__bcopyxx_text_start = .);
- *(.bcopyxx.text)
- HIDDEN(__bcopyxx_text_end = .);
- }
- HIDDEN(__bcopyxx_text_len = ABSOLUTE(__bcopyxx_text_end) - ABSOLUTE(__bcopyxx_text_start));
- HIDDEN(__bcopyxx_text_dwords = (__bcopyxx_text_len + 3) >> 2);
-
- .bcopyxx.data : {
- HIDDEN(__bcopyxx_data_start = .);
- *(.bcopyxx.text)
- HIDDEN(__bcopyxx_data_end = .);
- }
- HIDDEN(__bcopyxx_data_len = ABSOLUTE(__bcopyxx_data_end) - ABSOLUTE(__bcopyxx_data_start));
- HIDDEN(__bcopyxx_data_dwords = (__bcopyxx_data_len + 3) >> 2);
-
- HIDDEN(__bcopyxx_end = .);
- HIDDEN(__bcopyxx_len = ABSOLUTE(__bcopyxx_end) - ABSOLUTE(__bcopyxx_start));
- HIDDEN(__bcopyxx_dwords = (__bcopyxx_len + 3) >> 2);
-
- . = ALIGN(4);
- .data16 : {
- HIDDEN(__data16_start = .);
- *(.data16)
- HIDDEN(__data16_end = .);
- }
- HIDDEN(__data16_len = ABSOLUTE(__data16_end) - ABSOLUTE(__data16_start));
- HIDDEN(__data16_dwords = (__data16_len + 3) >> 2);
-
- . = ALIGN(4);
- HIDDEN(__config_lma = .);
- . += SIZEOF(.config);
-
- . = ALIGN(4);
- HIDDEN(__replacestub_lma = .);
- . += SIZEOF(.replacestub);
-
- /* The 32-bit code loads above the non-progbits sections */
-
- . = ALIGN(16);
- HIDDEN(__pm_code_lma = .);
-
- HIDDEN(__high_clear_start = .);
-
- . = ALIGN(512);
- .adv (NOLOAD) : {
- HIDDEN(__adv_start = .);
- *(.adv)
- HIDDEN(__adv_end = .);
- }
- HIDDEN(__adv_len = ABSOLUTE(__adv_end) - ABSOLUTE(__adv_start));
- HIDDEN(__adv_dwords = (__adv_len + 3) >> 2);
-
- /* Late uninitialized sections */
-
- . = ALIGN(4);
- .uibss (NOLOAD) : {
- HIDDEN(__uibss_start = .);
- *(.uibss)
- HIDDEN(__uibss_end = .);
- }
- HIDDEN(__uibss_len = ABSOLUTE(__uibss_end) - ABSOLUTE(__uibss_start));
- HIDDEN(__uibss_dwords = (__uibss_len + 3) >> 2);
-
- HIDDEN(_end16 = .);
- HIDDEN(__assert_end16 = ASSERT(_end16 <= 0x10000, "64K overflow"));
-
- /*
- * Special 16-bit segments
- */
-
- . = ALIGN(65536);
- .real_mode (NOLOAD) : {
- *(.real_mode)
- }
- HIDDEN(real_mode_seg = core_real_mode >> 4);
-
- . = ALIGN(65536);
- .xfer_buf (NOLOAD) : {
- *(.xfer_buf)
- }
- HIDDEN(xfer_buf_seg = core_xfer_buf >> 4);
-
- /*
- * Used to allocate lowmem buffers from 32-bit code
- */
- .lowmem (NOLOAD) : {
- HIDDEN(__lowmem_start = .);
- *(.lowmem)
- HIDDEN(__lowmem_end = .);
- }
- HIDDEN(__lowmem_len = ABSOLUTE(__lowmem_end) - ABSOLUTE(__lowmem_start));
- HIDDEN(__lowmem_dwords = (__lowmem_len + 3) >> 2);
-
- HIDDEN(__high_clear_end = .);
-
- HIDDEN(__high_clear_len = ABSOLUTE(__high_clear_end) - ABSOLUTE(__high_clear_start));
- HIDDEN(__high_clear_dwords = (__high_clear_len + 3) >> 2);
-
- /* Start of the lowmem heap */
- . = ALIGN(16);
- HIDDEN(__lowmem_heap = .);
-
- /*
- * 32-bit code. This is a hack for the moment due to the
- * real-mode segments also allocated.
- */
-
- . = 0x100000;
-
- HIDDEN(__pm_code_start = .);
-
- HIDDEN(__text_vma = .);
- HIDDEN(__text_lma = __pm_code_lma);
- .text : AT(__text_lma) {
- FILL(0x90909090)
- HIDDEN(__text_start = .);
- *(.text)
- *(.text.*)
- HIDDEN(__text_end = .);
- }
-
- . = ALIGN(16);
-
- HIDDEN(__rodata_vma = .);
- HIDDEN(__rodata_lma = __rodata_vma + __text_lma - __text_vma);
- .rodata : AT(__rodata_lma) {
- HIDDEN(__rodata_start = .);
- *(.rodata)
- *(.rodata.*)
- HIDDEN(__rodata_end = .);
- }
-
- . = ALIGN(4);
-
- HIDDEN(__ctors_vma = .);
- HIDDEN(__ctors_lma = __ctors_vma + __text_lma - __text_vma);
- .ctors : AT(__ctors_lma) {
- HIDDEN(__ctors_start = .);
- KEEP (*(SORT(.preinit_array*)))
- KEEP (*(SORT(.init_array*)))
- KEEP (*(SORT(.ctors*)))
- HIDDEN(__ctors_end = .);
- }
-
- HIDDEN(__dtors_vma = .);
- HIDDEN(__dtors_lma = __dtors_vma + __text_lma - __text_vma);
- .dtors : AT(__dtors_lma) {
- HIDDEN(__dtors_start = .);
- KEEP (*(SORT(.fini_array*)))
- KEEP (*(SORT(.dtors*)))
- HIDDEN(__dtors_end = .);
- }
-
- . = ALIGN(4);
-
- HIDDEN(__dynsym_vma = .);
- HIDDEN(__dynsym_lma = __dynsym_vma + __text_lma - __text_vma);
- .dynsym : AT(__dynsym_lma) {
- HIDDEN(__dynsym_start = .);
- *(.dynsym)
- HIDDEN(__dynsym_end = .);
- }
- HIDDEN(__dynsym_len = __dynsym_end - __dynsym_start);
-
- . = ALIGN(4);
-
- HIDDEN(__dynstr_vma = .);
- HIDDEN(__dynstr_lma = __dynstr_vma + __text_lma - __text_vma);
- .dynstr : AT(__dynstr_lma) {
- HIDDEN(__dynstr_start = .);
- *(.dynstr)
- HIDDEN(__dynstr_end = .);
- }
- HIDDEN(__dynstr_len = __dynstr_end - __dynstr_start);
-
- . = ALIGN(4);
-
- HIDDEN(__gnu_hash_vma = .);
- HIDDEN(__gnu_hash_lma = __gnu_hash_vma + __text_lma - __text_vma);
- .gnu.hash : AT(__gnu_hash_lma) {
- HIDDEN(__gnu_hash_start = .);
- *(.gnu.hash)
- HIDDEN(__gnu_hash_end = .);
- }
-
-
- . = ALIGN(4);
-
- HIDDEN(__dynlink_vma = .);
- HIDDEN(__dynlink_lma = __dynlink_vma + __text_lma - __text_vma);
- .dynlink : AT(__dynlink_lma) {
- HIDDEN(__dynlink_start = .);
- *(.dynlink)
- HIDDEN(__dynlink_end = .);
- }
-
- . = ALIGN(4);
-
- HIDDEN(__got_vma = .);
- HIDDEN(__got_lma = __got_vma + __text_lma - __text_vma);
- .got : AT(__got_lma) {
- HIDDEN(__got_start = .);
- KEEP (*(.got.plt))
- KEEP (*(.got))
- HIDDEN(__got_end = .);
- }
-
- . = ALIGN(4);
-
- HIDDEN(__dynamic_vma = .);
- HIDDEN(__dynamic_lma = __dynamic_vma + __text_lma - __text_vma);
- .dynamic : AT(__dynamic_lma) {
- HIDDEN(__dynamic_start = .);
- *(.dynamic)
- HIDDEN(__dynamic_end = .);
- }
-
- . = ALIGN(16);
-
- HIDDEN(__data_vma = .);
- HIDDEN(__data_lma = __data_vma + __text_lma - __text_vma);
- .data : AT(__data_lma) {
- HIDDEN(__data_start = .);
- *(.data)
- *(.data.*)
- HIDDEN(__data_end = .);
- }
-
- HIDDEN(__pm_code_end = .);
- HIDDEN(__pm_code_len = ABSOLUTE(__pm_code_end) - ABSOLUTE(__pm_code_start));
- HIDDEN(__pm_code_dwords = (__pm_code_len + 3) >> 2);
-
- . = ALIGN(128);
-
- HIDDEN(__bss_vma = .);
- HIDDEN(__bss_lma = .); /* Dummy */
- .bss (NOLOAD) : AT (__bss_lma) {
- HIDDEN(__bss_start = .);
- *(.bss)
- *(.bss.*)
- *(COMMON)
- HIDDEN(__bss_end = .);
- }
- HIDDEN(__bss_len = ABSOLUTE(__bss_end) - ABSOLUTE(__bss_start));
- HIDDEN(__bss_dwords = (__bss_len + 3) >> 2);
-
- /* Data saved away before bss initialization */
- . = ALIGN(128);
-
- HIDDEN(__savedata_vma = .);
- HIDDEN(__savedata_lma = .); /* Dummy */
- .savedata (NOLOAD) : AT (__savedata_lma) {
- HIDDEN(__savedata_start = .);
- *(.savedata)
- *(.savedata.*)
- HIDDEN(__savedata_end = .);
- }
- HIDDEN(__savedata_len = ABSOLUTE(__savedata_end) - ABSOLUTE(__savedata_start));
- HIDDEN(__savedata_dwords = (__savedata_len + 3) >> 2);
-
- /* XXX: This stack should be unified with the COM32 stack */
- HIDDEN(__stack_vma = .);
- __stack_lma = .; /* Dummy */
- .stack (NOLOAD) : AT(__stack_lma) {
- HIDDEN(__stack_start = .);
- *(.stack)
- HIDDEN(__stack_end = .);
- }
- HIDDEN(__stack_len = ABSOLUTE(__stack_end) - ABSOLUTE(__stack_start));
- HIDDEN(__stack_dwords = (__stack_len + 3) >> 2);
-
- HIDDEN(_end = .);
-
- /* Heap follows after our own PM code */
- . = ALIGN(65536);
- HIDDEN(free_high_memory = .);
-
- /* Stuff we don't need... */
- /DISCARD/ : {
- *(.eh_frame)
- }
-}
diff --git a/core/thread/schedule.c b/core/thread/schedule.c
index 5a426f1..31a2840 100644
--- a/core/thread/schedule.c
+++ b/core/thread/schedule.c
@@ -4,6 +4,10 @@
#include "core.h"
#include <dprintf.h>
+#ifndef DEBUG_THREAD
+#define dprintf
+#endif
+
void (*sched_hook_func)(void);
/*
diff --git a/core/x86_64/syslinux.ld b/core/x86_64/syslinux.ld
deleted file mode 100644
index 1057112..0000000
--- a/core/x86_64/syslinux.ld
+++ /dev/null
@@ -1,428 +0,0 @@
-/* -----------------------------------------------------------------------
- *
- * Copyright 2008-2009 H. Peter Anvin - All Rights Reserved
- * Copyright 2009 Intel Corporation; author: H. Peter Anvin
- *
- * 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, Inc., 51 Franklin St, Fifth Floor,
- * Boston MA 02110-1301, USA; either version 2 of the License, or
- * (at your option) any later version; incorporated herein by reference.
- *
- * ----------------------------------------------------------------------- */
-
-/*
- * Linker script for the SYSLINUX core
- */
-
-OUTPUT_FORMAT("elf64-x86-64", "elf64-x86-64", "elf64-x86-64")
-OUTPUT_ARCH(i386:x86-64)
-EXTERN(_start)
-ENTRY(_start)
-
-STACK32_LEN = 65536;
-
-SECTIONS
-{
- /* Prefix structure for the compression program */
- . = 0;
- __module_start = .;
- .prefix : {
- *(.prefix)
- }
-
- /* "Early" sections (before the load) */
- . = 0x1000;
-
- .earlybss (NOLOAD) : {
- __earlybss_start = .;
- *(.earlybss)
- __earlybss_end = .;
- }
- __earlybss_len = ABSOLUTE(__earlybss_end) - ABSOLUTE(__earlybss_start);
- __earlybss_dwords = (__earlybss_len + 3) >> 2;
-
- . = ALIGN(4);
- .bss16 (NOLOAD) : {
- __bss16_start = .;
- *(.bss16)
- __bss16_end = .;
- }
- __bss16_len = ABSOLUTE(__bss16_end) - ABSOLUTE(__bss16_start);
- __bss16_dwords = (__bss16_len + 3) >> 2;
-
- . = ALIGN(4);
- .config : AT (__config_lma) {
- __config_start = .;
- *(.config)
- __config_end = .;
- }
- __config_len = ABSOLUTE(__config_end) - ABSOLUTE(__config_start);
- __config_dwords = (__config_len + 3) >> 2;
-
- /* Generated and/or copied code */
-
- . = ALIGN(128); /* Minimum separation from mutable data */
- .replacestub : AT (__replacestub_lma) {
- __replacestub_start = .;
- *(.replacestub)
- __replacestub_end = .;
- }
- __replacestub_len = ABSOLUTE(__replacestub_end) - ABSOLUTE(__replacestub_start);
- __replacestub_dwords = (__replacestub_len + 3) >> 2;
-
- . = ALIGN(16);
- __gentextnr_lma = .;
- .gentextnr : AT(__gentextnr_lma) {
- __gentextnr_start = .;
- *(.gentextnr)
- __gentextnr_end = .;
- }
- __gentextnr_len = ABSOLUTE(__gentextnr_end) - ABSOLUTE(__gentextnr_start);
- __gentextnr_dwords = (__gentextnr_len + 3) >> 2;
-
- . = STACK_BASE;
- .stack16 : AT(STACK_BASE) {
- __stack16_start = .;
- . += STACK_LEN;
- __stack16_end = .;
- }
- __stack16_len = ABSOLUTE(__stack16_end) - ABSOLUTE(__stack16_start);
- __stack16_dwords = (__stack16_len + 3) >> 2;
-
- /* Initialized sections */
-
- . = 0x7c00;
- .init : {
- FILL(0x90909090)
- __init_start = .;
- *(.init)
- __init_end = .;
- }
- __init_len = ABSOLUTE(__init_end) - ABSOLUTE(__init_start);
- __init_dwords = (__init_len + 3) >> 2;
-
- .text16 : {
- FILL(0x90909090)
- __text16_start = .;
- *(.text16)
- __text16_end = .;
- }
- __text16_len = ABSOLUTE(__text16_end) - ABSOLUTE(__text16_start);
- __text16_dwords = (__text16_len + 3) >> 2;
-
- /*
- * .textnr is used for 32-bit code that is used on the code
- * path to initialize the .text segment
- */
- . = ALIGN(16);
- .textnr : {
- FILL(0x90909090)
- __textnr_start = .;
- *(.textnr)
- __textnr_end = .;
- }
- __textnr_len = ABSOLUTE(__textnr_end) - ABSOLUTE(__textnr_start);
- __textnr_dwords = (__textnr_len + 3) >> 2;
-
- . = ALIGN(16);
- __bcopyxx_start = .;
-
- .bcopyxx.text : {
- FILL(0x90909090)
- __bcopyxx_text_start = .;
- *(.bcopyxx.text)
- __bcopyxx_text_end = .;
- }
- __bcopyxx_text_len = ABSOLUTE(__bcopyxx_text_end) - ABSOLUTE(__bcopyxx_text_start);
- __bcopyxx_text_dwords = (__bcopyxx_text_len + 3) >> 2;
-
- .bcopyxx.data : {
- __bcopyxx_data_start = .;
- *(.bcopyxx.text)
- __bcopyxx_data_end = .;
- }
- __bcopyxx_data_len = ABSOLUTE(__bcopyxx_data_end) - ABSOLUTE(__bcopyxx_data_start);
- __bcopyxx_data_dwords = (__bcopyxx_data_len + 3) >> 2;
-
- __bcopyxx_end = .;
- __bcopyxx_len = ABSOLUTE(__bcopyxx_end) - ABSOLUTE(__bcopyxx_start);
- __bcopyxx_dwords = (__bcopyxx_len + 3) >> 2;
-
- . = ALIGN(4);
- .data16 : {
- __data16_start = .;
- *(.data16)
- __data16_end = .;
- }
- __data16_len = ABSOLUTE(__data16_end) - ABSOLUTE(__data16_start);
- __data16_dwords = (__data16_len + 3) >> 2;
-
- . = ALIGN(4);
- __config_lma = .;
- . += SIZEOF(.config);
-
- . = ALIGN(4);
- __replacestub_lma = .;
- . += SIZEOF(.replacestub);
-
- /* The 32-bit code loads above the non-progbits sections */
-
- . = ALIGN(16);
- __pm_code_lma = .;
-
- __high_clear_start = .;
-
- . = ALIGN(512);
- .adv (NOLOAD) : {
- __adv_start = .;
- *(.adv)
- __adv_end = .;
- }
- __adv_len = ABSOLUTE(__adv_end) - ABSOLUTE(__adv_start);
- __adv_dwords = (__adv_len + 3) >> 2;
-
- /* Late uninitialized sections */
-
- . = ALIGN(4);
- .uibss (NOLOAD) : {
- __uibss_start = .;
- *(.uibss)
- __uibss_end = .;
- }
- __uibss_len = ABSOLUTE(__uibss_end) - ABSOLUTE(__uibss_start);
- __uibss_dwords = (__uibss_len + 3) >> 2;
-
- _end16 = .;
- __assert_end16 = ASSERT(_end16 <= 0x10000, "64K overflow");
-
- /*
- * Special 16-bit segments
- */
-
- . = ALIGN(65536);
- .real_mode (NOLOAD) : {
- *(.real_mode)
- }
- real_mode_seg = core_real_mode >> 4;
-
- . = ALIGN(65536);
- .xfer_buf (NOLOAD) : {
- *(.xfer_buf)
- }
- xfer_buf_seg = core_xfer_buf >> 4;
-
- /*
- * The auxilliary data segment is used by the 16-bit code
- * for items that don't need to live in the bottom 64K.
- */
-
- . = ALIGN(16);
- .auxseg (NOLOAD) : {
- __auxseg_start = .;
- *(.auxseg)
- __auxseg_end = .;
- }
- __auxseg_len = ABSOLUTE(__auxseg_end) - ABSOLUTE(__auxseg_start);
- __auxseg_dwords = (__auxseg_len + 3) >> 2;
- aux_seg = __auxseg_start >> 4;
-
- /*
- * Used to allocate lowmem buffers from 32-bit code
- */
- .lowmem (NOLOAD) : {
- __lowmem_start = .;
- *(.lowmem)
- __lowmem_end = .;
- }
- __lowmem_len = ABSOLUTE(__lowmem_end) - ABSOLUTE(__lowmem_start);
- __lowmem_dwords = (__lowmem_len + 3) >> 2;
-
- __high_clear_end = .;
-
- __high_clear_len = ABSOLUTE(__high_clear_end) - ABSOLUTE(__high_clear_start);
- __high_clear_dwords = (__high_clear_len + 3) >> 2;
-
- /* Start of the lowmem heap */
- . = ALIGN(16);
- __lowmem_heap = .;
-
- /*
- * 32-bit code. This is a hack for the moment due to the
- * real-mode segments also allocated.
- */
-
- . = 0x100000;
-
- __pm_code_start = .;
-
- __text_vma = .;
- __text_lma = __pm_code_lma;
- .text : AT(__text_lma) {
- FILL(0x90909090)
- __text_start = .;
- *(.text)
- *(.text.*)
- __text_end = .;
- }
-
- . = ALIGN(16);
-
- __rodata_vma = .;
- __rodata_lma = __rodata_vma + __text_lma - __text_vma;
- .rodata : AT(__rodata_lma) {
- __rodata_start = .;
- *(.rodata)
- *(.rodata.*)
- __rodata_end = .;
- }
-
- . = ALIGN(4);
-
- __ctors_vma = .;
- __ctors_lma = __ctors_vma + __text_lma - __text_vma;
- .ctors : AT(__ctors_lma) {
- __ctors_start = .;
- KEEP (*(SORT(.ctors.*)))
- KEEP (*(.ctors))
- __ctors_end = .;
- }
-
- __dtors_vma = .;
- __dtors_lma = __dtors_vma + __text_lma - __text_vma;
- .dtors : AT(__dtors_lma) {
- __dtors_start = .;
- KEEP (*(SORT(.dtors.*)))
- KEEP (*(.dtors))
- __dtors_end = .;
- }
-
- . = ALIGN(4);
-
- __dynsym_vma = .;
- __dynsym_lma = __dynsym_vma + __text_lma - __text_vma;
- .dynsym : AT(__dynsym_lma) {
- __dynsym_start = .;
- *(.dynsym)
- __dynsym_end = .;
- }
- __dynsym_len = __dynsym_end - __dynsym_start;
-
- . = ALIGN(4);
-
- __dynstr_vma = .;
- __dynstr_lma = __dynstr_vma + __text_lma - __text_vma;
- .dynstr : AT(__dynstr_lma) {
- __dynstr_start = .;
- *(.dynstr)
- __dynstr_end = .;
- }
- __dynstr_len = __dynstr_end - __dynstr_start;
-
- . = ALIGN(4);
-
- __gnu_hash_vma = .;
- __gnu_hash_lma = __gnu_hash_vma + __text_lma - __text_vma;
- .gnu.hash : AT(__gnu_hash_lma) {
- __gnu_hash_start = .;
- *(.gnu.hash)
- __gnu_hash_end = .;
- }
-
-
- . = ALIGN(4);
-
- __dynlink_vma = .;
- __dynlink_lma = __dynlink_vma + __text_lma - __text_vma;
- .dynlink : AT(__dynlink_lma) {
- __dynlink_start = .;
- *(.dynlink)
- __dynlink_end = .;
- }
-
- . = ALIGN(4);
-
- __got_vma = .;
- __got_lma = __got_vma + __text_lma - __text_vma;
- .got : AT(__got_lma) {
- __got_start = .;
- KEEP (*(.got.plt))
- KEEP (*(.got))
- __got_end = .;
- }
-
- . = ALIGN(4);
-
- __dynamic_vma = .;
- __dynamic_lma = __dynamic_vma + __text_lma - __text_vma;
- .dynamic : AT(__dynamic_lma) {
- __dynamic_start = .;
- *(.dynamic)
- __dynamic_end = .;
- }
-
- . = ALIGN(16);
-
- __data_vma = .;
- __data_lma = __data_vma + __text_lma - __text_vma;
- .data : AT(__data_lma) {
- __data_start = .;
- *(.data)
- *(.data.*)
- __data_end = .;
- }
-
- __pm_code_end = .;
- __pm_code_len = ABSOLUTE(__pm_code_end) - ABSOLUTE(__pm_code_start);
- __pm_code_dwords = (__pm_code_len + 3) >> 2;
-
- . = ALIGN(128);
-
- __bss_vma = .;
- __bss_lma = .; /* Dummy */
- .bss (NOLOAD) : AT (__bss_lma) {
- __bss_start = .;
- *(.bss)
- *(.bss.*)
- *(COMMON)
- __bss_end = .;
- }
- __bss_len = ABSOLUTE(__bss_end) - ABSOLUTE(__bss_start);
- __bss_dwords = (__bss_len + 3) >> 2;
-
- /* Very large objects which don't need to be zeroed */
-
- __hugebss_vma = .;
- __hugebss_lma = .; /* Dummy */
- .hugebss (NOLOAD) : AT (__hugebss_lma) {
- __hugebss_start = .;
- *(.hugebss)
- *(.hugebss.*)
- __hugebss_end = .;
- }
- __hugebss_len = ABSOLUTE(__hugebss_end) - ABSOLUTE(__hugebss_start);
- __hugebss_dwords = (__hugebss_len + 3) >> 2;
-
-
- /* XXX: This stack should be unified with the COM32 stack */
- __stack_vma = .;
- __stack_lma = .; /* Dummy */
- .stack (NOLOAD) : AT(__stack_lma) {
- __stack_start = .;
- *(.stack)
- __stack_end = .;
- }
- __stack_len = ABSOLUTE(__stack_end) - ABSOLUTE(__stack_start);
- __stack_dwords = (__stack_len + 3) >> 2;
-
- _end = .;
-
- /* COM32R and kernels are loaded after our own PM code */
- . = ALIGN(65536);
- free_high_memory = .;
-
- /* Stuff we don't need... */
- /DISCARD/ : {
- *(.eh_frame)
- }
-}
diff --git a/diag/geodsp/Makefile b/diag/geodsp/Makefile
index 3fee73d..73e4429 100644
--- a/diag/geodsp/Makefile
+++ b/diag/geodsp/Makefile
@@ -1,6 +1,6 @@
## -----------------------------------------------------------------------
##
-## Copyright 2010-2011 Gene Cumm
+## Copyright 2010-2015 Gene Cumm
##
## Portions from core/Makefile:
## Copyright 1998-2009 H. Peter Anvin - All Rights Reserved
@@ -22,12 +22,13 @@ include $(MAKEDIR)/embedded.mk
coredir = $(topdir)/core
VPATH = $(SRC)
-BTARGET = geodsp1s.bin geodspms.bin \
+BTARGET = geodsp1s.bin geodsp1s_f.bin geodspms.bin \
geodsp1s.img.xz geodspms.img.xz
NASMOPT = -i $(coredir)/ -i $(SRC)/ -Ox -f bin -dBINFMT
NASMOPT += -w+orphan-labels
CFLAGS = -g -O
+LIBS = $(coredir)/writehex.inc $(coredir)/macros.inc $(coredir)/diskboot.inc geodsplib.inc
all: $(BTARGET)
@@ -42,9 +43,12 @@ all: $(BTARGET)
%.img: %.bin mk-lba-img.pl
$(PERL) $(SRC)/mk-lba-img.pl $< > $@ || ( rm -f $@ ; false )
-%.bin: %.asm $(coredir)/writehex.inc $(coredir)/macros.inc $(coredir)/diskboot.inc
+%.bin: %.asm $(LIBS)
$(NASM) $(NASMOPT) -o $@ -l $(@:.bin=.lst) $<
+%_f.bin: %.asm $(LIBS)
+ $(NASM) $(NASMOPT) -o $@ -dFORCE_80 -l $(@:.bin=.lst) $<
+
mk-lba-img: mk-lba-img.c
$(CC) $(CFLAGS) -o $@ $<
diff --git a/diag/geodsp/README b/diag/geodsp/README
index 9129b69..4539106 100644
--- a/diag/geodsp/README
+++ b/diag/geodsp/README
@@ -27,3 +27,27 @@ majority of the BIOS parameter block).
dd bs=1 skip=3 count=87 if=/dev/fd0 of=fd0.bpb
dd conv=notrunc if=geodspms.img of=/dev/fd0
dd conv=notrunc bs=1 seek=3 count=87 if=fd0.bpb of=/dev/fd0
+
+
+Sample output:
+
+ CHS 0081,FE,3F
+ @CHS 0000,01,01:0000003F
+ @CHS 0001,00,01:00003EC1
+ @EDD 0000003F:0000003E
+ @EDD 00003EC1:00003EC1
+ D=EDD
+ end
+
+The first line is the interpreted geometry per INT 13h AH=08h,DI=00h (in
+hex). The second line is the data value at the sector CHS 0,1,1
+(indicating effective sectors per track). The third line is the data
+value at CHS 1,0,1 (indicating effective heads per head count). The
+fourth line indicates the value read at LBA 63. The fifth line
+indicates the value read at LBA 16065. The sixth line indicates the
+final expected mode.
+
+Images created by the Perl variant up to and including 6.03 are off by
+one and shifted by one byte. In the above, the second line might read
+"00003E00" instead of "0000003F".
+
diff --git a/diag/geodsp/geodsp1s.asm b/diag/geodsp/geodsp1s.asm
index 4ea84c4..50d97e7 100644
--- a/diag/geodsp/geodsp1s.asm
+++ b/diag/geodsp/geodsp1s.asm
@@ -1,6 +1,6 @@
; -----------------------------------------------------------------------
;
-; Copyright 2010 Gene Cumm
+; Copyright 2010-2015 Gene Cumm
;
; Portions from diskstart.inc:
; Copyright 1994-2009 H. Peter Anvin - All Rights Reserved
@@ -55,7 +55,14 @@ retry_count equ 16
dbuf equ 8000h
int13_ret equ 7e00h
-
+; Uncomment to test EDD
+%define TEST_EDD 1
+; Uncomment to show errors (while it still continues)
+%define SHOW_ERR 1
+; Uncomment to have room for a partition table
+%define HAVE_PTABLE 1
+; Uncomment to force DL == 80h
+; %define FORCE_80 1
; extern real_mode_seg
; section .real_mode write nobits align=65536
@@ -82,24 +89,43 @@ start:
xor cx,cx
mov ss,cx
mov sp,StackBuf-2 ; Just below BSS (-2 for alignment)
+%ifdef FORCE_80
+ mov dl,80h ; Should encode as B2h 80h
+%else
+ nop ; Reserve the space for forcing DL
+ nop ; Should encode as 90h 90h
+%endif ; FORCE_80
push dx ; Save drive number (in DL)
; Kill everything else and let the BIOS sort it out later
mov es,cx
mov ds,cx
sti
+; clc ; just in case it's not clear
+
+write_drivenum:
+; mov al,[DriveNumber]
+ mov al,dl
+ call writehex2
get_geo: ; DL and ES ready
mov ah,08h
mov di,0
int 13h
write_geo:
- jc .bad_geo
+ jnc .ok_geo
+%ifdef SHOW_ERR
+ mov al,'!'
+ call writechr
+%endif ; SHOW_ERR
+ clc
+.ok_geo:
mov si,s_chs
call writestr_early
call write_chs
- call crlf
- jmp short .done
-.bad_geo:
+ mov si,s_crlf
+ call writestr_early
+; jmp short .done
+; .bad_geo:
.done:
mov bx,dbuf
@@ -117,8 +143,9 @@ get_c1c: ; 1,0,1
;
; Do we have EBIOS (EDD)?
;
-edd:
-.check:
+%ifdef TEST_EDD
+ edd:
+ .check:
mov bx,55AAh
mov ah,41h ; EDD existence query
mov dl,[DriveNumber]
@@ -134,21 +161,22 @@ edd:
mov bx,dbuf
xor edx,edx
mov dword [s_chs],m_EDD_SP
-.get_lba63:
+ .get_lba63:
mov eax,63 ; Same length as mov al,64; movzx eax,al
call getonesec_ebios
jc .bad_edd ;read error
call write_edd_lba
-.get_lba16065:
+ .get_lba16065:
mov eax,16065
call getonesec_ebios
jc .bad_edd ;read error
call write_edd_lba
-.good_edd:
+ .good_edd:
mov dword [s_type],m_EDD0
-.bad_edd:
-.noedd:
-.end:
+ .bad_edd:
+ .noedd:
+ .end:
+%endif ; TEST_EDD
write_final_type:
mov si,s_typespec
@@ -161,9 +189,10 @@ write_final_type:
;
; getonesec implementation for EBIOS (EDD)
;
-getonesec_ebios:
+%ifdef TEST_EDD
+ getonesec_ebios:
mov cx,retry_count
-.retry:
+ .retry:
; Form DAPA on stack
push edx
push eax
@@ -180,7 +209,7 @@ getonesec_ebios:
jc .error
ret
-.error:
+ .error:
; Some systems seem to get "stuck" in an error state when
; using EBIOS. Doesn't happen when using CBIOS, which is
; good, since some other systems get timeout failures
@@ -195,6 +224,7 @@ getonesec_ebios:
; Total failure.
stc
ret
+%endif ; TEST_EDD
;
; getonesec_chs:
@@ -208,7 +238,13 @@ getonesec_chs: ; We could use an xchg and get a loop
mov ax,0201h ; Read one sector
call xint13
popad
- jc .error
+ jnc .no_error
+%ifdef SHOW_ERR
+ mov al,'!'
+ call writechr
+%endif ; SHOW_ERR
+ clc
+.no_error:
ret
.error:
@@ -217,8 +253,8 @@