summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@linux.intel.com>2010-07-01 14:26:36 -0700
committerH. Peter Anvin <hpa@linux.intel.com>2010-07-01 14:26:36 -0700
commitd5872766e499376994c7a56a1c4c9e8fcc6c874c (patch)
treecba1a7ca12a3eecc31027b88b325541d0829df94
parentf06f55139583f1d0022e78805df6d23fa72ae7d0 (diff)
parent55574c609a2f5ca69e98e5ec57eb909190d12061 (diff)
downloadsyslinux-d5872766e499376994c7a56a1c4c9e8fcc6c874c.tar.gz
syslinux-d5872766e499376994c7a56a1c4c9e8fcc6c874c.tar.xz
syslinux-d5872766e499376994c7a56a1c4c9e8fcc6c874c.zip
Merge branch 'master' into lua
Resolved Conflicts: com32/Makefile Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
-rw-r--r--.gitignore6
-rw-r--r--BUGS4
-rw-r--r--MCONFIG32
-rw-r--r--MCONFIG.build33
-rw-r--r--MCONFIG.devel2
-rw-r--r--MCONFIG.embedded38
-rw-r--r--Makefile33
-rw-r--r--Makefile.private4
-rw-r--r--NEWS258
-rw-r--r--README2
-rw-r--r--TODO22
-rwxr-xr-xcodepage/cptable.pl45
-rw-r--r--com32/LICENCE5
-rw-r--r--com32/MCONFIG68
-rw-r--r--com32/Makefile3
-rw-r--r--com32/cmenu/.gitignore2
-rw-r--r--com32/cmenu/CHANGES (renamed from menu/CHANGES)0
-rw-r--r--com32/cmenu/HISTORY (renamed from menu/HISTORY)0
-rw-r--r--com32/cmenu/MANUAL (renamed from menu/MANUAL)0
-rw-r--r--com32/cmenu/MENU_FORMAT (renamed from menu/MENU_FORMAT)0
-rw-r--r--com32/cmenu/Makefile (renamed from menu/Makefile)32
-rw-r--r--com32/cmenu/README (renamed from menu/README)0
-rw-r--r--com32/cmenu/TODO (renamed from menu/TODO)0
-rw-r--r--com32/cmenu/adv_menu.tpl (renamed from menu/adv_menu.tpl)49
-rw-r--r--com32/cmenu/complex.c450
-rw-r--r--com32/cmenu/display.c (renamed from menu/display.c)17
-rw-r--r--com32/cmenu/libmenu/com32io.c83
-rw-r--r--com32/cmenu/libmenu/com32io.h68
-rw-r--r--com32/cmenu/libmenu/des.c1064
-rw-r--r--com32/cmenu/libmenu/des.h8
-rw-r--r--com32/cmenu/libmenu/help.c232
-rw-r--r--com32/cmenu/libmenu/help.h (renamed from menu/libmenu/help.h)8
-rw-r--r--com32/cmenu/libmenu/menu.c1273
-rw-r--r--com32/cmenu/libmenu/menu.h294
-rw-r--r--com32/cmenu/libmenu/passwords.c159
-rw-r--r--com32/cmenu/libmenu/passwords.h27
-rw-r--r--com32/cmenu/libmenu/syslnx.c95
-rw-r--r--com32/cmenu/libmenu/syslnx.h (renamed from menu/libmenu/syslnx.h)8
-rw-r--r--com32/cmenu/libmenu/tui.c258
-rw-r--r--com32/cmenu/libmenu/tui.h (renamed from menu/libmenu/tui.h)67
-rw-r--r--com32/cmenu/menugen.py (renamed from menu/menugen.py)0
-rw-r--r--com32/cmenu/password (renamed from menu/password)0
-rw-r--r--com32/cmenu/simple.c82
-rw-r--r--com32/cmenu/test.menu (renamed from menu/test.menu)0
-rw-r--r--com32/cmenu/test2.menu (renamed from menu/test2.menu)0
-rw-r--r--com32/gdbstub/Makefile2
-rw-r--r--com32/gdbstub/gdbstub.c814
-rw-r--r--com32/gdbstub/main.c56
-rw-r--r--com32/gdbstub/serial.c165
-rw-r--r--com32/gdbstub/serial.h6
-rw-r--r--com32/gfxboot/.gitignore1
-rw-r--r--com32/gfxboot/Makefile44
-rw-r--r--com32/gfxboot/gfxboot.c938
-rw-r--r--com32/gfxboot/realmode_callback.asm190
-rw-r--r--com32/gplinclude/README1
-rw-r--r--com32/gplinclude/cpuid.h269
-rw-r--r--com32/gplinclude/disk/bootloaders.h19
-rw-r--r--com32/gplinclude/disk/common.h33
-rw-r--r--com32/gplinclude/disk/errno_disk.h50
-rw-r--r--com32/gplinclude/disk/error.h13
-rw-r--r--com32/gplinclude/disk/geom.h326
-rw-r--r--com32/gplinclude/disk/mbrs.h18
-rw-r--r--com32/gplinclude/disk/msdos.h19
-rw-r--r--com32/gplinclude/disk/partition.h37
-rw-r--r--com32/gplinclude/disk/read.h18
-rw-r--r--com32/gplinclude/disk/swsusp.h19
-rw-r--r--com32/gplinclude/disk/util.h21
-rw-r--r--com32/gplinclude/disk/write.h26
-rw-r--r--com32/gplinclude/dmi/dmi.h98
-rw-r--r--com32/gplinclude/dmi/dmi_base_board.h (renamed from com32/include/dmi/dmi_base_board.h)43
-rw-r--r--com32/gplinclude/dmi/dmi_battery.h57
-rw-r--r--com32/gplinclude/dmi/dmi_bios.h107
-rw-r--r--com32/gplinclude/dmi/dmi_cache.h47
-rw-r--r--com32/gplinclude/dmi/dmi_chassis.h50
-rw-r--r--com32/gplinclude/dmi/dmi_ipmi.h33
-rw-r--r--com32/gplinclude/dmi/dmi_memory.h77
-rw-r--r--com32/gplinclude/dmi/dmi_processor.h112
-rw-r--r--com32/gplinclude/dmi/dmi_system.h (renamed from com32/include/dmi/dmi_system.h)35
-rw-r--r--com32/gplinclude/memory.h53
-rw-r--r--com32/gplinclude/vpd/vpd.h33
-rw-r--r--com32/gpllib/Makefile44
-rw-r--r--com32/gpllib/cpuid.c456
-rw-r--r--com32/gpllib/disk/ata.c62
-rw-r--r--com32/gpllib/disk/bootloaders.c46
-rw-r--r--com32/gpllib/disk/errno_disk.c12
-rw-r--r--com32/gpllib/disk/error.c23
-rw-r--r--com32/gpllib/disk/geom.c271
-rw-r--r--com32/gpllib/disk/labels.c654
-rw-r--r--com32/gpllib/disk/mbrs.c127
-rw-r--r--com32/gpllib/disk/msdos.c162
-rw-r--r--com32/gpllib/disk/read.c135
-rw-r--r--com32/gpllib/disk/swsusp.c27
-rw-r--r--com32/gpllib/disk/util.c45
-rw-r--r--com32/gpllib/disk/write.c126
-rw-r--r--com32/gpllib/dmi/dmi.c1002
-rw-r--r--com32/gpllib/dmi/dmi_base_board.c37
-rw-r--r--com32/gpllib/dmi/dmi_battery.c72
-rw-r--r--com32/gpllib/dmi/dmi_bios.c79
-rw-r--r--com32/gpllib/dmi/dmi_cache.c134
-rw-r--r--com32/gpllib/dmi/dmi_chassis.c113
-rw-r--r--com32/gpllib/dmi/dmi_ipmi.c55
-rw-r--r--com32/gpllib/dmi/dmi_memory.c259
-rw-r--r--com32/gpllib/dmi/dmi_processor.c429
-rw-r--r--com32/gpllib/memory.c445
-rw-r--r--com32/gpllib/vpd/vpd.c103
-rw-r--r--com32/hdt/Makefile126
-rw-r--r--com32/hdt/README19
-rw-r--r--com32/hdt/art/backgnd.pngbin0 -> 10155 bytes
-rw-r--r--com32/hdt/art/hdt-black.pngbin0 -> 52537 bytes
-rw-r--r--com32/hdt/art/hdt.pngbin0 -> 19732 bytes
-rw-r--r--com32/hdt/floppy/hdt.cfg78
-rw-r--r--com32/hdt/floppy/mtools.conf2
-rw-r--r--com32/hdt/hdt-ata.c38
-rw-r--r--com32/hdt/hdt-ata.h76
-rw-r--r--com32/hdt/hdt-cli-cpu.c227
-rw-r--r--com32/hdt/hdt-cli-disk.c253
-rw-r--r--com32/hdt/hdt-cli-dmi.c688
-rw-r--r--com32/hdt/hdt-cli-hdt.c375
-rw-r--r--com32/hdt/hdt-cli-kernel.c155
-rw-r--r--com32/hdt/hdt-cli-memory.c134
-rw-r--r--com32/hdt/hdt-cli-pci.c318
-rw-r--r--com32/hdt/hdt-cli-pxe.c98
-rw-r--r--com32/hdt/hdt-cli-syslinux.c62
-rw-r--r--com32/hdt/hdt-cli-vesa.c142
-rw-r--r--com32/hdt/hdt-cli-vpd.c81
-rw-r--r--com32/hdt/hdt-cli.c1121
-rw-r--r--com32/hdt/hdt-cli.h210
-rw-r--r--com32/hdt/hdt-common.c666
-rw-r--r--com32/hdt/hdt-common.h226
-rw-r--r--com32/hdt/hdt-menu-about.c87
-rw-r--r--com32/hdt/hdt-menu-disk.c264
-rw-r--r--com32/hdt/hdt-menu-dmi.c381
-rw-r--r--com32/hdt/hdt-menu-kernel.c87
-rw-r--r--com32/hdt/hdt-menu-memory.c382
-rw-r--r--com32/hdt/hdt-menu-pci.c203
-rw-r--r--com32/hdt/hdt-menu-processor.c287
-rw-r--r--com32/hdt/hdt-menu-pxe.c125
-rw-r--r--com32/hdt/hdt-menu-summary.c195
-rw-r--r--com32/hdt/hdt-menu-syslinux.c82
-rw-r--r--com32/hdt/hdt-menu-vesa.c129
-rw-r--r--com32/hdt/hdt-menu-vpd.c114
-rw-r--r--com32/hdt/hdt-menu.c337
-rw-r--r--com32/hdt/hdt-menu.h135
-rw-r--r--com32/hdt/hdt-util.c93
-rw-r--r--com32/hdt/hdt-util.h34
-rw-r--r--com32/hdt/hdt.c86
-rw-r--r--com32/hdt/hdt.h47
-rw-r--r--com32/include/alloca.h2
-rw-r--r--com32/include/bitsize/stddef.h2
-rw-r--r--com32/include/bitsize/stdint.h28
-rw-r--r--com32/include/colortbl.h18
-rw-r--r--com32/include/com32.h138
-rw-r--r--com32/include/console.h4
-rw-r--r--com32/include/cpufeature.h178
-rw-r--r--com32/include/cpuid.h222
-rw-r--r--com32/include/ctype.h50
-rw-r--r--com32/include/dev.h5
-rw-r--r--com32/include/dirent.h20
-rw-r--r--com32/include/dmi/dmi.h80
-rw-r--r--com32/include/dmi/dmi_bios.h148
-rw-r--r--com32/include/dmi/dmi_chassis.h123
-rw-r--r--com32/include/dmi/dmi_processor.h482
-rw-r--r--com32/include/dprintf.h22
-rw-r--r--com32/include/elf.h2
-rw-r--r--com32/include/endian.h2
-rw-r--r--com32/include/ilog2.h48
-rw-r--r--com32/include/inttypes.h2
-rw-r--r--com32/include/klibc/archsetjmp.h12
-rw-r--r--com32/include/klibc/compiler.h4
-rw-r--r--com32/include/klibc/diverr.h2
-rw-r--r--com32/include/klibc/endian.h2
-rw-r--r--com32/include/libansi.h103
-rw-r--r--com32/include/netinet/in.h49
-rw-r--r--com32/include/stdbool.h2
-rw-r--r--com32/include/stdint.h56
-rw-r--r--com32/include/stdio.h23
-rw-r--r--com32/include/stdlib.h41
-rw-r--r--com32/include/sys/cpu.h136
-rw-r--r--com32/include/sys/dirent.h45
-rw-r--r--com32/include/sys/elf32.h104
-rw-r--r--com32/include/sys/elf64.h104
-rw-r--r--com32/include/sys/elfcommon.h2
-rw-r--r--com32/include/sys/gpxe.h16
-rw-r--r--com32/include/sys/io.h24
-rw-r--r--com32/include/sys/pci.h124
-rw-r--r--com32/include/sys/stat.h4
-rw-r--r--com32/include/sys/times.h2
-rw-r--r--com32/include/sys/types.h6
-rw-r--r--com32/include/syslinux/adv.h4
-rw-r--r--com32/include/syslinux/advconst.h2
-rw-r--r--com32/include/syslinux/align.h48
-rw-r--r--com32/include/syslinux/boot.h2
-rw-r--r--com32/include/syslinux/bootpm.h24
-rw-r--r--com32/include/syslinux/bootrm.h39
-rw-r--r--com32/include/syslinux/config.h194
-rw-r--r--com32/include/syslinux/features.h16
-rw-r--r--com32/include/syslinux/idle.h1
-rw-r--r--com32/include/syslinux/keyboard.h51
-rw-r--r--com32/include/syslinux/linux.h18
-rw-r--r--com32/include/syslinux/memscan.h38
-rw-r--r--com32/include/syslinux/movebits.h47
-rw-r--r--com32/include/syslinux/pmapi.h75
-rw-r--r--com32/include/syslinux/pxe.h494
-rw-r--r--com32/include/syslinux/pxe_api.h571
-rw-r--r--com32/include/syslinux/vesacon.h4
-rw-r--r--com32/include/syslinux/video.h4
-rw-r--r--com32/include/unistd.h3
-rw-r--r--com32/include/zconf.h55
-rw-r--r--com32/lib/MCONFIG45
-rw-r--r--com32/lib/Makefile78
-rw-r--r--com32/lib/abort.c2
-rw-r--r--com32/lib/asprintf.c28
-rw-r--r--com32/lib/atexit.c4
-rw-r--r--com32/lib/atexit.h6
-rw-r--r--com32/lib/atox.c4
-rw-r--r--com32/lib/calloc.c2
-rw-r--r--com32/lib/chdir.c15
-rw-r--r--com32/lib/com32.ld68
-rw-r--r--com32/lib/creat.c2
-rw-r--r--com32/lib/ctypes.c514
-rw-r--r--com32/lib/dprintf.c19
-rw-r--r--com32/lib/exit.c4
-rw-r--r--com32/lib/fclose.c4
-rw-r--r--com32/lib/fdopendir.c15
-rw-r--r--com32/lib/fgetc.c6
-rw-r--r--com32/lib/fgets.c32
-rw-r--r--com32/lib/fopen.c54
-rw-r--r--com32/lib/fopendev.c56
-rw-r--r--com32/lib/fprintf.c16
-rw-r--r--com32/lib/fputc.c6
-rw-r--r--com32/lib/fputs.c4
-rw-r--r--com32/lib/fread.c38
-rw-r--r--com32/lib/fread2.c4
-rw-r--r--com32/lib/free.c129
-rw-r--r--com32/lib/fwrite.c38
-rw-r--r--com32/lib/fwrite2.c4
-rw-r--r--com32/lib/getcwd.c11
-rw-r--r--com32/lib/getopt.c88
-rw-r--r--com32/lib/jpeg/bgr24.c135
-rw-r--r--com32/lib/jpeg/bgra32.c158
-rw-r--r--com32/lib/jpeg/grey.c87
-rw-r--r--com32/lib/jpeg/jidctflt.c22
-rw-r--r--com32/lib/jpeg/rgb24.c135
-rw-r--r--com32/lib/jpeg/rgba32.c155
-rw-r--r--com32/lib/jpeg/tinyjpeg-internal.h45
-rw-r--r--com32/lib/jpeg/tinyjpeg.c243
-rw-r--r--com32/lib/jpeg/yuv420p.c133
-rw-r--r--com32/lib/libgcc/__divdi3.c30
-rw-r--r--com32/lib/libgcc/__moddi3.c30
-rw-r--r--com32/lib/libgcc/__udivdi3.c4
-rw-r--r--com32/lib/libgcc/__udivmoddi4.c42
-rw-r--r--com32/lib/libgcc/__umoddi3.c8
-rw-r--r--com32/lib/lmalloc.c57
-rw-r--r--com32/lib/lrand48.c25
-rw-r--r--com32/lib/lstrdup.c18
-rw-r--r--com32/lib/malloc.c192
-rw-r--r--com32/lib/malloc.h11
-rw-r--r--com32/lib/math/strtod.c199
-rw-r--r--com32/lib/memccpy.c18
-rw-r--r--com32/lib/memchr.c12
-rw-r--r--com32/lib/memcmp.c16
-rw-r--r--com32/lib/memcpy.S2
-rw-r--r--com32/lib/memmem.c44
-rw-r--r--com32/lib/memmove.S37
-rw-r--r--com32/lib/mempcpy.S2
-rw-r--r--com32/lib/memset.S2
-rw-r--r--com32/lib/memswap.c19
-rw-r--r--com32/lib/onexit.c32
-rw-r--r--com32/lib/pci/bios.c17
-rw-r--r--com32/lib/pci/cfgtype.c120
-rw-r--r--com32/lib/pci/pci.h3
-rw-r--r--com32/lib/pci/readbios.c15
-rw-r--r--com32/lib/pci/readx.c91
-rw-r--r--com32/lib/pci/scan.c833
-rw-r--r--com32/lib/pci/writebios.c14
-rw-r--r--com32/lib/pci/writex.c78
-rw-r--r--com32/lib/perror.c2
-rw-r--r--com32/lib/printf.c14
-rw-r--r--com32/lib/putchar.c4
-rw-r--r--com32/lib/puts.c6
-rw-r--r--com32/lib/qsort.c49
-rw-r--r--com32/lib/realloc.c144
-rw-r--r--com32/lib/seed48.c8
-rw-r--r--com32/lib/setjmp.S2
-rw-r--r--com32/lib/snprintf.c12
-rw-r--r--com32/lib/sprintf.c12
-rw-r--r--com32/lib/srand48.c7
-rw-r--r--com32/lib/sscanf.c12
-rw-r--r--com32/lib/stpcpy.c20
-rw-r--r--com32/lib/stpncpy.c20
-rw-r--r--com32/lib/strcasecmp.c23
-rw-r--r--com32/lib/strcat.c4
-rw-r--r--com32/lib/strchr.c12
-rw-r--r--com32/lib/strcmp.c19
-rw-r--r--com32/lib/strcpy.c14
-rw-r--r--com32/lib/strdup.c10
-rw-r--r--com32/lib/strerror.c20
-rw-r--r--com32/lib/strlcat.c30
-rw-r--r--com32/lib/strlcpy.c22
-rw-r--r--com32/lib/strlen.c8
-rw-r--r--com32/lib/strncasecmp.c23
-rw-r--r--com32/lib/strncat.c4
-rw-r--r--com32/lib/strncmp.c19
-rw-r--r--com32/lib/strncpy.c18
-rw-r--r--com32/lib/strndup.c12
-rw-r--r--com32/lib/strnlen.c8
-rw-r--r--com32/lib/strntoimax.c2
-rw-r--r--com32/lib/strntoumax.c100
-rw-r--r--com32/lib/strrchr.c14
-rw-r--r--com32/lib/strsep.c18
-rw-r--r--com32/lib/strspn.c56
-rw-r--r--com32/lib/strstr.c2
-rw-r--r--com32/lib/strtok.c8
-rw-r--r--com32/lib/strtox.c4
-rw-r--r--com32/lib/sys/ansi.c725
-rw-r--r--com32/lib/sys/ansi.h70
-rw-r--r--com32/lib/sys/ansicon_write.c264
-rw-r--r--com32/lib/sys/ansiserial_write.c19
-rw-r--r--com32/lib/sys/argv.c95
-rw-r--r--com32/lib/sys/cfarcall.c5
-rw-r--r--com32/lib/sys/close.c38
-rw-r--r--com32/lib/sys/colortable.c6
-rw-r--r--com32/lib/sys/entry.S60
-rw-r--r--com32/lib/sys/err_read.c18
-rw-r--r--com32/lib/sys/err_write.c18
-rw-r--r--com32/lib/sys/farcall.c17
-rw-r--r--com32/lib/sys/file.h66
-rw-r--r--com32/lib/sys/fileclose.c13
-rw-r--r--com32/lib/sys/fileread.c87
-rw-r--r--com32/lib/sys/fstat.c36
-rw-r--r--com32/lib/sys/ftell.c8
-rw-r--r--com32/lib/sys/gpxe.c50
-rw-r--r--com32/lib/sys/intcall.c4
-rw-r--r--com32/lib/sys/isatty.c14
-rw-r--r--com32/lib/sys/libansi.c247
-rw-r--r--com32/lib/sys/line_input.c84
-rw-r--r--com32/lib/sys/null_read.c16
-rw-r--r--com32/lib/sys/null_write.c16
-rw-r--r--com32/lib/sys/open.c55
-rw-r--r--com32/lib/sys/openconsole.c20
-rw-r--r--com32/lib/sys/opendev.c88
-rw-r--r--com32/lib/sys/openmem.c61
-rw-r--r--com32/lib/sys/rawcon_read.c52
-rw-r--r--com32/lib/sys/rawcon_write.c37
-rw-r--r--com32/lib/sys/read.c12
-rw-r--r--com32/lib/sys/readdir.c30
-rw-r--r--com32/lib/sys/screensize.c24
-rw-r--r--com32/lib/sys/serial_write.c40
-rw-r--r--com32/lib/sys/stdcon_read.c49
-rw-r--r--com32/lib/sys/stdcon_write.c62
-rw-r--r--com32/lib/sys/times.c8
-rw-r--r--com32/lib/sys/vesa/background.c583
-rw-r--r--com32/lib/sys/vesa/debug.h20
-rw-r--r--com32/lib/sys/vesa/drawtxt.c408
-rw-r--r--com32/lib/sys/vesa/fill.h47
-rw-r--r--com32/lib/sys/vesa/fmtpixel.c79
-rw-r--r--com32/lib/sys/vesa/i915resolution.c795
-rw-r--r--com32/lib/sys/vesa/initvesa.c486
-rw-r--r--com32/lib/sys/vesa/screencpy.c135
-rw-r--r--com32/lib/sys/vesa/vesa.h101
-rw-r--r--com32/lib/sys/vesa/video.h46
-rw-r--r--com32/lib/sys/vesacon_write.c156
-rw-r--r--com32/lib/sys/vesaserial_write.c23
-rw-r--r--com32/lib/sys/write.c12
-rw-r--r--com32/lib/sys/x86_init_fpu.c42
-rw-r--r--com32/lib/sys/xserial_write.c116
-rw-r--r--com32/lib/sys/zfile.c174
-rw-r--r--com32/lib/sys/zfopen.c54
-rw-r--r--com32/lib/syslinux/addlist.c20
-rw-r--r--com32/lib/syslinux/adv.c10
-rw-r--r--com32/lib/syslinux/advwrite.c8
-rw-r--r--com32/lib/syslinux/cleanup.c8
-rw-r--r--com32/lib/syslinux/config.c8
-rw-r--r--com32/lib/syslinux/dsinfo.c18
-rw-r--r--com32/lib/syslinux/dump_mmap.c17
-rw-r--r--com32/lib/syslinux/dump_movelist.c15
-rw-r--r--com32/lib/syslinux/features.c12
-rw-r--r--com32/lib/syslinux/floadfile.c114
-rw-r--r--com32/lib/syslinux/freelist.c12
-rw-r--r--com32/lib/syslinux/getadv.c42
-rw-r--r--com32/lib/syslinux/idle.c24
-rw-r--r--com32/lib/syslinux/initramfs.c48
-rw-r--r--com32/lib/syslinux/initramfs_archive.c10
-rw-r--r--com32/lib/syslinux/initramfs_file.c164
-rw-r--r--com32/lib/syslinux/initramfs_loadfile.c12
-rw-r--r--com32/lib/syslinux/ipappend.c24
-rw-r--r--com32/lib/syslinux/keyboard.c44
-rw-r--r--com32/lib/syslinux/load_linux.c644
-rw-r--r--com32/lib/syslinux/loadfile.c24
-rw-r--r--com32/lib/syslinux/localboot.c8
-rw-r--r--com32/lib/syslinux/memmap.c133
-rw-r--r--com32/lib/syslinux/memscan.c158
-rw-r--r--com32/lib/syslinux/movebits.c946
-rw-r--r--com32/lib/syslinux/pxe_dns.c75
-rw-r--r--com32/lib/syslinux/pxe_get_cached.c69
-rw-r--r--com32/lib/syslinux/pxe_get_nic.c67
-rw-r--r--com32/lib/syslinux/reboot.c10
-rw-r--r--com32/lib/syslinux/run_command.c23
-rw-r--r--com32/lib/syslinux/run_default.c10
-rw-r--r--com32/lib/syslinux/runimage.c41
-rw-r--r--com32/lib/syslinux/serial.c14
-rw-r--r--com32/lib/syslinux/setadv.c114
-rw-r--r--com32/lib/syslinux/shuffle.c346
-rw-r--r--com32/lib/syslinux/shuffle_pm.c56
-rw-r--r--com32/lib/syslinux/shuffle_rm.c144
-rw-r--r--com32/lib/syslinux/version.c16
-rw-r--r--com32/lib/syslinux/video/fontquery.c54
-rw-r--r--com32/lib/syslinux/video/forcetext.c42
-rw-r--r--com32/lib/syslinux/video/reportmode.c45
-rw-r--r--com32/lib/syslinux/zloadfile.c18
-rw-r--r--com32/lib/syslinux/zonelist.c328
-rw-r--r--com32/lib/vasprintf.c20
-rw-r--r--com32/lib/vdprintf.c111
-rw-r--r--com32/lib/vfprintf.c18
-rw-r--r--com32/lib/vprintf.c2
-rw-r--r--com32/lib/vsnprintf.c785
-rw-r--r--com32/lib/vsprintf.c2
-rw-r--r--com32/lib/vsscanf.c615
-rw-r--r--com32/lib/zalloc.c10
-rw-r--r--com32/lib/zlib/crc32.c2
-rw-r--r--com32/lib/zlib/example.c566
-rw-r--r--com32/lib/zlib/gzio.c1017
-rw-r--r--com32/lib/zlib/minigzip.c322
-rw-r--r--com32/libutil/Makefile2
-rw-r--r--com32/libutil/ansiline.c45
-rw-r--r--com32/libutil/ansiraw.c49
-rw-r--r--com32/libutil/base64.c131
-rw-r--r--com32/libutil/crypt-md5.c247
-rw-r--r--com32/libutil/get_key.c227
-rw-r--r--com32/libutil/include/base64.h4
-rw-r--r--com32/libutil/include/md5.h8
-rw-r--r--com32/libutil/include/sha1.h8
-rw-r--r--com32/libutil/include/xcrypt.h4
-rw-r--r--com32/libutil/md5.c279
-rw-r--r--com32/libutil/sha1hash.c288
-rw-r--r--com32/libutil/sha256crypt.c1037
-rw-r--r--com32/libutil/sha512crypt.c1185
-rw-r--r--com32/libutil/unbase64.c59
-rw-r--r--com32/mboot/Makefile46
-rw-r--r--com32/mboot/apm.c86
-rw-r--r--com32/mboot/initvesa.c226
-rw-r--r--com32/mboot/map.c353
-rw-r--r--com32/mboot/mb_header.h (renamed from com32/modules/mb_header.h)68
-rw-r--r--com32/mboot/mb_info.h (renamed from com32/modules/mb_info.h)216
-rw-r--r--com32/mboot/mboot.c247
-rw-r--r--com32/mboot/mboot.h98
-rw-r--r--com32/mboot/mem.c205
-rw-r--r--com32/mboot/solaris.c62
-rw-r--r--com32/mboot/syslinux.c45
-rw-r--r--com32/mboot/vesa.h100
-rw-r--r--com32/menu/Makefile2
-rw-r--r--com32/menu/background.c10
-rw-r--r--com32/menu/colors.c227
-rw-r--r--com32/menu/drain.c30
-rw-r--r--com32/menu/execute.c81
-rw-r--r--com32/menu/menu.c23
-rw-r--r--com32/menu/menu.h191
-rw-r--r--com32/menu/menumain.c1886
-rw-r--r--com32/menu/passwd.c100
-rw-r--r--com32/menu/printmsg.c140
-rw-r--r--com32/menu/readconfig.c1649
-rw-r--r--com32/menu/refstr.c92
-rw-r--r--com32/menu/refstr.h8
-rw-r--r--com32/menu/vesamenu.c29
-rw-r--r--com32/modules/Makefile21
-rw-r--r--com32/modules/cat.c33
-rw-r--r--com32/modules/chain.c2263
-rw-r--r--com32/modules/cmd.c26
-rw-r--r--com32/modules/config.c39
-rw-r--r--com32/modules/cpuid.c351
-rw-r--r--com32/modules/cpuidtest.c134
-rw-r--r--com32/modules/disk.c62
-rw-r--r--com32/modules/dmi.c504
-rw-r--r--com32/modules/dmi_utils.c65
-rw-r--r--com32/modules/dmitest.c248
-rw-r--r--com32/modules/elf.c367
-rw-r--r--com32/modules/ethersel.c252
-rw-r--r--com32/modules/gpxecmd.c86
-rw-r--r--com32/modules/host.c42
-rw-r--r--com32/modules/i386-elf.h237
-rw-r--r--com32/modules/ifcpu.c184
-rw-r--r--com32/modules/ifcpu64.c114
-rw-r--r--com32/modules/ifplop.c165
-rw-r--r--com32/modules/kbdmap.c54
-rw-r--r--com32/modules/linux.c321
-rw-r--r--com32/modules/ls.c177
-rw-r--r--com32/modules/mboot.c1083
-rw-r--r--com32/modules/meminfo.c154
-rw-r--r--com32/modules/pcitest.c114
-rw-r--r--com32/modules/pmload.c248
-rw-r--r--com32/modules/pwd.c51
-rw-r--r--com32/modules/reboot.c15
-rw-r--r--com32/modules/sanboot.c129
-rw-r--r--com32/modules/sdi.c254
-rw-r--r--com32/modules/vesainfo.c93
-rw-r--r--com32/modules/vpdtest.c69
-rw-r--r--com32/rosh/MCONFIG27
-rw-r--r--com32/rosh/Makefile38
-rw-r--r--com32/rosh/rosh.c1178
-rw-r--r--com32/rosh/rosh.h228
-rw-r--r--com32/samples/Makefile4
-rw-r--r--com32/samples/advdump.c36
-rw-r--r--com32/samples/cat.c31
-rw-r--r--com32/samples/entrydump.c60
-rw-r--r--com32/samples/fancyhello.c22
-rw-r--r--com32/samples/hello.c12
-rw-r--r--com32/samples/keytest.c64
-rw-r--r--com32/samples/localboot.c4
-rw-r--r--com32/samples/resolv.c52
-rw-r--r--com32/samples/serialinfo.c19
-rw-r--r--com32/sysdump/Makefile60
-rw-r--r--com32/sysdump/README19
-rw-r--r--com32/sysdump/acpi.c259
-rw-r--r--com32/sysdump/backend.h55
-rw-r--r--com32/sysdump/be_srec.c85
-rw-r--r--com32/sysdump/be_tftp.c178
-rw-r--r--com32/sysdump/be_ymodem.c175
-rw-r--r--com32/sysdump/cpio.c75
-rw-r--r--com32/sysdump/cpuid.c91
-rw-r--r--com32/sysdump/ctime.c77
-rw-r--r--com32/sysdump/ctime.h8
-rw-r--r--com32/sysdump/data.h2
-rw-r--r--com32/sysdump/dmi.c126
-rw-r--r--com32/sysdump/main.c99
-rw-r--r--com32/sysdump/memmap.c85
-rw-r--r--com32/sysdump/memory.c51
-rw-r--r--com32/sysdump/pci.c70
-rw-r--r--com32/sysdump/rbtree.c132
-rw-r--r--com32/sysdump/rbtree.h53
-rw-r--r--com32/sysdump/serial.c169
-rw-r--r--com32/sysdump/serial.h19
-rw-r--r--com32/sysdump/srecsend.h9
-rw-r--r--com32/sysdump/sysdump.h15
-rw-r--r--com32/sysdump/vesa.c63
-rw-r--r--com32/sysdump/ymodem.txt2108
-rw-r--r--com32/sysdump/zout.c99
-rw-r--r--com32/tools/.gitignore1
-rw-r--r--com32/tools/Makefile30
-rw-r--r--com32/tools/relocs.c693
-rw-r--r--core/Makefile100
-rw-r--r--core/abort.inc22
-rw-r--r--core/adv.inc60
-rw-r--r--core/bcopy32.inc695
-rw-r--r--core/bcopyxx.inc318
-rw-r--r--core/bios.inc8
-rw-r--r--core/bootsect.inc151
-rw-r--r--core/cache.inc114
-rw-r--r--core/call16.c41
-rw-r--r--core/callback.inc215
-rwxr-xr-xcore/checksumiso.pl51
-rw-r--r--core/cleanup.inc12
-rw-r--r--core/cmdline.inc65
-rw-r--r--core/codepage.S5
-rw-r--r--core/com32.inc441
-rw-r--r--core/comboot.inc413
-rw-r--r--core/common.inc25
-rw-r--r--core/config.inc21
-rw-r--r--core/configinit.inc12
-rw-r--r--core/conio.inc82
-rw-r--r--core/console.c22
-rw-r--r--core/cpuinit.inc86
-rw-r--r--core/diskfs.inc173
-rw-r--r--core/diskstart.inc874
-rw-r--r--core/dnsresolv.inc384
-rw-r--r--core/ext2_fs.inc183
-rw-r--r--core/extern.inc32
-rw-r--r--core/extlinux.asm1583
-rw-r--r--core/font.inc31
-rw-r--r--core/fs/btrfs/btrfs.c665
-rw-r--r--core/fs/btrfs/btrfs.h292
-rw-r--r--core/fs/btrfs/crc32c.h50
-rw-r--r--core/fs/cache.c125
-rw-r--r--core/fs/chdir.c103
-rw-r--r--core/fs/diskio.c378
-rw-r--r--core/fs/ext2/bmap.c228
-rw-r--r--core/fs/ext2/ext2.c335
-rw-r--r--core/fs/ext2/ext2_fs.h310
-rw-r--r--core/fs/fat/fat.c795
-rw-r--r--core/fs/fat/fat_fs.h158
-rw-r--r--core/fs/fs.c475
-rw-r--r--core/fs/getcwd.c13
-rw-r--r--core/fs/getfssec.c190
-rw-r--r--core/fs/iso9660/iso9660.c355
-rw-r--r--core/fs/iso9660/iso9660_fs.h51
-rw-r--r--core/fs/lib/close.c9
-rw-r--r--core/fs/lib/loadconfig.c53
-rw-r--r--core/fs/lib/mangle.c47
-rw-r--r--core/fs/loadhigh.c113
-rw-r--r--core/fs/newconfig.c41
-rw-r--r--core/fs/nonextextent.c13
-rw-r--r--core/fs/pxe/dhcp_option.c259
-rw-r--r--core/fs/pxe/dnsresolv.c349
-rw-r--r--core/fs/pxe/idle.c112
-rw-r--r--core/fs/pxe/portnum.c68
-rw-r--r--core/fs/pxe/pxe.c1698
-rw-r--r--core/fs/pxe/pxe.h252
-rw-r--r--core/fs/readdir.c57
-rw-r--r--core/getc.inc40
-rw-r--r--core/graphics.inc82
-rw-r--r--core/head.inc7
-rw-r--r--core/highmem.inc27
-rw-r--r--core/idle.c49
-rw-r--r--core/idle.inc81
-rw-r--r--core/include/cache.h23
-rw-r--r--core/include/codepage.h27
-rw-r--r--core/include/core.h74
-rw-r--r--core/include/ctype.h25
-rw-r--r--core/include/disk.h38
-rw-r--r--core/include/fs.h228
-rw-r--r--core/include/pmapi.h8
-rw-r--r--core/init.inc118
-rw-r--r--core/io.inc35
-rw-r--r--core/isolinux.asm750
-rw-r--r--core/kaboom.c16
-rw-r--r--core/kernel.inc6
-rw-r--r--core/keywords2
-rw-r--r--core/keywords.inc6
-rw-r--r--core/layout.inc124
-rw-r--r--core/ldlinux.asm1734
-rw-r--r--core/loadhigh.inc86
-rw-r--r--core/localboot.inc7
-rw-r--r--core/lzo/enter.ash89
-rw-r--r--core/lzo/leave.ash114
-rw-r--r--core/lzo/lzo1c_d.ash184
-rw-r--r--core/lzo/lzo1f_d.ash176
-rw-r--r--core/lzo/lzo1x_d.ash401
-rw-r--r--core/lzo/lzo1x_f1.S63
-rw-r--r--core/lzo/lzo_asm.h287
-rw-r--r--core/macros.inc90
-rw-r--r--core/mem/free.c154
-rw-r--r--core/mem/init.c38
-rw-r--r--core/mem/malloc.c99
-rw-r--r--core/mem/malloc.h82
-rw-r--r--core/parsecmd.inc38
-rw-r--r--core/parseconfig.inc128
-rw-r--r--core/plaincon.inc2
-rw-r--r--core/pm.inc450
-rw-r--r--core/pmapi.c40
-rw-r--r--core/pmcall.inc70
-rw-r--r--core/prefix.inc17
-rw-r--r--core/printf.c20
-rw-r--r--core/pxe.inc1
-rw-r--r--core/pxeidle.inc92
-rw-r--r--core/pxelinux.asm2785
-rw-r--r--core/rawcon.inc4
-rw-r--r--core/rllpack.c105
-rw-r--r--core/rllpack.inc156
-rw-r--r--core/runkernel.inc288
-rw-r--r--core/serirq.inc219
-rw-r--r--core/stack.inc20
-rw-r--r--core/strcasecmp.c11
-rw-r--r--core/strcpy.inc2
-rw-r--r--core/strecpy.inc28
-rw-r--r--core/strncasecmp.c24
-rw-r--r--core/syslinux.ld358
-rw-r--r--core/timer.inc46
-rw-r--r--core/ui.inc120
-rw-r--r--core/writedec.inc2
-rw-r--r--core/writehex.inc1
-rw-r--r--core/writestr.inc1
-rwxr-xr-xdevel/Nindent18
-rw-r--r--doc/CodingStyle.txt831
-rw-r--r--doc/comboot.txt332
-rw-r--r--doc/extlinux.txt8
-rw-r--r--doc/gpt.txt53
-rw-r--r--doc/memdisk.txt67
-rw-r--r--doc/menu.txt128
-rw-r--r--doc/pxelinux.txt4
-rw-r--r--doc/syslinux.txt63
-rw-r--r--dos/Makefile33
-rw-r--r--dos/__divdi3.c30
-rw-r--r--dos/__udivmoddi4.c42
-rw-r--r--dos/argv.c82
-rw-r--r--dos/atou.c8
-rw-r--r--dos/conio.c22
-rw-r--r--dos/crt0.S29
-rw-r--r--dos/dosexe.ld131
-rw-r--r--dos/errno.h35
-rw-r--r--dos/free.c93
-rw-r--r--dos/getsetsl.c100
-rw-r--r--dos/header.S54
-rw-r--r--dos/int2526.S76
-rw-r--r--dos/malloc.c167
-rw-r--r--dos/malloc.h10
-rw-r--r--dos/memmove.S36
-rw-r--r--dos/mystuff.h15
-rw-r--r--dos/perror.c2
-rw-r--r--dos/printf.c481
-rw-r--r--dos/skipatou.c8
-rw-r--r--dos/stdint.h56
-rw-r--r--dos/stdio.h2
-rw-r--r--dos/stdlib.h3
-rw-r--r--dos/string.h9
-rw-r--r--dos/syslinux.c1078
-rw-r--r--dosutil/.gitignore1
-rw-r--r--dosutil/Makefile60
-rw-r--r--dosutil/README10
-rw-r--r--dosutil/copybs.asm (renamed from dos/copybs.asm)0
-rw-r--r--dosutil/eltorito.asm1099
-rw-r--r--dosutil/eltorito.txt50
-rw-r--r--dosutil/mdiskchk.c357
-rw-r--r--dosutil/mdiskchk.combin0 -> 8106 bytes
-rw-r--r--dummy.c2
-rw-r--r--extlinux/Makefile18
-rw-r--r--extlinux/btrfs.h22
-rw-r--r--extlinux/ext2_fs.h508
-rw-r--r--extlinux/fat.h7
-rw-r--r--extlinux/main.c1460
-rwxr-xr-xgen-id.sh5
-rw-r--r--gpxe/.gitignore1
-rw-r--r--gpxe/Makefile10
-rw-r--r--gpxe/VERSION2
-rw-r--r--gpxe/gpxe.diff73
-rw-r--r--gpxe/pxelinux.gpxe5
-rw-r--r--gpxe/src/Makefile211
-rw-r--r--gpxe/src/Makefile.housekeeping677
-rw-r--r--gpxe/src/README.pixify90
-rw-r--r--gpxe/src/arch/i386/Config148
-rw-r--r--gpxe/src/arch/i386/Makefile151
-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/core/basemem_packet.c2
-rw-r--r--gpxe/src/arch/i386/core/dumpregs.c6
-rw-r--r--gpxe/src/arch/i386/core/etherboot.prefix.lds100
-rw-r--r--gpxe/src/arch/i386/core/gdbidt.S8
-rw-r--r--gpxe/src/arch/i386/core/gdbmach.c4
-rw-r--r--gpxe/src/arch/i386/core/nap.c12
-rw-r--r--gpxe/src/arch/i386/core/pic8259.c3
-rw-r--r--gpxe/src/arch/i386/core/prefixudata.lds8
-rw-r--r--gpxe/src/arch/i386/core/prefixzdata.lds8
-rw-r--r--gpxe/src/arch/i386/core/rdtsc_timer.c89
-rw-r--r--gpxe/src/arch/i386/core/realmode.c23
-rw-r--r--gpxe/src/arch/i386/core/relocate.c14
-rw-r--r--gpxe/src/arch/i386/core/setjmp.S2
-rw-r--r--gpxe/src/arch/i386/core/stack.S4
-rw-r--r--gpxe/src/arch/i386/core/stack16.S4
-rw-r--r--gpxe/src/arch/i386/core/start16.lds8
-rw-r--r--gpxe/src/arch/i386/core/start16z.lds65
-rw-r--r--gpxe/src/arch/i386/core/start32.S325
-rw-r--r--gpxe/src/arch/i386/core/timer2.c (renamed from gpxe/src/arch/i386/core/i386_timer.c)26
-rw-r--r--gpxe/src/arch/i386/core/video_subr.c2
-rw-r--r--gpxe/src/arch/i386/core/virtaddr.S4
-rw-r--r--gpxe/src/arch/i386/core/x86_io.c96
-rw-r--r--gpxe/src/arch/i386/drivers/net/undi.c4
-rw-r--r--gpxe/src/arch/i386/drivers/net/undiisr.S12
-rw-r--r--gpxe/src/arch/i386/drivers/net/undiload.c7
-rw-r--r--gpxe/src/arch/i386/drivers/net/undinet.c328
-rw-r--r--gpxe/src/arch/i386/drivers/net/undionly.c20
-rw-r--r--gpxe/src/arch/i386/drivers/net/undipreload.c2
-rw-r--r--gpxe/src/arch/i386/drivers/net/undirom.c6
-rw-r--r--gpxe/src/arch/i386/drivers/timer_bios.c57
-rw-r--r--gpxe/src/arch/i386/drivers/timer_rdtsc.c69
-rw-r--r--gpxe/src/arch/i386/firmware/pcbios/basemem.c2
-rw-r--r--gpxe/src/arch/i386/firmware/pcbios/bios_console.c6
-rw-r--r--gpxe/src/arch/i386/firmware/pcbios/e820mangler.S83
-rw-r--r--gpxe/src/arch/i386/firmware/pcbios/fakee820.c7
-rw-r--r--gpxe/src/arch/i386/firmware/pcbios/gateA20.c15
-rw-r--r--gpxe/src/arch/i386/firmware/pcbios/hidemem.c34
-rw-r--r--gpxe/src/arch/i386/firmware/pcbios/memmap.c31
-rw-r--r--gpxe/src/arch/i386/firmware/pcbios/pnpbios.c2
-rw-r--r--gpxe/src/arch/i386/hci/commands/pxe_cmd.c33
-rw-r--r--gpxe/src/arch/i386/image/bootsector.c2
-rw-r--r--gpxe/src/arch/i386/image/bzimage.c483
-rw-r--r--gpxe/src/arch/i386/image/com32.c46
-rw-r--r--gpxe/src/arch/i386/image/comboot.c46
-rw-r--r--gpxe/src/arch/i386/image/elfboot.c2
-rw-r--r--gpxe/src/arch/i386/image/eltorito.c2
-rw-r--r--gpxe/src/arch/i386/image/multiboot.c56
-rw-r--r--gpxe/src/arch/i386/image/nbi.c18
-rw-r--r--gpxe/src/arch/i386/image/pxe_image.c28
-rw-r--r--gpxe/src/arch/i386/include/basemem.h2
-rw-r--r--gpxe/src/arch/i386/include/basemem_packet.h2
-rw-r--r--gpxe/src/arch/i386/include/bios.h5
-rw-r--r--gpxe/src/arch/i386/include/biosint.h17
-rw-r--r--gpxe/src/arch/i386/include/bits/byteswap.h47
-rw-r--r--gpxe/src/arch/i386/include/bits/compiler.h27
-rw-r--r--gpxe/src/arch/i386/include/bits/elf.h91
-rw-r--r--gpxe/src/arch/i386/include/bits/elf_x.h5
-rw-r--r--gpxe/src/arch/i386/include/bits/endian.h2
-rw-r--r--gpxe/src/arch/i386/include/bits/errfile.h9
-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.h8
-rw-r--r--gpxe/src/arch/i386/include/bits/timer.h15
-rw-r--r--gpxe/src/arch/i386/include/bits/timer2.h8
-rw-r--r--gpxe/src/arch/i386/include/bits/uaccess.h10
-rw-r--r--gpxe/src/arch/i386/include/bits/umalloc.h14
-rw-r--r--gpxe/src/arch/i386/include/bootsector.h2
-rw-r--r--gpxe/src/arch/i386/include/bzimage.h5
-rw-r--r--gpxe/src/arch/i386/include/callbacks_arch.h243
-rw-r--r--gpxe/src/arch/i386/include/comboot.h53
-rw-r--r--gpxe/src/arch/i386/include/fakee820.h2
-rw-r--r--gpxe/src/arch/i386/include/gdbmach.h2
-rw-r--r--gpxe/src/arch/i386/include/gpxe/abft.h (renamed from gpxe/src/include/gpxe/abft.h)2
-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.h (renamed from gpxe/src/include/gpxe/ibft.h)2
-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.h3
-rw-r--r--gpxe/src/arch/i386/include/io.h265
-rw-r--r--gpxe/src/arch/i386/include/librm.h305
-rw-r--r--gpxe/src/arch/i386/include/limits.h2
-rw-r--r--gpxe/src/arch/i386/include/memsizes.h2
-rw-r--r--gpxe/src/arch/i386/include/multiboot.h2
-rw-r--r--gpxe/src/arch/i386/include/pci_io.h35
-rw-r--r--gpxe/src/arch/i386/include/pic8259.h2
-rw-r--r--gpxe/src/arch/i386/include/pnpbios.h2
-rw-r--r--gpxe/src/arch/i386/include/pxe.h (renamed from gpxe/src/include/pxe.h)3
-rw-r--r--gpxe/src/arch/i386/include/pxe_addr.h17
-rw-r--r--gpxe/src/arch/i386/include/pxe_api.h (renamed from gpxe/src/include/pxe_api.h)68
-rw-r--r--gpxe/src/arch/i386/include/pxe_call.h30
-rw-r--r--gpxe/src/arch/i386/include/pxe_types.h (renamed from gpxe/src/include/pxe_types.h)7
-rw-r--r--gpxe/src/arch/i386/include/pxeparent.h11
-rw-r--r--gpxe/src/arch/i386/include/realmode.h93
-rw-r--r--gpxe/src/arch/i386/include/registers.h15
-rw-r--r--gpxe/src/arch/i386/include/setjmp.h38
-rw-r--r--gpxe/src/arch/i386/include/smbios.h60
-rw-r--r--gpxe/src/arch/i386/include/undi.h12
-rw-r--r--gpxe/src/arch/i386/include/undiload.h2
-rw-r--r--gpxe/src/arch/i386/include/undinet.h2
-rw-r--r--gpxe/src/arch/i386/include/undipreload.h2
-rw-r--r--gpxe/src/arch/i386/include/undirom.h2
-rw-r--r--gpxe/src/arch/i386/include/virtaddr.h105
-rw-r--r--gpxe/src/arch/i386/interface/pcbios/abft.c (renamed from gpxe/src/core/abft.c)2
-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.c11
-rw-r--r--gpxe/src/arch/i386/interface/pcbios/ib_srpboot.c73
-rw-r--r--gpxe/src/arch/i386/interface/pcbios/ibft.c (renamed from gpxe/src/core/ibft.c)67
-rw-r--r--gpxe/src/arch/i386/interface/pcbios/int13.c93
-rw-r--r--gpxe/src/arch/i386/interface/pcbios/iscsiboot.c (renamed from gpxe/src/usr/iscsiboot.c)47
-rw-r--r--gpxe/src/arch/i386/interface/pcbios/keepsan.c26
-rw-r--r--gpxe/src/arch/i386/interface/pcbios/memtop_umalloc.c (renamed from gpxe/src/arch/i386/core/umalloc.c)36
-rw-r--r--gpxe/src/arch/i386/interface/pcbios/pcibios.c (renamed from gpxe/src/arch/i386/core/pcibios.c)13
-rw-r--r--gpxe/src/arch/i386/interface/pcbios/sbft.c105
-rw-r--r--gpxe/src/arch/i386/interface/pxe/pxe_call.c117
-rw-r--r--gpxe/src/arch/i386/interface/pxe/pxe_entry.S50
-rw-r--r--gpxe/src/arch/i386/interface/pxe/pxe_errors.c (renamed from gpxe/src/interface/pxe/pxe_errors.c)0
-rw-r--r--gpxe/src/arch/i386/interface/pxe/pxe_file.c (renamed from gpxe/src/interface/pxe/pxe_file.c)42
-rw-r--r--gpxe/src/arch/i386/interface/pxe/pxe_loader.c (renamed from gpxe/src/interface/pxe/pxe_loader.c)5
-rw-r--r--gpxe/src/arch/i386/interface/pxe/pxe_preboot.c (renamed from gpxe/src/interface/pxe/pxe_preboot.c)27
-rw-r--r--gpxe/src/arch/i386/interface/pxe/pxe_tftp.c (renamed from gpxe/src/interface/pxe/pxe_tftp.c)30
-rw-r--r--gpxe/src/arch/i386/interface/pxe/pxe_udp.c (renamed from gpxe/src/interface/pxe/pxe_udp.c)2
-rw-r--r--gpxe/src/arch/i386/interface/pxe/pxe_undi.c (renamed from gpxe/src/interface/pxe/pxe_undi.c)237
-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.c8
-rw-r--r--gpxe/src/arch/i386/interface/syslinux/com32_wrapper.S2
-rw-r--r--gpxe/src/arch/i386/interface/syslinux/comboot_call.c258
-rw-r--r--gpxe/src/arch/i386/interface/syslinux/comboot_resolv.c2
-rw-r--r--gpxe/src/arch/i386/prefix/bImageprefix.S611
-rw-r--r--gpxe/src/arch/i386/prefix/bootpart.S2
-rw-r--r--gpxe/src/arch/i386/prefix/comprefix.S46
-rw-r--r--gpxe/src/arch/i386/prefix/dskprefix.S14
-rw-r--r--gpxe/src/arch/i386/prefix/elf_dprefix.S94
-rw-r--r--gpxe/src/arch/i386/prefix/elfprefix.S94
-rwxr-xr-xgpxe/src/arch/i386/prefix/exeprefix.S41
-rw-r--r--gpxe/src/arch/i386/prefix/hdprefix.S14
-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.S2
-rw-r--r--gpxe/src/arch/i386/prefix/libprefix.S202
-rw-r--r--gpxe/src/arch/i386/prefix/lkrnprefix.S14
-rw-r--r--gpxe/src/arch/i386/prefix/lmelf_dprefix.S161
-rw-r--r--gpxe/src/arch/i386/prefix/lmelf_prefix.S161
-rw-r--r--gpxe/src/arch/i386/prefix/nbiprefix.S21
-rw-r--r--gpxe/src/arch/i386/prefix/pxeprefix.S392
-rw-r--r--gpxe/src/arch/i386/prefix/romprefix.S654
-rw-r--r--gpxe/src/arch/i386/prefix/undiloader.S49
-rw-r--r--gpxe/src/arch/i386/prefix/unnrv2b.S2
-rw-r--r--gpxe/src/arch/i386/prefix/unnrv2b16.S9
-rw-r--r--gpxe/src/arch/i386/prefix/xromprefix.S9
-rw-r--r--gpxe/src/arch/i386/scripts/i386-kir.lds1
-rw-r--r--gpxe/src/arch/i386/scripts/i386.lds280
-rw-r--r--gpxe/src/arch/i386/transitions/libkir.S2
-rw-r--r--gpxe/src/arch/i386/transitions/librm.S55
-rw-r--r--gpxe/src/arch/i386/transitions/librm_mgmt.c103
-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.c (renamed from gpxe/src/arch/i386/core/pcidirect.c)11
-rw-r--r--gpxe/src/arch/x86/core/x86_string.c (renamed from gpxe/src/arch/i386/core/i386_string.c)6
-rw-r--r--gpxe/src/arch/x86/include/bits/pci_io.h15
-rw-r--r--gpxe/src/arch/x86/include/bits/string.h (renamed from gpxe/src/arch/i386/include/bits/string.h)6
-rw-r--r--gpxe/src/arch/x86/include/gpxe/efi/efix86_nap.h18
-rw-r--r--gpxe/src/arch/x86/include/gpxe/pcibios.h (renamed from gpxe/src/arch/i386/include/pcibios.h)57
-rw-r--r--gpxe/src/arch/x86/include/gpxe/pcidirect.h (renamed from gpxe/src/arch/i386/include/pcidirect.h)55
-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.h175
-rw-r--r--gpxe/src/config/.gitignore1
-rw-r--r--gpxe/src/config/config.c (renamed from gpxe/src/core/config.c)94
-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.c2
-rw-r--r--gpxe/src/core/ansiesc.c2
-rw-r--r--gpxe/src/core/asprintf.c2
-rw-r--r--gpxe/src/core/base64.c68
-rw-r--r--gpxe/src/core/basename.c2
-rw-r--r--gpxe/src/core/bitmap.c2
-rw-r--r--gpxe/src/core/bitops.c2
-rw-r--r--gpxe/src/core/console.c17
-rw-r--r--gpxe/src/core/cpio.c2
-rw-r--r--gpxe/src/core/ctype.c48
-rw-r--r--gpxe/src/core/cwuri.c7
-rw-r--r--gpxe/src/core/debug.c9
-rw-r--r--gpxe/src/core/device.c9
-rw-r--r--gpxe/src/core/downloader.c27
-rw-r--r--gpxe/src/core/exec.c14
-rw-r--r--gpxe/src/core/filter.c2
-rw-r--r--gpxe/src/core/gdbstub.c17
-rw-r--r--gpxe/src/core/gdbudp.c2
-rw-r--r--gpxe/src/core/getkey.c16
-rw-r--r--gpxe/src/core/getopt.c2
-rw-r--r--gpxe/src/core/image.c39
-rw-r--r--gpxe/src/core/init.c25
-rw-r--r--gpxe/src/core/interface.c2
-rw-r--r--gpxe/src/core/iobuf.c2
-rw-r--r--gpxe/src/core/job.c10
-rw-r--r--gpxe/src/core/linebuf.c2
-rw-r--r--gpxe/src/core/main.c49
-rw-r--r--gpxe/src/core/malloc.c8
-rw-r--r--gpxe/src/core/misc.c17
-rw-r--r--gpxe/src/core/monojob.c9
-rw-r--r--gpxe/src/core/null_nap.c3
-rw-r--r--gpxe/src/core/nvo.c4
-rw-r--r--gpxe/src/core/open.c41
-rw-r--r--gpxe/src/core/pc_kbd.c2
-rw-r--r--gpxe/src/core/posix_io.c4
-rw-r--r--gpxe/src/core/process.c26
-rw-r--r--gpxe/src/core/random.c2
-rw-r--r--gpxe/src/core/refcnt.c2
-rw-r--r--gpxe/src/core/resolv.c53
-rw-r--r--gpxe/src/core/serial.c4
-rw-r--r--gpxe/src/core/settings.c562
-rw-r--r--gpxe/src/core/string.c2
-rw-r--r--gpxe/src/core/timer.c91
-rw-r--r--gpxe/src/core/uri.c173
-rw-r--r--gpxe/src/core/uuid.c4
-rw-r--r--gpxe/src/core/vsprintf.c2
-rw-r--r--gpxe/src/core/xfer.c16
-rw-r--r--gpxe/src/crypto/aes_wrap.c123
-rw-r--r--gpxe/src/crypto/arc4.c131
-rw-r--r--gpxe/src/crypto/asn1.c33
-rw-r--r--gpxe/src/crypto/axtls/aes.c10
-rw-r--r--gpxe/src/crypto/axtls/axtls_asn1.c867
-rw-r--r--gpxe/src/crypto/axtls/crypto.h2
-rw-r--r--gpxe/src/crypto/axtls_aes.c144
-rw-r--r--gpxe/src/crypto/axtls_sha1.c7
-rw-r--r--gpxe/src/crypto/cbc.c101
-rw-r--r--gpxe/src/crypto/chap.c4
-rw-r--r--gpxe/src/crypto/cipher.c24
-rw-r--r--gpxe/src/crypto/crandom.c55
-rw-r--r--gpxe/src/crypto/crc32.c54
-rw-r--r--gpxe/src/crypto/cryptoLayer.h120
-rw-r--r--gpxe/src/crypto/crypto_null.c64
-rw-r--r--gpxe/src/crypto/framework.c86
-rw-r--r--gpxe/src/crypto/hmac.c8
-rw-r--r--gpxe/src/crypto/matrixssl/mpi.h487
-rw-r--r--gpxe/src/crypto/matrixssl/pscrypto.h661
-rw-r--r--gpxe/src/crypto/md5.c21
-rw-r--r--gpxe/src/crypto/sha1extra.c165
-rw-r--r--gpxe/src/crypto/ssl.c136
-rw-r--r--gpxe/src/crypto/ssl.h19
-rw-r--r--gpxe/src/crypto/ssl_constructs.h342
-rw-r--r--gpxe/src/crypto/x509.c183
-rw-r--r--gpxe/src/doc/pxe_extensions33
-rw-r--r--gpxe/src/doxygen.cfg434
-rw-r--r--gpxe/src/drivers/bitbash/bitbash.c2
-rw-r--r--gpxe/src/drivers/bitbash/i2c_bit.c149
-rw-r--r--gpxe/src/drivers/bitbash/spi_bit.c53
-rw-r--r--gpxe/src/drivers/block/ata.c35
-rw-r--r--gpxe/src/drivers/block/ramdisk.c10
-rw-r--r--gpxe/src/drivers/block/scsi.c133
-rw-r--r--gpxe/src/drivers/block/srp.c523
-rw-r--r--gpxe/src/drivers/bus/eisa.c9
-rw-r--r--gpxe/src/drivers/bus/isa.c11
-rw-r--r--gpxe/src/drivers/bus/isapnp.c13
-rw-r--r--gpxe/src/drivers/bus/mca.c11
-rw-r--r--gpxe/src/drivers/bus/pci.c14
-rw-r--r--gpxe/src/drivers/bus/pcibackup.c90
-rw-r--r--gpxe/src/drivers/bus/pciextra.c7
-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.h2
-rw-r--r--gpxe/src/drivers/infiniband/MT25408_PRM.h8
-rw-r--r--gpxe/src/drivers/infiniband/arbel.c189
-rw-r--r--gpxe/src/drivers/infiniband/arbel.h2
-rw-r--r--gpxe/src/drivers/infiniband/hermon.c838
-rw-r--r--gpxe/src/drivers/infiniband/hermon.h91
-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.h14
-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/3c509.c4
-rw-r--r--gpxe/src/drivers/net/3c509.h2
-rw-r--r--gpxe/src/drivers/net/3c515.c3
-rw-r--r--gpxe/src/drivers/net/3c529.c2
-rw-r--r--gpxe/src/drivers/net/3c595.c32
-rw-r--r--gpxe/src/drivers/net/3c595.h2
-rw-r--r--gpxe/src/drivers/net/3c5x9.c2
-rw-r--r--gpxe/src/drivers/net/3c90x.c1837
-rw-r--r--gpxe/src/drivers/net/3c90x.h302
-rw-r--r--gpxe/src/drivers/net/3c90x.txt307
-rw-r--r--gpxe/src/drivers/net/amd8111e.c4
-rw-r--r--gpxe/src/drivers/net/amd8111e.h2
-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.c10
-rw-r--r--gpxe/src/drivers/net/bnx2.h108
-rw-r--r--gpxe/src/drivers/net/cs89x0.c6
-rw-r--r--gpxe/src/drivers/net/cs89x0.h2
-rw-r--r--gpxe/src/drivers/net/davicom.c14
-rw-r--r--gpxe/src/drivers/net/depca.c2
-rw-r--r--gpxe/src/drivers/net/dmfe.c30
-rw-r--r--gpxe/src/drivers/net/e1000/e1000.c426
-rw-r--r--gpxe/src/drivers/net/e1000/e1000.h5
-rw-r--r--gpxe/src/drivers/net/e1000/e1000_hw.c170
-rw-r--r--gpxe/src/drivers/net/e1000/e1000_hw.h20
-rw-r--r--gpxe/src/drivers/net/e1000/e1000_osdep.h51
-rw-r--r--gpxe/src/drivers/net/eepro.c2
-rw-r--r--gpxe/src/drivers/net/eepro100.c1692
-rw-r--r--gpxe/src/drivers/net/eepro100.h206
-rw-r--r--gpxe/src/drivers/net/epic100.c10
-rw-r--r--gpxe/src/drivers/net/epic100.h2
-rw-r--r--gpxe/src/drivers/net/etherfabric.c5534
-rw-r--r--gpxe/src/drivers/net/etherfabric.h2
-rw-r--r--gpxe/src/drivers/net/etherfabric_nic.h204
-rw-r--r--gpxe/src/drivers/net/forcedeth.c104
-rw-r--r--gpxe/src/drivers/net/hfa384x.h2
-rw-r--r--gpxe/src/drivers/net/ipoib.c1057
-rw-r--r--gpxe/src/drivers/net/legacy.c6
-rw-r--r--gpxe/src/drivers/net/mlx_ipoib/MT23108_PRM.h2800
-rw-r--r--gpxe/src/drivers/net/mlx_ipoib/MT23108_PRM_append.h199
-rw-r--r--gpxe/src/drivers/net/mlx_ipoib/MT25218_PRM.h3463
-rw-r--r--gpxe/src/drivers/net/mlx_ipoib/bit_ops.h126
-rw-r--r--gpxe/src/drivers/net/mlx_ipoib/cmdif.h50
-rw-r--r--gpxe/src/drivers/net/mlx_ipoib/cmdif_comm.c564
-rw-r--r--gpxe/src/drivers/net/mlx_ipoib/cmdif_comm.h60
-rw-r--r--gpxe/src/drivers/net/mlx_ipoib/cmdif_mt23108.c193
-rw-r--r--gpxe/src/drivers/net/mlx_ipoib/cmdif_mt25218.c457
-rw-r--r--gpxe/src/drivers/net/mlx_ipoib/cmdif_priv.h50
-rw-r--r--gpxe/src/drivers/net/mlx_ipoib/doc/README.boot_over_ib176
-rw-r--r--gpxe/src/drivers/net/mlx_ipoib/ib_driver.c342
-rw-r--r--gpxe/src/drivers/net/mlx_ipoib/ib_driver.h169
-rw-r--r--gpxe/src/drivers/net/mlx_ipoib/ib_mad.c396
-rw-r--r--gpxe/src/drivers/net/mlx_ipoib/ib_mad.h110
-rw-r--r--gpxe/src/drivers/net/mlx_ipoib/ib_mt23108.c1701
-rw-r--r--gpxe/src/drivers/net/mlx_ipoib/ib_mt25218.c1929
-rw-r--r--gpxe/src/drivers/net/mlx_ipoib/ipoib.c1027
-rw-r--r--gpxe/src/drivers/net/mlx_ipoib/ipoib.h297
-rw-r--r--gpxe/src/drivers/net/mlx_ipoib/mad_attrib.h244
-rw-r--r--gpxe/src/drivers/net/mlx_ipoib/mt23108.c242
-rw-r--r--gpxe/src/drivers/net/mlx_ipoib/mt23108.h543
-rw-r--r--gpxe/src/drivers/net/mlx_ipoib/mt23108_imp.c229
-rw-r--r--gpxe/src/drivers/net/mlx_ipoib/mt25218.c242
-rw-r--r--gpxe/src/drivers/net/mlx_ipoib/mt25218.h546
-rw-r--r--gpxe/src/drivers/net/mlx_ipoib/mt25218_imp.c229
-rw-r--r--gpxe/src/drivers/net/mlx_ipoib/mt_version.c23
-rw-r--r--gpxe/src/drivers/net/mlx_ipoib/patches/dhcpd.patch23
-rw-r--r--gpxe/src/drivers/net/mlx_ipoib/samples/dhcpd.conf56
-rw-r--r--gpxe/src/drivers/net/mtd80x.c74
-rw-r--r--[-rwxr-xr-x]gpxe/src/drivers/net/mtnic.c1041
-rw-r--r--[-rwxr-xr-x]gpxe/src/drivers/net/mtnic.h286
-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.c19
-rw-r--r--gpxe/src/drivers/net/natsemi.h2
-rw-r--r--gpxe/src/drivers/net/ne2k_isa.c375
-rw-r--r--[-rwxr-xr-x]gpxe/src/drivers/net/ns83820.c4
-rw-r--r--gpxe/src/drivers/net/ns8390.c24
-rw-r--r--gpxe/src/drivers/net/ns8390.h2
-rw-r--r--gpxe/src/drivers/net/p80211hdr.h2
-rw-r--r--gpxe/src/drivers/net/pcnet32.c20
-rw-r--r--gpxe/src/drivers/net/phantom/nx_bitops.h2
-rw-r--r--gpxe/src/drivers/net/phantom/nxhal_nic_interface.h2
-rw-r--r--gpxe/src/drivers/net/phantom/phantom.c1531
-rw-r--r--gpxe/src/drivers/net/phantom/phantom.h157
-rw-r--r--gpxe/src/drivers/net/phantom/phantom_hw.h2
-rw-r--r--gpxe/src/drivers/net/pnic.c8
-rw-r--r--gpxe/src/drivers/net/pnic_api.h2
-rw-r--r--gpxe/src/drivers/net/prism2.c4
-rw-r--r--gpxe/src/drivers/net/prism2_pci.c17
-rw-r--r--gpxe/src/drivers/net/prism2_plx.c29
-rw-r--r--gpxe/src/drivers/net/r8169.c3102
-rw-r--r--gpxe/src/drivers/net/r8169.h487
-rw-r--r--gpxe/src/drivers/net/rtl8139.c66
-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.c20
-rw-r--r--gpxe/src/drivers/net/sis900.h2
-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.c3
-rw-r--r--gpxe/src/drivers/net/smc9000.h11
-rw-r--r--gpxe/src/drivers/net/sundance.c34
-rw-r--r--gpxe/src/drivers/net/tg3.c70
-rw-r--r--gpxe/src/drivers/net/tg3.h109
-rw-r--r--gpxe/src/drivers/net/tlan.c125
-rw-r--r--gpxe/src/drivers/net/tlan.h37
-rw-r--r--gpxe/src/drivers/net/tulip.c78
-rw-r--r--gpxe/src/drivers/net/via-rhine.c58
-rw-r--r--gpxe/src/drivers/net/via-velocity.c6
-rw-r--r--gpxe/src/drivers/net/virtio-net.c291
-rw-r--r--gpxe/src/drivers/net/w89c840.c10
-rw-r--r--gpxe/src/drivers/net/wlan_compat.h2
-rw-r--r--gpxe/src/drivers/nvs/nvs.c2
-rw-r--r--gpxe/src/drivers/nvs/spi.c2
-rw-r--r--gpxe/src/drivers/nvs/threewire.c55
-rw-r--r--gpxe/src/hci/commands/autoboot_cmd.c2
-rw-r--r--gpxe/src/hci/commands/config_cmd.c4
-rw-r--r--gpxe/src/hci/commands/dhcp_cmd.c92
-rw-r--r--gpxe/src/hci/commands/digest_cmd.c120
-rw-r--r--gpxe/src/hci/commands/ifmgmt_cmd.c21
-rw-r--r--gpxe/src/hci/commands/image_cmd.c45
-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.c2
-rw-r--r--gpxe/src/hci/commands/route_cmd.c2
-rw-r--r--gpxe/src/hci/commands/sanboot_cmd.c2
-rw-r--r--gpxe/src/hci/commands/time_cmd.c84
-rw-r--r--gpxe/src/hci/editstring.c2
-rw-r--r--gpxe/src/hci/mucurses/ansi_screen.c4
-rw-r--r--gpxe/src/hci/mucurses/clear.c2
-rw-r--r--gpxe/src/hci/mucurses/colour.c2
-rw-r--r--gpxe/src/hci/mucurses/cursor.h2
-rw-r--r--gpxe/src/hci/mucurses/mucurses.c2
-rw-r--r--gpxe/src/hci/mucurses/mucurses.h2
-rw-r--r--gpxe/src/hci/mucurses/print.c2
-rw-r--r--gpxe/src/hci/mucurses/widgets/editbox.c13
-rw-r--r--gpxe/src/hci/mucurses/winattrs.c2
-rw-r--r--gpxe/src/hci/mucurses/wininit.c6
-rw-r--r--gpxe/src/hci/readline.c2
-rw-r--r--gpxe/src/hci/shell.c9
-rw-r--r--gpxe/src/hci/shell_banner.c5
-rw-r--r--gpxe/src/hci/strerror.c19
-rw-r--r--gpxe/src/hci/tui/login_ui.c137
-rw-r--r--gpxe/src/hci/tui/settings_ui.c14
-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.c57
-rw-r--r--gpxe/src/image/embed.S7
-rw-r--r--gpxe/src/image/embedded.c114
-rw-r--r--gpxe/src/image/script.c21
-rw-r--r--gpxe/src/image/segment.c13
-rw-r--r--gpxe/src/include/assert.h2
-rw-r--r--gpxe/src/include/byteswap.h37
-rw-r--r--gpxe/src/include/compiler.h369
-rw-r--r--gpxe/src/include/console.h7
-rw-r--r--gpxe/src/include/ctype.h4
-rw-r--r--gpxe/src/include/curses.h2
-rw-r--r--gpxe/src/include/debug.h28
-rw-r--r--gpxe/src/include/dhcp.h12
-rw-r--r--gpxe/src/include/elf.h6
-rw-r--r--gpxe/src/include/endian.h2
-rw-r--r--gpxe/src/include/errno.h2
-rw-r--r--gpxe/src/include/etherboot.h2
-rw-r--r--gpxe/src/include/getopt.h2
-rw-r--r--gpxe/src/include/gpxe/acpi.h2
-rw-r--r--gpxe/src/include/gpxe/aes.h26
-rw-r--r--gpxe/src/include/gpxe/ansiesc.h2
-rw-r--r--gpxe/src/include/gpxe/aoe.h35
-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.h9
-rw-r--r--gpxe/src/include/gpxe/asn1.h8
-rw-r--r--gpxe/src/include/gpxe/ata.h4
-rw-r--r--gpxe/src/include/gpxe/base64.h26
-rw-r--r--gpxe/src/include/gpxe/bitbash.h2
-rw-r--r--gpxe/src/include/gpxe/bitmap.h2
-rw-r--r--gpxe/src/include/gpxe/bitops.h229
-rw-r--r--gpxe/src/include/gpxe/blockdev.h22
-rw-r--r--gpxe/src/include/gpxe/cbc.h100
-rw-r--r--gpxe/src/include/gpxe/chap.h8
-rw-r--r--gpxe/src/include/gpxe/command.h6
-rw-r--r--gpxe/src/include/gpxe/cpio.h2
-rw-r--r--gpxe/src/include/gpxe/crc32.h10
-rw-r--r--gpxe/src/include/gpxe/crypto.h134
-rw-r--r--gpxe/src/include/gpxe/device.h7
-rw-r--r--gpxe/src/include/gpxe/dhcp.h170
-rw-r--r--gpxe/src/include/gpxe/dhcpopts.h2
-rw-r--r--gpxe/src/include/gpxe/dhcppkt.h33
-rw-r--r--gpxe/src/include/gpxe/dns.h2
-rw-r--r--gpxe/src/include/gpxe/downloader.h2
-rw-r--r--gpxe/src/include/gpxe/eapol.h112
-rw-r--r--gpxe/src/include/gpxe/editbox.h14
-rw-r--r--gpxe/src/include/gpxe/editstring.h2
-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.h7
-rw-r--r--gpxe/src/include/gpxe/elf.h2
-rw-r--r--gpxe/src/include/gpxe/embedded.h9
-rw-r--r--gpxe/src/include/gpxe/errfile.h45
-rw-r--r--gpxe/src/include/gpxe/errortab.h6
-rw-r--r--gpxe/src/include/gpxe/ethernet.h26
-rw-r--r--gpxe/src/include/gpxe/fakedhcp.h6
-rw-r--r--gpxe/src/include/gpxe/features.h36
-rw-r--r--gpxe/src/include/gpxe/filter.h2
-rw-r--r--gpxe/src/include/gpxe/ftp.h2
-rw-r--r--gpxe/src/include/gpxe/gdbserial.h2
-rw-r--r--gpxe/src/include/gpxe/gdbstub.h6
-rw-r--r--gpxe/src/include/gpxe/gdbudp.h2
-rw-r--r--gpxe/src/include/gpxe/hidemem.h2
-rw-r--r--gpxe/src/include/gpxe/hmac.h8
-rw-r--r--gpxe/src/include/gpxe/http.h2
-rw-r--r--gpxe/src/include/gpxe/i2c.h70
-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.h2
-rw-r--r--gpxe/src/include/gpxe/ieee80211.h1160
-rw-r--r--gpxe/src/include/gpxe/if_arp.h2
-rw-r--r--gpxe/src/include/gpxe/if_ether.h3
-rw-r--r--gpxe/src/include/gpxe/image.h36
-rw-r--r--gpxe/src/include/gpxe/in.h7
-rw-r--r--gpxe/src/include/gpxe/infiniband.h682
-rw-r--r--gpxe/src/include/gpxe/init.h14
-rw-r--r--gpxe/src/include/gpxe/interface.h2
-rw-r--r--gpxe/src/include/gpxe/io.h506
-rw-r--r--gpxe/src/include/gpxe/iobuf.h40
-rw-r--r--gpxe/src/include/gpxe/ip.h2
-rw-r--r--gpxe/src/include/gpxe/ip6.h2
-rw-r--r--gpxe/src/include/gpxe/ipoib.h70
-rw-r--r--gpxe/src/include/gpxe/isa.h7
-rw-r--r--gpxe/src/include/gpxe/isa_ids.h2
-rw-r--r--gpxe/src/include/gpxe/isapnp.h7
-rw-r--r--gpxe/src/include/gpxe/iscsi.h28
-rw-r--r--gpxe/src/include/gpxe/job.h4
-rw-r--r--gpxe/src/include/gpxe/keys.h31
-rw-r--r--gpxe/src/include/gpxe/linebuf.h2
-rw-r--r--gpxe/src/include/gpxe/linux_compat.h2
-rw-r--r--gpxe/src/include/gpxe/list.h2
-rw-r--r--gpxe/src/include/gpxe/login_ui.h14
-rw-r--r--gpxe/src/include/gpxe/malloc.h2
-rw-r--r--gpxe/src/include/gpxe/mca.h7
-rw-r--r--gpxe/src/include/gpxe/md5.h6
-rw-r--r--gpxe/src/include/gpxe/memmap.h2
-rw-r--r--gpxe/src/include/gpxe/monojob.h2
-rw-r--r--gpxe/src/include/gpxe/nap.h56
-rw-r--r--gpxe/src/include/gpxe/net80211.h1186
-rw-r--r--gpxe/src/include/gpxe/netdevice.h196
-rw-r--r--gpxe/src/include/gpxe/null_nap.h23
-rw-r--r--gpxe/src/include/gpxe/nvo.h2
-rw-r--r--gpxe/src/include/gpxe/nvs.h2
-rw-r--r--gpxe/src/include/gpxe/open.h16
-rw-r--r--gpxe/src/include/gpxe/pci.h54
-rw-r--r--gpxe/src/include/gpxe/pci_ids.h3
-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.h2
-rw-r--r--gpxe/src/include/gpxe/process.h9
-rw-r--r--gpxe/src/include/gpxe/profile.h2
-rw-r--r--gpxe/src/include/gpxe/ramdisk.h2
-rw-r--r--gpxe/src/include/gpxe/rarp.h2
-rw-r--r--gpxe/src/include/gpxe/rc80211.h19
-rw-r--r--gpxe/src/include/gpxe/refcnt.h2
-rw-r--r--gpxe/src/include/gpxe/resolv.h10
-rw-r--r--gpxe/src/include/gpxe/retry.h11
-rw-r--r--gpxe/src/include/gpxe/rotate.h29
-rw-r--r--gpxe/src/include/gpxe/rsa.h6
-rw-r--r--gpxe/src/include/gpxe/sanboot.h20
-rw-r--r--gpxe/src/include/gpxe/scsi.h31
-rw-r--r--gpxe/src/include/gpxe/sec80211.h83
-rw-r--r--gpxe/src/include/gpxe/segment.h2
-rw-r--r--gpxe/src/include/gpxe/serial.h2
-rw-r--r--gpxe/src/include/gpxe/settings.h97
-rw-r--r--gpxe/src/include/gpxe/settings_ui.h2
-rw-r--r--gpxe/src/include/gpxe/sha1.h15
-rw-r--r--gpxe/src/include/gpxe/shell.h2
-rw-r--r--gpxe/src/include/gpxe/shell_banner.h2
-rw-r--r--gpxe/src/include/gpxe/smbios.h161
-rw-r--r--gpxe/src/include/gpxe/socket.h16
-rw-r--r--gpxe/src/include/gpxe/spi.h10
-rw-r--r--gpxe/src/include/gpxe/spi_bit.h2
-rw-r--r--gpxe/src/include/gpxe/srp.h868
-rw-r--r--gpxe/src/include/gpxe/tables.h263
-rw-r--r--gpxe/src/include/gpxe/tcp.h16
-rw-r--r--gpxe/src/include/gpxe/tcpip.h22
-rw-r--r--gpxe/src/include/gpxe/tftp.h2
-rw-r--r--gpxe/src/include/gpxe/threewire.h16
-rw-r--r--gpxe/src/include/gpxe/timer.h97
-rw-r--r--gpxe/src/include/gpxe/tls.h34
-rw-r--r--gpxe/src/include/gpxe/uaccess.h319
-rw-r--r--gpxe/src/include/gpxe/udp.h3
-rw-r--r--gpxe/src/include/gpxe/umalloc.h57
-rw-r--r--gpxe/src/include/gpxe/uri.h47
-rw-r--r--gpxe/src/include/gpxe/uuid.h2
-rw-r--r--gpxe/src/include/gpxe/virtio-pci.h (renamed from gpxe/src/drivers/net/virtio-pci.h)39
-rw-r--r--gpxe/src/include/gpxe/virtio-ring.h (renamed from gpxe/src/drivers/net/virtio-ring.h)59
-rw-r--r--gpxe/src/include/gpxe/vsprintf.h2
-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.h6
-rw-r--r--gpxe/src/include/hci/ifmgmt_cmd.h30
-rw-r--r--gpxe/src/include/igmp.h42
-rw-r--r--gpxe/src/include/lib.h42
-rw-r--r--gpxe/src/include/libgen.h2
-rw-r--r--gpxe/src/include/little_bswap.h2
-rw-r--r--gpxe/src/include/mii.h122
-rw-r--r--gpxe/src/include/nfs.h63
-rw-r--r--gpxe/src/include/nic.h5
-rw-r--r--gpxe/src/include/nmb.h22
-rw-r--r--gpxe/src/include/readline/readline.h2
-rw-r--r--gpxe/src/include/stdarg.h2
-rw-r--r--gpxe/src/include/stddef.h8
-rw-r--r--gpxe/src/include/stdint.h12
-rw-r--r--gpxe/src/include/stdio.h2
-rw-r--r--gpxe/src/include/stdlib.h3
-rw-r--r--gpxe/src/include/string.h2
-rw-r--r--gpxe/src/include/strings.h2
-rw-r--r--gpxe/src/include/unistd.h20
-rw-r--r--gpxe/src/include/usr/aoeboot.h6
-rw-r--r--gpxe/src/include/usr/autoboot.h10
-rw-r--r--gpxe/src/include/usr/dhcpmgmt.h5
-rw-r--r--gpxe/src/include/usr/ifmgmt.h2
-rw-r--r--gpxe/src/include/usr/imgmgmt.h2
-rw-r--r--gpxe/src/include/usr/iscsiboot.h6
-rw-r--r--gpxe/src/include/usr/iwmgmt.h17
-rw-r--r--gpxe/src/include/usr/route.h2
-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.c (renamed from gpxe/src/arch/i386/firmware/pcbios/smbios.c)122
-rw-r--r--gpxe/src/interface/smbios/smbios_settings.c (renamed from gpxe/src/arch/i386/firmware/pcbios/smbios_settings.c)52
-rw-r--r--gpxe/src/libgcc/__divdi3.c2
-rw-r--r--gpxe/src/libgcc/__moddi3.c2
-rw-r--r--gpxe/src/libgcc/__udivdi3.c2
-rw-r--r--gpxe/src/libgcc/__udivmoddi4.c2
-rw-r--r--gpxe/src/libgcc/__umoddi3.c2
-rw-r--r--gpxe/src/libgcc/icc.c8
-rw-r--r--gpxe/src/libgcc/libgcc.h24
-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.c210
-rw-r--r--gpxe/src/net/arp.c17
-rw-r--r--gpxe/src/net/cachedhcp.c76
-rw-r--r--gpxe/src/net/dhcpopts.c21
-rw-r--r--gpxe/src/net/dhcppkt.c92
-rw-r--r--gpxe/src/net/eapol.c85
-rw-r--r--gpxe/src/net/ethernet.c109
-rw-r--r--gpxe/src/net/fakedhcp.c45
-rw-r--r--gpxe/src/net/icmp.c103
-rw-r--r--gpxe/src/net/icmpv6.c2
-rw-r--r--gpxe/src/net/infiniband.c726
-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.c2
-rw-r--r--gpxe/src/net/ipv4.c68
-rw-r--r--gpxe/src/net/ipv6.c1
-rw-r--r--gpxe/src/net/mii.c147
-rw-r--r--gpxe/src/net/netdev_settings.c38
-rw-r--r--gpxe/src/net/netdevice.c144
-rw-r--r--gpxe/src/net/nullnet.c2
-rw-r--r--gpxe/src/net/rarp.c2
-rw-r--r--gpxe/src/net/retry.c15
-rw-r--r--gpxe/src/net/tcp.c146
-rw-r--r--gpxe/src/net/tcp/ftp.c89
-rw-r--r--gpxe/src/net/tcp/http.c83
-rw-r--r--gpxe/src/net/tcp/https.c2
-rw-r--r--gpxe/src/net/tcp/iscsi.c104
-rw-r--r--gpxe/src/net/tcpip.c26
-rw-r--r--gpxe/src/net/tls.c282
-rw-r--r--gpxe/src/net/udp.c42
-rw-r--r--gpxe/src/net/udp/dhcp.c1686
-rw-r--r--gpxe/src/net/udp/dns.c80
-rw-r--r--gpxe/src/net/udp/slam.c10
-rw-r--r--gpxe/src/net/udp/tftp.c204
-rw-r--r--gpxe/src/proto/fsp.c243
-rw-r--r--gpxe/src/proto/igmp.c167
-rw-r--r--gpxe/src/proto/nfs.c616
-rw-r--r--gpxe/src/proto/nmb.c110
-rw-r--r--gpxe/src/tests/gdbstub_test.S4
-rwxr-xr-x[-rw-r--r--]gpxe/src/tests/gdbstub_test.gdb0
-rw-r--r--gpxe/src/tests/uri_test.c7
-rw-r--r--gpxe/src/usr/aoeboot.c73
-rw-r--r--gpxe/src/usr/autoboot.c118
-rw-r--r--gpxe/src/usr/dhcpmgmt.c34
-rw-r--r--gpxe/src/usr/ifmgmt.c72
-rw-r--r--gpxe/src/usr/imgmgmt.c15
-rw-r--r--gpxe/src/usr/iwmgmt.c244
-rw-r--r--gpxe/src/usr/pxemenu.c383
-rw-r--r--gpxe/src/usr/route.c4
-rw-r--r--gpxe/src/util/.gitignore4
-rwxr-xr-xgpxe/src/util/diffsize.pl101
-rwxr-xr-xgpxe/src/util/disrom.pl47
-rwxr-xr-xgpxe/src/util/dskpad.pl12
-rw-r--r--gpxe/src/util/efirom.c280
-rw-r--r--gpxe/src/util/elf2efi.c808
-rwxr-xr-xgpxe/src/util/geniso7
-rwxr-xr-xgpxe/src/util/genliso51
-rwxr-xr-xgpxe/src/util/gensdsk65
-rw-r--r--gpxe/src/util/iccfix.c156
-rwxr-xr-xgpxe/src/util/licence.pl149
-rwxr-xr-xgpxe/src/util/makerom.pl30
-rwxr-xr-x[-rw-r--r--]gpxe/src/util/mergerom.pl0
-rwxr-xr-xgpxe/src/util/mkconfig.pl205
-rwxr-xr-xgpxe/src/util/modrom.pl4
-rwxr-xr-xgpxe/src/util/padimg.pl44
-rw-r--r--gpxe/src/util/parserom.pl3
-rwxr-xr-xgpxe/src/util/sortobjdump.pl2
-rw-r--r--gpxe/src/util/zbin.c141
-rw-r--r--libfat/cache.c58
-rw-r--r--libfat/fat.h132
-rw-r--r--libfat/fatchain.c190
-rw-r--r--libfat/libfat.h18
-rw-r--r--libfat/libfatint.h36
-rw-r--r--libfat/open.c172
-rw-r--r--libfat/searchdir.c67
-rw-r--r--libfat/ulint.h84
-rw-r--r--libinstaller/Makefile9
-rw-r--r--libinstaller/advio.c160
-rwxr-xr-xlibinstaller/bin2c.pl4
-rw-r--r--libinstaller/fat.c129
-rw-r--r--libinstaller/linux/fiemap.h68
-rw-r--r--libinstaller/linux/loop.h96
-rw-r--r--libinstaller/linuxioctl.h47
-rw-r--r--libinstaller/setadv.c186
-rw-r--r--libinstaller/setadv.h16
-rw-r--r--libinstaller/syslinux.h37
-rw-r--r--libinstaller/syslxcom.c286
-rw-r--r--libinstaller/syslxcom.h22
-rw-r--r--libinstaller/syslxint.h230
-rw-r--r--libinstaller/syslxmod.c370
-rw-r--r--libinstaller/syslxopt.c237
-rw-r--r--libinstaller/syslxopt.h38
-rw-r--r--linux/Makefile17
-rw-r--r--linux/syslinux.c738
-rw-r--r--lzo/.gitignore1
-rw-r--r--lzo/LZO.TXT291
-rw-r--r--lzo/Makefile39
-rw-r--r--lzo/include/lzo/lzo1.h96
-rw-r--r--lzo/include/lzo/lzo1a.h96
-rw-r--r--lzo/include/lzo/lzo1b.h160
-rw-r--r--lzo/include/lzo/lzo1c.h160
-rw-r--r--lzo/include/lzo/lzo1f.h108
-rw-r--r--lzo/include/lzo/lzo1x.h177
-rw-r--r--lzo/include/lzo/lzo1y.h145
-rw-r--r--lzo/include/lzo/lzo1z.h150
-rw-r--r--lzo/include/lzo/lzo2a.h92
-rw-r--r--lzo/include/lzo/lzo_asm.h139
-rw-r--r--lzo/include/lzo/lzoconf.h417
-rw-r--r--lzo/include/lzo/lzodefs.h1807
-rw-r--r--lzo/include/lzo/lzoutil.h73
-rw-r--r--lzo/prepcore.c385
-rw-r--r--lzo/src/compr1b.h81
-rw-r--r--lzo/src/compr1c.h81
-rw-r--r--lzo/src/config1x.h118
-rw-r--r--lzo/src/lzo1_d.ch155
-rw-r--r--lzo/src/lzo1x_1.c50
-rw-r--r--lzo/src/lzo1x_1k.c50
-rw-r--r--lzo/src/lzo1x_1l.c50
-rw-r--r--lzo/src/lzo1x_1o.c50
-rw-r--r--lzo/src/lzo1x_9x.c881
-rw-r--r--lzo/src/lzo1x_c.ch351
-rw-r--r--lzo/src/lzo1x_d.ch466
-rw-r--r--lzo/src/lzo1x_d1.c46
-rw-r--r--lzo/src/lzo1x_d2.c46
-rw-r--r--lzo/src/lzo1x_d3.c108
-rw-r--r--lzo/src/lzo1x_o.c45
-rw-r--r--lzo/src/lzo1x_oo.ch366
-rw-r--r--lzo/src/lzo_conf.h323
-rw-r--r--lzo/src/lzo_crc.c167
-rw-r--r--lzo/src/lzo_dict.h316
-rw-r--r--lzo/src/lzo_dll.ch64
-rw-r--r--lzo/src/lzo_init.c176
-rw-r--r--lzo/src/lzo_mchw.ch242
-rw-r--r--lzo/src/lzo_ptr.c92
-rw-r--r--lzo/src/lzo_ptr.h154
-rw-r--r--lzo/src/lzo_str.c71
-rw-r--r--lzo/src/lzo_swd.ch707
-rw-r--r--lzo/src/lzo_util.c165
-rw-r--r--lzo/src/miniacc.h6553
-rw-r--r--lzo/src/stats1a.h137
-rw-r--r--lzo/src/stats1b.h142
-rw-r--r--lzo/src/stats1c.h61
-rw-r--r--man/extlinux.164
-rw-r--r--man/syslinux.112
-rw-r--r--mbr/Makefile33
-rw-r--r--mbr/adjust.h53
-rw-r--r--mbr/altmbr.S304
-rwxr-xr-xmbr/checksize.pl36
-rw-r--r--mbr/gptmbr.S79
-rw-r--r--mbr/isohdpfx.S103
-rw-r--r--mbr/isohdppx.S2
-rw-r--r--mbr/mbr.S14
-rw-r--r--memdisk/Makefile87
-rw-r--r--memdisk/acpi.h55
-rw-r--r--memdisk/bda.h56
-rw-r--r--memdisk/compiler.h9
-rw-r--r--memdisk/conio.c553
-rw-r--r--memdisk/conio.h2
-rw-r--r--memdisk/dskprobe.c114
-rw-r--r--memdisk/dskprobe.h21
-rw-r--r--memdisk/e820.h9
-rw-r--r--memdisk/e820func.c133
-rw-r--r--memdisk/e820test.c87
-rw-r--r--memdisk/eltorito.c58
-rw-r--r--memdisk/eltorito.h80
-rw-r--r--memdisk/inflate.c1401
-rw-r--r--memdisk/memdisk.h121
-rw-r--r--memdisk/memdisk.inc (renamed from memdisk/memdisk.asm)330
-rw-r--r--memdisk/memdisk.ld (renamed from dos/com16.ld)27
-rw-r--r--memdisk/memdisk16.asm238
-rw-r--r--memdisk/memdisk_chs_512.asm5
-rw-r--r--memdisk/memdisk_edd_512.asm5
-rw-r--r--memdisk/memdisk_iso_2048.asm5
-rw-r--r--memdisk/memdisk_iso_512.asm5
-rw-r--r--memdisk/memmove.S139
-rw-r--r--memdisk/msetup.c220
-rw-r--r--memdisk/mstructs.h178
-rwxr-xr-xmemdisk/postprocess.pl6
-rw-r--r--memdisk/setup.c1939
-rw-r--r--memdisk/start32.S105
-rw-r--r--memdisk/unzip.c413
-rw-r--r--memdump/Makefile12
-rw-r--r--memdump/__divdi3.c30
-rw-r--r--memdump/__udivmoddi4.c42
-rw-r--r--memdump/argv.c82
-rw-r--r--memdump/conio.c22
-rw-r--r--memdump/file.h25
-rw-r--r--memdump/io.h24
-rw-r--r--memdump/main.c200
-rw-r--r--memdump/malloc.h10
-rw-r--r--memdump/mystuff.h5
-rw-r--r--memdump/printf.c481
-rw-r--r--memdump/serial.c111
-rw-r--r--memdump/skipatou.c8
-rw-r--r--memdump/srecsend.c75
-rw-r--r--memdump/srecsend.h10
-rw-r--r--memdump/stdbool.h32
-rw-r--r--memdump/stdint.h56
-rw-r--r--memdump/stdio.h2
-rw-r--r--memdump/stdlib.h2
-rw-r--r--memdump/string.h8
-rw-r--r--memdump/strtoul.c90
-rw-r--r--memdump/ymsend.c270
-rw-r--r--memdump/ymsend.h18
-rw-r--r--menu/complex.c423
-rw-r--r--menu/libmenu/com32io.c146
-rw-r--r--menu/libmenu/com32io.h112
-rw-r--r--menu/libmenu/des.c1101
-rw-r--r--menu/libmenu/des.h8
-rw-r--r--menu/libmenu/help.c200
-rw-r--r--menu/libmenu/menu.c1300
-rw-r--r--menu/libmenu/menu.h291
-rw-r--r--menu/libmenu/passwords.c140
-rw-r--r--menu/libmenu/passwords.h27
-rw-r--r--menu/libmenu/scancodes.h86
-rw-r--r--menu/libmenu/syslnx.c88
-rw-r--r--menu/libmenu/tui.c357
-rw-r--r--menu/simple.c79
-rw-r--r--mime/image/x-lss16.xml39
-rw-r--r--modules/Makefile13
-rw-r--r--modules/int18.asm16
-rw-r--r--modules/poweroff.asm102
-rw-r--r--modules/pxechain.asm23
-rw-r--r--mtools/Makefile10
-rw-r--r--mtools/syslinux.c532
-rw-r--r--sample/Makefile16
-rw-r--r--sample/atou.c13
-rw-r--r--sample/c32echo.c29
-rw-r--r--sample/conio.c37
-rw-r--r--sample/fd.c64
-rw-r--r--sample/filetest.c129
-rw-r--r--sample/hello.c23
-rw-r--r--sample/hello2.c32
-rw-r--r--sample/mdiskchk.c146
-rwxr-xr-xsample/mdiskchk.combin9680 -> 0 bytes
-rw-r--r--sample/printf.c486
-rw-r--r--sample/skipatou.c13
-rw-r--r--syslinux.spec.in7
-rw-r--r--utils/Makefile32
-rw-r--r--utils/bin2hex.pl8
-rw-r--r--utils/gethostip.c176
-rw-r--r--utils/isohdpfxarray.pl57
-rw-r--r--utils/isohybrid.c559
-rw-r--r--utils/isohybrid.h27
-rw-r--r--utils/isohybrid.in150
-rwxr-xr-xutils/keytab-lilo32
-rw-r--r--utils/memdiskfind.c158
-rw-r--r--utils/mkdiskimage.in36
-rwxr-xr-xutils/pxelinux-options499
-rw-r--r--version2
-rw-r--r--win32/Makefile30
-rwxr-xr-xwin32/find-mingw.sh8
-rw-r--r--win32/hello.c4
-rw-r--r--win32/syslinux.c818
1726 files changed, 204145 insertions, 80866 deletions
diff --git a/.gitignore b/.gitignore
index 7657c3d0..cece7b5f 100644
--- a/.gitignore
+++ b/.gitignore
@@ -9,13 +9,16 @@
*.elf
*.exe
*.gen
+*.lib
*.lnx
*.lo
*.lsr
*.lst
*.map
*.o
+*.obj
*.orig
+*.raw
*.rej
*.s
*.sec
@@ -34,7 +37,10 @@
/linux/syslinux
/linux/syslinux-nomtools
/utils/gethostip
+/utils/isohdpfx.c
/utils/isohybrid
+/utils/isohybrid.pl
+/utils/memdiskfind
/utils/mkdiskimage
/version.h
/version.mk
diff --git a/BUGS b/BUGS
deleted file mode 100644
index 9639da80..00000000
--- a/BUGS
+++ /dev/null
@@ -1,4 +0,0 @@
-Known bugs that have not yet been fixed:
-
-- PXELINUX: Some PXE stacks fail with routing enabled, some with
- routing disabled. Try both?
diff --git a/MCONFIG b/MCONFIG
index 9900ac4a..c76b5917 100644
--- a/MCONFIG
+++ b/MCONFIG
@@ -32,13 +32,17 @@ BOOTDIR = /boot
EXTLINUXDIR = $(BOOTDIR)/extlinux
NASM = nasm
-NASMOPT = -O9999
+NASMOPT = -Ox
PERL = perl
+UPX = upx
+
+CHMOD = chmod
CC = gcc
gcc_ok = $(shell tmpf=gcc_ok.$$$$.tmp; \
- if $(CC) $(1) -c $(topdir)/dummy.c -o $$tmpf 2>/dev/null ; \
+ if $(CC) $(GCCOPT) $(1) -c $(topdir)/dummy.c \
+ -o $$tmpf 2>/dev/null ; \
then echo '$(1)'; else echo '$(2)'; fi; \
rm -f $$tmpf)
@@ -50,5 +54,29 @@ NM = nm
RANLIB = ranlib
GZIPPROG = gzip
PNGTOPNM = pngtopnm
+MCOPY = mcopy
+MFORMAT = mformat
+MKISOFS = mkisofs
+SED = sed
+WGET = wget
com32 = $(topdir)/com32
+
+# Common warnings we want for all gcc-generated code
+GCCWARN := -W -Wall -Wstrict-prototypes
+# Extremely useful variant for debugging...
+#GCCWARN += -Wno-clobbered -Werror
+
+# Common stanza to make gcc generate .*.d dependency files
+MAKEDEPS = -Wp,-MT,$@,-MD,$(dir $@).$(notdir $@).d
+
+# Dependencies that exclude system headers; use whenever we use
+# header files from the platform.
+UMAKEDEPS = -Wp,-MT,$@,-MMD,$(dir $@).$(notdir $@).d
+
+# Items that are only appropriate during development; this file is
+# removed when tarballs are generated.
+-include $(topdir)/MCONFIG.devel
+
+# Local additions, like -DDEBUG can go here
+-include $(topdir)/MCONFIG.local
diff --git a/MCONFIG.build b/MCONFIG.build
new file mode 100644
index 00000000..d1abff2a
--- /dev/null
+++ b/MCONFIG.build
@@ -0,0 +1,33 @@
+## -*- makefile -*- ------------------------------------------------------
+##
+## Copyright 2001-2008 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
+## the Free Software Foundation, Inc., 53 Temple Place Ste 330,
+## Boston MA 02111-1307, USA; either version 2 of the License, or
+## (at your option) any later version; incorporated herein by reference.
+##
+## -----------------------------------------------------------------------
+
+##
+## Right now we don't distinguish between "build" system and the "host"
+## system, although we really should...
+##
+include $(topdir)/MCONFIG
+
+OPTFLAGS = -g -Os
+INCLUDES =
+CFLAGS = -W -Wall -Wno-sign-compare -D_FILE_OFFSET_BITS=64 \
+ $(OPTFLAGS) $(INCLUDES)
+LDFLAGS =
+LIBS =
+
+.SUFFIXES: .c .o .S .s .i .elf .com .bin .asm .lst .c32 .lss
+
+%.o: %.c
+ $(CC) $(UMAKEDEPS) $(CFLAGS) -c -o $@ $<
+%.i: %.c
+ $(CC) $(UMAKEDEPS) $(CFLAGS) -E -o $@ $<
+%.s: %.c
+ $(CC) $(UMAKEDEPS) $(CFLAGS) -S -o $@ $<
diff --git a/MCONFIG.devel b/MCONFIG.devel
new file mode 100644
index 00000000..104207f5
--- /dev/null
+++ b/MCONFIG.devel
@@ -0,0 +1,2 @@
+# Useful while doing development, but not for production.
+GCCWARN += -Wno-clobbered -Werror
diff --git a/MCONFIG.embedded b/MCONFIG.embedded
index fee374f7..9f5846d7 100644
--- a/MCONFIG.embedded
+++ b/MCONFIG.embedded
@@ -16,20 +16,40 @@
include $(topdir)/MCONFIG
-GCCOPT := $(call gcc_ok,-m32,) \
- $(call gcc_ok,-ffreestanding,) \
- $(call gcc_ok,-fno-stack-protector,) \
- $(call gcc_ok,-falign-functions=0,-malign-functions=0) \
- $(call gcc_ok,-falign-jumps=0,-malign-jumps=0) \
- $(call gcc_ok,-falign-loops=0,-malign-loops=0) \
- -march=i386 -Os -fomit-frame-pointer -mregparm=3 -DREGPARM=3 \
+GCCOPT := $(call gcc_ok,-m32,)
+GCCOPT += $(call gcc_ok,-ffreestanding,)
+GCCOPT += $(call gcc_ok,-fno-stack-protector,)
+GCCOPT += $(call gcc_ok,-fwrapv,)
+GCCOPT += $(call gcc_ok,-freg-struct-return,)
+GCCOPT += -march=i386 -Os -fomit-frame-pointer -mregparm=3 -DREGPARM=3 \
-msoft-float
+GCCOPT += $(call gcc_ok,-fno-exceptions,)
+GCCOPT += $(call gcc_ok,-fno-asynchronous-unwind-tables,)
+GCCOPT += $(call gcc_ok,-fno-strict-aliasing,)
+GCCOPT += $(call gcc_ok,-falign-functions=0,-malign-functions=0)
+GCCOPT += $(call gcc_ok,-falign-jumps=0,-malign-jumps=0)
+GCCOPT += $(call gcc_ok,-falign-labels=0,-malign-labels=0)
+GCCOPT += $(call gcc_ok,-falign-loops=0,-malign-loops=0)
+GCCOPT += $(call gcc_ok,-mpreferred-stack-boundary=2,)
+GCCOPT += $(call gcc_ok,-mincoming-stack-boundary=2,)
LIBGCC := $(shell $(CC) $(GCCOPT) --print-libgcc)
LD += -m elf_i386
-CFLAGS = $(GCCOPT) -g -W -Wall $(OPTFLAGS) $(INCLUDES)
-SFLAGS = $(CFLAGS) -D__ASSEMBLY__
+
+# Note: use += for CFLAGS and SFLAGS in case something is set in MCONFIG.local
+CFLAGS += $(GCCOPT) -g $(GCCWARN) -Wno-sign-compare $(OPTFLAGS) $(INCLUDES)
+SFLAGS += $(CFLAGS) -D__ASSEMBLY__
.SUFFIXES: .c .o .S .s .i .elf .com .bin .asm .lst .c32 .lss
+%.o: %.c
+ $(CC) $(MAKEDEPS) $(CFLAGS) -c -o $@ $<
+%.i: %.c
+ $(CC) $(MAKEDEPS) $(CFLAGS) -E -o $@ $<
+%.s: %.c
+ $(CC) $(MAKEDEPS) $(CFLAGS) -S -o $@ $<
+%.o: %.S
+ $(CC) $(MAKEDEPS) $(SFLAGS) -Wa,-a=$*.lst -c -o $@ $<
+%.s: %.S
+ $(CC) $(MAKEDEPS) $(SFLAGS) -E -o $@ $<
diff --git a/Makefile b/Makefile
index ffbc48f1..fccd0f53 100644
--- a/Makefile
+++ b/Makefile
@@ -1,6 +1,7 @@
## -----------------------------------------------------------------------
##
-## Copyright 1998-2008 H. Peter Anvin - All Rights Reserved
+## Copyright 1998-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
@@ -29,17 +30,21 @@ include $(topdir)/MCONFIG
#
# List of module objects that should be installed for all derivatives
-MODULES = memdisk/memdisk memdump/memdump.com \
- modules/*.com com32/menu/*.c32 com32/modules/*.c32
-
+MODULES = memdisk/memdisk memdump/memdump.com modules/*.com \
+ com32/menu/*.c32 com32/modules/*.c32 com32/mboot/*.c32 \
+ com32/hdt/*.c32 com32/rosh/*.c32 com32/gfxboot/*.c32 \
+ com32/sysdump/*.c32
# syslinux.exe is BTARGET so as to not require everyone to have the
# mingw suite installed
BTARGET = version.gen version.h version.mk
BOBJECTS = $(BTARGET) \
- mbr/mbr.bin mbr/gptmbr.bin \
+ mbr/mbr.bin mbr/altmbr.bin mbr/gptmbr.bin \
+ mbr/mbr_c.bin mbr/altmbr_c.bin mbr/gptmbr_c.bin \
+ mbr/mbr_f.bin mbr/altmbr_f.bin mbr/gptmbr_f.bin \
core/pxelinux.0 core/isolinux.bin core/isolinux-debug.bin \
gpxe/gpxelinux.0 dos/syslinux.com win32/syslinux.exe \
+ dosutil/*.com dosutil/*.sys \
$(MODULES)
# BSUBDIRs build the on-target binary components.
@@ -48,10 +53,10 @@ BOBJECTS = $(BTARGET) \
# Note: libinstaller is both a BSUBDIR and an ISUBDIR. It contains
# files that depend only on the B phase, but may have to be regenerated
# for "make installer".
-BSUBDIRS = codepage core memdisk modules com32 mbr memdump gpxe sample \
- libinstaller dos win32
+BSUBDIRS = codepage com32 lzo core memdisk modules mbr memdump gpxe sample \
+ libinstaller dos win32 dosutil
ITARGET =
-IOBJECTS = $(ITARGET) dos/copybs.com \
+IOBJECTS = $(ITARGET) \
utils/gethostip utils/isohybrid utils/mkdiskimage \
mtools/syslinux linux/syslinux extlinux/extlinux
ISUBDIRS = libinstaller mtools linux extlinux utils
@@ -63,13 +68,12 @@ INSTALL_SBIN = extlinux/extlinux
# Things to install in /usr/lib/syslinux
INSTALL_AUX = core/pxelinux.0 gpxe/gpxelinux.0 core/isolinux.bin \
core/isolinux-debug.bin \
- dos/syslinux.com dos/copybs.com win32/syslinux.exe \
- mbr/mbr.bin mbr/gptmbr.bin \
- $(MODULES)
+ dos/syslinux.com win32/syslinux.exe \
+ mbr/*.bin $(MODULES)
INSTALL_AUX_OPT = win32/syslinux.exe
# These directories manage their own installables
-INSTALLSUBDIRS = com32 utils
+INSTALLSUBDIRS = com32 utils dosutil
# Things to install in /boot/extlinux
EXTBOOTINSTALL = $(MODULES)
@@ -153,11 +157,6 @@ local-spotless:
spotless: local-clean local-dist local-spotless
set -e ; for i in $(BESUBDIRS) $(IESUBDIRS) $(BSUBDIRS) $(ISUBDIRS) ; do $(MAKE) -C $$i $@ ; done
-local-depend:
-
-depend: local-depend
- $(MAKE) -C memdisk depend
-
# Shortcut to build linux/syslinux using klibc
klibc:
$(MAKE) clean
diff --git a/Makefile.private b/Makefile.private
index 866bd7b6..c70c204d 100644
--- a/Makefile.private
+++ b/Makefile.private
@@ -17,7 +17,8 @@
#
.PHONY: official release
-PRIVATE = Makefile.private .depend */.depend
+# These files are removed when tarballs are generated.
+PRIVATE = Makefile.private MCONFIG.devel
GIT_DIR ?= .git
ABS_GIT_DIR := $(shell cd '$(GIT_DIR)' 2>/dev/null && pwd)
@@ -36,7 +37,6 @@ burn: isolinux.iso
official:
$(MAKE) spotless CC='$(CC) -m32'
- $(MAKE) depend CC='$(CC) -m32'
$(MAKE) all CC='$(CC) -m32'
$(MAKE) dist CC='$(CC) -m32'
diff --git a/NEWS b/NEWS
index fbee5944..6fad0103 100644
--- a/NEWS
+++ b/NEWS
@@ -2,6 +2,261 @@ Starting with 1.47, changes marked with SYSLINUX, PXELINUX, ISOLINUX
or EXTLINUX apply to that specific program only; other changes apply
to all derivatives.
+Changes in 4.01:
+ * ISOLINUX: fix initialization on systems which don't zero
+ low memory.
+ * SYSLINUX/EXTLINUX: fix handing of disk read retries in
+ EDD mode.
+ * ISOLINUX: change the initialization sequence to avoid
+ problems with certain (old) BIOSes. Special thanks to
+ Helmut Hullen for invaluable debugging support.
+ * ifplop.c32: new module which detects if the PLoP Boot Loader
+ already has booted a CDROM or USB drive (Gert Hulselmans).
+
+Changes in 4.00:
+ * Major code base changes; all filesystem rewritten in C.
+ This work was done primarily by Liu Aleaxander (Yuanhan Liu).
+ * EXTLINUX: btrfs and ext4 support. btrfs support was done by
+ Alek Du of Intel.
+ * EXTLINUX is no longer a separate derivative; extlinux and
+ syslinux both install the same loader (ldlinux.sys); for the
+ Linux-based installers the extlinux binary is used for a
+ mounted filesystem; the syslinux binary for an unmounted
+ filesystem.
+ * When loading a new configuration file with the CONFIG
+ command, one can now also specify a new current directory
+ with an APPEND statement.
+ * Full ADV support for Syslinux, to boot-once and MENU SAVE
+ works.
+ * Full support of GPT-partitioned disks, including disks
+ and/or parititions larger than 2 TiB (if supported by BIOS.)
+ * The GPT handover protocol adjusted to the current T13
+ committee draft; see doc/gpt.txt.
+ * HDT: code cleanup, small bugfixes
+ * The "linux" syslinux installer (syslinux-nomtools) now has a
+ command-line syntax closer to the extlinux installer. The
+ mtools, dos and win32 installers will get this new syntax
+ eventually, but it is not implemented yet.
+ * chain.c32: support booting GPT partitions by index, GUID, label.
+ * chain.c32: support booting the Syslinux partition with "fs".
+ * chain.c32: implement gpt.txt hand-over protocol.
+ * chain.c32: support for chainloading Grub stage 2.
+ * PXELINUX: TFTP URL syntax (tftp://) supported even when not
+ running gPXE/gpxelinux.
+ * New ls.c32 module to display the contents of the disk from
+ the command line, and pwd.c32 to display the current
+ directory.
+ * rosh.c32 (read only shell) updated and hopefully usable.
+ * PXELINUX: Support "localboot -1", just like the other
+ derivatives.
+ * gfxboot.com removed in favor of gfxboot.c32.
+ * New MENU HELP statement to display fullscreen help text as a
+ result of a menu selection.
+ * memdiskfind utility that can be used with the phram driver
+ in the Linux kernel to mount a memdisk.
+ * ifcpu.c32: Adding usage when no parameters are given,
+ adding PAE support.
+ * ifcpu.c32, ifcpu64.c32: handle more than one argument per
+ target.
+ * isohybrid: C version which does not require Perl.
+ * New command MENU IMMEDIATE to permit hotkeys to activate
+ immediately without needing Enter.
+ * mdiskchk.com supports a --no-sequential (or -n) option to
+ suppress the classic all-drive-probing heuristic. Useful
+ on BIOSes who crash/hang when certain drive numbers are
+ probed.
+ * ElTorito.Sys DOS driver now scans drive numbers upwards
+ instead of downwards, in order to avoid a fairly common
+ bug on some BIOSes where probing drive 0xFF causes a
+ failure.
+
+Changes in 3.86:
+ * chain.c32: fix chainloading the MBR of a hard disk (broken
+ in 3.85).
+ * mboot.c32: report the boot loader name in the information
+ structure.
+ * com32: set argv[0] in a com32 module.
+ * core: add a workaround for a bug in Xen HVM older than
+ version 3.3: disable halt on those platforms.
+ * Fix problems where certain operations in com32 modules would
+ cause the core to believe the system was idle.
+ * MEMDISK: fix MBR detection when used with a DOSEMU header or
+ an offset.
+ * MEMDISK: generate the mBFT checksum correctly.
+
+Changes in 3.85:
+ * gPXELINUX: updated to gPXE 1.0.0. gPXELINUX can now do NBP
+ chainloading, and does not require a second DHCP.
+ * vesamenu.c32: unbreak the default "grey hole" background.
+ * We no longer have a built-in default of "linux auto".
+ Instead, if no DEFAULT or UI statement is found, or the
+ configuration file is missing entirely, we drop to the boot:
+ prompt with an error message (if NOESCAPE is set, we stop
+ with a "boot failed" message; this is also the case for
+ PXELINUX if the configuration file is not found.)
+ * chain.c32: support chainloading Grub4DOS; patch by Gert
+ Hulselmans.
+ * New tool: sysdump.c32, can be used to produce system
+ information for debugging via tftp or ymodem (serial port).
+ * "vga=current" on the Linux command line is now supported.
+ * chain.c32: support for Windows Recovery Console, via the
+ "cmldr=" option.
+ * chain.c32: should now support loading NTLDR from different
+ type media than loaded from.
+ * chain.c32: support chainloading to a FAT/NTFS partition with
+ invalid "hidden sectors" via the "sethidden" option.
+ * memdisk: fix the mBFT ACPI table.
+ * vesamenu.c32: if the image is smaller than the screen, tile
+ it across the whole screen.
+ * mkdiskimage: -s option for producing a sparse image.
+ * vesamenu.c32: support arbitrary resolution setting (beyond
+ BIOS support) on some Intel-based video chipsets. This code
+ is a modified version of the "915resolution" tool by
+ Steve Tomljenovic; your mileage might vary.
+
+Changes in 3.84:
+ * SYSLINUX: make the DOS installer work for MS-DOS 7.x/8.x
+ (Win9x/ME) again.
+ * HDT: updated to version 0.3.6 (numerous changes.)
+ * mboot.c32: now supports video mode setting if requested by
+ the image.
+ * MEMDISK: Fix floppy images of PC-DOS.
+ * MEMDISK: Add support for emulation of CD-ROM images; patch
+ by Shao Miller.
+ * MEMDISK: Comply with the Win9x "safe hook" standard,
+ allowing a protected-mode driver.
+ * MEMDISK: New "mBFT" ACPI table, by analogy with the iSCSI
+ iBFT table. This allows detection from a protected-mode
+ operating system without EDD support.
+ * 32-bit version of the gfxboot loader (gfxboot.c32), so far
+ experimental. This will replace gfxboot.com in the future.
+ * vesamenu.c32: new MENU RESOLUTION directive to set a screen
+ resolution other than 640x480.
+ * chain.c32: add support for loading isolinux.bin.
+ * chain.c32: make sure to always return to text mode.
+ * eltorito.sys: DOS driver for generic CD-ROMs; by Gary Tong
+ and Bart Lagerweij.
+
+Changes in 3.83:
+ * PXELINUX: clear memory before handing over to a chainloaded
+ NBP. This may help avoid a bug in Windows RIS.
+ * PXELINUX: fix localboot after NBP chainloading on certain
+ BIOSes (including ASUS A8N-E, but possibly others.)
+ * chain.c32: support chainloaded bootloaders on ISOLINUX.
+ * PXELINUX: allow filenames up to 251 characters.
+ * MEMDISK: fix problems booting from USB on Thinkpads, and
+ possibly other machines or hardware combinations.
+ * isohybrid: fix the -id option.
+ * HDT: updated to version 0.3.4.
+ * MEMDISK: the stack size is now configurable, with the stack=
+ option.
+ * Simple menu: fix Ctrl-W (word erase) in command-line edit.
+ * Simple menu: fix crash on some platforms.
+ * Gfxboot: fixes to the configuration file parsing.
+ * PXELINUX: add a tool to override specific DHCP options via
+ values hardcoded in the pxelinux.0 file. These hardcoded
+ values can be either "before DHCP" (defaults if DHCP do not
+ provide values), or "after DHCP" (overrides DHCP). The tool
+ pxelinux-options can be used to set these options. This
+ feature does not apply to gpxelinux.0; when used with gPXE
+ this is better handled by modifying the embedded script.
+
+Changes in 3.82:
+ * isohybrid: fix the -partok logic for loading from a partition.
+ * ISOLINUX: deal with systems which return from INT 13h with
+ interrupts disabled.
+ * Do not invoke the idle handler during large file loads.
+ * Simple menu: make ONTIMEOUT work with MENU HIDDEN.
+ * PXELINUX: handle TFTP servers which have extra NULs at the
+ end of an OACK packet.
+
+Changes in 3.81:
+ * Shuffler: fix bug in real-mode entry. This affected a
+ number of modules, probably in relatively unimportant ways,
+ but it completely broke linux.c32.
+ * Improved performance.
+ * Attempt to halt the processor while idle. This can cause
+ bad reponsiveness when using a serial console especially for
+ automated input; if that ends up being a problem, use the
+ new "NOHALT 1" configuration command.
+ * linux.c32 now suppresses all messages if the "quiet" flag is
+ specified.
+ * isohybrid: add a variety of options, and a help message.
+ * ISOLINUX: fix booting in hybrid mode when CBIOS is used.
+ This unfortunately means that the isohybrid handoff protocol
+ has changed, so the isohybrid utility must version-match
+ isolinux.bin.
+ * Drop support for ACPI 3 extended memory flags.
+ * Menu system: don't set the autocr flag on the serial
+ console.
+ * altmbr: fix handling of logical partitions.
+ * altmbr: cap at 439 bytes so the partition select byte isn't
+ part of the file.
+
+Changes in 3.80:
+ * New shuffler mechanism and API.
+ * Rewritten mboot.c32 module.
+ * The syslinux_boot_linux() function has been simplified.
+ * Don't hang trying to boot a "menu quit" label from the CLI.
+ * Fix problem with boot-once "sticking" on some BIOSes.
+ * isohybrid: fix problem with images over 2 GB in size.
+ * APM poweroff module (poweroff.com) by Sebastian Herbszt.
+ * ISOLINUX: fix the handling of large directories. Bug found
+ and fixed by Steffen Winterfeldt.
+
+Changes in 3.75:
+ * PXELINUX: fix the "keeppxe" option, which was broken in
+ 3.74.
+ * MEMDISK: correct the extraction of geometry information from
+ the MBR of a hard disk image, again broken in 3.74.
+ * extlinux(1) man page from Brian Pellin.
+ * Simple menu: MENU SAVE is now controllable on a menu-by-menu
+ or entry-by-entry basis.
+ * gPXELINUX: fix interrupt-disabling bug.
+ * HDT: fix lockup on machines with certain PCI configurations.
+
+Changes in 3.74:
+ * New UI directive, which allows a more natural way to specify
+ a menu system (or not.) With the UI directive specifying
+ the menu system, the DEFAULT directive can be used to select
+ the default entry inside the menus.
+ * kbdmap.c32: new module to load a new keyboard map
+ dynamically.
+ * isohybrid: workaround bug in some versions of binutils.
+ * Fix issue with the placement of the initrd on some machines.
+ * ifcpu64: fix handling of less than three arguments.
+ * Fix bug in the shuffle library when dealing with a very
+ large number of fragments.
+ * Documentation fixes by Vicente Jimenez Aguilar.
+ * gPXE updated to version 0.9.7.
+ * hdt.c32: Hardware Detection Tool, an interactive hardware
+ analyzer module by Erwan Velu.
+ * MEMDISK: enable automatic determination of the disk geometry
+ for a large floppy disk image if (and only if) it is
+ formatted with a FAT filesystem.
+ * SYSLINUX: fix the handling of .bss files on FAT12/16.
+ * Suppress the Loading ... message if "quiet" is specified on
+ the kernel command line.
+ * Fix the use of "CONSOLE 0" with menu.c32.
+ * Allow COM32 modules to be aware of all memory even in the
+ presence of a memory hole. The "linux.c32" module can be
+ used to load a kernel (or memdisk) plus large initrd on
+ such a system.
+ * MBR: produce alternate MBR variants which force the drive
+ number to hd0 (_f variants), or force the drive number to
+ hd0 if the Ctrl key is pressed (_c variants.) Furthermore,
+ add an MBR variant (altmbr*.bin) which ignores the active
+ flag and instead boots the partition number specified in the
+ byte at offset 439 decimal.
+ * Add IPAPPEND strings to com32 modules, especially needed for
+ linux.c32.
+ * New MENU SAVE directive which saves the latest menu
+ selection until the next boot. Currently only implemented for
+ EXTLINUX.
+ * gfxboot.com: *experimental* interface module to Steffen
+ Winterfeldt's "gfxboot" graphical front end
+ (http://gfxboot.sourceforge.net/). Module by Sebastian Herbszt.
+
Changes in 3.73:
* Upgrade gPXE to release version 0.9.5.
* Fix a number of build errors on various platforms.
@@ -16,6 +271,9 @@ Changes in 3.73:
* mboot.c32: add "-solaris" option to pass DHCP information to
the Solaris kernel; required for automatic Solaris boot
without using Solaris' pxeboot program.
+ * config.c32: trivial COM32 module to restart Syslinux with
+ another configuration file from the command line (equivalent
+ to the CONFIG command in the configuratin file.)
Changes in 3.72:
* Include the pxechain.com module from Jeffery Hutzelman at
diff --git a/README b/README
index 0e92ea2e..aebc421c 100644
--- a/README
+++ b/README
@@ -25,7 +25,7 @@ for details.
SYSLINUX is:
- Copyright 1994-2008 H. Peter Anvin - All Rights Reserved
+ Copyright 1994-2010 H. Peter Anvin et al - 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
diff --git a/TODO b/TODO
deleted file mode 100644
index 530b4bfb..00000000
--- a/TODO
+++ /dev/null
@@ -1,22 +0,0 @@
-*** To do in the short term:
-
-- PXELINUX: Figure out localboot/idle problems.
-
-- PXELINUX: Support changing the default server and boot file prefix?
-
-- Library support for all the comboot system calls.
-
-- Deal with non-512-byte sectors (if I can get media which does...)
-
-
-*** Future projects:
-
-- Clean up the command-line parsing.
-
-- Cleaned up documentation, with a real man page.
-
-- API call to get directory listing.
-
-- COM32-based CLI.
-
-- Rewrite the filesystems to run in protected mode C code.
diff --git a/codepage/cptable.pl b/codepage/cptable.pl
index c7e20023..e29cf006 100755
--- a/codepage/cptable.pl
+++ b/codepage/cptable.pl
@@ -82,7 +82,7 @@ open(CPOUT, '>', $cpout)
# Magic number, in anticipation of being able to load these
# files dynamically...
#
-print CPOUT pack("VV", 0x8fad232b, 0x9c295319);
+print CPOUT pack("VV", 0x58a8b3d4, 0x51d21eb1);
# Header fields available for future use...
print CPOUT pack("VVVVVV", 0, 0, 0, 0, 0, 0);
@@ -97,6 +97,7 @@ print CPOUT pack("VVVVVV", 0, 0, 0, 0, 0, 0);
# ... where @ytab is console codepage -> Unicode and
# %tabx is Unicode -> filesystem codepage.
#
+@uctab = (undef) x 256;
for ($i = 0; $i < 256; $i++) {
$uuc = $ucase{$ytab[$i]}; # Unicode upper case
if (defined($tabx{$uuc})) {
@@ -106,18 +107,48 @@ for ($i = 0; $i < 256; $i++) {
# Upper case equivalent stripped of accents
$u = $tabx{${$decomp{$uuc}}[0]};
} else {
- # No equivalent at all found. Set this to zero, which should
- # prevent shortname matching altogether (still making longname
- # matching possible, of course.)
- $u = 0;
+ # No equivalent at all found. Assume it is a lower-case-only
+ # character, like greek alpha in CP437.
+ $u = $i;
}
+ $uctab[$i] = $u;
print CPOUT pack("C", $u);
}
#
+# Self (shortname) lowercase table.
+# This depends both on the console codepage and the filesystem codepage;
+# the logical transcoding operation is:
+#
+# $taby{$lcase{$xtab[$i]}}
+#
+# ... where @ytab is console codepage -> Unicode and
+# %tabx is Unicode -> filesystem codepage.
+#
+@lctab = (undef) x 256;
+for ($i = 0; $i < 256; $i++) {
+ $llc = $lcase{$xtab[$i]}; # Unicode lower case
+ if (defined($l = $taby{$llc}) && $uctab[$l] == $i) {
+ # Straight-forward conversion
+ } elsif (defined($l = $tabx{${$decomp{$llc}}[0]}) && $uctab[$l] == $i) {
+ # Lower case equivalent stripped of accents
+ } else {
+ # No equivalent at all found. Find *anything* that matches the
+ # bijection criterion...
+ for ($l = 0; $l < 256; $l++) {
+ last if ($uctab[$l] == $i);
+ }
+ $l = $i if ($l == 256); # If nothing, we're screwed anyway...
+ }
+ $lctab[$i] = $l;
+ print CPOUT pack("C", $l);
+}
+
+#
# Unicode (longname) matching table.
# This only depends on the console codepage.
#
+$pp0 = ''; $pp1 = '';
for ($i = 0; $i < 256; $i++) {
if (!defined($ytab[$i])) {
$p0 = $p1 = 0xffff;
@@ -136,8 +167,10 @@ for ($i = 0; $i < 256; $i++) {
# Only the BMP is supported...
$p0 = 0xffff if ($p0 > 0xffff);
$p1 = 0xffff if ($p1 > 0xffff);
- print CPOUT pack("vv", $p0, $p1);
+ $pp0 .= pack("v", $p0);
+ $pp1 .= pack("v", $p1);
}
+print CPOUT $pp0, $pp1;
close (CPOUT);
diff --git a/com32/LICENCE b/com32/LICENCE
index 4fd64b3c..7eec7862 100644
--- a/com32/LICENCE
+++ b/com32/LICENCE
@@ -2,7 +2,8 @@ libcom32 and libutil are licensed under the MIT license:
## -----------------------------------------------------------------------
##
-## Copyright 2004-2008 H. Peter Anvin - All Rights Reserved
+## Copyright 2004-2009 H. Peter Anvin - All Rights Reserved
+## Portions Copyright 2009 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
@@ -27,5 +28,5 @@ libcom32 and libutil are licensed under the MIT license:
##
## -----------------------------------------------------------------------
-The files in the samples and modules directories are mostly under the
+The files in the sample, modules and libgpl directories are mostly under the
GNU GPL (see the file COPYING in the directory above.)
diff --git a/com32/MCONFIG b/com32/MCONFIG
index 2b7e018b..a74ed326 100644
--- a/com32/MCONFIG
+++ b/com32/MCONFIG
@@ -1,6 +1,7 @@
## -*- makefile -*- -------------------------------------------------------
-##
-## Copyright 2008 H. Peter Anvin - All Rights Reserved
+##
+## 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
@@ -16,49 +17,77 @@
include $(topdir)/MCONFIG
-GCCOPT := $(call gcc_ok,-std=gnu99,) \
- $(call gcc_ok,-m32,) \
- $(call gcc_ok,-fno-stack-protector,) \
- -mregparm=3 -DREGPARM=3 -march=i386 -Os
+GCCOPT := $(call gcc_ok,-std=gnu99,)
+GCCOPT += $(call gcc_ok,-m32,)
+GCCOPT += $(call gcc_ok,-fno-stack-protector,)
+GCCOPT += $(call gcc_ok,-fwrapv,)
+GCCOPT += $(call gcc_ok,-freg-struct-return,)
+GCCOPT += -mregparm=3 -DREGPARM=3 -march=i386 -Os
+GCCOPT += $(call gcc_ok,-fPIE,-fPIC)
+GCCOPT += $(call gcc_ok,-fno-exceptions,)
+GCCOPT += $(call gcc_ok,-fno-asynchronous-unwind-tables,)
+GCCOPT += $(call gcc_ok,-fno-strict-aliasing,)
+GCCOPT += $(call gcc_ok,-falign-functions=0,-malign-functions=0)
+GCCOPT += $(call gcc_ok,-falign-jumps=0,-malign-jumps=0)
+GCCOPT += $(call gcc_ok,-falign-labels=0,-malign-labels=0)
+GCCOPT += $(call gcc_ok,-falign-loops=0,-malign-loops=0)
+GCCOPT += $(call gcc_ok,-mpreferred-stack-boundary=2,)
+GCCOPT += $(call gcc_ok,-incoming-stack-boundary=2,)
+
+com32 := $(topdir)/com32
+RELOCS := $(com32)/tools/relocs
-com32 = $(topdir)/com32
+ifneq ($(NOGPL),1)
+GPLLIB = $(com32)/gpllib/libcom32gpl.a
+GPLINCLUDE = -I$(com32)/gplinclude
+else
+GPLLIB =
+GPLINCLUDE =
+endif
-CFLAGS = $(GCCOPT) -W -Wall -march=i386 \
+CFLAGS = $(GCCOPT) $(GCCWARN) -march=i386 \
-fomit-frame-pointer -D__COM32__ \
-nostdinc -iwithprefix include \
- -I$(com32)/libutil/include -I$(com32)/include
-SFLAGS = $(GCCOPT) -D__COM32__ -march=i386
-LDFLAGS = -m elf_i386 -T $(com32)/lib/com32.ld
+ -I$(com32)/libutil/include -I$(com32)/include $(GPLINCLUDE)
+SFLAGS = $(GCCOPT) $(GCCWARN) -march=i386 \
+ -fomit-frame-pointer -D__COM32__ \
+ -nostdinc -iwithprefix include \
+ -I$(com32)/libutil/include -I$(com32)/include $(GPLINCLUDE)
+
+COM32LD = $(com32)/lib/com32.ld
+LDFLAGS = -m elf_i386 --emit-relocs -T $(COM32LD)
LIBGCC := $(shell $(CC) $(GCCOPT) --print-libgcc)
-LNXCFLAGS = -I$(com32)/libutil/include -W -Wall -O -g -D_GNU_SOURCE
+LNXCFLAGS = -I$(com32)/libutil/include $(GCCWARN) -O -g \
+ -D_GNU_SOURCE -D_FORTIFY_SOURCE=0 -Wno-error
LNXSFLAGS = -g
LNXLDFLAGS = -g
-C_LIBS = $(com32)/libutil/libutil_com.a $(com32)/lib/libcom32.a $(LIBGCC)
+C_LIBS = $(com32)/libutil/libutil_com.a $(GPLLIB) \
+ $(com32)/lib/libcom32.a $(LIBGCC)
C_LNXLIBS = $(com32)/libutil/libutil_lnx.a
.SUFFIXES: .lss .c .lo .o .elf .c32 .lnx
.PRECIOUS: %.o
%.o: %.S
- $(CC) $(SFLAGS) -c -o $@ $<
+ $(CC) $(MAKEDEPS) $(SFLAGS) -c -o $@ $<
.PRECIOUS: %.o
%.o: %.c
- $(CC) $(CFLAGS) -c -o $@ $<
+ $(CC) $(MAKEDEPS) $(CFLAGS) -c -o $@ $<
.PRECIOUS: %.elf
-%.elf: %.o $(LIBS) $(C_LIBS)
- $(LD) $(LDFLAGS) -o $@ $^
+%.elf: %.o $(LIBS) $(C_LIBS) $(COM32LD)
+ $(LD) $(LDFLAGS) -o $@ $(filter-out $(COM32LD),$^)
.PRECIOUS: %.lo
%.lo: %.S
- $(CC) $(LNXSFLAGS) -c -o $@ $<
+ $(CC) $(MAKEDEPS) $(LNXSFLAGS) -c -o $@ $<
.PRECIOUS: %.lo
%.lo: %.c
- $(CC) $(LNXCFLAGS) -c -o $@ $<
+ $(CC) $(MAKEDEPS) $(LNXCFLAGS) -c -o $@ $<
.PRECIOUS: %.lnx
%.lnx: %.lo $(LNXLIBS) $(C_LNXLIBS)
@@ -66,3 +95,4 @@ C_LNXLIBS = $(com32)/libutil/libutil_lnx.a
%.c32: %.elf
$(OBJCOPY) -O binary $< $@
+ $(RELOCS) $< >> $@ || ( rm -f $@ ; false )
diff --git a/com32/Makefile b/com32/Makefile
index 5d1ff449..b090c403 100644
--- a/com32/Makefile
+++ b/com32/Makefile
@@ -1,4 +1,5 @@
-SUBDIRS = lib libutil modules menu samples lua/src
+SUBDIRS = tools lib gpllib libutil modules mboot menu samples rosh cmenu \
+ hdt gfxboot sysdump lua/src
all tidy dist clean spotless install:
set -e; for d in $(SUBDIRS); do $(MAKE) -C $$d $@; done
diff --git a/com32/cmenu/.gitignore b/com32/cmenu/.gitignore
new file mode 100644
index 00000000..4add14ba
--- /dev/null
+++ b/com32/cmenu/.gitignore
@@ -0,0 +1,2 @@
+test.c
+test2.c
diff --git a/menu/CHANGES b/com32/cmenu/CHANGES
index cce21838..cce21838 100644
--- a/menu/CHANGES
+++ b/com32/cmenu/CHANGES
diff --git a/menu/HISTORY b/com32/cmenu/HISTORY
index 8e9beb3f..8e9beb3f 100644
--- a/menu/HISTORY
+++ b/com32/cmenu/HISTORY
diff --git a/menu/MANUAL b/com32/cmenu/MANUAL
index 4e70149c..4e70149c 100644
--- a/menu/MANUAL
+++ b/com32/cmenu/MANUAL
diff --git a/menu/MENU_FORMAT b/com32/cmenu/MENU_FORMAT
index 24cb02f8..24cb02f8 100644
--- a/menu/MENU_FORMAT
+++ b/com32/cmenu/MENU_FORMAT
diff --git a/menu/Makefile b/com32/cmenu/Makefile
index 151e2822..794af741 100644
--- a/menu/Makefile
+++ b/com32/cmenu/Makefile
@@ -1,6 +1,7 @@
## -----------------------------------------------------------------------
##
-## Copyright 2001-2008 H. Peter Anvin - All Rights Reserved
+## Copyright 2001-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
@@ -11,14 +12,16 @@
## -----------------------------------------------------------------------
##
-## samples for syslinux users
+## Makefile for the complex menu system
##
+NOGPL := 1
+
# This must be defined before MCONFIG is included
LIBS = libmenu/libmenu.a
-topdir = ..
-include $(topdir)/com32/MCONFIG
+topdir = ../..
+include ../MCONFIG
CFLAGS += -I./libmenu
@@ -36,21 +39,6 @@ MENUS = $(CMENUS) $(IMENUS)
%.c: %.menu adv_menu.tpl
python menugen.py --input=$< --output=$@ --template=adv_menu.tpl
-.PRECIOUS: %.o
-%.o: %.S
- $(CC) $(SFLAGS) -c -o $@ $<
-
-.PRECIOUS: %.o
-%.o: %.c %.h
- $(CC) $(CFLAGS) -c -o $@ $<
-
-.PRECIOUS: %.elf
-%.elf: %.o libmenu/libmenu.a $(LIBS)
- $(LD) $(LDFLAGS) -o $@ $^
-
-%.c32: %.elf
- $(OBJCOPY) -O binary $< $@
-
all: menus
libmenu/libmenu.a: $(LIBMENU)
@@ -59,12 +47,12 @@ libmenu/libmenu.a: $(LIBMENU)
$(RANLIB) $@
tidy dist:
- rm -f *.o *.lo *.a *.lst *.elf
+ rm -f *.o *.lo *.a *.lst *.elf .*.d */.*.d
libclean:
rm -f libmenu/*.o libmenu/*.a
-clean: tidy menuclean
+clean: tidy menuclean libclean
rm -f *.lss *.c32 *.com
menuclean:
@@ -76,3 +64,5 @@ spotless: clean libclean menuclean
menus: $(MENUS)
install: # Don't install samples
+
+-include .*.d */.*.d
diff --git a/menu/README b/com32/cmenu/README
index d585d2fa..d585d2fa 100644
--- a/menu/README
+++ b/com32/cmenu/README
diff --git a/menu/TODO b/com32/cmenu/TODO
index d2ee82c4..d2ee82c4 100644
--- a/menu/TODO
+++ b/com32/cmenu/TODO
diff --git a/menu/adv_menu.tpl b/com32/cmenu/adv_menu.tpl
index 6ce4acf8..871c7827 100644
--- a/menu/adv_menu.tpl
+++ b/com32/cmenu/adv_menu.tpl
@@ -40,6 +40,7 @@ modify this template to suit your needs
#include "com32io.h"
#include <string.h>
#include <stdlib.h>
+#include <unistd.h>
#define MAX_CMD_LINE_LENGTH 514
@@ -182,36 +183,41 @@ TIMEOUTCODE timeout(const char *cmd)
}
}
-TIMEOUTCODE ontimeout()
+TIMEOUTCODE ontimeout(void)
{
return timeout(timeoutcmd);
}
-TIMEOUTCODE ontotaltimeout()
+TIMEOUTCODE ontotaltimeout(void)
{
return timeout(totaltimeoutcmd);
}
-void keys_handler(t_menusystem *ms, t_menuitem *mi,unsigned int scancode)
+void keys_handler(t_menusystem * ms __attribute__ (( unused )), t_menuitem * mi, int scancode)
{
- char nc;
+ int nc, nr;
- if ( ((scancode >> 8) == F1) && (mi->helpid != 0xFFFF) ) { // If scancode of F1 and non-trivial helpid
+ if (getscreensize(1, &nr, &nc)) {
+ /* Unknown screen size? */
+ nc = 80;
+ nr = 24;
+ }
+
+ if ( (scancode == KEY_F1) && (mi->helpid != 0xFFFF) ) { // If scancode of F1 and non-trivial helpid
runhelpsystem(mi->helpid);
}
// If user hit TAB, and item is an "executable" item
// and user has privileges to edit it, edit it in place.
- if (((scancode & 0xFF) == 0x09) && (mi->action == OPT_RUN) &&
- (EDIT_ROW < getnumrows()) && (EDIT_ROW > 0) &&
+ if ((scancode == KEY_TAB) && (mi->action == OPT_RUN) &&
+ (EDIT_ROW < nr) && (EDIT_ROW > 0) &&
(isallowed(username,"editcmd") || isallowed(username,"root"))) {
- nc = getnumcols();
// User typed TAB and has permissions to edit command line
- gotoxy(EDIT_ROW,1,ms->menupage);
+ gotoxy(EDIT_ROW,1);
csprint("Command line:",0x07);
editstring(mi->data,ACTIONLEN);
- gotoxy(EDIT_ROW,1,ms->menupage);
- cprint(' ',0x07,nc-1,ms->menupage);
+ gotoxy(EDIT_ROW,1);
+ cprint(' ',0x07,nc-1);
}
}
@@ -220,23 +226,30 @@ t_handler_return login_handler(t_menusystem *ms, t_menuitem *mi)
(void)mi; // Unused
char pwd[40];
char login[40];
- char nc;
+ int nc, nr;
t_handler_return rv;
+ (void)ms;
+
rv = ACTION_INVALID;
if (PWD_ROW < 0) return rv; // No need to authenticate
if (mi->item == loginstr) { /* User wants to login */
- nc = getnumcols();
- gotoxy(PWD_ROW,1,ms->menupage);
+ if (getscreensize(1, &nr, &nc)) {
+ /* Unknown screen size? */
+ nc = 80;
+ nr = 24;
+ }
+
+ gotoxy(PWD_ROW,1);
csprint("Enter Username: ",0x07);
getstring(login, sizeof username);
- gotoxy(PWD_ROW,1,ms->menupage);
- cprint(' ',0x07,nc,ms->menupage);
+ gotoxy(PWD_ROW,1);
+ cprint(' ',0x07,nc);
csprint("Enter Password: ",0x07);
getpwd(pwd, sizeof pwd);
- gotoxy(PWD_ROW,1,ms->menupage);
- cprint(' ',0x07,nc,ms->menupage);
+ gotoxy(PWD_ROW,1);
+ cprint(' ',0x07,nc);
if (authenticate_user(login,pwd))
{
diff --git a/com32/cmenu/complex.c b/com32/cmenu/complex.c
new file mode 100644
index 00000000..b80005d1
--- /dev/null
+++ b/com32/cmenu/complex.c
@@ -0,0 +1,450 @@
+/* -*- c -*- ------------------------------------------------------------- *
+ *
+ * Copyright 2004-2005 Murali Krishnan Ganapathy - 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
+ * the Free Software Foundation, Inc., 53 Temple Place Ste 330,
+ * Boston MA 02111-1307, USA; either version 2 of the License, or
+ * (at your option) any later version; incorporated herein by reference.
+ *
+ * ----------------------------------------------------------------------- */
+
+#ifndef NULL
+#define NULL ((void *) 0)
+#endif
+
+#include "menu.h"
+#include "com32io.h"
+#include "help.h"
+#include "passwords.h"
+#include "des.h"
+#include <stdlib.h>
+#include <stdio.h>
+#include <unistd.h>
+#include <getkey.h>
+
+/* Global variables */
+char infoline[160];
+char buffer[80];
+
+// Different network options
+static char nonet[] = "<n>etwork [none]";
+static char dhcpnet[] = "<n>etwork [dhcp]";
+static char statnet[] = "<n>etwork [static]";
+
+static char loginstr[] = "<L>ogin ";
+static char logoutstr[] = "<L>ogout ";
+
+struct {
+ unsigned int baseurl:1; // Do we need to specify by url
+ unsigned int mountcd:1; // Should we mount the cd
+ unsigned int winrep:1; // Want to repair windows?
+ unsigned int linrep:1; // Want to repair linux?
+} flags;
+
+// Some menu options
+t_menuitem *baseurl, *mountcd, *network, *runprep, *winrep, *linrep;
+t_menuitem *stat, *dhcp, *none, *prepopt, *secret;
+
+// all the menus we are going to declare
+unsigned char TESTING, RESCUE, MAIN, PREPMENU, NETMENU, LONGMENU, SECRETMENU;
+
+char username[12]; // Name of user currently using the system
+
+/* End globals */
+
+TIMEOUTCODE ontimeout(void)
+{
+ beep();
+ return CODE_WAIT;
+}
+
+#define INFLINE 22
+#define PWDLINE 3
+#define PWDPROMPT 21
+#define PWDCOLUMN 60
+#define PWDATTR 0x74
+#define EDITPROMPT 21
+
+void keys_handler(t_menusystem * ms __attribute__ (( unused )), t_menuitem * mi, int scancode)
+{
+ int nc, nr;
+
+ if ((scancode) == KEY_F1 && mi->helpid != 0xFFFF) { // If scancode of F1
+ runhelpsystem(mi->helpid);
+ }
+ // If user hit TAB, and item is an "executable" item
+ // and user has privileges to edit it, edit it in place.
+ if ((scancode == KEY_TAB) && (mi->action == OPT_RUN) &&
+ (isallowed(username, "editcmd") || isallowed(username, "root"))) {
+ if (getscreensize(1, &nr, &nc)) {
+ /* Unknown screen size? */
+ nc = 80;
+ nr = 24;
+ }
+ // User typed TAB and has permissions to edit command line
+ gotoxy(EDITPROMPT, 1);
+ csprint("Command line:", 0x07);
+ editstring(mi->data, ACTIONLEN);
+ gotoxy(EDITPROMPT, 1);
+ clear_line();
+ }
+}
+
+t_handler_return login_handler(t_menusystem * ms, t_menuitem * mi)
+{
+ (void)mi; // Unused
+ char pwd[40];
+ char login[40];
+ int nc, nr;
+ t_handler_return rv;
+
+ (void)ms;
+
+ if (mi->item == loginstr) { /* User wants to login */
+ if (getscreensize(1, &nr, &nc)) {
+ /* Unknown screen size? */
+ nc = 80;
+ nr = 24;
+ }
+ gotoxy(PWDPROMPT, 1);
+ csprint("Enter Username: ", 0x07);
+ getstring(login, sizeof username);
+ gotoxy(PWDPROMPT, 1);
+ clear_line();
+ csprint("Enter Password: ", 0x07);
+ getpwd(pwd, sizeof pwd);
+ gotoxy(PWDPROMPT, 1);
+ clear_line();
+
+ if (authenticate_user(login, pwd)) {
+ strcpy(username, login);
+ mi->item = logoutstr; // Change item to read "Logout"
+ } else
+ strcpy(username, GUEST_USER);
+ } else // User needs to logout
+ {
+ strcpy(username, GUEST_USER);
+ mi->item = loginstr;
+ }
+
+ if (strcmp(username, GUEST_USER) == 0) {
+ prepopt->action = OPT_INACTIVE;
+ secret->action = OPT_INVISIBLE;
+ } else {
+ prepopt->action = OPT_SUBMENU;
+ prepopt->itemdata.radiomenunum = PREPMENU;
+ secret->action = OPT_SUBMENU;
+ secret->itemdata.submenunum = SECRETMENU;
+ }
+ rv.valid = 0;
+ rv.refresh = 1;
+ rv.reserved = 0;
+ return rv;
+}
+
+void msys_handler(t_menusystem * ms, t_menuitem * mi)
+{
+ int nc, nr;
+ void *v;
+
+ if (getscreensize(1, &nr, &nc)) {
+ /* Unknown screen size? */
+ nc = 80;
+ nr = 24;
+ }
+ gotoxy(PWDLINE, PWDCOLUMN);
+ csprint("User: ", PWDATTR);
+ cprint(ms->fillchar, ms->fillattr, sizeof username);
+ gotoxy(PWDLINE, PWDCOLUMN + 6);
+ csprint(username, PWDATTR);
+
+ if (mi->parindex != PREPMENU) // If we are not in the PREP MENU
+ {
+ gotoxy(INFLINE, 0);
+ reset_colors();
+ clear_line();
+ gotoxy(INFLINE + 1, 0);
+ clear_line();
+ return;
+ }
+ strcpy(infoline, " ");
+ if (flags.baseurl)
+ strcat(infoline, "baseurl=http://192.168.11.12/gui ");
+ if (flags.mountcd)
+ strcat(infoline, "mountcd=yes ");
+ v = (void *)network->data;
+ if (v != NULL) // Some network option specified
+ {
+ strcat(infoline, "network=");
+ strcat(infoline, (char *)(((t_menuitem *) v)->data));
+ }
+ if (flags.winrep)
+ strcat(infoline, "repair=win ");
+ if (flags.linrep)
+ strcat(infoline, "repair=lin ");
+
+ gotoxy(INFLINE, 0);
+ reset_colors();
+ clear_line();
+ gotoxy(INFLINE + 1, 0);
+ clear_line();
+ gotoxy(INFLINE, 0);
+ csprint("Kernel Arguments:", 0x07);
+ gotoxy(INFLINE, 17);
+ csprint(infoline, 0x07);
+}
+
+t_handler_return network_handler(t_menusystem * ms, t_menuitem * mi)
+{
+ // mi=network since this is handler only for that.
+ (void)ms; // Unused
+
+ if (mi->data == (void *)none)
+ mi->item = nonet;
+ if (mi->data == (void *)stat)
+ mi->item = statnet;
+ if (mi->data == (void *)dhcp)
+ mi->item = dhcpnet;
+ return ACTION_INVALID; // VALID or INVALID does not matter
+}
+
+t_handler_return checkbox_handler(t_menusystem * ms, t_menuitem * mi)
+{
+ (void)ms; /* Unused */
+
+ t_handler_return rv;
+
+ if (mi->action != OPT_CHECKBOX)
+ return ACTION_INVALID;
+
+ if (strcmp(mi->data, "baseurl") == 0)
+ flags.baseurl = (mi->itemdata.checked ? 1 : 0);
+ if (strcmp(mi->data, "winrepair") == 0) {
+ if (mi->itemdata.checked) {
+ flags.winrep = 1;
+ linrep->action = OPT_INACTIVE;
+ } else {
+ flags.winrep = 0;
+ linrep->action = OPT_CHECKBOX;
+ }
+ }
+ if (strcmp(mi->data, "linrepair") == 0) {
+ if (mi->itemdata.checked) {
+ flags.linrep = 1;
+ winrep->action = OPT_INACTIVE;
+ } else {
+ flags.winrep = 0;
+ winrep->action = OPT_CHECKBOX;
+ }
+ }
+ if (strcmp(mi->data, "mountcd") == 0)
+ flags.mountcd = (mi->itemdata.checked ? 1 : 0);
+
+ rv.valid = 0;
+ rv.refresh = 1;
+ rv.reserved = 0;
+ return rv;
+}
+
+int main(void)
+{
+ t_menuitem *curr;
+ char cmd[160];
+ char ip[30];
+
+ // Set default username as guest
+ strcpy(username, GUEST_USER);
+
+ // Switch video mode here
+ // setvideomode(0x18); // or whatever mode you want
+
+ // Choose the default title and setup default values for all attributes....
+ init_passwords("/isolinux/password");
+ init_help("/isolinux/help");
+ init_menusystem(NULL);
+ set_window_size(1, 1, 20, 78); // Leave some space around
+
+ // Choose the default values for all attributes and char's
+ // -1 means choose defaults (Actually the next 4 lines are not needed)
+ //set_normal_attr (-1,-1,-1,-1);
+ //set_status_info (-1,-1); // Display status on the last line
+ //set_title_info (-1,-1);
+ //set_misc_info(-1,-1,-1,-1);
+
+ // Register the menusystem handler
+ reg_handler(HDLR_SCREEN, &msys_handler);
+ reg_handler(HDLR_KEYS, &keys_handler);
+ // Register the ontimeout handler, with a time out of 10 seconds
+ reg_ontimeout(ontimeout, 10, 0);
+
+ NETMENU = add_menu(" Init Network ", -1);
+ none = add_item("<N>one", "Dont start network", OPT_RADIOITEM, "no ", 0);
+ dhcp = add_item("<d>hcp", "Use DHCP", OPT_RADIOITEM, "dhcp ", 0);
+ stat =
+ add_item("<s>tatic", "Use static IP I will specify later",
+ OPT_RADIOITEM, "static ", 0);
+
+ TESTING = add_menu(" Testing ", -1);
+ set_menu_pos(5, 55);
+ add_item("<M>emory Test", "Perform extensive memory testing", OPT_RUN,
+ "memtest", 0);
+ add_item("<I>nvisible", "You dont see this", OPT_INVISIBLE, "junk", 0);
+ add_item("<E>xit this menu", "Go one level up", OPT_EXITMENU, "exit", 0);
+
+ RESCUE = add_menu(" Rescue Options ", -1);
+ add_item("<L>inux Rescue", "linresc", OPT_RUN, "linresc", 0);
+ add_item("<D>os Rescue", "dosresc", OPT_RUN, "dosresc", 0);
+ add_item("<W>indows Rescue", "winresc", OPT_RUN, "winresc", 0);
+ add_item("<E>xit this menu", "Go one level up", OPT_EXITMENU, "exit", 0);
+
+ PREPMENU = add_menu(" Prep options ", -1);
+ baseurl =
+ add_item("<b>aseurl by IP?", "Specify gui baseurl by IP address",
+ OPT_CHECKBOX, "baseurl", 0);
+ mountcd =
+ add_item("<m>ountcd?", "Mount the cdrom drive?", OPT_CHECKBOX,
+ "mountcd", 0);
+ network =
+ add_item(dhcpnet, "How to initialise network device?", OPT_RADIOMENU,
+ NULL, NETMENU);
+ add_sep();
+ winrep =
+ add_item("Reinstall <w>indows",
+ "Re-install the windows side of a dual boot setup",
+ OPT_CHECKBOX, "winrepair", 0);
+ linrep =
+ add_item("Reinstall <l>inux",
+ "Re-install the linux side of a dual boot setup", OPT_CHECKBOX,
+ "linrepair", 0);
+ add_sep();
+ runprep =
+ add_item("<R>un prep now", "Execute prep with the above options",
+ OPT_RUN, "prep", 0);
+ add_item("<E>xit this menu", "Go up one level", OPT_EXITMENU, "exitmenu",
+ 0);
+ baseurl->handler = &checkbox_handler;
+ mountcd->handler = &checkbox_handler;
+ winrep->handler = &checkbox_handler;
+ linrep->handler = &checkbox_handler;
+ network->handler = &network_handler;
+ flags.baseurl = 0;
+ flags.mountcd = 0;
+ flags.winrep = 0;
+ flags.linrep = 0;
+
+ SECRETMENU = add_menu(" Secret Menu ", -1);
+ add_item("secret 1", "Secret", OPT_RUN, "A", 0);
+ add_item("secret 2", "Secret", OPT_RUN, "A", 0);
+
+ LONGMENU = add_menu(" Long Menu ", 40); // Override default here
+ add_item("<A>a", "Aa", OPT_RUN, "A", 0);
+ add_item("<B>b", "Ab", OPT_RUN, "A", 0);
+ add_item("<C>", "A", OPT_RUN, "A", 0);
+ add_item("<D>", "A", OPT_RUN, "A", 0);
+ add_item("<E>", "A", OPT_RUN, "A", 0);
+ add_item("<F>", "A", OPT_RUN, "A", 0);
+ add_item("<G>", "A", OPT_RUN, "A", 0);
+ add_item("<H>", "A", OPT_RUN, "A", 0);
+ add_item("<I>", "A", OPT_RUN, "A", 0);
+ add_item("<J>", "A", OPT_RUN, "A", 0);
+ add_item("<K>", "A", OPT_RUN, "A", 0);
+ add_item("<L>", "A", OPT_RUN, "A", 0);
+ add_item("<J>", "A", OPT_RUN, "A", 0);
+ add_item("<K>", "A", OPT_RUN, "A", 0);
+ add_item("<L>", "A", OPT_RUN, "A", 0);
+ add_item("<M>", "A", OPT_RUN, "A", 0);
+ add_item("<N>", "A", OPT_RUN, "A", 0);
+ add_item("<O>", "A", OPT_RUN, "A", 0);
+ add_item("<P>", "A", OPT_RUN, "A", 0);
+ add_item("<Q>", "A", OPT_RUN, "A", 0);
+ add_item("<R>", "A", OPT_RUN, "A", 0);
+ add_item("<S>", "A", OPT_RUN, "A", 0);
+ add_item("<T>", "A", OPT_RUN, "A", 0);
+ add_item("<U>", "A", OPT_RUN, "A", 0);
+ add_item("<V>", "A", OPT_RUN, "A", 0);
+ add_item("<W>", "A", OPT_RUN, "A", 0);
+ add_item("<X>", "A", OPT_RUN, "A", 0);
+ add_item("<Y>", "A", OPT_RUN, "A", 0);
+ add_item("<Z>", "A", OPT_RUN, "A", 0);
+ add_item("<1>", "A", OPT_RUN, "A", 0);
+ add_item("<2>", "A", OPT_RUN, "A", 0);
+ add_item("<3>", "A", OPT_RUN, "A", 0);
+ add_item("<4>", "A", OPT_RUN, "A", 0);
+ add_item("<5>", "A", OPT_RUN, "A", 0);
+ add_item("<6>", "A", OPT_RUN, "A", 0);
+ add_item("<7>", "A", OPT_RUN, "A", 0);
+ add_item("<8>", "A", OPT_RUN, "A", 0);
+ add_item("<9>", "A", OPT_RUN, "A", 0);
+
+ MAIN = add_menu(" Main Menu ", 8);
+ curr = add_item(loginstr, "Login as a privileged user", OPT_RUN, NULL, 0);
+ set_item_options(-1, 23);
+ curr->handler = &login_handler;
+
+ add_item("<P>repare", "prep", OPT_RUN, "prep", 0);
+ set_item_options(-1, 24);
+ prepopt =
+ add_item("<P>rep options...",
+ "Options for prep image: Requires authenticated user",
+ OPT_INACTIVE, NULL, PREPMENU);
+ set_item_options(-1, 25);
+
+ add_item("<R>escue options...", "Troubleshoot a system", OPT_SUBMENU, NULL,
+ RESCUE);
+ set_item_options(-1, 26);
+ add_item("<T>esting...", "Options to test hardware", OPT_SUBMENU, NULL,
+ TESTING);
+ set_item_options(-1, 27);
+ add_item("<L>ong Menu...", "test menu system", OPT_SUBMENU, NULL, LONGMENU);
+ set_item_options(-1, 28);
+ secret =
+ add_item("<S>ecret Menu...", "Secret menu", OPT_INVISIBLE, NULL,
+ SECRETMENU);
+ set_item_options(-1, 29);
+ add_item("<E>xit to prompt", "Exit the menu system", OPT_EXITMENU, "exit",
+ 0);
+ set_item_options(-1, 30);
+ csprint("Press any key within 5 seconds to show menu...", 0x07);
+ if (get_key(stdin, 50) == KEY_NONE) // Granularity of 100 milliseconds
+ {
+ csprint("Sorry! Time's up.\r\n", 0x07);
+ return 1;
+ }
+ curr = showmenus(MAIN);
+ if (curr) {
+ if (curr->action == OPT_RUN) {
+ strcpy(cmd, curr->data);
+ if (curr == runprep) {
+ strcat(cmd, infoline);
+ if (network->data == (void *)stat) // We want static
+ {
+ csprint("Enter IP address (last two octets only): ", 0x07);
+ strcpy(ip, "Junk");
+ editstring(ip, sizeof ip);
+ strcat(cmd, "ipaddr=192.168.");
+ strcat(cmd, ip);
+ }
+ }
+ if (issyslinux())
+ runsyslinuxcmd(cmd);
+ else
+ csprint(cmd, 0x07);
+ return 1; // Should not happen when run from SYSLINUX
+ }
+ }
+ // If user quits the menu system, control comes here
+ // If you want to execute some specific command uncomment the next two lines
+
+ // if (syslinux) runcommand(YOUR_COMMAND_HERE);
+ // else csprint(YOUR_COMMAND_HERE,0x07);
+
+ // Deallocate space used for these data structures
+ close_passwords();
+ close_help();
+ close_menusystem();
+
+ // Return to prompt
+ return 0;
+}
diff --git a/menu/display.c b/com32/cmenu/display.c
index 5391d7fd..3acdf6aa 100644
--- a/menu/display.c
+++ b/com32/cmenu/display.c
@@ -22,16 +22,15 @@
#include <com32.h>
#include <stdio.h>
-
int main(int argc, char *argv[])
{
- if (argc < 2) {
- csprint("Usage: display.c32 <textfile>\n",0x07);
- exit(1);
- }
+ if (argc < 2) {
+ csprint("Usage: display.c32 <textfile>\n", 0x07);
+ exit(1);
+ }
- init_help(NULL); // No base dir, so all filenames must be absolute
- runhelp(argv[1]);
- close_help();
- return 0;
+ init_help(NULL); // No base dir, so all filenames must be absolute
+ runhelp(argv[1]);
+ close_help();
+ return 0;
}
diff --git a/com32/cmenu/libmenu/com32io.c b/com32/cmenu/libmenu/com32io.c
new file mode 100644
index 00000000..6a27d1a1
--- /dev/null
+++ b/com32/cmenu/libmenu/com32io.c
@@ -0,0 +1,83 @@
+/* -*- c -*- ------------------------------------------------------------- *
+ *
+ * Copyright 2004-2005 Murali Krishnan Ganapathy - 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
+ * the Free Software Foundation, Inc., 53 Temple Place Ste 330,
+ * Boston MA 02111-1307, USA; either version 2 of the License, or
+ * (at your option) any later version; incorporated herein by reference.
+ *
+ * ----------------------------------------------------------------------- */
+
+#include <string.h>
+#include <com32.h>
+#include "com32io.h"
+#include "tui.h"
+#include "syslnx.h"
+
+com32sys_t inreg, outreg; // Global register sets for use
+
+void getpos(char *row, char *col, char page)
+{
+ REG_AH(inreg) = 0x03;
+ REG_BH(inreg) = page;
+ __intcall(0x10, &inreg, &outreg);
+ *row = REG_DH(outreg);
+ *col = REG_DL(outreg);
+}
+
+unsigned char sleep(unsigned int msec)
+{
+ unsigned long micro = 1000 * msec;
+
+ REG_AH(inreg) = 0x86;
+ REG_CX(inreg) = (micro >> 16);
+ REG_DX(inreg) = (micro & 0xFFFF);
+ __intcall(0x15, &inreg, &outreg);
+ return REG_AH(outreg);
+}
+
+char inputc(char *scancode)
+{
+ syslinux_idle(); /* So syslinux can perform periodic activity */
+ REG_AH(inreg) = 0x10;
+ __intcall(0x16, &inreg, &outreg);
+ if (scancode)
+ *scancode = REG_AH(outreg);
+ return REG_AL(outreg);
+}
+
+void getcursorshape(char *start, char *end)
+{
+ char page = 0; // XXX TODO
+ REG_AH(inreg) = 0x03;
+ REG_BH(inreg) = page;
+ __intcall(0x10, &inreg, &outreg);
+ *start = REG_CH(outreg);
+ *end = REG_CL(outreg);
+}
+
+void setcursorshape(char start, char end)
+{
+ REG_AH(inreg) = 0x01;
+ REG_CH(inreg) = start;
+ REG_CL(inreg) = end;
+ __intcall(0x10, &inreg, &outreg);
+}
+
+void setvideomode(char mode)
+{
+ REG_AH(inreg) = 0x00;
+ REG_AL(inreg) = mode;
+ __intcall(0x10, &inreg, &outreg);
+}
+
+// Get char displayed at current position
+unsigned char getcharat(char page)
+{
+ REG_AH(inreg) = 0x08;
+ REG_BH(inreg) = page;
+ __intcall(0x16, &inreg, &outreg);
+ return REG_AL(outreg);
+}
diff --git a/com32/cmenu/libmenu/com32io.h b/com32/cmenu/libmenu/com32io.h
new file mode 100644
index 00000000..6ff6857e
--- /dev/null
+++ b/com32/cmenu/libmenu/com32io.h
@@ -0,0 +1,68 @@
+/* -*- c -*- ------------------------------------------------------------- *
+ *
+ * Copyright 2004-2005 Murali Krishnan Ganapathy - 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
+ * the Free Software Foundation, Inc., 53 Temple Place Ste 330,
+ * Boston MA 02111-1307, USA; either version 2 of the License, or
+ * (at your option) any later version; incorporated herein by reference.
+ *
+ * ----------------------------------------------------------------------- */
+
+#ifndef __COM32IO_H__
+#define __COM32IO_H__
+
+#include <com32.h>
+#include <stdio.h>
+#include <libansi.h>
+
+#ifndef NULL
+#define NULL ((void *)0)
+#endif
+
+/* Bits representing ShiftFlags, See Int16/Function 2 or Mem[0x417] to get this info */
+
+#define INSERT_ON (1<<7)
+#define CAPSLOCK_ON (1<<6)
+#define NUMLOCK_ON (1<<5)
+#define SCRLLOCK_ON (1<<4)
+#define ALT_PRESSED (1<<3)
+#define CTRL_PRESSED (1<<2)
+// actually 1<<1 is Left Shift, 1<<0 is right shift
+#define SHIFT_PRESSED (1<<1 | 1 <<0)
+
+/* BIOS Assisted output routines */
+
+void getpos(char *row, char *col, char page);
+
+char inputc(char *scancode); // Return ASCII char by val, and scancode by reference
+
+void setcursorshape(char start, char end); // Set cursor shape
+void getcursorshape(char *start, char *end); // Get shape for current page
+
+// Get char displayed at current position in specified page
+unsigned char getcharat(char page);
+
+static inline unsigned char readbiosb(unsigned int ofs)
+{
+ return *((unsigned char *)MK_PTR(0, ofs));
+}
+
+static inline char getshiftflags(void)
+{
+ return readbiosb(0x417);
+}
+
+void scrollupwindow(char top, char left, char bot, char right, char attr, char numlines); //Scroll up given window
+
+void setvideomode(char mode); // Set the video mode.
+
+static inline char getvideomode(void) // Get the current video mode
+{
+ return readbiosb(0x449);
+}
+
+unsigned char sleep(unsigned int msec); // Sleep for specified time
+
+#endif
diff --git a/com32/cmenu/libmenu/des.c b/com32/cmenu/libmenu/des.c
new file mode 100644
index 00000000..37148b24
--- /dev/null
+++ b/com32/cmenu/libmenu/des.c
@@ -0,0 +1,1064 @@
+/*
+ * FreeSec: libcrypt for NetBSD
+ *
+ * Copyright (c) 1994 David Burren
+ * All rights reserved.
+ *
+ * Adapted for FreeBSD-2.0 by Geoffrey M. Rehmet
+ * this file should now *only* export crypt(), in order to make
+ * binaries of libcrypt exportable from the USA
+ *
+ * Adapted for FreeBSD-4.0 by Mark R V Murray
+ * this file should now *only* export crypt_des(), in order to make
+ * a module that can be optionally included in libcrypt.
+ *
+ * Adapted for pxelinux menu environment by Th.Gebhardt
+ * removed dependencies of standard C libs
+ * added LOWSPACE option (using common space for different arrays)
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of other contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * This is an original implementation of the DES and the crypt(3) interfaces
+ * by David Burren <davidb@werj.com.au>.
+ *
+ * An excellent reference on the underlying algorithm (and related
+ * algorithms) is:
+ *
+ * B. Schneier, Applied Cryptography: protocols, algorithms,
+ * and source code in C, John Wiley & Sons, 1994.
+ *
+ * Note that in that book's description of DES the lookups for the initial,
+ * pbox, and final permutations are inverted (this has been brought to the
+ * attention of the author). A list of errata for this book has been
+ * posted to the sci.crypt newsgroup by the author and is available for FTP.
+ *
+ * ARCHITECTURE ASSUMPTIONS:
+ * It is assumed that the 8-byte arrays passed by reference can be
+ * addressed as arrays of u_int32_t's (ie. the CPU is not picky about
+ * alignment).
+ */
+
+#define LOWSPACE
+
+#ifndef NULL
+#define NULL ((void *) 0)
+#endif
+
+typedef unsigned long my_u_int32_t;
+typedef unsigned char my_u_char_t;
+
+/* Re-entrantify me -- all this junk needs to be in
+ * struct crypt_data to make this really reentrant... */
+static my_u_char_t inv_key_perm[64];
+static my_u_char_t inv_comp_perm[56];
+static my_u_char_t u_sbox[8][64];
+static my_u_char_t un_pbox[32];
+static my_u_int32_t en_keysl[16], en_keysr[16];
+static my_u_int32_t de_keysl[16], de_keysr[16];
+
+#ifndef LOWSPACE
+static my_u_int32_t ip_maskl[8][256], ip_maskr[8][256];
+static my_u_int32_t fp_maskl[8][256], fp_maskr[8][256];
+static my_u_int32_t key_perm_maskl[8][128], key_perm_maskr[8][128];
+static my_u_int32_t comp_maskl[8][128], comp_maskr[8][128];
+#endif
+
+static my_u_int32_t saltbits;
+static my_u_int32_t old_salt;
+static my_u_int32_t old_rawkey0, old_rawkey1;
+
+#ifdef LOWSPACE
+static my_u_int32_t common[8][256];
+#endif
+
+/* Static stuff that stays resident and doesn't change after
+ * being initialized, and therefore doesn't need to be made
+ * reentrant. */
+static my_u_char_t init_perm[64], final_perm[64];
+static my_u_char_t m_sbox[4][4096];
+
+#ifndef LOWSPACE
+static my_u_int32_t psbox[4][256];
+#endif
+
+/* A pile of data */
+static const my_u_char_t ascii64[] =
+ "./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
+
+static const my_u_char_t IP[64] = {
+ 58, 50, 42, 34, 26, 18, 10, 2, 60, 52, 44, 36, 28, 20, 12, 4,
+ 62, 54, 46, 38, 30, 22, 14, 6, 64, 56, 48, 40, 32, 24, 16, 8,
+ 57, 49, 41, 33, 25, 17, 9, 1, 59, 51, 43, 35, 27, 19, 11, 3,
+ 61, 53, 45, 37, 29, 21, 13, 5, 63, 55, 47, 39, 31, 23, 15, 7
+};
+
+static const my_u_char_t key_perm[56] = {
+ 57, 49, 41, 33, 25, 17, 9, 1, 58, 50, 42, 34, 26, 18,
+ 10, 2, 59, 51, 43, 35, 27, 19, 11, 3, 60, 52, 44, 36,
+ 63, 55, 47, 39, 31, 23, 15, 7, 62, 54, 46, 38, 30, 22,
+ 14, 6, 61, 53, 45, 37, 29, 21, 13, 5, 28, 20, 12, 4
+};
+
+static const my_u_char_t key_shifts[16] = {
+ 1, 1, 2, 2, 2, 2, 2, 2, 1, 2, 2, 2, 2, 2, 2, 1
+};
+
+static const my_u_char_t comp_perm[48] = {
+ 14, 17, 11, 24, 1, 5, 3, 28, 15, 6, 21, 10,
+ 23, 19, 12, 4, 26, 8, 16, 7, 27, 20, 13, 2,
+ 41, 52, 31, 37, 47, 55, 30, 40, 51, 45, 33, 48,
+ 44, 49, 39, 56, 34, 53, 46, 42, 50, 36, 29, 32
+};
+
+/*
+ * No E box is used, as it's replaced by some ANDs, shifts, and ORs.
+ */
+
+static const my_u_char_t sbox[8][64] = {
+ {
+ 14, 4, 13, 1, 2, 15, 11, 8, 3, 10, 6, 12, 5, 9, 0, 7,
+ 0, 15, 7, 4, 14, 2, 13, 1, 10, 6, 12, 11, 9, 5, 3, 8,
+ 4, 1, 14, 8, 13, 6, 2, 11, 15, 12, 9, 7, 3, 10, 5, 0,
+ 15, 12, 8, 2, 4, 9, 1, 7, 5, 11, 3, 14, 10, 0, 6, 13},
+ {
+ 15, 1, 8, 14, 6, 11, 3, 4, 9, 7, 2, 13, 12, 0, 5, 10,
+ 3, 13, 4, 7, 15, 2, 8, 14, 12, 0, 1, 10, 6, 9, 11, 5,
+ 0, 14, 7, 11, 10, 4, 13, 1, 5, 8, 12, 6, 9, 3, 2, 15,
+ 13, 8, 10, 1, 3, 15, 4, 2, 11, 6, 7, 12, 0, 5, 14, 9},
+ {
+ 10, 0, 9, 14, 6, 3, 15, 5, 1, 13, 12, 7, 11, 4, 2, 8,
+ 13, 7, 0, 9, 3, 4, 6, 10, 2, 8, 5, 14, 12, 11, 15, 1,
+ 13, 6, 4, 9, 8, 15, 3, 0, 11, 1, 2, 12, 5, 10, 14, 7,
+ 1, 10, 13, 0, 6, 9, 8, 7, 4, 15, 14, 3, 11, 5, 2, 12},
+ {
+ 7, 13, 14, 3, 0, 6, 9, 10, 1, 2, 8, 5, 11, 12, 4, 15,
+ 13, 8, 11, 5, 6, 15, 0, 3, 4, 7, 2, 12, 1, 10, 14, 9,
+ 10, 6, 9, 0, 12, 11, 7, 13, 15, 1, 3, 14, 5, 2, 8, 4,
+ 3, 15, 0, 6, 10, 1, 13, 8, 9, 4, 5, 11, 12, 7, 2, 14},
+ {
+ 2, 12, 4, 1, 7, 10, 11, 6, 8, 5, 3, 15, 13, 0, 14, 9,
+ 14, 11, 2, 12, 4, 7, 13, 1, 5, 0, 15, 10, 3, 9, 8, 6,
+ 4, 2, 1, 11, 10, 13, 7, 8, 15, 9, 12, 5, 6, 3, 0, 14,
+ 11, 8, 12, 7, 1, 14, 2, 13, 6, 15, 0, 9, 10, 4, 5, 3},
+ {
+ 12, 1, 10, 15, 9, 2, 6, 8, 0, 13, 3, 4, 14, 7, 5, 11,
+ 10, 15, 4, 2, 7, 12, 9, 5, 6, 1, 13, 14, 0, 11, 3, 8,
+ 9, 14, 15, 5, 2, 8, 12, 3, 7, 0, 4, 10, 1, 13, 11, 6,
+ 4, 3, 2, 12, 9, 5, 15, 10, 11, 14, 1, 7, 6, 0, 8, 13},
+ {
+ 4, 11, 2, 14, 15, 0, 8, 13, 3, 12, 9, 7, 5, 10, 6, 1,
+ 13, 0, 11, 7, 4, 9, 1, 10, 14, 3, 5, 12, 2, 15, 8, 6,
+ 1, 4, 11, 13, 12, 3, 7, 14, 10, 15, 6, 8, 0, 5, 9, 2,
+ 6, 11, 13, 8, 1, 4, 10, 7, 9, 5, 0, 15, 14, 2, 3, 12},
+ {
+ 13, 2, 8, 4, 6, 15, 11, 1, 10, 9, 3, 14, 5, 0, 12, 7,
+ 1, 15, 13, 8, 10, 3, 7, 4, 12, 5, 6, 11, 0, 14, 9, 2,
+ 7, 11, 4, 1, 9, 12, 14, 2, 0, 6, 10, 13, 15, 3, 5, 8,
+ 2, 1, 14, 7, 4, 10, 8, 13, 15, 12, 9, 0, 3, 5, 6, 11}
+};
+
+static const my_u_char_t pbox[32] = {
+ 16, 7, 20, 21, 29, 12, 28, 17, 1, 15, 23, 26, 5, 18, 31, 10,
+ 2, 8, 24, 14, 32, 27, 3, 9, 19, 13, 30, 6, 22, 11, 4, 25
+};
+
+static const my_u_int32_t bits32[32] = {
+ 0x80000000, 0x40000000, 0x20000000, 0x10000000,
+ 0x08000000, 0x04000000, 0x02000000, 0x01000000,
+ 0x00800000, 0x00400000, 0x00200000, 0x00100000,
+ 0x00080000, 0x00040000, 0x00020000, 0x00010000,
+ 0x00008000, 0x00004000, 0x00002000, 0x00001000,
+ 0x00000800, 0x00000400, 0x00000200, 0x00000100,
+ 0x00000080, 0x00000040, 0x00000020, 0x00000010,
+ 0x00000008, 0x00000004, 0x00000002, 0x00000001
+};
+
+static const my_u_int32_t bits28[28] = {
+ 0x08000000, 0x04000000, 0x02000000, 0x01000000,
+ 0x00800000, 0x00400000, 0x00200000, 0x00100000,
+ 0x00080000, 0x00040000, 0x00020000, 0x00010000,
+ 0x00008000, 0x00004000, 0x00002000, 0x00001000,
+ 0x00000800, 0x00000400, 0x00000200, 0x00000100,
+ 0x00000080, 0x00000040, 0x00000020, 0x00000010,
+ 0x00000008, 0x00000004, 0x00000002, 0x00000001
+};
+
+static const my_u_int32_t bits24[24] = {
+ 0x00800000, 0x00400000, 0x00200000, 0x00100000,
+ 0x00080000, 0x00040000, 0x00020000, 0x00010000,
+ 0x00008000, 0x00004000, 0x00002000, 0x00001000,
+ 0x00000800, 0x00000400, 0x00000200, 0x00000100,
+ 0x00000080, 0x00000040, 0x00000020, 0x00000010,
+ 0x00000008, 0x00000004, 0x00000002, 0x00000001
+};
+
+static const my_u_char_t bits8[8] =
+ { 0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x01 };
+// static const my_u_int32_t *bits28, *bits24;
+
+static int ascii_to_bin(char ch)
+{
+ if (ch > 'z')
+ return (0);
+ if (ch >= 'a')
+ return (ch - 'a' + 38);
+ if (ch > 'Z')
+ return (0);
+ if (ch >= 'A')
+ return (ch - 'A' + 12);
+ if (ch > '9')
+ return (0);
+ if (ch >= '.')
+ return (ch - '.');
+ return (0);
+}
+
+static void des_init(void)
+{
+
+#ifdef LOWSPACE
+ int i, j, b;
+#else
+ int i, j, b, k, inbit, obit;
+ my_u_int32_t *p, *il, *ir, *fl, *fr;
+#endif
+ static int des_initialised = 0;
+
+ if (des_initialised == 1)
+ return;
+
+ old_rawkey0 = old_rawkey1 = 0L;
+ saltbits = 0L;
+ old_salt = 0L;
+ // bits24 = (bits28 = bits32 + 4) + 4;
+
+ /*
+ * Invert the S-boxes, reordering the input bits.
+ */
+ for (i = 0; i < 8; i++)
+ for (j = 0; j < 64; j++) {
+ b = (j & 0x20) | ((j & 1) << 4) | ((j >> 1) & 0xf);
+ u_sbox[i][j] = sbox[i][b];
+ }
+
+ /*
+ * Convert the inverted S-boxes into 4 arrays of 8 bits.
+ * Each will handle 12 bits of the S-box input.
+ */
+ for (b = 0; b < 4; b++)
+ for (i = 0; i < 64; i++)
+ for (j = 0; j < 64; j++)
+ m_sbox[b][(i << 6) | j] =
+ (my_u_char_t) ((u_sbox[(b << 1)][i] << 4) |
+ u_sbox[(b << 1) + 1][j]);
+
+ /*
+ * Set up the initial & final permutations into a useful form, and
+ * initialise the inverted key permutation.
+ */
+ for (i = 0; i < 64; i++) {
+ init_perm[final_perm[i] = IP[i] - 1] = (my_u_char_t) i;
+ inv_key_perm[i] = 255;
+ }
+
+ /*
+ * Invert the key permutation and initialise the inverted key
+ * compression permutation.
+ */
+ for (i = 0; i < 56; i++) {
+ inv_key_perm[key_perm[i] - 1] = (my_u_char_t) i;
+ inv_comp_perm[i] = 255;
+ }
+
+ /*
+ * Invert the key compression permutation.
+ */
+ for (i = 0; i < 48; i++) {
+ inv_comp_perm[comp_perm[i] - 1] = (my_u_char_t) i;
+ }
+
+ /*
+ * Set up the OR-mask arrays for the initial and final permutations,
+ * and for the key initial and compression permutations.
+ */
+
+#ifndef LOWSPACE
+ for (k = 0; k < 8; k++) {
+ for (i = 0; i < 256; i++) {
+ *(il = &ip_maskl[k][i]) = 0L;
+ *(ir = &ip_maskr[k][i]) = 0L;
+ *(fl = &fp_maskl[k][i]) = 0L;
+ *(fr = &fp_maskr[k][i]) = 0L;
+ for (j = 0; j < 8; j++) {
+ inbit = 8 * k + j;
+ if (i & bits8[j]) {
+ if ((obit = init_perm[inbit]) < 32)
+ *il |= bits32[obit];
+ else
+ *ir |= bits32[obit - 32];
+ if ((obit = final_perm[inbit]) < 32)
+ *fl |= bits32[obit];
+ else
+ *fr |= bits32[obit - 32];
+ }
+ }
+ }
+ for (i = 0; i < 128; i++) {
+ *(il = &key_perm_maskl[k][i]) = 0L;
+ *(ir = &key_perm_maskr[k][i]) = 0L;
+ for (j = 0; j < 7; j++) {
+ inbit = 8 * k + j;
+ if (i & bits8[j + 1]) {
+ if ((obit = inv_key_perm[inbit]) == 255)
+ continue;
+ if (obit < 28)
+ *il |= bits28[obit];
+ else
+ *ir |= bits28[obit - 28];
+ }
+ }
+ *(il = &comp_maskl[k][i]) = 0L;
+ *(ir = &comp_maskr[k][i]) = 0L;
+ for (j = 0; j < 7; j++) {
+ inbit = 7 * k + j;
+ if (i & bits8[j + 1]) {
+ if ((obit = inv_comp_perm[inbit]) == 255)
+ continue;
+ if (obit < 24)
+ *il |= bits24[obit];
+ else
+ *ir |= bits24[obit - 24];
+ }
+ }
+ }
+ }
+#endif
+
+ /*
+ * Invert the P-box permutation, and convert into OR-masks for
+ * handling the output of the S-box arrays setup above.
+ */
+ for (i = 0; i < 32; i++)
+ un_pbox[pbox[i] - 1] = (my_u_char_t) i;
+
+#ifndef LOWSPACE
+ for (b = 0; b < 4; b++)
+ for (i = 0; i < 256; i++) {
+ *(p = &psbox[b][i]) = 0L;
+ for (j = 0; j < 8; j++) {
+ if (i & bits8[j])
+ *p |= bits32[un_pbox[8 * b + j]];
+ }
+ }
+#endif
+ des_initialised = 1;
+}
+
+#ifdef LOWSPACE
+
+static void setup_ip_maskl(void)
+{
+ int i, j, k, inbit, obit;
+ my_u_int32_t *il;
+
+ for (k = 0; k < 8; k++) {
+ for (i = 0; i < 256; i++) {
+ *(il = &common[k][i]) = 0L;
+ for (j = 0; j < 8; j++) {
+ inbit = 8 * k + j;
+ if (i & bits8[j]) {
+ if ((obit = init_perm[inbit]) < 32)
+ *il |= bits32[obit];
+ }
+ }
+ }
+ }
+}
+
+static void setup_ip_maskr(void)
+{
+ int i, j, k, inbit, obit;
+ my_u_int32_t *ir;
+
+ for (k = 0; k < 8; k++) {
+ for (i = 0; i < 256; i++) {
+ *(ir = &common[k][i]) = 0L;
+ for (j = 0; j < 8; j++) {
+ inbit = 8 * k + j;
+ if (i & bits8[j]) {
+ if ((obit = init_perm[inbit]) >= 32)
+ *ir |= bits32[obit - 32];
+ }
+ }
+ }
+ }
+}
+
+static void setup_fp_maskl(void)
+{
+ int i, j, k, inbit, obit;
+ my_u_int32_t *fl;
+
+ for (k = 0; k < 8; k++) {
+ for (i = 0; i < 256; i++) {
+ *(fl = &common[k][i]) = 0L;
+ for (j = 0; j < 8; j++) {
+ inbit = 8 * k + j;
+ if (i & bits8[j]) {
+ if ((obit = final_perm[inbit]) < 32)
+ *fl |= bits32[obit];
+ }
+ }
+ }
+ }
+}
+
+static void setup_fp_maskr(void)
+{
+ int i, j, k, inbit, obit;
+ my_u_int32_t *fr;
+
+ for (k = 0; k < 8; k++) {
+ for (i = 0; i < 256; i++) {
+ *(fr = &common[k][i]) = 0L;
+ for (j = 0; j < 8; j++) {
+ inbit = 8 * k + j;
+ if (i & bits8[j]) {
+ if ((obit = final_perm[inbit]) >= 32)
+ *fr |= bits32[obit - 32];
+ }
+ }
+ }
+ }
+}
+
+static void setup_key_perm_maskl(void)
+{
+ int i, j, k, inbit, obit;
+ my_u_int32_t *il;
+
+ for (k = 0; k < 8; k++) {
+ for (i = 0; i < 128; i++) {
+ *(il = &common[k][i]) = 0L;
+ for (j = 0; j < 7; j++) {
+ inbit = 8 * k + j;
+ if (i & bits8[j + 1]) {
+ if ((obit = inv_key_perm[inbit]) == 255)
+ continue;
+ if (obit < 28)
+ *il |= bits28[obit];
+ }
+ }
+ }
+ }
+}
+
+static void setup_key_perm_maskr(void)
+{
+ int i, j, k, inbit, obit;
+ my_u_int32_t *ir;
+
+ for (k = 0; k < 8; k++) {
+ for (i = 0; i < 128; i++) {
+ *(ir = &common[k][i]) = 0L;
+ for (j = 0; j < 7; j++) {
+ inbit = 8 * k + j;
+ if (i & bits8[j + 1]) {
+ if ((obit = inv_key_perm[inbit]) == 255)
+ continue;
+ if (obit >= 28)
+ *ir |= bits28[obit - 28];
+ }
+ }
+ }
+ }
+}
+
+static void setup_comp_maskl(void)
+{
+ int i, j, k, inbit, obit;
+ my_u_int32_t *il;
+
+ for (k = 0; k < 8; k++) {
+ for (i = 0; i < 128; i++) {
+ *(il = &common[k][i]) = 0L;
+ for (j = 0; j < 7; j++) {
+ inbit = 7 * k + j;
+ if (i & bits8[j + 1]) {
+ if ((obit = inv_comp_perm[inbit]) == 255)
+ continue;
+ if (obit < 24)
+ *il |= bits24[obit];
+ }
+ }
+ }
+ }
+}
+
+static void setup_comp_maskr(void)
+{
+ int i, j, k, inbit, obit;
+ my_u_int32_t *ir;
+
+ for (k = 0; k < 8; k++) {
+ for (i = 0; i < 128; i++) {
+ *(ir = &common[k][i]) = 0L;
+ for (j = 0; j < 7; j++) {
+ inbit = 7 * k + j;
+ if (i & bits8[j + 1]) {
+ if ((obit = inv_comp_perm[inbit]) == 255)
+ continue;
+ if (obit >= 24)
+ *ir |= bits24[obit - 24];
+ }
+ }
+ }
+ }
+}
+
+static void setup_psbox(void)
+{
+ int i, j, b;
+ my_u_int32_t *p;
+
+ for (b = 0; b < 4; b++)
+ for (i = 0; i < 256; i++) {
+ *(p = &common[b][i]) = 0L;
+ for (j = 0; j < 8; j++) {
+ if (i & bits8[j])
+ *p |= bits32[un_pbox[8 * b + j]];
+ }
+ }
+}
+
+#endif
+
+static void setup_salt(my_u_int32_t salt)
+{
+ my_u_int32_t obit, saltbit;
+ int i;
+
+ if (salt == old_salt)
+ return;
+ old_salt = salt;
+
+ saltbits = 0L;
+ saltbit = 1;
+ obit = 0x800000;
+ for (i = 0; i < 24; i++) {
+ if (salt & saltbit)
+ saltbits |= obit;
+ saltbit <<= 1;
+ obit >>= 1;
+ }
+}
+
+static my_u_int32_t char_to_int(const char *key)
+{
+ my_u_int32_t byte0, byte1, byte2, byte3;
+ byte0 = (my_u_int32_t) (my_u_char_t) key[0];
+ byte1 = (my_u_int32_t) (my_u_char_t) key[1];
+ byte2 = (my_u_int32_t) (my_u_char_t) key[2];
+ byte3 = (my_u_int32_t) (my_u_char_t) key[3];
+
+ return byte0 << 24 | byte1 << 16 | byte2 << 8 | byte3;
+}
+
+static int des_setkey(const char *key)
+{
+ my_u_int32_t k0, k1, rawkey0, rawkey1;
+ int shifts, round;
+
+ des_init();
+
+ /* rawkey0 = ntohl(*(const my_u_int32_t *) key);
+ * rawkey1 = ntohl(*(const my_u_int32_t *) (key + 4));
+ */
+
+ rawkey0 = char_to_int(key);
+ rawkey1 = char_to_int(key + 4);
+
+ if ((rawkey0 | rawkey1)
+ && rawkey0 == old_rawkey0 && rawkey1 == old_rawkey1) {
+ /*
+ * Already setup for this key.
+ * This optimisation fails on a zero key (which is weak and
+ * has bad parity anyway) in order to simplify the starting
+ * conditions.
+ */
+ return (0);
+ }
+ old_rawkey0 = rawkey0;
+ old_rawkey1 = rawkey1;
+
+ /*
+ * Do key permutation and split into two 28-bit subkeys.
+ */
+
+#ifdef LOWSPACE
+ setup_key_perm_maskl();
+ k0 = common[0][rawkey0 >> 25]
+ | common[1][(rawkey0 >> 17) & 0x7f]
+ | common[2][(rawkey0 >> 9) & 0x7f]
+ | common[3][(rawkey0 >> 1) & 0x7f]
+ | common[4][rawkey1 >> 25]
+ | common[5][(rawkey1 >> 17) & 0x7f]
+ | common[6][(rawkey1 >> 9) & 0x7f]
+ | common[7][(rawkey1 >> 1) & 0x7f];
+ setup_key_perm_maskr();
+ k1 = common[0][rawkey0 >> 25]
+ | common[1][(rawkey0 >> 17) & 0x7f]
+ | common[2][(rawkey0 >> 9) & 0x7f]
+ | common[3][(rawkey0 >> 1) & 0x7f]
+ | common[4][rawkey1 >> 25]
+ | common[5][(rawkey1 >> 17) & 0x7f]
+ | common[6][(rawkey1 >> 9) & 0x7f]
+ | common[7][(rawkey1 >> 1) & 0x7f];
+#else
+ k0 = key_perm_maskl[0][rawkey0 >> 25]
+ | key_perm_maskl[1][(rawkey0 >> 17) & 0x7f]
+ | key_perm_maskl[2][(rawkey0 >> 9) & 0x7f]
+ | key_perm_maskl[3][(rawkey0 >> 1) & 0x7f]
+ | key_perm_maskl[4][rawkey1 >> 25]
+ | key_perm_maskl[5][(rawkey1 >> 17) & 0x7f]
+ | key_perm_maskl[6][(rawkey1 >> 9) & 0x7f]
+ | key_perm_maskl[7][(rawkey1 >> 1) & 0x7f];
+ k1 = key_perm_maskr[0][rawkey0 >> 25]
+ | key_perm_maskr[1][(rawkey0 >> 17) & 0x7f]
+ | key_perm_maskr[2][(rawkey0 >> 9) & 0x7f]
+ | key_perm_maskr[3][(rawkey0 >> 1) & 0x7f]
+ | key_perm_maskr[4][rawkey1 >> 25]
+ | key_perm_maskr[5][(rawkey1 >> 17) & 0x7f]
+ | key_perm_maskr[6][(rawkey1 >> 9) & 0x7f]
+ | key_perm_maskr[7][(rawkey1 >> 1) & 0x7f];
+#endif
+
+ /*
+ * Rotate subkeys and do compression permutation.
+ */
+ shifts = 0;
+ for (round = 0; round < 16; round++) {
+ my_u_int32_t t0, t1;
+
+ shifts += key_shifts[round];
+
+ t0 = (k0 << shifts) | (k0 >> (28 - shifts));
+ t1 = (k1 << shifts) | (k1 >> (28 - shifts));
+
+#ifdef LOWSPACE
+ setup_comp_maskl();
+ de_keysl[15 - round] = en_keysl[round] = common[0][(t0 >> 21) & 0x7f]
+ | common[1][(t0 >> 14) & 0x7f]
+ | common[2][(t0 >> 7) & 0x7f]
+ | common[3][t0 & 0x7f]
+ | common[4][(t1 >> 21) & 0x7f]
+ | common[5][(t1 >> 14) & 0x7f]
+ | common[6][(t1 >> 7) & 0x7f]
+ | common[7][t1 & 0x7f];
+
+ setup_comp_maskr();
+ de_keysr[15 - round] = en_keysr[round] = common[0][(t0 >> 21) & 0x7f]
+ | common[1][(t0 >> 14) & 0x7f]
+ | common[2][(t0 >> 7) & 0x7f]
+ | common[3][t0 & 0x7f]
+ | common[4][(t1 >> 21) & 0x7f]
+ | common[5][(t1 >> 14) & 0x7f]
+ | common[6][(t1 >> 7) & 0x7f]
+ | common[7][t1 & 0x7f];
+#else
+ de_keysl[15 - round] =
+ en_keysl[round] = comp_maskl[0][(t0 >> 21) & 0x7f]
+ | comp_maskl[1][(t0 >> 14) & 0x7f]
+ | comp_maskl[2][(t0 >> 7) & 0x7f]
+ | comp_maskl[3][t0 & 0x7f]
+ | comp_maskl[4][(t1 >> 21) & 0x7f]
+ | comp_maskl[5][(t1 >> 14) & 0x7f]
+ | comp_maskl[6][(t1 >> 7) & 0x7f]
+ | comp_maskl[7][t1 & 0x7f];
+
+ de_keysr[15 - round] =
+ en_keysr[round] = comp_maskr[0][(t0 >> 21) & 0x7f]
+ | comp_maskr[1][(t0 >> 14) & 0x7f]
+ | comp_maskr[2][(t0 >> 7) & 0x7f]
+ | comp_maskr[3][t0 & 0x7f]
+ | comp_maskr[4][(t1 >> 21) & 0x7f]
+ | comp_maskr[5][(t1 >> 14) & 0x7f]
+ | comp_maskr[6][(t1 >> 7) & 0x7f]
+ | comp_maskr[7][t1 & 0x7f];
+#endif
+ }
+ return (0);
+}
+
+static int
+do_des(my_u_int32_t l_in, my_u_int32_t r_in, my_u_int32_t * l_out,
+ my_u_int32_t * r_out, int count)
+{
+ /*
+ * l_in, r_in, l_out, and r_out are in pseudo-"big-endian" format.
+ */
+ my_u_int32_t l, r, *kl, *kr, *kl1, *kr1;
+ my_u_int32_t f, r48l, r48r;
+ int round;
+
+ if (count == 0) {
+ return (1);
+ } else if (count > 0) {
+ /*
+ * Encrypting
+ */
+ kl1 = en_keysl;
+ kr1 = en_keysr;
+ } else {
+ /*
+ * Decrypting
+ */
+ count = -count;
+ kl1 = de_keysl;
+ kr1 = de_keysr;
+ }
+
+ /*
+ * Do initial permutation (IP).
+ */
+
+#ifdef LOWSPACE
+ setup_ip_maskl();
+ l = common[0][l_in >> 24]
+ | common[1][(l_in >> 16) & 0xff]
+ | common[2][(l_in >> 8) & 0xff]
+ | common[3][l_in & 0xff]
+ | common[4][r_in >> 24]
+ | common[5][(r_in >> 16) & 0xff]
+ | common[6][(r_in >> 8) & 0xff]
+ | common[7][r_in & 0xff];
+ setup_ip_maskr();
+ r = common[0][l_in >> 24]
+ | common[1][(l_in >> 16) & 0xff]
+ | common[2][(l_in >> 8) & 0xff]
+ | common[3][l_in & 0xff]
+ | common[4][r_in >> 24]
+ | common[5][(r_in >> 16) & 0xff]
+ | common[6][(r_in >> 8) & 0xff]
+ | common[7][r_in & 0xff];
+#else
+ l = ip_maskl[0][l_in >> 24]
+ | ip_maskl[1][(l_in >> 16) & 0xff]
+ | ip_maskl[2][(l_in >> 8) & 0xff]
+ | ip_maskl[3][l_in & 0xff]
+ | ip_maskl[4][r_in >> 24]
+ | ip_maskl[5][(r_in >> 16) & 0xff]
+ | ip_maskl[6][(r_in >> 8) & 0xff]
+ | ip_maskl[7][r_in & 0xff];
+ r = ip_maskr[0][l_in >> 24]
+ | ip_maskr[1][(l_in >> 16) & 0xff]
+ | ip_maskr[2][(l_in >> 8) & 0xff]
+ | ip_maskr[3][l_in & 0xff]
+ | ip_maskr[4][r_in >> 24]
+ | ip_maskr[5][(r_in >> 16) & 0xff]
+ | ip_maskr[6][(r_in >> 8) & 0xff]
+ | ip_maskr[7][r_in & 0xff];
+#endif
+
+ while (count--) {
+ /*
+ * Do each round.
+ */
+ kl = kl1;
+ kr = kr1;
+ round = 16;
+ while (round--) {
+ /*
+ * Expand R to 48 bits (simulate the E-box).
+ */
+ r48l = ((r & 0x00000001) << 23)
+ | ((r & 0xf8000000) >> 9)
+ | ((r & 0x1f800000) >> 11)
+ | ((r & 0x01f80000) >> 13)
+ | ((r & 0x001f8000) >> 15);
+
+ r48r = ((r & 0x0001f800) << 7)
+ | ((r & 0x00001f80) << 5)
+ | ((r & 0x000001f8) << 3)
+ | ((r & 0x0000001f) << 1)
+ | ((r & 0x80000000) >> 31);
+ /*
+ * Do salting for crypt() and friends, and
+ * XOR with the permuted key.
+ */
+ f = (r48l ^ r48r) & saltbits;
+ r48l ^= f ^ *kl++;
+ r48r ^= f ^ *kr++;
+ /*
+ * Do sbox lookups (which shrink it back to 32 bits)
+ * and do the pbox permutation at the same time.
+ */
+
+#ifdef LOWSPACE
+ setup_psbox();
+ f = common[0][m_sbox[0][r48l >> 12]]
+ | common[1][m_sbox[1][r48l & 0xfff]]
+ | common[2][m_sbox[2][r48r >> 12]]
+ | common[3][m_sbox[3][r48r & 0xfff]];
+#else
+ f = psbox[0][m_sbox[0][r48l >> 12]]
+ | psbox[1][m_sbox[1][r48l & 0xfff]]
+ | psbox[2][m_sbox[2][r48r >> 12]]
+ | psbox[3][m_sbox[3][r48r & 0xfff]];
+#endif
+ /*
+ * Now that we've permuted things, complete f().
+ */
+ f ^= l;
+ l = r;
+ r = f;
+ }
+ r = l;
+ l = f;
+ }
+ /*
+ * Do final permutation (inverse of IP).
+ */
+
+#ifdef LOWSPACE
+ setup_fp_maskl();
+ *l_out = common[0][l >> 24]
+ | common[1][(l >> 16) & 0xff]
+ | common[2][(l >> 8) & 0xff]
+ | common[3][l & 0xff]
+ | common[4][r >> 24]
+ | common[5][(r >> 16) & 0xff]
+ | common[6][(r >> 8) & 0xff]
+ | common[7][r & 0xff];
+ setup_fp_maskr();
+ *r_out = common[0][l >> 24]
+ | common[1][(l >> 16) & 0xff]
+ | common[2][(l >> 8) & 0xff]
+ | common[3][l & 0xff]
+ | common[4][r >> 24]
+ | common[5][(r >> 16) & 0xff]
+ | common[6][(r >> 8) & 0xff]
+ | common[7][r & 0xff];
+#else
+ *l_out = fp_maskl[0][l >> 24]
+ | fp_maskl[1][(l >> 16) & 0xff]
+ | fp_maskl[2][(l >> 8) & 0xff]
+ | fp_maskl[3][l & 0xff]
+ | fp_maskl[4][r >> 24]
+ | fp_maskl[5][(r >> 16) & 0xff]
+ | fp_maskl[6][(r >> 8) & 0xff]
+ | fp_maskl[7][r & 0xff];
+ *r_out = fp_maskr[0][l >> 24]
+ | fp_maskr[1][(l >> 16) & 0xff]
+ | fp_maskr[2][(l >> 8) & 0xff]
+ | fp_maskr[3][l & 0xff]
+ | fp_maskr[4][r >> 24]
+ | fp_maskr[5][(r >> 16) & 0xff]
+ | fp_maskr[6][(r >> 8) & 0xff]
+ | fp_maskr[7][r & 0xff];
+#endif
+ return (0);
+}
+
+#if 0
+static int des_cipher(const char *in, char *out, my_u_int32_t salt, int count)
+{
+ my_u_int32_t l_out, r_out, rawl, rawr;
+ int retval;
+ union {
+ my_u_int32_t *ui32;
+ const char *c;
+ } trans;
+
+ des_init();
+
+ setup_salt(salt);
+
+ trans.c = in;
+ rawl = ntohl(*trans.ui32++);
+ rawr = ntohl(*trans.ui32);
+
+ retval = do_des(rawl, rawr, &l_out, &r_out, count);
+
+ trans.c = out;
+ *trans.ui32++ = htonl(l_out);
+ *trans.ui32 = htonl(r_out);
+ return (retval);
+}
+#endif
+
+void setkey(const char *key)
+{
+ int i, j;
+ char *p, packed_keys[8];
+
+ p = packed_keys;
+
+ for (i = 0; i < 8; i++) {
+ p[i] = 0;
+ for (j = 0; j < 8; j++)
+ if (*key++ & 1)
+ p[i] |= bits8[j];
+ }
+ des_setkey(p);
+}
+
+void encrypt(char *block, int flag)
+{
+ my_u_int32_t io[2];
+ my_u_char_t *p;
+ int i, j;
+
+ des_init();
+
+ setup_salt(0L);
+ p = (my_u_char_t *)block;
+ for (i = 0; i < 2; i++) {
+ io[i] = 0L;
+ for (j = 0; j < 32; j++)
+ if (*p++ & 1)
+ io[i] |= bits32[j];
+ }
+ do_des(io[0], io[1], io, io + 1, flag ? -1 : 1);
+ for (i = 0; i < 2; i++)
+ for (j = 0; j < 32; j++)
+ block[(i << 5) | j] = (io[i] & bits32[j]) ? 1 : 0;
+}
+
+char *crypt(const char *key, const char *setting)
+{
+ my_u_int32_t count, salt, l, r0, r1, keybuf[2];
+ my_u_char_t *p, *q;
+ static char output[21];
+
+ des_init();
+
+ /*
+ * Copy the key, shifting each character up by one bit
+ * and padding with zeros.
+ */
+ q = (my_u_char_t *) keybuf;
+ while (q - (my_u_char_t *) keybuf - 8) {
+ *q++ = *key << 1;
+ if (*(q - 1))
+ key++;
+ }
+ if (des_setkey((char *)keybuf))
+ return (NULL);
+
+#if 0
+ if (*setting == _PASSWORD_EFMT1) {
+ int i;
+ /*
+ * "new"-style:
+ * setting - underscore, 4 bytes of count, 4 bytes of salt
+ * key - unlimited characters
+ */
+ for (i = 1, count = 0L; i < 5; i++)
+ count |= ascii_to_bin(setting[i]) << ((i - 1) * 6);
+
+ for (i = 5, salt = 0L; i < 9; i++)
+ salt |= ascii_to_bin(setting[i]) << ((i - 5) * 6);
+
+ while (*key) {
+ /*
+ * Encrypt the key with itself.
+ */
+ if (des_cipher((char *)keybuf, (char *)keybuf, 0L, 1))
+ return (NULL);
+ /*
+ * And XOR with the next 8 characters of the key.
+ */
+ q = (my_u_char_t *) keybuf;
+ while (q - (my_u_char_t *) keybuf - 8 && *key)
+ *q++ ^= *key++ << 1;
+
+ if (des_setkey((char *)keybuf))
+ return (NULL);
+ }
+ strncpy(output, setting, 9);
+
+ /*
+ * Double check that we weren't given a short setting.
+ * If we were, the above code will probably have created
+ * wierd values for count and salt, but we don't really care.
+ * Just make sure the output string doesn't have an extra
+ * NUL in it.
+ */
+ output[9] = '\0';
+ p = (my_u_char_t *) output + strlen(output);
+ } else
+#endif
+ {
+ /*
+ * "old"-style:
+ * setting - 2 bytes of salt
+ * key - up to 8 characters
+ */
+ count = 25;
+
+ salt = (ascii_to_bin(setting[1]) << 6)
+ | ascii_to_bin(setting[0]);
+
+ output[0] = setting[0];
+ /*
+ * If the encrypted password that the salt was extracted from
+ * is only 1 character long, the salt will be corrupted. We
+ * need to ensure that the output string doesn't have an extra
+ * NUL in it!
+ */
+ output[1] = setting[1] ? setting[1] : output[0];
+
+ p = (my_u_char_t *) output + 2;
+ }
+ setup_salt(salt);
+ /*
+ * Do it.
+ */
+ if (do_des(0L, 0L, &r0, &r1, (int)count))
+ return (NULL);
+ /*
+ * Now encode the result...
+ */
+ l = (r0 >> 8);
+ *p++ = ascii64[(l >> 18) & 0x3f];
+ *p++ = ascii64[(l >> 12) & 0x3f];
+ *p++ = ascii64[(l >> 6) & 0x3f];
+ *p++ = ascii64[l & 0x3f];
+
+ l = (r0 << 16) | ((r1 >> 16) & 0xffff);
+ *p++ = ascii64[(l >> 18) & 0x3f];
+ *p++ = ascii64[(l >> 12) & 0x3f];
+ *p++ = ascii64[(l >> 6) & 0x3f];
+ *p++ = ascii64[l & 0x3f];
+
+ l = r1 << 2;
+ *p++ = ascii64[(l >> 12) & 0x3f];
+ *p++ = ascii64[(l >> 6) & 0x3f];
+ *p++ = ascii64[l & 0x3f];
+ *p = 0;
+
+ return (output);
+}
diff --git a/com32/cmenu/libmenu/des.h b/com32/cmenu/libmenu/des.h
new file mode 100644
index 00000000..d820d423
--- /dev/null
+++ b/com32/cmenu/libmenu/des.h
@@ -0,0 +1,8 @@
+
+#ifndef _DES_H_
+#define _DES_H_
+
+// des crypt
+extern char *crypt(const char *key, const char *salt);
+
+#endif
diff --git a/com32/cmenu/libmenu/help.c b/com32/cmenu/libmenu/help.c
new file mode 100644
index 00000000..0df1e103
--- /dev/null
+++ b/com32/cmenu/libmenu/help.c
@@ -0,0 +1,232 @@
+/* -*- c -*- ------------------------------------------------------------- *
+ *
+ * Copyright 2004-2005 Murali Krishnan Ganapathy - 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
+ * the Free Software Foundation, Inc., 53 Temple Place Ste 330,
+ * Boston MA 02111-1307, USA; either version 2 of the License, or
+ * (at your option) any later version; incorporated herein by reference.
+ *
+ * ----------------------------------------------------------------------- */
+
+#include "help.h"
+#include <stdio.h>
+#include "string.h"
+#include "com32io.h"
+#include <syslinux/loadfile.h> // to read entire file into memory
+
+int nc, nr; // Number of columns/rows of the screen
+char helpbasedir[HELPDIRLEN]; // name of help directory limited to HELPDIRLEN
+
+// Find the occurence of the count'th \n in buffer (or NULL) if not found
+static char *findline(char *buffer, int count)
+{
+ int ctr;
+ char *p = buffer - 1;
+
+ if (count < 1)
+ return buffer;
+ for (ctr = 0; ctr < count; ctr++) {
+ p = strchr(p + 1, '\n');
+ if (p == NULL)
+ return NULL;
+ }
+ return p;
+}
+
+// return the number of lines in buffer
+static int countlines(char *buffer)
+{
+ int ans;
+ const char *p;
+
+ p = buffer - 1;
+ ans = 1;
+ while (p) {
+ p = strchr(p + 1, '\n');
+ ans++;
+ }
+ return ans;
+}
+
+// Print numlines of text starting from buf
+static void printtext(char *buf, int from)
+{
+ char *f, *t;
+ int right, nlines, i;
+
+ // clear window to print
+ right = nc - HELP_RIGHT_MARGIN;
+ nlines = nr - HELP_BODY_ROW - HELP_BOTTOM_MARGIN - 1;
+
+ f = findline(buf, from);
+ if (!f)
+ return; // nothing to print
+ if (*f == '\n')
+ f++; // start of from+1st line
+ t = f;
+ while (i < nlines) {
+ gotoxy(HELP_BODY_ROW + i, HELP_LEFT_MARGIN);
+ clear_end_of_line();
+ putchar(SO);
+ gotoxy(HELP_BODY_ROW + i, nc - 1);
+ putch(LEFT_BORDER, 0x07);
+ putchar(SI);
+
+ gotoxy(HELP_BODY_ROW + i, HELP_LEFT_MARGIN);
+ while (*t != '\n') {
+ if (*t == '\0')
+ return;
+ putchar(*t);
+ t++;
+ }
+ putchar('\n');
+ t++;
+ i++;
+ }
+}
+
+void showhelp(const char *filename)
+{
+ char ph;
+ char *title, *text;
+ union {
+ char *buffer;
+ void *vbuf;
+ } buf; // This is to avoild type-punning issues
+
+ char line[512];
+ size_t size;
+ int scan;
+ int rv, numlines, curr_line;
+
+ if (getscreensize(1, &nr, &nc)) {
+ /* Unknown screen size? */
+ nc = 80;
+ nr = 24;
+ }
+ ph = nr - HELP_BODY_ROW;
+ cls();
+
+ /* Turn autowrap off, to avoid scrolling the menu */
+ printf(CSI "?7l");
+
+ if (filename == NULL) { // print file contents
+ strcpy(line, "Filename not given");
+ goto puke;
+ }
+
+ rv = loadfile(filename, (void **)&buf.vbuf, &size); // load entire file into memory
+ if (rv < 0) { // Error reading file or no such file
+ sprintf(line, "Error reading file or file not found\n file=%s", filename);
+ goto puke;
+ }
+
+ title = buf.buffer;
+ text = findline(title, 1); // end of first line
+ *text++ = '\0'; // end the title string and increment text
+
+ // Now we have a file just print it.
+ numlines = countlines(text);
+ curr_line = 0;
+ scan = KEY_ESC + 1; // anything except ESCAPE
+
+ /* top, left, bottom, right, attr */
+ drawbox(0, 0, nr - 1, nc - 1, 0x07);
+ while (scan != KEY_ESC) {
+ /* Title */
+ gotoxy(1, (nc - strlen(title)) / 2);
+ fputs(title, stdout);
+ drawhorizline(2, HELP_LEFT_MARGIN - 1, nc - HELP_RIGHT_MARGIN, 0x07, 0); // dumb==0
+ /* Text */
+ printtext(text, curr_line);
+ gotoxy(HELP_BODY_ROW - 1, nc - HELP_RIGHT_MARGIN);
+ if (curr_line > 0)
+ putchar(HELP_MORE_ABOVE);
+ else
+ putchar(' ');
+ gotoxy(nr - HELP_BOTTOM_MARGIN - 1, nc - HELP_RIGHT_MARGIN);
+ if (curr_line < numlines - ph)
+ putchar(HELP_MORE_BELOW);
+ else
+ putchar(' ');
+
+ scan = get_key(stdout, 0); // wait for user keypress
+
+ switch (scan) {
+ case KEY_HOME:
+ curr_line = 0;
+ break;
+ case KEY_END:
+ curr_line = numlines;
+ break;
+ case KEY_UP:
+ curr_line--;
+ break;
+ case KEY_DOWN:
+ curr_line++;
+ break;
+ case KEY_PGUP:
+ curr_line -= ph;
+ break;
+ case KEY_PGDN:
+ curr_line += ph;
+ break;
+ default:
+ break;
+ }
+ if (curr_line > numlines - ph)
+ curr_line = numlines - ph;
+ if (curr_line < 0)
+ curr_line = 0;
+ }
+out:
+ cls();
+ return;
+
+puke:
+ gotoxy(HELP_BODY_ROW, HELP_LEFT_MARGIN);
+ fputs(line, stdout);
+ while (1) {
+ scan = get_key(stdin, 0);
+ if (scan == KEY_ESC)
+ break;
+ }
+ goto out;
+}
+
+void runhelp(const char *filename)
+{
+ char fullname[HELPDIRLEN + 16];
+
+ cls();
+ cursoroff();
+ if (helpbasedir[0] != 0) {
+ strcpy(fullname, helpbasedir);
+ strcat(fullname, "/");
+ strcat(fullname, filename);
+ showhelp(fullname);
+ } else
+ showhelp(filename); // Assume filename is absolute
+}
+
+void runhelpsystem(unsigned int helpid)
+{
+ char filename[15];
+
+ sprintf(filename, "hlp%05d.txt", helpid);
+ runhelp(filename);
+}
+
+void init_help(const char *helpdir)
+{
+ if (helpdir != NULL)
+ strcpy(helpbasedir, helpdir);
+ else
+ helpbasedir[0] = 0;
+}
+
+void close_help(void)
+{
+}
diff --git a/menu/libmenu/help.h b/com32/cmenu/libmenu/help.h
index 06832d84..de01b46e 100644
--- a/menu/libmenu/help.h
+++ b/com32/cmenu/libmenu/help.h
@@ -22,15 +22,15 @@
#define HELP_TITLE_HEIGHT 1
#define HELP_BODY_ROW (HELP_TITLE_HEIGHT+3)
#define HELP_LEFT_MARGIN 2
-#define HELP_RIGHT_MARGIN 2 // Assume all lines dont cross this
-#define HELP_BOTTOM_MARGIN 2 // Number of lines not use from bottom of screen
+#define HELP_RIGHT_MARGIN 2 // Assume all lines dont cross this
+#define HELP_BOTTOM_MARGIN 1 // Number of lines not use from bottom of screen
#define HELPBOX BOX_SINSIN
#define HELPDIRLEN 64
#define HELPPAGE 2
-#define HELP_MORE_ABOVE 24 // to print when more is available above
-#define HELP_MORE_BELOW 25 // same as above but for below
+#define HELP_MORE_ABOVE '^' // to print when more is available above
+#define HELP_MORE_BELOW 'v' // same as above but for below
// Display one screen of help information
void showhelp(const char *filename);
diff --git a/com32/cmenu/libmenu/menu.c b/com32/cmenu/libmenu/menu.c
new file mode 100644
index 00000000..13754768
--- /dev/null
+++ b/com32/cmenu/libmenu/menu.c
@@ -0,0 +1,1273 @@
+/* -*- c -*- ------------------------------------------------------------- *
+ *
+ * Copyright 2004-2005 Murali Krishnan Ganapathy - 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
+ * the Free Software Foundation, Inc., 53 Temple Place Ste 330,
+ * Boston MA 02111-1307, USA; either version 2 of the License, or
+ * (at your option) any later version; incorporated herein by reference.
+ *
+ * ----------------------------------------------------------------------- */
+
+#include "menu.h"
+#include "com32io.h"
+#include <stdlib.h>
+#include <console.h>
+
+// Local Variables
+static pt_menusystem ms; // Pointer to the menusystem
+char TITLESTR[] =
+ "COMBOOT Menu System for SYSLINUX developed by Murali Krishnan Ganapathy";
+char TITLELONG[] = " TITLE too long ";
+char ITEMLONG[] = " ITEM too long ";
+char ACTIONLONG[] = " ACTION too long ";
+char STATUSLONG[] = " STATUS too long ";
+char EMPTYSTR[] = "";
+
+/* Forward declarations */
+int calc_visible(pt_menu menu, int first);
+int next_visible(pt_menu menu, int index);
+int prev_visible(pt_menu menu, int index);
+int next_visible_sep(pt_menu menu, int index);
+int prev_visible_sep(pt_menu menu, int index);
+int calc_first_early(pt_menu menu, int curr);
+int calc_first_late(pt_menu menu, int curr);
+int isvisible(pt_menu menu, int first, int curr);
+
+/* Basic Menu routines */
+
+// This is same as inputc except it honors the ontimeout handler
+// and calls it when needed. For the callee, there is no difference
+// as this will not return unless a key has been pressed.
+static int getch(void)
+{
+ t_timeout_handler th;
+ int key;
+ unsigned long i;
+
+ // Wait until keypress if no handler specified
+ if ((ms->ontimeout == NULL) && (ms->ontotaltimeout == NULL))
+ return get_key(stdin, 0);
+
+ th = ms->ontimeout;
+ for (;;) {
+ for (i = 0; i < ms->tm_numsteps; i++) {
+ key = get_key(stdin, ms->tm_stepsize);
+ if (key != KEY_NONE)
+ return key;
+
+ if ((ms->tm_total_timeout == 0) || (ms->ontotaltimeout == NULL))
+ continue; // Dont bother with calculations if no handler
+ ms->tm_sofar_timeout += ms->tm_stepsize;
+ if (ms->tm_sofar_timeout >= ms->tm_total_timeout) {
+ th = ms->ontotaltimeout;
+ ms->tm_sofar_timeout = 0;
+ break; // Get out of the for loop
+ }
+ }
+ if (!th)
+ continue; // no handler
+ key = th();
+ switch (key) {
+ case CODE_ENTER: // Pretend user hit enter
+ return KEY_ENTER;
+ case CODE_ESCAPE: // Pretend user hit escape
+ return KEY_ESC;
+ default:
+ break;
+ }
+ }
+ return KEY_NONE;
+}
+
+int find_shortcut(pt_menu menu, uchar shortcut, int index)
+// Find the next index with specified shortcut key
+{
+ int ans;
+ pt_menuitem mi;
+
+ // Garbage in garbage out
+ if ((index < 0) || (index >= menu->numitems))
+ return index;
+ ans = index + 1;
+ // Go till end of menu
+ while (ans < menu->numitems) {
+ mi = menu->items[ans];
+ if ((mi->action == OPT_INVISIBLE) || (mi->action == OPT_SEP)
+ || (mi->shortcut != shortcut))
+ ans++;
+ else
+ return ans;
+ }
+ // Start at the beginning and try again
+ ans = 0;
+ while (ans < index) {
+ mi = menu->items[ans];
+ if ((mi->action == OPT_INVISIBLE) || (mi->action == OPT_SEP)
+ || (mi->shortcut != shortcut))
+ ans++;
+ else
+ return ans;
+ }
+ return index; // Sorry not found
+}
+
+/* Redraw background and title */
+static void reset_ui(void)
+{
+ uchar tpos;
+
+ cls();
+ clearwindow(ms->minrow, ms->mincol, ms->maxrow, ms->maxcol,
+ ms->fillchar, ms->fillattr);
+
+ tpos = (ms->numcols - strlen(ms->title) - 1) >> 1; // center it on line
+ gotoxy(ms->minrow, ms->mincol);
+ cprint(ms->tfillchar, ms->titleattr, ms->numcols);
+ gotoxy(ms->minrow, ms->mincol + tpos);
+ csprint(ms->title, ms->titleattr);
+
+ cursoroff();
+}
+
+/*
+ * Print a menu item
+ *
+ * attr[0] is non-hilite attr, attr[1] is highlight attr
+ */
+void printmenuitem(const char *str, uchar * attr)
+{
+ int hlite = NOHLITE; // Initially no highlighting
+
+ while (*str) {
+ switch (*str) {
+ case BELL: // No Bell Char
+ break;
+ case ENABLEHLITE: // Switch on highlighting
+ hlite = HLITE;
+ break;
+ case DISABLEHLITE: // Turn off highlighting
+ hlite = NOHLITE;
+ break;
+ default:
+ putch(*str, attr[hlite]);
+ }
+ str++;
+ }
+}
+
+
+/**
+ * print_line - Print a whole line in a menu
+ * @menu: current menu to handle
+ * @curr: index of the current entry highlighted
+ * @top: top coordinate of the @menu
+ * @left: left coordinate of the @menu
+ * @x: index in the menu of curr
+ * @row: row currently displayed
+ * @radio: radio item?
+ **/
+static void print_line(pt_menu menu, int curr, uchar top, uchar left,
+ int x, int row, bool radio)
+{
+ pt_menuitem ci;
+ char fchar[6], lchar[6]; // The first and last char in for each entry
+ const char *str; // Item string (cf printmenuitem)
+ char sep[MENULEN]; // Separator (OPT_SEP)
+ uchar *attr; // Attribute
+ int menuwidth = menu->menuwidth + 3;
+
+ if (row >= menu->menuheight)
+ return;
+
+ ci = menu->items[x];
+
+ memset(sep, ms->box_horiz, menuwidth);
+ sep[menuwidth - 1] = 0;
+
+ // Setup the defaults now
+ if (radio) {
+ fchar[0] = '\b';
+ fchar[1] = SO;
+ fchar[2] = (x == curr ? RADIOSEL : RADIOUNSEL);
+ fchar[3] = SI;
+ fchar[4] = '\0'; // Unselected ( )
+ lchar[0] = '\0'; // Nothing special after
+ attr = ms->normalattr; // Always same attribute
+ } else {
+ lchar[0] = fchar[0] = ' ';
+ lchar[1] = fchar[1] = '\0'; // fchar and lchar are just spaces
+ attr = (x == curr ? ms->reverseattr : ms->normalattr); // Normal attributes
+ }
+ str = ci->item; // Pointer to item string
+ switch (ci->action) // set up attr,str,fchar,lchar for everything
+ {
+ case OPT_INACTIVE:
+ if (radio)
+ attr = ms->inactattr;
+ else
+ attr = (x == curr ? ms->revinactattr : ms->inactattr);
+ break;
+ case OPT_SUBMENU:
+ if (radio)
+ break; // Not supported for radio menu
+ lchar[0] = '>';
+ lchar[1] = 0;
+ break;
+ case OPT_RADIOMENU:
+ if (radio)
+ break; // Not supported for radio menu
+ lchar[0] = RADIOMENUCHAR;
+ lchar[1] = 0;
+ break;
+ case OPT_CHECKBOX:
+ if (radio)
+ break; // Not supported for radio menu
+ lchar[0] = '\b';
+ lchar[1] = SO;
+ lchar[2] = (ci->itemdata.checked ? CHECKED : UNCHECKED);
+ lchar[3] = SI;
+ lchar[4] = 0;
+ break;
+ case OPT_SEP:
+ fchar[0] = '\b';
+ fchar[1] = SO;
+ fchar[2] = LEFT_MIDDLE_BORDER;
+ fchar[3] = MIDDLE_BORDER;
+ fchar[4] = MIDDLE_BORDER;
+ fchar[5] = 0;
+ memset(sep, MIDDLE_BORDER, menuwidth);
+ sep[menuwidth - 1] = 0;
+ str = sep;
+ lchar[0] = MIDDLE_BORDER;
+ lchar[1] = RIGHT_MIDDLE_BORDER;
+ lchar[2] = SI;
+ lchar[3] = 0;
+ break;
+ case OPT_EXITMENU:
+ if (radio)
+ break; // Not supported for radio menu
+ fchar[0] = '<';
+ fchar[1] = 0;
+ break;
+ default: // Just to keep the compiler happy
+ break;
+ }
+
+ // Wipe area with spaces
+ gotoxy(top + row, left - 2);
+ cprint(ms->spacechar, attr[NOHLITE], menuwidth + 2);
+
+ // Print first part
+ gotoxy(top + row, left - 2);
+ csprint(fchar, attr[NOHLITE]);
+
+ // Print main part
+ gotoxy(top + row, left);
+ printmenuitem(str, attr);
+
+ // Print last part
+ gotoxy(top + row, left + menuwidth - 1);
+ csprint(lchar, attr[NOHLITE]);
+}
+
+// print the menu starting from FIRST
+// will print a maximum of menu->menuheight items
+static void printmenu(pt_menu menu, int curr, uchar top, uchar left, uchar first, bool radio)
+{
+ int x, row; // x = index, row = position from top
+ int numitems, menuwidth;
+ pt_menuitem ci;
+
+ numitems = calc_visible(menu, first);
+ if (numitems > menu->menuheight)
+ numitems = menu->menuheight;
+
+ menuwidth = menu->menuwidth + 3;
+ clearwindow(top, left - 2, top + numitems + 1, left + menuwidth + 1,
+ ms->fillchar, ms->shadowattr);
+ drawbox(top - 1, left - 3, top + numitems, left + menuwidth,
+ ms->normalattr[NOHLITE]);
+
+ // Menu title
+ x = (menuwidth - strlen(menu->title) - 1) >> 1;
+ gotoxy(top - 1, left + x);
+ printmenuitem(menu->title, ms->normalattr);
+
+ // All lines in the menu
+ row = -1; // 1 less than inital value of x
+ for (x = first; x < menu->numitems; x++) {
+ ci = menu->items[x];
+ if (ci->action == OPT_INVISIBLE)
+ continue;
+ row++;
+ if (row >= numitems)
+ break; // Already have enough number of items
+ print_line(menu, curr, top, left, x, row, radio);
+ }
+ // Check if we need to MOREABOVE and MOREBELOW to be added
+ // reuse x
+ row = 0;
+ x = next_visible_sep(menu, 0); // First item
+ if (!isvisible(menu, first, x)) // There is more above
+ {
+ row = 1;
+ gotoxy(top, left + menuwidth);
+ cprint(MOREABOVE, ms->normalattr[NOHLITE], 1);
+ }
+ x = prev_visible_sep(menu, menu->numitems); // last item
+ if (!isvisible(menu, first, x)) // There is more above
+ {
+ row = 1;
+ gotoxy(top + numitems - 1, left + menuwidth);
+ cprint(MOREBELOW, ms->normalattr[NOHLITE], 1);
+ }
+ // Add a scroll box
+ x = ((numitems - 1) * curr) / (menu->numitems);
+ if ((x > 0) && (row == 1)) {
+ gotoxy(top + x, left + menuwidth);
+ csprint("\016\141\017", ms->normalattr[NOHLITE]);
+ }
+ if (ms->handler)
+ ms->handler(ms, menu->items[curr]);
+}
+
+void cleanupmenu(pt_menu menu, uchar top, uchar left, int numitems)
+{
+ if (numitems > menu->menuheight)
+ numitems = menu->menuheight;
+ clearwindow(top, left - 2, top + numitems + 1, left + menu->menuwidth + 4, ms->fillchar, ms->fillattr); // Clear the shadow
+ clearwindow(top - 1, left - 3, top + numitems, left + menu->menuwidth + 3, ms->fillchar, ms->fillattr); // main window
+}
+
+
+/* Handle one menu */
+static pt_menuitem getmenuoption(pt_menu menu, uchar top, uchar left, uchar startopt, bool radio)
+ // Return item chosen or NULL if ESC was hit.
+{
+ int prev, prev_first, curr, i, first, tmp;
+ int asc = 0;
+ bool redraw = true; // Need to draw the menu the first time
+ uchar numitems;
+ pt_menuitem ci; // Current item
+ t_handler_return hr; // Return value of handler
+
+ numitems = calc_visible(menu, 0);
+ // Setup status line
+ gotoxy(ms->minrow + ms->statline, ms->mincol);
+ cprint(ms->spacechar, ms->statusattr[NOHLITE], ms->numcols);
+
+ // Initialise current menu item
+ curr = next_visible(menu, startopt);
+ prev = curr;
+
+ gotoxy(ms->minrow + ms->statline, ms->mincol);
+ cprint(ms->spacechar, ms->statusattr[NOHLITE], ms->numcols);
+ gotoxy(ms->minrow + ms->statline, ms->mincol);
+ printmenuitem(menu->items[curr]->status, ms->statusattr);
+ first = calc_first_early(menu, curr);
+ prev_first = first;
+ while (1) // Forever
+ {
+ /* Redraw everything if:
+ * + we need to scroll (take care of scroll bars, ...)
+ * + menuoption
+ */
+ if (prev_first != first || redraw) {
+ printmenu(menu, curr, top, left, first, radio);
+ } else {
+ /* Redraw only the highlighted entry */
+ print_line(menu, curr, top, left, prev, prev - first, radio);
+ print_line(menu, curr, top, left, curr, curr - first, radio);
+ }
+ redraw = false;
+ prev = curr;
+ prev_first = first;
+ ci = menu->items[curr];
+ asc = getch();
+ switch (asc) {
+ case KEY_CTRL('L'):
+ redraw = true;
+ break;
+ case KEY_HOME:
+ curr = next_visible(menu, 0);
+ first = calc_first_early(menu, curr);
+ break;
+ case KEY_END:
+ curr = prev_visible(menu, numitems - 1);
+ first = calc_first_late(menu, curr);
+ break;
+ case KEY_PGDN:
+ for (i = 0; i < 5; i++)
+ curr = next_visible(menu, curr + 1);
+ first = calc_first_late(menu, curr);
+ break;
+ case KEY_PGUP:
+ for (i = 0; i < 5; i++)
+ curr = prev_visible(menu, curr - 1);
+ first = calc_first_early(menu, curr);
+ break;
+ case KEY_UP:
+ curr = prev_visible(menu, curr - 1);
+ if (curr < first)
+ first = calc_first_early(menu, curr);
+ break;
+ case KEY_DOWN:
+ curr = next_visible(menu, curr + 1);
+ if (!isvisible(menu, first, curr))
+ first = calc_first_late(menu, curr);
+ break;
+ case KEY_LEFT:
+ case KEY_ESC:
+ return NULL;
+ break;
+ case KEY_RIGHT:
+ case KEY_ENTER:
+ if (ci->action == OPT_INACTIVE)
+ break;
+ if (ci->action == OPT_CHECKBOX)
+ break;
+ if (ci->action == OPT_SEP)
+ break;
+ if (ci->action == OPT_EXITMENU)
+ return NULL; // As if we hit Esc
+ // If we are going into a radio menu, dont call handler, return ci
+ if (ci->action == OPT_RADIOMENU)
+ return ci;
+ if (ci->handler != NULL) // Do we have a handler
+ {
+ hr = ci->handler(ms, ci);
+ if (hr.refresh) // Do we need to refresh
+ {
+ // Cleanup menu using old number of items
+ cleanupmenu(menu, top, left, numitems);
+ // Recalculate the number of items
+ numitems = calc_visible(menu, 0);
+ // Reprint the menu
+ printmenu(menu, curr, top, left, first, radio);
+ }
+ if (hr.valid)
+ return ci;
+ } else
+ return ci;
+ break;
+ case SPACECHAR:
+ if (ci->action != OPT_CHECKBOX)
+ break;
+ ci->itemdata.checked = !ci->itemdata.checked;
+ if (ci->handler != NULL) // Do we have a handler
+ {
+ hr = ci->handler(ms, ci);
+ if (hr.refresh) // Do we need to refresh
+ {
+ // Cleanup menu using old number of items
+ cleanupmenu(menu, top, left, numitems);
+ // Recalculate the number of items
+ numitems = calc_visible(menu, 0);
+ // Reprint the menu
+ printmenu(menu, curr, top, left, first, radio);
+ }
+ }
+ break;
+ default:
+ // Check if this is a shortcut key
+ if (((asc >= 'A') && (asc <= 'Z')) ||
+ ((asc >= 'a') && (asc <= 'z')) ||
+ ((asc >= '0') && (asc <= '9'))) {
+ tmp = find_shortcut(menu, asc, curr);
+ if ((tmp > curr) && (!isvisible(menu, first, tmp)))
+ first = calc_first_late(menu, tmp);
+ if (tmp < curr)
+ first = calc_first_early(menu, tmp);
+ curr = tmp;
+ } else {
+ if (ms->keys_handler) // Call extra keys handler
+ ms->keys_handler(ms, menu->items[curr], asc);
+
+ /* The handler may have changed the UI, reset it on exit */
+ reset_ui();
+ // Cleanup menu using old number of items
+ cleanupmenu(menu, top, left, numitems);
+ // Recalculate the number of items
+ numitems = calc_visible(menu, 0);
+ // Reprint the menu
+ printmenu(menu, curr, top, left, first, radio);
+ }
+ break;
+ }
+ // Update status line
+ /* Erase the previous status */
+ gotoxy(ms->minrow + ms->statline, ms->mincol);
+ cprint(ms->spacechar, ms->statusattr[NOHLITE], ms->numcols);
+ /* Print the new status */
+ gotoxy(ms->minrow + ms->statline, ms->mincol);
+ printmenuitem(menu->items[curr]->status, ms->statusattr);
+ }
+ return NULL; // Should never come here
+}
+
+/* Handle the entire system of menu's. */
+pt_menuitem runmenusystem(uchar top, uchar left, pt_menu cmenu, uchar startopt,
+ uchar menutype)
+ /*
+ * cmenu
+ * Which menu should be currently displayed
+ * top,left
+ * What is the position of the top,left corner of the menu
+ * startopt
+ * which menu item do I start with
+ * menutype
+ * NORMALMENU or RADIOMENU
+ *
+ * Return Value:
+ * Returns a pointer to the final item chosen, or NULL if nothing chosen.
+ */
+{
+ pt_menuitem opt, choice;
+ uchar startat, mt;
+ uchar row, col;
+
+ if (cmenu == NULL)
+ return NULL;
+
+startover:
+ // Set the menu height
+ cmenu->menuheight = ms->maxrow - top - 3;
+ if (cmenu->menuheight > ms->maxmenuheight)
+ cmenu->menuheight = ms->maxmenuheight;
+ if (menutype == NORMALMENU)
+ opt = getmenuoption(cmenu, top, left, startopt, false);
+ else // menutype == RADIOMENU
+ opt = getmenuoption(cmenu, top, left, startopt, true);
+
+ if (opt == NULL) {
+ // User hit Esc
+ cleanupmenu(cmenu, top, left, calc_visible(cmenu, 0));
+ return NULL;
+ }
+ // Are we done with the menu system?
+ if ((opt->action != OPT_SUBMENU) && (opt->action != OPT_RADIOMENU)) {
+ cleanupmenu(cmenu, top, left, calc_visible(cmenu, 0));
+ return opt; // parent cleanup other menus
+ }
+ // Either radiomenu or submenu
+ // Do we have a valid menu number? The next hack uses the fact that
+ // itemdata.submenunum = itemdata.radiomenunum (since enum data type)
+ if (opt->itemdata.submenunum >= ms->nummenus) // This is Bad....
+ {
+ gotoxy(12, 12); // Middle of screen
+ csprint("ERROR: Invalid submenu requested.", 0x07);
+ cleanupmenu(cmenu, top, left, calc_visible(cmenu, 0));
+ return NULL; // Pretend user hit esc
+ }
+ // Call recursively for submenu
+ // Position the submenu below the current item,
+ // covering half the current window (horizontally)
+ row = ms->menus[(unsigned int)opt->itemdata.submenunum]->row;
+ col = ms->menus[(unsigned int)opt->itemdata.submenunum]->col;
+ if (row == 0xFF)
+ row = top + opt->index + 2;
+ if (col == 0xFF)
+ col = left + 3 + (cmenu->menuwidth >> 1);
+ mt = (opt->action == OPT_SUBMENU ? NORMALMENU : RADIOMENU);
+ startat = 0;
+ if ((opt->action == OPT_RADIOMENU) && (opt->data != NULL))
+ startat = ((t_menuitem *) opt->data)->index;
+
+ choice = runmenusystem(row, col,
+ ms->menus[(unsigned int)opt->itemdata.submenunum],
+ startat, mt);
+ if (opt->action == OPT_RADIOMENU) {
+ if (choice != NULL)
+ opt->data = (void *)choice; // store choice in data field
+ if (opt->handler != NULL)
+ opt->handler(ms, opt);
+ choice = NULL; // Pretend user hit esc
+ }
+ if (choice == NULL) // User hit Esc in submenu
+ {
+ // Startover
+ startopt = opt->index;
+ goto startover;
+ } else {
+ cleanupmenu(cmenu, top, left, calc_visible(cmenu, 0));
+ return choice;
+ }
+}
+
+// Finds the indexof the menu with given name
+uchar find_menu_num(const char *name)
+{
+ int i;
+ pt_menu m;
+
+ if (name == NULL)
+ return (uchar) (-1);
+ for (i = 0; i < ms->nummenus; i++) {
+ m = ms->menus[i];
+ if ((m->name) && (strcmp(m->name, name) == 0))
+ return i;
+ }
+ return (uchar) (-1);
+}
+
+// Run through all items and if they are submenus
+// with a non-trivial "action" and trivial submenunum
+// replace submenunum with the menu with name "action"
+void fix_submenus(void)
+{
+ int i, j;
+ pt_menu m;
+ pt_menuitem mi;
+
+ i = 0;
+ for (i = 0; i < ms->nummenus; i++) {
+ m = ms->menus[i];
+ for (j = 0; j < m->numitems; j++) {
+ mi = m->items[j];
+ // if item is a submenu and has non-empty non-trivial data string
+ if (mi->data && strlen(mi->data) > 0 &&
+ ((mi->action == OPT_SUBMENU)
+ || (mi->action == OPT_RADIOMENU))) {
+ mi->itemdata.submenunum = find_menu_num(mi->data);
+ }
+ }
+ }
+}
+
+/* User Callable functions */
+
+pt_menuitem showmenus(uchar startmenu)
+{
+ pt_menuitem rv;
+
+ fix_submenus(); // Fix submenu numbers incase nick names were used
+
+ /* Turn autowrap off, to avoid scrolling the menu */
+ printf(CSI "?7l");
+
+ // Setup screen for menusystem
+ reset_ui();
+
+ // Go, main menu cannot be a radio menu
+ rv = runmenusystem(ms->minrow + MENUROW, ms->mincol + MENUCOL,
+ ms->menus[(unsigned int)startmenu], 0, NORMALMENU);
+
+ // Hide the garbage we left on the screen
+ cursoron();
+ cls();
+ gotoxy(ms->minrow, ms->mincol);
+
+ // Return user choice
+ return rv;
+}
+
+pt_menusystem init_menusystem(const char *title)
+{
+ int i;
+
+ ms = NULL;
+ ms = (pt_menusystem) malloc(sizeof(t_menusystem));
+ if (ms == NULL)
+ return NULL;
+ ms->nummenus = 0;
+ // Initialise all menu pointers
+ for (i = 0; i < MAXMENUS; i++)
+ ms->menus[i] = NULL;
+
+ ms->title = (char *)malloc(TITLELEN + 1);
+ if (title == NULL)
+ strcpy(ms->title, TITLESTR); // Copy string
+ else
+ strcpy(ms->title, title);
+
+ // Timeout settings
+ ms->tm_stepsize = TIMEOUTSTEPSIZE;
+ ms->tm_numsteps = TIMEOUTNUMSTEPS;
+
+ ms->normalattr[NOHLITE] = NORMALATTR;
+ ms->normalattr[HLITE] = NORMALHLITE;
+
+ ms->reverseattr[NOHLITE] = REVERSEATTR;
+ ms->reverseattr[HLITE] = REVERSEHLITE;
+
+ ms->inactattr[NOHLITE] = INACTATTR;
+ ms->inactattr[HLITE] = INACTHLITE;
+
+ ms->revinactattr[NOHLITE] = REVINACTATTR;
+ ms->revinactattr[HLITE] = REVINACTHLITE;
+
+ ms->statusattr[NOHLITE] = STATUSATTR;
+ ms->statusattr[HLITE] = STATUSHLITE;
+
+ ms->statline = STATLINE;
+ ms->tfillchar = TFILLCHAR;
+ ms->titleattr = TITLEATTR;
+
+ ms->fillchar = FILLCHAR;
+ ms->fillattr = FILLATTR;
+ ms->spacechar = SPACECHAR;
+ ms->shadowattr = SHADOWATTR;
+
+ ms->menupage = MENUPAGE; // Usually no need to change this at all
+
+ // Initialise all handlers
+ ms->handler = NULL;
+ ms->keys_handler = NULL;
+ ms->ontimeout = NULL; // No timeout handler
+ ms->tm_total_timeout = 0;
+ ms->tm_sofar_timeout = 0;
+ ms->ontotaltimeout = NULL;
+
+ // Setup ACTION_{,IN}VALID
+ ACTION_VALID.valid = 1;
+ ACTION_VALID.refresh = 0;
+ ACTION_INVALID.valid = 0;
+ ACTION_INVALID.refresh = 0;
+
+ // Figure out the size of the screen we are in now.
+ // By default we use the whole screen for our menu
+ if (getscreensize(1, &ms->numrows, &ms->numcols)) {
+ /* Unknown screen size? */
+ ms->numcols = 80;
+ ms->numrows = 24;
+ }
+ ms->minrow = ms->mincol = 0;
+ ms->maxcol = ms->numcols - 1;
+ ms->maxrow = ms->numrows - 1;
+
+ // How many entries per menu can we display at a time
+ ms->maxmenuheight = ms->maxrow - ms->minrow - 3;
+ if (ms->maxmenuheight > MAXMENUHEIGHT)
+ ms->maxmenuheight = MAXMENUHEIGHT;
+
+ console_ansi_raw();
+
+ return ms;
+}
+
+void set_normal_attr(uchar normal, uchar selected, uchar inactivenormal,
+ uchar inactiveselected)
+{
+ if (normal != 0xFF)
+ ms->normalattr[0] = normal;
+ if (selected != 0xFF)
+ ms->reverseattr[0] = selected;
+ if (inactivenormal != 0xFF)
+ ms->inactattr[0] = inactivenormal;
+ if (inactiveselected != 0xFF)
+ ms->revinactattr[0] = inactiveselected;
+}
+
+void set_normal_hlite(uchar normal, uchar selected, uchar inactivenormal,
+ uchar inactiveselected)
+{
+ if (normal != 0xFF)
+ ms->normalattr[1] = normal;
+ if (selected != 0xFF)
+ ms->reverseattr[1] = selected;
+ if (inactivenormal != 0xFF)
+ ms->inactattr[1] = inactivenormal;
+ if (inactiveselected != 0xFF)
+ ms->revinactattr[1] = inactiveselected;
+}
+
+void set_status_info(uchar statusattr, uchar statushlite, uchar statline)
+{
+ if (statusattr != 0xFF)
+ ms->statusattr[NOHLITE] = statusattr;
+ if (statushlite != 0xFF)
+ ms->statusattr[HLITE] = statushlite;
+ // statline is relative to minrow
+ if (statline >= ms->numrows)
+ statline = ms->numrows - 1;
+ ms->statline = statline; // relative to ms->minrow, 0 based
+}
+
+void set_title_info(uchar tfillchar, uchar titleattr)
+{
+ if (tfillchar != 0xFF)
+ ms->tfillchar = tfillchar;
+ if (titleattr != 0xFF)
+ ms->titleattr = titleattr;
+}
+
+void set_misc_info(uchar fillchar, uchar fillattr, uchar spacechar,
+ uchar shadowattr)
+{
+ if (fillchar != 0xFF)
+ ms->fillchar = fillchar;
+ if (fillattr != 0xFF)
+ ms->fillattr = fillattr;
+ if (spacechar != 0xFF)
+ ms->spacechar = spacechar;
+ if (shadowattr != 0xFF)
+ ms->shadowattr = shadowattr;
+}
+
+void set_menu_options(uchar maxmenuheight)
+{
+ if (maxmenuheight != 0xFF)
+ ms->maxmenuheight = maxmenuheight;
+}
+
+// Set the window which menusystem should use
+void set_window_size(uchar top, uchar left, uchar bot, uchar right)
+{
+ int nr, nc;
+
+ if ((top > bot) || (left > right))
+ return; // Sorry no change will happen here
+
+ if (getscreensize(1, &nr, &nc)) {
+ /* Unknown screen size? */
+ nr = 80;
+ nc = 24;
+ }
+ if (bot >= nr)
+ bot = nr - 1;
+ if (right >= nc)
+ right = nc - 1;
+ ms->minrow = top;
+ ms->mincol = left;
+ ms->maxrow = bot;
+ ms->maxcol = right;
+ ms->numcols = right - left + 1;
+ ms->numrows = bot - top + 1;
+ if (ms->statline >= ms->numrows)
+ ms->statline = ms->numrows - 1; // Clip statline if need be
+}
+
+void reg_handler(t_handler htype, void *handler)
+{
+ // If bad value set to default screen handler
+ switch (htype) {
+ case HDLR_KEYS:
+ ms->keys_handler = (t_keys_handler) handler;
+ break;
+ default:
+ ms->handler = (t_menusystem_handler) handler;
+ break;
+ }
+}
+
+void unreg_handler(t_handler htype)
+{
+ switch (htype) {
+ case HDLR_KEYS:
+ ms->keys_handler = NULL;
+ break;
+ default:
+ ms->handler = NULL;
+ break;
+ }
+}
+
+void reg_ontimeout(t_timeout_handler handler, unsigned int numsteps,
+ unsigned int stepsize)
+{
+ ms->ontimeout = handler;
+ if (numsteps != 0)
+ ms->tm_numsteps = numsteps;
+ if (stepsize != 0)
+ ms->tm_stepsize = stepsize;
+}
+
+void unreg_ontimeout(void)
+{
+ ms->ontimeout = NULL;
+}
+
+void reg_ontotaltimeout(t_timeout_handler handler,
+ unsigned long numcentiseconds)
+{
+ if (numcentiseconds != 0) {
+ ms->ontotaltimeout = handler;
+ ms->tm_total_timeout = numcentiseconds * 10; // to convert to milliseconds
+ ms->tm_sofar_timeout = 0;
+ }
+}
+
+void unreg_ontotaltimeout(void)
+{
+ ms->ontotaltimeout = NULL;
+}
+
+int next_visible(pt_menu menu, int index)
+{
+ int ans;
+ if (index < 0)
+ ans = 0;
+ else if (index >= menu->numitems)
+ ans = menu->numitems - 1;
+ else
+ ans = index;
+ while ((ans < menu->numitems - 1) &&
+ ((menu->items[ans]->action == OPT_INVISIBLE) ||
+ (menu->items[ans]->action == OPT_SEP)))
+ ans++;
+ return ans;
+}
+
+int prev_visible(pt_menu menu, int index) // Return index of prev visible
+{
+ int ans;
+ if (index < 0)
+ ans = 0;
+ else if (index >= menu->numitems)
+ ans = menu->numitems - 1;
+ else
+ ans = index;
+ while ((ans > 0) &&
+ ((menu->items[ans]->action == OPT_INVISIBLE) ||
+ (menu->items[ans]->action == OPT_SEP)))
+ ans--;
+ return ans;
+}
+
+int next_visible_sep(pt_menu menu, int index)
+{
+ int ans;
+ if (index < 0)
+ ans = 0;
+ else if (index >= menu->numitems)
+ ans = menu->numitems - 1;
+ else
+ ans = index;
+ while ((ans < menu->numitems - 1) &&
+ (menu->items[ans]->action == OPT_INVISIBLE))
+ ans++;
+ return ans;
+}
+
+int prev_visible_sep(pt_menu menu, int index) // Return index of prev visible
+{
+ int ans;
+ if (index < 0)
+ ans = 0;
+ else if (index >= menu->numitems)
+ ans = menu->numitems - 1;
+ else
+ ans = index;
+ while ((ans > 0) && (menu->items[ans]->action == OPT_INVISIBLE))
+ ans--;
+ return ans;
+}
+
+int calc_visible(pt_menu menu, int first)
+{
+ int ans, i;
+
+ if (menu == NULL)
+ return 0;
+ ans = 0;
+ for (i = first; i < menu->numitems; i++)
+ if (menu->items[i]->action != OPT_INVISIBLE)
+ ans++;
+ return ans;
+}
+
+// is curr visible if first entry is first?
+int isvisible(pt_menu menu, int first, int curr)
+{
+ if (curr < first)
+ return 0;
+ return (calc_visible(menu, first) - calc_visible(menu, curr) <
+ menu->menuheight);
+}
+
+// Calculate the first entry to be displayed
+// so that curr is visible and make curr as late as possible
+int calc_first_late(pt_menu menu, int curr)
+{
+ int ans, i, nv;
+
+ nv = calc_visible(menu, 0);
+ if (nv <= menu->menuheight)
+ return 0;
+ // Start with curr and go back menu->menuheight times
+ ans = curr + 1;
+ for (i = 0; i < menu->menuheight; i++)
+ ans = prev_visible_sep(menu, ans - 1);
+ return ans;
+}
+
+// Calculate the first entry to be displayed
+// so that curr is visible and make curr as early as possible
+int calc_first_early(pt_menu menu, int curr)
+{
+ int ans, i, nv;
+
+ nv = calc_visible(menu, 0);
+ if (nv <= menu->menuheight)
+ return 0;
+ // Start with curr and go back till >= menu->menuheight
+ // items are visible
+ nv = calc_visible(menu, curr); // Already nv of them are visible
+ ans = curr;
+ for (i = 0; i < menu->menuheight - nv; i++)
+ ans = prev_visible_sep(menu, ans - 1);
+ return ans;
+}
+
+// Create a new menu and return its position
+uchar add_menu(const char *title, int maxmenusize)
+{
+ int num, i;
+ pt_menu m;
+
+ num = ms->nummenus;
+ if (num >= MAXMENUS)
+ return -1;
+ m = NULL;
+ m = (pt_menu) malloc(sizeof(t_menu));
+ if (m == NULL)
+ return -1;
+ ms->menus[num] = m;
+ m->numitems = 0;
+ m->name = NULL;
+ m->row = 0xFF;
+ m->col = 0xFF;
+ if (maxmenusize < 1)
+ m->maxmenusize = MAXMENUSIZE;
+ else
+ m->maxmenusize = maxmenusize;
+ m->items = (pt_menuitem *) malloc(sizeof(pt_menuitem) * (m->maxmenusize));
+ for (i = 0; i < m->maxmenusize; i++)
+ m->items[i] = NULL;
+
+ m->title = (char *)malloc(MENULEN + 1);
+ if (title) {
+ if (strlen(title) > MENULEN - 2)
+ strcpy(m->title, TITLELONG);
+ else
+ strcpy(m->title, title);
+ } else
+ strcpy(m->title, EMPTYSTR);
+ m->menuwidth = strlen(m->title);
+ ms->nummenus++;
+ return ms->nummenus - 1;
+}
+
+void set_menu_name(const char *name) // Set the "name" of this menu
+{
+ pt_menu m;
+
+ m = ms->menus[ms->nummenus - 1];
+ if (m->name) // Free up previous name
+ {
+ free(m->name);
+ m->name = NULL;
+ }
+
+ if (name) {
+ m->name = (char *)malloc(strlen(name) + 1);
+ strcpy(m->name, name);
+ }
+}
+
+// Create a new named menu and return its position
+uchar add_named_menu(const char *name, const char *title, int maxmenusize)
+{
+ add_menu(title, maxmenusize);
+ set_menu_name(name);
+ return ms->nummenus - 1;
+}
+
+void set_menu_pos(uchar row, uchar col) // Set the position of this menu.
+{
+ pt_menu m;
+
+ m = ms->menus[ms->nummenus - 1];
+ m->row = row;
+ m->col = col;
+}
+
+pt_menuitem add_sep(void) // Add a separator to current menu
+{
+ pt_menuitem mi;
+ pt_menu m;
+
+ m = (ms->menus[ms->nummenus - 1]);
+ mi = NULL;
+ mi = (pt_menuitem) malloc(sizeof(t_menuitem));
+ if (mi == NULL)
+ return NULL;
+ m->items[(unsigned int)m->numitems] = mi;
+ mi->handler = NULL; // No handler
+ mi->item = mi->status = mi->data = NULL;
+ mi->action = OPT_SEP;
+ mi->index = m->numitems++;
+ mi->parindex = ms->nummenus - 1;
+ mi->shortcut = 0;
+ mi->helpid = 0;
+ return mi;
+}
+
+// Add item to the "current" menu
+pt_menuitem add_item(const char *item, const char *status, t_action action,
+ const char *data, uchar itemdata)
+{
+ pt_menuitem mi;
+ pt_menu m;
+ const char *str;
+ uchar inhlite = 0; // Are we inside hlite area
+
+ m = (ms->menus[ms->nummenus - 1]);
+ mi = NULL;
+ mi = (pt_menuitem) malloc(sizeof(t_menuitem));
+ if (mi == NULL)
+ return NULL;
+ m->items[(unsigned int)m->numitems] = mi;
+ mi->handler = NULL; // No handler
+
+ // Allocate space to store stuff
+ mi->item = (char *)malloc(MENULEN + 1);
+ mi->status = (char *)malloc(STATLEN + 1);
+ mi->data = (char *)malloc(ACTIONLEN + 1);
+
+ if (item) {
+ if (strlen(item) > MENULEN) {
+ strcpy(mi->item, ITEMLONG);
+ } else {
+ strcpy(mi->item, item);
+ }
+ if (strlen(mi->item) > m->menuwidth)
+ m->menuwidth = strlen(mi->item);
+ } else
+ strcpy(mi->item, EMPTYSTR);
+
+ if (status) {
+ if (strlen(status) > STATLEN) {
+ strcpy(mi->status, STATUSLONG);
+ } else {
+ strcpy(mi->status, status);
+ }
+ } else
+ strcpy(mi->status, EMPTYSTR);
+
+ mi->action = action;
+ str = mi->item;
+ mi->shortcut = 0;
+ mi->helpid = 0xFFFF;
+ inhlite = 0; // We have not yet seen an ENABLEHLITE char
+ // Find the first char in [A-Za-z0-9] after ENABLEHLITE and not arg to control char
+ while (*str) {
+ if (*str == ENABLEHLITE) {
+ inhlite = 1;
+ }
+ if (*str == DISABLEHLITE) {
+ inhlite = 0;
+ }
+ if ((inhlite == 1) &&
+ (((*str >= 'A') && (*str <= 'Z')) ||
+ ((*str >= 'a') && (*str <= 'z')) ||
+ ((*str >= '0') && (*str <= '9')))) {
+ mi->shortcut = *str;
+ break;
+ }
+ ++str;
+ }
+ if ((mi->shortcut >= 'A') && (mi->shortcut <= 'Z')) // Make lower case
+ mi->shortcut = mi->shortcut - 'A' + 'a';
+
+ if (data) {
+ if (strlen(data) > ACTIONLEN) {
+ strcpy(mi->data, ACTIONLONG);
+ } else {
+ strcpy(mi->data, data);
+ }
+ } else
+ strcpy(mi->data, EMPTYSTR);
+
+ switch (action) {
+ case OPT_SUBMENU:
+ mi->itemdata.submenunum = itemdata;
+ break;
+ case OPT_CHECKBOX:
+ mi->itemdata.checked = itemdata;
+ break;
+ case OPT_RADIOMENU:
+ mi->itemdata.radiomenunum = itemdata;
+ if (mi->data)
+ free(mi->data);
+ mi->data = NULL; // No selection made
+ break;
+ default: // to keep the compiler happy
+ break;
+ }
+ mi->index = m->numitems++;
+ mi->parindex = ms->nummenus - 1;
+ return mi;
+}
+
+// Set the shortcut key for the current item
+void set_item_options(uchar shortcut, int helpid)
+{
+ pt_menuitem mi;
+ pt_menu m;
+
+ m = (ms->menus[ms->nummenus - 1]);
+ if (m->numitems <= 0)
+ return;
+ mi = m->items[(unsigned int)m->numitems - 1];
+
+ if (shortcut != 0xFF)
+ mi->shortcut = shortcut;
+ if (helpid != 0xFFFF)
+ mi->helpid = helpid;
+}
+
+// Free internal datasutructures
+void close_menusystem(void)
+{
+}
+
+// append_line_helper(pt_menu menu,char *line)
+void append_line_helper(int menunum, char *line)
+{
+ pt_menu menu;
+ pt_menuitem mi, ri;
+ char *app;
+ int ctr;
+
+ menu = ms->menus[menunum];
+ for (ctr = 0; ctr < (int)menu->numitems; ctr++) {
+ mi = menu->items[ctr];
+ app = NULL; //What to append
+ switch (mi->action) {
+ case OPT_CHECKBOX:
+ if (mi->itemdata.checked)
+ app = mi->data;
+ break;
+ case OPT_RADIOMENU:
+ if (mi->data) { // Some selection has been made
+ ri = (pt_menuitem) (mi->data);
+ app = ri->data;
+ }
+ break;
+ case OPT_SUBMENU:
+ append_line_helper(mi->itemdata.submenunum, line);
+ break;
+ default:
+ break;
+ }
+ if (app) {
+ strcat(line, " ");
+ strcat(line, app);
+ }
+ }
+}
+
+// Generate string based on state of checkboxes and radioitem in given menu
+// Assume line points to large enough buffer
+void gen_append_line(const char *menu_name, char *line)
+{
+ int menunum;
+
+ menunum = find_menu_num(menu_name);
+ if (menunum < 0)
+ return; // No such menu
+ append_line_helper(menunum, line);
+}
diff --git a/com32/cmenu/libmenu/menu.h b/com32/cmenu/libmenu/menu.h
new file mode 100644
index 00000000..141d2ef0
--- /dev/null
+++ b/com32/cmenu/libmenu/menu.h
@@ -0,0 +1,294 @@
+/* -*- c -*- ------------------------------------------------------------- *
+ *
+ * Copyright 2004-2005 Murali Krishnan Ganapathy - 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
+ * the Free Software Foundation, Inc., 53 Temple Place Ste 330,
+ * Boston MA 02111-1307, USA; either version 2 of the License, or
+ * (at your option) any later version; incorporated herein by reference.
+ *
+ * ----------------------------------------------------------------------- */
+
+/* This program can be compiled for DOS with the OpenWatcom compiler
+ * (http://www.openwatcom.org/):
+ *
+ * wcl -3 -osx -mt <filename>.c
+ */
+
+#ifndef __MENU_H__
+#define __MENU_H__
+
+#include "com32io.h"
+#include "tui.h"
+#include "syslnx.h"
+#include <string.h>
+#include <unistd.h>
+
+// TIMEOUT PARAMETERS
+/* If no key is pressed within TIMEOUTNUMSTEPS * TIMEOUTSTEPSIZE milliseconds
+ and if a timeout handler is registered, then that will be called.
+ The handler should either either take control from there on, or return without
+ producing any change in the current video settings.
+
+ For e.g. the handler could
+ * Could just quit the menu program
+ * beep and return.
+
+ TIMEOUTSTEPSIZE is the interval for which the program sleeps without checking for
+ any keystroke. So increasing this will make the response of the system slow.
+ Decreasing this will make a lot of interrupt calls using up your CPU. Default
+ value of TIMEOUTSTEPSIZE of 0.1 seconds should be right in most cases.
+
+ TIMEOUTNUMSTEPS of 3000 corresponds to a wait time of 300 seconds or 5 minutes
+*/
+
+#define TIMEOUTSTEPSIZE 10
+#define TIMEOUTNUMSTEPS 30000L
+
+// Attributes
+#define NORMALATTR 0x17
+#define NORMALHLITE 0x1F // Normal Highlight attribute
+#define REVERSEATTR 0x70
+#define REVERSEHLITE 0x78 // Reverse Hightlight attribute
+#define INACTATTR 0x18
+#define INACTHLITE 0x10 // Inactive Highlight attribute
+#define REVINACTATTR 0x78
+#define REVINACTHLITE 0x70 // Reverse Inactive Highlight attr
+
+#define STATUSATTR 0x74
+#define STATUSHLITE 0x7B // Status highlight
+
+#define FILLCHAR ' '
+#define FILLATTR NORMALATTR
+#define SHADOWATTR 0x00
+#define SPACECHAR ' '
+
+#define TFILLCHAR ' '
+#define TITLEATTR 0x70
+
+#define ENABLEHLITE '<' // Char which turns on highlight
+#define DISABLEHLITE '>' // Char which turns off highlight
+#define NOHLITE 0 // The offset into attrib array for non-hilite
+#define HLITE 1 // The offset for Hlite attrib
+
+#define MOREABOVE '^' // char to print when more menu items available above
+#define MOREBELOW 'v' // more items available below
+
+// Attributes of the menu system
+#define MAXMENUS 250 // Maximum number of menu's allowed
+#define MAXMENUSIZE 100 // Default value for max num of entries in each menu
+#define MAXMENUHEIGHT 20 // Maximum number of entries displayed
+#define MENUBOXTYPE BOX_SINSIN // Default box type Look at tui.h for other values
+
+// Upper bounds on lengths
+// We copy the given string, so user can reuse the space used to store incoming arguments.
+#define MENULEN 78 // Each menu entry is atmost MENULEN chars
+#define STATLEN 78 // Maximum length of status string
+#define TITLELEN 78 // Maximum length of title string
+#define ACTIONLEN 255 // Maximum length of an action string
+
+// Layout of menu
+#define MENUROW 3 // Row where menu is displayed (relative to window)
+#define MENUCOL 4 // Col where menu is displayed (relative to window)
+#define MENUPAGE 1 // show in display page 1
+#define STATLINE 24 // Line number where status line starts (relative to window)
+
+// Used for printing debugging messages
+#define DEBUGLINE 23 // debugging info goes here
+
+// Other Chars
+#define RADIOMENUCHAR '>' // > symbol for radio menu?
+#define CHECKED '\140' // Check mark
+#define UNCHECKED '\146' // Light bullet
+#define RADIOSEL '.' // Current Radio Selection
+#define RADIOUNSEL ' ' // Radio option not selected
+
+typedef unsigned char uchar;
+
+// Types of menu's
+#define NORMALMENU 1
+#define RADIOMENU 2
+
+typedef enum { OPT_INACTIVE, OPT_SUBMENU, OPT_RUN, OPT_EXITMENU, OPT_CHECKBOX,
+ OPT_RADIOMENU, OPT_SEP, OPT_INVISIBLE,
+ OPT_RADIOITEM
+} t_action;
+
+typedef union {
+ uchar submenunum; // For submenu's
+ uchar checked; // For check boxes
+ uchar radiomenunum; // Item mapping to a radio menu
+} t_itemdata;
+
+struct s_menuitem;
+struct s_menu;
+struct s_menusystem;
+
+typedef struct {
+ unsigned int valid:1; // Is action valid?
+ unsigned int refresh:1; // Should we recompute menu stuff?
+ unsigned int reserved:6; // For future expansion
+} t_handler_return;
+
+t_handler_return ACTION_VALID, ACTION_INVALID; // Specific values
+
+typedef t_handler_return(*t_item_handler) (struct s_menusystem *,
+ struct s_menuitem *);
+typedef void (*t_menusystem_handler) (struct s_menusystem *,
+ struct s_menuitem *);
+typedef void (*t_keys_handler) (struct s_menusystem *, struct s_menuitem *,
+ unsigned int scancode);
+ // Last parameter = HIGH BYTE = scan code , LOW BYTE = ASCII CODE
+
+typedef enum { HDLR_SCREEN, HDLR_KEYS } t_handler;
+// Types of handlers for menu system
+
+// TIMEOUT is the list of possible values which can be returned by the handler
+// instructing the menusystem what to do. The default is CODE_WAIT
+typedef enum { CODE_WAIT, CODE_ENTER, CODE_ESCAPE } TIMEOUTCODE;
+typedef TIMEOUTCODE(*t_timeout_handler) (void);
+
+typedef struct s_menuitem {
+ char *item;
+ char *status;
+ char *data; // string containing kernel to run.. but...
+ // for radio menu's this is a pointer to the item selected or NULL (initially)
+ // for submenu's this string could be name of menu
+ void *extra_data; // Any other data user can point to
+ unsigned int helpid; // Used for Context sensitive help
+ t_item_handler handler; // Pointer to function of type menufn
+ t_action action;
+ t_itemdata itemdata; // Data depends on action value
+ uchar shortcut; // one of [A-Za-z0-9] shortcut for this menu item
+ uchar index; // Index within the menu array
+ uchar parindex; // Index of the menu in which this item appears.
+
+} t_menuitem;
+
+typedef t_menuitem *pt_menuitem; // Pointer to type menuitem
+
+typedef struct s_menu {
+ pt_menuitem *items; // pointer to array of pointer to menuitems
+ char *title; // Title string for menu
+ char *name; // menu can be referred to by this string
+ int maxmenusize; // the size of array allocated
+ uchar numitems; // how many items do we actually have
+ uchar menuwidth;
+ uchar row, col; // Position where this menu should be displayed
+ uchar menuheight; // Maximum number of items to be displayed
+} t_menu;
+
+typedef t_menu *pt_menu; // Pointer to type menu
+
+typedef struct s_menusystem {
+ pt_menu menus[MAXMENUS];
+ char *title;
+ t_menusystem_handler handler; // Menu system handler
+ t_keys_handler keys_handler; // Handler for unknown keys
+ t_timeout_handler ontimeout; // Timeout handler
+ unsigned long tm_numsteps;
+ // Time to wait for key press=numsteps * stepsize milliseconds
+ unsigned int tm_stepsize; // Timeout step size (in milliseconds)
+ // Total timeout max time spent idle before we call handler
+ unsigned long tm_total_timeout; // (in milli seconds)
+ unsigned long tm_sofar_timeout; // All accumulated timeout
+ // total timeout handler
+ t_timeout_handler ontotaltimeout; // Total timeout handler
+
+ int maxmenuheight;
+ uchar nummenus;
+ uchar normalattr[2]; // [0] is non-hlite attr, [1] is hlite attr
+ uchar reverseattr[2];
+ uchar inactattr[2];
+ uchar revinactattr[2];
+ uchar statusattr[2];
+ uchar fillchar;
+ uchar fillattr;
+ uchar spacechar;
+ uchar tfillchar;
+ uchar titleattr;
+ uchar shadowattr;
+ uchar statline;
+ uchar menupage;
+ int maxrow, minrow, numrows; // Number of rows in the window
+ int maxcol, mincol, numcols; // Number of columns in the window
+
+ // Menu box look
+ char box_horiz, box_ltrt, box_rtlt; // Some chars of the box, for redrawing portions of the box
+
+} t_menusystem;
+
+typedef t_menusystem *pt_menusystem; // Pointer to type menusystem
+
+pt_menuitem showmenus(uchar startmenu);
+
+pt_menusystem init_menusystem(const char *title);
+
+void close_menusystem(void); // Deallocate memory used
+
+void set_normal_attr(uchar normal, uchar selected, uchar inactivenormal,
+ uchar inactiveselected);
+
+void set_normal_hlite(uchar normal, uchar selected, uchar inactivenormal,
+ uchar inactiveselected);
+
+void set_status_info(uchar statusattr, uchar statushlite, uchar statline);
+
+void set_title_info(uchar tfillchar, uchar titleattr);
+
+void set_misc_info(uchar fillchar, uchar fillattr, uchar spacechar,
+ uchar shadowattr);
+
+void set_window_size(uchar top, uchar left, uchar bot, uchar right); // Set the window which menusystem should use
+
+void set_menu_options(uchar maxmenuheight);
+// maximum height of a menu
+
+void reg_handler(t_handler htype, void *handler); // Register handler
+
+void unreg_handler(t_handler htype);
+
+void reg_ontimeout(t_timeout_handler, unsigned int numsteps,
+ unsigned int stepsize);
+// Set timeout handler, set 0 for default values.
+// So stepsize=0 means numsteps is measured in centiseconds.
+void unreg_ontimeout(void);
+
+void reg_ontotaltimeout(t_timeout_handler, unsigned long numcentiseconds);
+void unreg_ontotaltimeout(void);
+
+// Find the number of the menu given the name
+// Returns -1 if not found
+uchar find_menu_num(const char *name);
+
+// Create a new menu and return its position
+uchar add_menu(const char *title, int maxmenusize);
+
+// Create a named menu and return its position
+uchar add_named_menu(const char *name, const char *title, int maxmenusize);
+
+void set_menu_pos(uchar row, uchar col); // Set the position of this menu.
+
+// Add item to the "current" menu
+pt_menuitem add_item(const char *item, const char *status, t_action action,
+ const char *data, uchar itemdata);
+
+// Set shortcut key and help id
+void set_item_options(uchar shortcut, int helpid);
+
+// Set the shortcut key for the current item
+static inline void set_shortcut(uchar shortcut)
+{
+ set_item_options(shortcut, 0xFFFF);
+}
+
+// Add a separator to the "current" menu
+pt_menuitem add_sep(void);
+
+// Generate string based on state of checkboxes and radioitem in given menu
+// and append string to existing contents of "line"
+// line must have enough space allocated
+void gen_append_line(const char *menu_name, char *line);
+
+#endif
diff --git a/com32/cmenu/libmenu/passwords.c b/com32/cmenu/libmenu/passwords.c
new file mode 100644
index 00000000..44ce461f
--- /dev/null
+++ b/com32/cmenu/libmenu/passwords.c
@@ -0,0 +1,159 @@
+/* -*- c -*- ------------------------------------------------------------- *
+ *
+ * Copyright 2004-2005 Murali Krishnan Ganapathy - 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
+ * the Free Software Foundation, Inc., 53 Temple Place Ste 330,
+ * Bostom MA 02111-1307, USA; either version 2 of the License, or
+ * (at your option) any later version; incorporated herein by reference.
+ *
+ * ----------------------------------------------------------------------- */
+
+#include "passwords.h"
+#include "des.h"
+#include "string.h"
+#include <stdlib.h>
+#include <stdio.h>
+#include "tui.h"
+
+#define MAX_LINE 512
+// Max line length in a pwdfile
+p_pwdentry userdb[MAX_USERS]; // Array of pointers
+int numusers; // Actual number of users
+
+// returns true or false, i.e. 1 or 0
+char authenticate_user(const char *username, const char *pwd)
+{
+ char salt[12];
+ int i;
+
+ for (i = 0; i < numusers; i++) {
+ if (userdb[i] == NULL)
+ continue;
+ if (strcmp(username, userdb[i]->username) == 0) {
+ strcpy(salt, userdb[i]->pwdhash);
+ salt[2] = '\0';
+ if (strcmp(userdb[i]->pwdhash, crypt(pwd, salt)) == 0)
+ return 1;
+ }
+ }
+ return 0;
+}
+
+// Does user USERNAME have permission PERM
+char isallowed(const char *username, const char *perm)
+{
+ int i;
+ char *dperm;
+ char *tmp;
+
+ // If no users, then everybody is allowed to do everything
+ if (numusers == 0)
+ return 1;
+ if (strcmp(username, GUEST_USER) == 0)
+ return 0;
+ dperm = (char *)malloc(strlen(perm) + 3);
+ strcpy(dperm + 1, perm);
+ dperm[0] = ':';
+ dperm[strlen(perm) + 1] = ':';
+ dperm[strlen(perm) + 2] = 0;
+ // Now dperm = ":perm:"
+ for (i = 0; i < numusers; i++) {
+ if (strcmp(userdb[i]->username, username) == 0) // Found the user
+ {
+ if (userdb[i]->perms == NULL)
+ return 0; // No permission
+ tmp = strstr(userdb[i]->perms, dperm); // Search for permission
+ free(dperm); // Release memory
+ if (tmp == NULL)
+ return 0;
+ else
+ return 1;
+ }
+ }
+ // User not found return 0
+ free(dperm);
+ return 0;
+}
+
+// Initialise the list of of user passwords permissions from file
+void init_passwords(const char *filename)
+{
+ int i;
+ char line[MAX_LINE], *p, *user, *pwdhash, *perms;
+ FILE *f;
+
+ for (i = 0; i < MAX_USERS; i++)
+ userdb[i] = NULL;
+ numusers = 0;
+
+ if (!filename)
+ return; // No filename specified
+
+ f = fopen(filename, "r");
+ if (!f)
+ return; // File does not exist
+
+ // Process each line
+ while (fgets(line, sizeof line, f)) {
+ // Replace EOLN with \0
+ p = strchr(line, '\r');
+ if (p)
+ *p = '\0';
+ p = strchr(line, '\n');
+ if (p)
+ *p = '\0';
+
+ // If comment line or empty ignore line
+ p = line;
+ while (*p == ' ')
+ p++; // skip initial spaces
+ if ((*p == '#') || (*p == '\0'))
+ continue; // Skip comment lines
+
+ user = p; // This is where username starts
+ p = strchr(user, ':');
+ if (p == NULL)
+ continue; // Malformed line skip
+ *p = '\0';
+ pwdhash = p + 1;
+ if (*pwdhash == 0)
+ continue; // Malformed line (no password specified)
+ p = strchr(pwdhash, ':');
+ if (p == NULL) { // No perms specified
+ perms = NULL;
+ } else {
+ *p = '\0';
+ perms = p + 1;
+ if (*perms == 0)
+ perms = NULL;
+ }
+ // At this point we have user,pwdhash and perms setup
+ userdb[numusers] = (p_pwdentry) malloc(sizeof(pwdentry));
+ strcpy(userdb[numusers]->username, user);
+ strcpy(userdb[numusers]->pwdhash, pwdhash);
+ if (perms == NULL)
+ userdb[numusers]->perms = NULL;
+ else {
+ userdb[numusers]->perms = (char *)malloc(strlen(perms) + 3);
+ (userdb[numusers]->perms)[0] = ':';
+ strcpy(userdb[numusers]->perms + 1, perms);
+ (userdb[numusers]->perms)[strlen(perms) + 1] = ':';
+ (userdb[numusers]->perms)[strlen(perms) + 2] = 0;
+ // Now perms field points to ":perms:"
+ }
+ numusers++;
+ }
+ fclose(f);
+}
+
+void close_passwords(void)
+{
+ int i;
+
+ for (i = 0; i < numusers; i++)
+ if (userdb[i] != NULL)
+ free(userdb[i]);
+ numusers = 0;
+}
diff --git a/com32/cmenu/libmenu/passwords.h b/com32/cmenu/libmenu/passwords.h
new file mode 100644
index 00000000..2e0ec27c
--- /dev/null
+++ b/com32/cmenu/libmenu/passwords.h
@@ -0,0 +1,27 @@
+#ifndef _PASSWORDS_H_
+#define _PASSWORDS_H_
+
+char authenticate_user(const char *username, const char *pwd);
+
+char isallowed(const char *username, const char *perm);
+
+// Initialise the list of of user passwords permissions from file
+void init_passwords(const char *filename);
+// Free all space used for internal data structures
+void close_passwords(void);
+
+#define MAX_USERS 128 // Maximum number of users
+#define USERNAME_LENGTH 12 // Max length of user name
+#define PWDHA