aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--MCONFIG5
-rw-r--r--MCONFIG.embedded2
-rw-r--r--NEWS2
-rw-r--r--README2
-rwxr-xr-xcodepage/cptable.pl40
-rw-r--r--com32/MCONFIG6
-rw-r--r--com32/cmenu/adv_menu.tpl4
-rw-r--r--com32/cmenu/complex.c4
-rw-r--r--com32/cmenu/libmenu/menu.c10
-rw-r--r--com32/cmenu/libmenu/menu.h8
-rw-r--r--com32/cmenu/libmenu/passwords.c2
-rw-r--r--com32/gfxboot/gfxboot.c8
-rw-r--r--com32/gplinclude/disk/bootloaders.h2
-rw-r--r--com32/gpllib/disk/ata.c2
-rw-r--r--com32/gpllib/disk/bootloaders.c2
-rw-r--r--com32/gpllib/dmi/dmi_processor.c52
-rw-r--r--com32/hdt/hdt-cli.c6
-rw-r--r--com32/hdt/hdt-cli.h2
-rw-r--r--com32/hdt/hdt-common.c2
-rw-r--r--com32/hdt/hdt-common.h2
-rw-r--r--com32/hdt/hdt-menu.c2
-rw-r--r--com32/hdt/hdt-menu.h2
-rw-r--r--com32/lib/MCONFIG5
-rw-r--r--com32/lib/chdir.c4
-rw-r--r--com32/lib/closedir.c1
-rw-r--r--com32/lib/fdopendir.c2
-rw-r--r--com32/lib/libgcc/__moddi3.c2
-rw-r--r--com32/lib/opendir.c1
-rw-r--r--com32/lib/readdir.c3
-rw-r--r--com32/lib/strcasecmp.c3
-rw-r--r--com32/lib/strcmp.c3
-rw-r--r--com32/lib/strncasecmp.c3
-rw-r--r--com32/lib/strncmp.c3
-rw-r--r--com32/lib/sys/argv.c2
-rw-r--r--com32/lib/sys/colortable.c2
-rw-r--r--com32/lib/sys/libansi.c34
-rw-r--r--com32/lib/sys/openmem.c3
-rw-r--r--com32/lib/sys/vesaserial_write.c2
-rw-r--r--com32/lib/syslinux/getadv.c2
-rw-r--r--com32/lib/syslinux/load_linux.c3
-rw-r--r--com32/lib/zlib/crc32.c2
-rw-r--r--com32/menu/menu.h1
-rw-r--r--com32/menu/menumain.c25
-rw-r--r--com32/menu/readconfig.c5
-rw-r--r--com32/modules/chain.c22
-rw-r--r--com32/rosh/MCONFIG4
-rw-r--r--com32/rosh/rosh.c8
-rw-r--r--core/Makefile5
-rw-r--r--core/bootsect.inc6
-rw-r--r--core/codepage.S5
-rw-r--r--core/dir.c6
-rw-r--r--core/fs.c64
-rw-r--r--core/fs/ext2/bmap.c10
-rw-r--r--core/fs/ext2/ext2.c127
-rw-r--r--core/fs/ext2/ext2_fs.h8
-rw-r--r--core/fs/fat/fat.c436
-rw-r--r--core/fs/fat/fat_fs.h29
-rw-r--r--core/fs/iso9660/iso9660.c77
-rw-r--r--core/fs/pxe/pxe.c489
-rw-r--r--core/include/codepage.h27
-rw-r--r--core/include/core.h3
-rw-r--r--core/include/disk.h3
-rw-r--r--core/include/fs.h29
-rw-r--r--core/kernel.inc2
-rw-r--r--core/malloc.c10
-rw-r--r--core/pxe.inc1
-rw-r--r--core/pxelinux.asm139
-rw-r--r--core/runkernel.inc24
-rw-r--r--doc/memdisk.txt15
-rw-r--r--doc/menu.txt8
-rw-r--r--extlinux/Makefile2
-rw-r--r--gpxe/gpxe.diff73
-rw-r--r--gpxe/pxelinux.gpxe1
-rw-r--r--gpxe/src/Makefile24
-rw-r--r--gpxe/src/Makefile.housekeeping220
-rw-r--r--gpxe/src/README.pixify90
-rw-r--r--gpxe/src/arch/i386/Makefile33
-rw-r--r--gpxe/src/arch/i386/Makefile.pcbios29
-rw-r--r--gpxe/src/arch/i386/core/basemem_packet.c2
-rw-r--r--gpxe/src/arch/i386/core/etherboot.prefix.lds100
-rw-r--r--gpxe/src/arch/i386/core/pic8259.c2
-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.c2
-rw-r--r--gpxe/src/arch/i386/core/realmode.c23
-rw-r--r--gpxe/src/arch/i386/core/relocate.c2
-rw-r--r--gpxe/src/arch/i386/core/setjmp.S2
-rw-r--r--gpxe/src/arch/i386/core/stack.S2
-rw-r--r--gpxe/src/arch/i386/core/stack16.S2
-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/timer2.c2
-rw-r--r--gpxe/src/arch/i386/core/virtaddr.S2
-rw-r--r--gpxe/src/arch/i386/core/x86_io.c2
-rw-r--r--gpxe/src/arch/i386/drivers/net/undi.c4
-rw-r--r--gpxe/src/arch/i386/drivers/net/undiisr.S6
-rw-r--r--gpxe/src/arch/i386/drivers/net/undiload.c7
-rw-r--r--gpxe/src/arch/i386/drivers/net/undinet.c273
-rw-r--r--gpxe/src/arch/i386/drivers/net/undionly.c2
-rw-r--r--gpxe/src/arch/i386/drivers/net/undipreload.c2
-rw-r--r--gpxe/src/arch/i386/drivers/net/undirom.c2
-rw-r--r--gpxe/src/arch/i386/firmware/pcbios/basemem.c2
-rw-r--r--gpxe/src/arch/i386/firmware/pcbios/bios_console.c2
-rw-r--r--gpxe/src/arch/i386/firmware/pcbios/e820mangler.S5
-rw-r--r--gpxe/src/arch/i386/firmware/pcbios/fakee820.c2
-rw-r--r--gpxe/src/arch/i386/firmware/pcbios/gateA20.c2
-rw-r--r--gpxe/src/arch/i386/firmware/pcbios/hidemem.c2
-rw-r--r--gpxe/src/arch/i386/firmware/pcbios/memmap.c2
-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.c2
-rw-r--r--gpxe/src/arch/i386/image/comboot.c2
-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.c44
-rw-r--r--gpxe/src/arch/i386/image/pxe_image.c18
-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.h2
-rw-r--r--gpxe/src/arch/i386/include/biosint.h2
-rw-r--r--gpxe/src/arch/i386/include/bits/byteswap.h2
-rw-r--r--gpxe/src/arch/i386/include/bits/compiler.h2
-rw-r--r--gpxe/src/arch/i386/include/bits/endian.h2
-rw-r--r--gpxe/src/arch/i386/include/bits/errfile.h3
-rw-r--r--gpxe/src/arch/i386/include/bits/io.h2
-rw-r--r--gpxe/src/arch/i386/include/bits/nap.h2
-rw-r--r--gpxe/src/arch/i386/include/bits/smbios.h2
-rw-r--r--gpxe/src/arch/i386/include/bits/stdint.h6
-rw-r--r--gpxe/src/arch/i386/include/bits/timer.h2
-rw-r--r--gpxe/src/arch/i386/include/bits/uaccess.h2
-rw-r--r--gpxe/src/arch/i386/include/bits/umalloc.h2
-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.h2
-rw-r--r--gpxe/src/arch/i386/include/fakee820.h2
-rw-r--r--gpxe/src/arch/i386/include/gpxe/abft.h2
-rw-r--r--gpxe/src/arch/i386/include/gpxe/bios_nap.h2
-rw-r--r--gpxe/src/arch/i386/include/gpxe/bios_smbios.h2
-rw-r--r--gpxe/src/arch/i386/include/gpxe/bios_timer.h2
-rw-r--r--gpxe/src/arch/i386/include/gpxe/ibft.h2
-rw-r--r--gpxe/src/arch/i386/include/gpxe/memtop_umalloc.h2
-rw-r--r--gpxe/src/arch/i386/include/gpxe/rdtsc_timer.h2
-rw-r--r--gpxe/src/arch/i386/include/gpxe/sbft.h125
-rw-r--r--gpxe/src/arch/i386/include/gpxe/timer2.h2
-rw-r--r--gpxe/src/arch/i386/include/gpxe/x86_io.h2
-rw-r--r--gpxe/src/arch/i386/include/int13.h2
-rw-r--r--[-rwxr-xr-x]gpxe/src/arch/i386/include/librm.h2
-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/pic8259.h2
-rw-r--r--gpxe/src/arch/i386/include/pnpbios.h2
-rw-r--r--gpxe/src/arch/i386/include/pxe.h3
-rw-r--r--gpxe/src/arch/i386/include/pxe_api.h68
-rw-r--r--gpxe/src/arch/i386/include/pxe_call.h28
-rw-r--r--gpxe/src/arch/i386/include/pxe_types.h2
-rw-r--r--gpxe/src/arch/i386/include/pxeparent.h11
-rw-r--r--gpxe/src/arch/i386/include/realmode.h2
-rw-r--r--gpxe/src/arch/i386/include/registers.h2
-rw-r--r--gpxe/src/arch/i386/include/setjmp.h2
-rw-r--r--gpxe/src/arch/i386/include/undi.h2
-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/interface/pcbios/abft.c2
-rw-r--r--gpxe/src/arch/i386/interface/pcbios/aoeboot.c62
-rw-r--r--gpxe/src/arch/i386/interface/pcbios/bios_nap.c2
-rw-r--r--gpxe/src/arch/i386/interface/pcbios/bios_smbios.c2
-rw-r--r--gpxe/src/arch/i386/interface/pcbios/bios_timer.c2
-rw-r--r--gpxe/src/arch/i386/interface/pcbios/biosint.c2
-rw-r--r--gpxe/src/arch/i386/interface/pcbios/ib_srpboot.c73
-rw-r--r--gpxe/src/arch/i386/interface/pcbios/ibft.c17
-rw-r--r--gpxe/src/arch/i386/interface/pcbios/int13.c79
-rw-r--r--gpxe/src/arch/i386/interface/pcbios/iscsiboot.c20
-rw-r--r--gpxe/src/arch/i386/interface/pcbios/keepsan.c26
-rw-r--r--gpxe/src/arch/i386/interface/pcbios/memtop_umalloc.c2
-rw-r--r--gpxe/src/arch/i386/interface/pcbios/pcibios.c2
-rw-r--r--gpxe/src/arch/i386/interface/pcbios/sbft.c105
-rw-r--r--gpxe/src/arch/i386/interface/pxe/pxe_call.c93
-rw-r--r--gpxe/src/arch/i386/interface/pxe/pxe_entry.S2
-rw-r--r--gpxe/src/arch/i386/interface/pxe/pxe_file.c42
-rw-r--r--gpxe/src/arch/i386/interface/pxe/pxe_loader.c5
-rw-r--r--gpxe/src/arch/i386/interface/pxe/pxe_preboot.c25
-rw-r--r--gpxe/src/arch/i386/interface/pxe/pxe_tftp.c17
-rw-r--r--gpxe/src/arch/i386/interface/pxe/pxe_udp.c2
-rw-r--r--gpxe/src/arch/i386/interface/pxe/pxe_undi.c215
-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.c2
-rw-r--r--gpxe/src/arch/i386/interface/syslinux/com32_wrapper.S2
-rw-r--r--gpxe/src/arch/i386/interface/syslinux/comboot_call.c31
-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.S6
-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.S6
-rw-r--r--gpxe/src/arch/i386/prefix/hromprefix.S12
-rw-r--r--gpxe/src/arch/i386/prefix/kkpxeprefix.S5
-rw-r--r--gpxe/src/arch/i386/prefix/kpxeprefix.S2
-rw-r--r--gpxe/src/arch/i386/prefix/libprefix.S2
-rw-r--r--gpxe/src/arch/i386/prefix/lkrnprefix.S6
-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.S8
-rw-r--r--gpxe/src/arch/i386/prefix/pxeprefix.S100
-rw-r--r--gpxe/src/arch/i386/prefix/romprefix.S480
-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.lds11
-rw-r--r--gpxe/src/arch/i386/transitions/libkir.S2
-rw-r--r--[-rwxr-xr-x]gpxe/src/arch/i386/transitions/librm.S2
-rw-r--r--[-rwxr-xr-x]gpxe/src/arch/i386/transitions/librm_mgmt.c2
-rw-r--r--gpxe/src/arch/x86/Makefile2
-rw-r--r--gpxe/src/arch/x86/core/pcidirect.c2
-rw-r--r--gpxe/src/arch/x86/core/x86_string.c2
-rw-r--r--gpxe/src/arch/x86/include/bits/pci_io.h2
-rw-r--r--gpxe/src/arch/x86/include/bits/string.h2
-rw-r--r--gpxe/src/arch/x86/include/gpxe/efi/efix86_nap.h2
-rw-r--r--gpxe/src/arch/x86/include/gpxe/pcibios.h2
-rw-r--r--gpxe/src/arch/x86/include/gpxe/pcidirect.h2
-rw-r--r--gpxe/src/arch/x86/interface/efi/efix86_nap.c2
-rw-r--r--gpxe/src/arch/x86/prefix/efidrvprefix.c2
-rw-r--r--gpxe/src/arch/x86/prefix/efiprefix.c2
-rw-r--r--gpxe/src/arch/x86/scripts/efi.lds1
-rw-r--r--gpxe/src/arch/x86_64/include/bits/stdint.h2
-rw-r--r--gpxe/src/config/config.c (renamed from gpxe/src/core/config.c)50
-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.h2
-rw-r--r--gpxe/src/config/defaults.h2
-rw-r--r--gpxe/src/config/defaults/pcbios.h6
-rw-r--r--gpxe/src/config/general.h33
-rw-r--r--gpxe/src/config/ioapi.h2
-rw-r--r--gpxe/src/config/nap.h2
-rw-r--r--gpxe/src/config/serial.h9
-rw-r--r--gpxe/src/config/timer.h2
-rw-r--r--gpxe/src/config/umalloc.h2
-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.c2
-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.c11
-rw-r--r--gpxe/src/core/cpio.c2
-rw-r--r--gpxe/src/core/ctype.c48
-rw-r--r--gpxe/src/core/cwuri.c2
-rw-r--r--gpxe/src/core/debug.c3
-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/getkey.c2
-rw-r--r--gpxe/src/core/getopt.c2
-rw-r--r--gpxe/src/core/image.c10
-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.c9
-rw-r--r--gpxe/src/core/malloc.c6
-rw-r--r--gpxe/src/core/misc.c17
-rw-r--r--gpxe/src/core/monojob.c2
-rw-r--r--gpxe/src/core/nvo.c2
-rw-r--r--gpxe/src/core/open.c41
-rw-r--r--gpxe/src/core/posix_io.c4
-rw-r--r--gpxe/src/core/process.c24
-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.c2
-rw-r--r--gpxe/src/core/settings.c500
-rw-r--r--gpxe/src/core/string.c2
-rw-r--r--gpxe/src/core/timer.c2
-rw-r--r--gpxe/src/core/uri.c165
-rw-r--r--gpxe/src/core/uuid.c2
-rw-r--r--gpxe/src/core/vsprintf.c2
-rw-r--r--gpxe/src/core/xfer.c5
-rw-r--r--gpxe/src/crypto/aes_wrap.c123
-rw-r--r--gpxe/src/crypto/arc4.c131
-rw-r--r--gpxe/src/crypto/asn1.c2
-rw-r--r--gpxe/src/crypto/axtls_aes.c15
-rw-r--r--gpxe/src/crypto/cbc.c2
-rw-r--r--gpxe/src/crypto/chap.c2
-rw-r--r--gpxe/src/crypto/crandom.c55
-rw-r--r--gpxe/src/crypto/crc32.c54
-rw-r--r--gpxe/src/crypto/crypto_null.c2
-rw-r--r--gpxe/src/crypto/hmac.c2
-rw-r--r--gpxe/src/crypto/md5.c14
-rw-r--r--gpxe/src/crypto/sha1extra.c165
-rw-r--r--gpxe/src/crypto/x509.c2
-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.c2
-rw-r--r--gpxe/src/drivers/bitbash/spi_bit.c53
-rw-r--r--gpxe/src/drivers/block/ata.c27
-rw-r--r--gpxe/src/drivers/block/ramdisk.c2
-rw-r--r--gpxe/src/drivers/block/scsi.c93
-rw-r--r--gpxe/src/drivers/block/srp.c523
-rw-r--r--gpxe/src/drivers/bus/eisa.c7
-rw-r--r--gpxe/src/drivers/bus/isa.c9
-rw-r--r--gpxe/src/drivers/bus/isapnp.c9
-rw-r--r--gpxe/src/drivers/bus/mca.c9
-rw-r--r--gpxe/src/drivers/bus/pci.c9
-rw-r--r--gpxe/src/drivers/bus/pcibackup.c90
-rw-r--r--gpxe/src/drivers/bus/pciextra.c7
-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.c18
-rw-r--r--gpxe/src/drivers/infiniband/arbel.h2
-rw-r--r--gpxe/src/drivers/infiniband/hermon.c702
-rw-r--r--gpxe/src/drivers/infiniband/hermon.h91
-rw-r--r--gpxe/src/drivers/infiniband/ib_sma.c553
-rw-r--r--gpxe/src/drivers/infiniband/linda.c99
-rw-r--r--gpxe/src/drivers/infiniband/linda.h5
-rw-r--r--gpxe/src/drivers/infiniband/linda_fw.c2
-rw-r--r--gpxe/src/drivers/infiniband/mlx_bitops.h14
-rw-r--r--gpxe/src/drivers/infiniband/qib_7220_regs.h11
-rwxr-xr-x[-rw-r--r--]gpxe/src/drivers/infiniband/qib_genbits.pl29
-rw-r--r--gpxe/src/drivers/net/3c509.c2
-rw-r--r--gpxe/src/drivers/net/3c509.h2
-rw-r--r--gpxe/src/drivers/net/3c515.c1
-rw-r--r--gpxe/src/drivers/net/3c529.c2
-rw-r--r--gpxe/src/drivers/net/3c595.c30
-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.c20
-rw-r--r--gpxe/src/drivers/net/b44.h3
-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.c2
-rw-r--r--gpxe/src/drivers/net/cs89x0.h2
-rw-r--r--gpxe/src/drivers/net/davicom.c10
-rw-r--r--gpxe/src/drivers/net/depca.c2
-rw-r--r--gpxe/src/drivers/net/dmfe.c10
-rw-r--r--gpxe/src/drivers/net/e1000/e1000.c392
-rw-r--r--gpxe/src/drivers/net/e1000/e1000.h2
-rw-r--r--gpxe/src/drivers/net/e1000/e1000_hw.c156
-rw-r--r--gpxe/src/drivers/net/e1000/e1000_hw.h20
-rw-r--r--gpxe/src/drivers/net/e1000/e1000_osdep.h1
-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.c6
-rw-r--r--gpxe/src/drivers/net/epic100.h2
-rw-r--r--gpxe/src/drivers/net/etherfabric.c92
-rw-r--r--gpxe/src/drivers/net/etherfabric.h2
-rw-r--r--gpxe/src/drivers/net/etherfabric_nic.h3
-rw-r--r--gpxe/src/drivers/net/forcedeth.c102
-rw-r--r--gpxe/src/drivers/net/hfa384x.h2
-rw-r--r--gpxe/src/drivers/net/ipoib.c878
-rw-r--r--gpxe/src/drivers/net/legacy.c6
-rw-r--r--gpxe/src/drivers/net/mtd80x.c74
-rw-r--r--gpxe/src/drivers/net/mtnic.c13
-rw-r--r--gpxe/src/drivers/net/mtnic.h3
-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.c8
-rw-r--r--gpxe/src/drivers/net/natsemi.h2
-rw-r--r--gpxe/src/drivers/net/ne2k_isa.c2
-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.c22
-rw-r--r--gpxe/src/drivers/net/phantom/phantom.h2
-rw-r--r--gpxe/src/drivers/net/phantom/phantom_hw.h2
-rw-r--r--gpxe/src/drivers/net/pnic.c6
-rw-r--r--gpxe/src/drivers/net/pnic_api.h2
-rw-r--r--gpxe/src/drivers/net/prism2.c2
-rw-r--r--gpxe/src/drivers/net/prism2_pci.c8
-rw-r--r--gpxe/src/drivers/net/prism2_plx.c24
-rw-r--r--gpxe/src/drivers/net/r8169.c27
-rw-r--r--gpxe/src/drivers/net/r8169.h83
-rw-r--r--gpxe/src/drivers/net/rtl8139.c63
-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.c12
-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.c15
-rw-r--r--gpxe/src/drivers/net/tg3.c67
-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.c74
-rw-r--r--gpxe/src/drivers/net/via-rhine.c10
-rw-r--r--gpxe/src/drivers/net/via-velocity.c2
-rw-r--r--gpxe/src/drivers/net/virtio-net.c2
-rw-r--r--gpxe/src/drivers/net/w89c840.c6
-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.c2
-rw-r--r--gpxe/src/hci/commands/dhcp_cmd.c2
-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.c25
-rw-r--r--gpxe/src/hci/commands/iwmgmt_cmd.c69
-rw-r--r--gpxe/src/hci/commands/login_cmd.c2
-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.c2
-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.c2
-rw-r--r--gpxe/src/hci/mucurses/winattrs.c2
-rw-r--r--gpxe/src/hci/mucurses/wininit.c2
-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.c2
-rw-r--r--gpxe/src/hci/tui/settings_ui.c12
-rw-r--r--gpxe/src/hci/wireless_errors.c118
-rw-r--r--gpxe/src/image/efi_image.c2
-rw-r--r--gpxe/src/image/elf.c57
-rw-r--r--gpxe/src/image/embedded.c2
-rw-r--r--gpxe/src/image/script.c10
-rw-r--r--gpxe/src/image/segment.c13
-rw-r--r--gpxe/src/include/assert.h2
-rw-r--r--gpxe/src/include/byteswap.h2
-rw-r--r--gpxe/src/include/compiler.h345
-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.h2
-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.h22
-rw-r--r--gpxe/src/include/gpxe/ansiesc.h2
-rw-r--r--gpxe/src/include/gpxe/aoe.h2
-rw-r--r--gpxe/src/include/gpxe/api.h2
-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.h2
-rw-r--r--gpxe/src/include/gpxe/ata.h4
-rw-r--r--gpxe/src/include/gpxe/base64.h2
-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.h2
-rw-r--r--gpxe/src/include/gpxe/blockdev.h2
-rw-r--r--gpxe/src/include/gpxe/cbc.h2
-rw-r--r--gpxe/src/include/gpxe/chap.h2
-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.h8
-rw-r--r--gpxe/src/include/gpxe/device.h7
-rw-r--r--gpxe/src/include/gpxe/dhcp.h23
-rw-r--r--gpxe/src/include/gpxe/dhcpopts.h2
-rw-r--r--gpxe/src/include/gpxe/dhcppkt.h2
-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.h2
-rw-r--r--gpxe/src/include/gpxe/editstring.h2
-rw-r--r--gpxe/src/include/gpxe/efi/efi.h21
-rw-r--r--gpxe/src/include/gpxe/efi/efi_io.h2
-rw-r--r--gpxe/src/include/gpxe/efi/efi_pci.h2
-rw-r--r--gpxe/src/include/gpxe/efi/efi_smbios.h2
-rw-r--r--gpxe/src/include/gpxe/efi/efi_timer.h2
-rw-r--r--gpxe/src/include/gpxe/efi/efi_uaccess.h2
-rw-r--r--gpxe/src/include/gpxe/efi/efi_umalloc.h2
-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/errfile.h29
-rw-r--r--gpxe/src/include/gpxe/errortab.h6
-rw-r--r--gpxe/src/include/gpxe/ethernet.h28
-rw-r--r--gpxe/src/include/gpxe/fakedhcp.h2
-rw-r--r--gpxe/src/include/gpxe/features.h14
-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.h2
-rw-r--r--gpxe/src/include/gpxe/http.h2
-rw-r--r--gpxe/src/include/gpxe/i2c.h2
-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.h205
-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.h14
-rw-r--r--gpxe/src/include/gpxe/ib_pathrec.h76
-rw-r--r--gpxe/src/include/gpxe/ib_sma.h59
-rw-r--r--gpxe/src/include/gpxe/ib_smc.h2
-rw-r--r--gpxe/src/include/gpxe/ib_srp.h79
-rw-r--r--gpxe/src/include/gpxe/icmp.h2
-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.h8
-rw-r--r--gpxe/src/include/gpxe/in.h3
-rw-r--r--gpxe/src/include/gpxe/infiniband.h218
-rw-r--r--gpxe/src/include/gpxe/init.h13
-rw-r--r--gpxe/src/include/gpxe/interface.h2
-rw-r--r--gpxe/src/include/gpxe/io.h2
-rw-r--r--gpxe/src/include/gpxe/iobuf.h2
-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.h31
-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.h17
-rw-r--r--gpxe/src/include/gpxe/job.h4
-rw-r--r--gpxe/src/include/gpxe/keys.h2
-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.h2
-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.h2
-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.h2
-rw-r--r--gpxe/src/include/gpxe/net80211.h1186
-rw-r--r--gpxe/src/include/gpxe/netdevice.h135
-rw-r--r--gpxe/src/include/gpxe/null_nap.h2
-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.h14
-rw-r--r--gpxe/src/include/gpxe/pci.h52
-rw-r--r--gpxe/src/include/gpxe/pci_ids.h3
-rw-r--r--gpxe/src/include/gpxe/pci_io.h2
-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.h8
-rw-r--r--gpxe/src/include/gpxe/retry.h2
-rw-r--r--gpxe/src/include/gpxe/rotate.h2
-rw-r--r--gpxe/src/include/gpxe/rsa.h2
-rw-r--r--gpxe/src/include/gpxe/sanboot.h10
-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.h64
-rw-r--r--gpxe/src/include/gpxe/settings_ui.h2
-rw-r--r--gpxe/src/include/gpxe/sha1.h11
-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.h21
-rw-r--r--gpxe/src/include/gpxe/socket.h2
-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.h15
-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.h2
-rw-r--r--gpxe/src/include/gpxe/tls.h2
-rw-r--r--gpxe/src/include/gpxe/uaccess.h2
-rw-r--r--gpxe/src/include/gpxe/udp.h2
-rw-r--r--gpxe/src/include/gpxe/umalloc.h2
-rw-r--r--gpxe/src/include/gpxe/uri.h46
-rw-r--r--gpxe/src/include/gpxe/uuid.h2
-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.h2
-rw-r--r--gpxe/src/include/gpxe/xfer.h2
-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.h4
-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.h2
-rw-r--r--gpxe/src/include/stdint.h12
-rw-r--r--gpxe/src/include/stdio.h2
-rw-r--r--gpxe/src/include/stdlib.h2
-rw-r--r--gpxe/src/include/string.h2
-rw-r--r--gpxe/src/include/strings.h2
-rw-r--r--gpxe/src/include/unistd.h2
-rw-r--r--gpxe/src/include/usr/autoboot.h6
-rw-r--r--gpxe/src/include/usr/dhcpmgmt.h2
-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/iwmgmt.h17
-rw-r--r--gpxe/src/include/usr/route.h2
-rw-r--r--gpxe/src/interface/efi/efi_console.c2
-rw-r--r--gpxe/src/interface/efi/efi_init.c18
-rw-r--r--gpxe/src/interface/efi/efi_io.c2
-rw-r--r--gpxe/src/interface/efi/efi_pci.c2
-rw-r--r--gpxe/src/interface/efi/efi_smbios.c2
-rw-r--r--gpxe/src/interface/efi/efi_snp.c21
-rw-r--r--gpxe/src/interface/efi/efi_strerror.c2
-rw-r--r--gpxe/src/interface/efi/efi_timer.c2
-rw-r--r--gpxe/src/interface/efi/efi_uaccess.c2
-rw-r--r--gpxe/src/interface/efi/efi_umalloc.c2
-rw-r--r--gpxe/src/interface/smbios/smbios.c2
-rw-r--r--gpxe/src/interface/smbios/smbios_settings.c27
-rw-r--r--gpxe/src/libgcc/icc.c8
-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.c15
-rw-r--r--gpxe/src/net/arp.c13
-rw-r--r--gpxe/src/net/cachedhcp.c76
-rw-r--r--gpxe/src/net/dhcpopts.c21
-rw-r--r--gpxe/src/net/dhcppkt.c14
-rw-r--r--gpxe/src/net/eapol.c85
-rw-r--r--gpxe/src/net/ethernet.c56
-rw-r--r--gpxe/src/net/fakedhcp.c2
-rw-r--r--gpxe/src/net/icmp.c2
-rw-r--r--gpxe/src/net/infiniband.c405
-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.c (renamed from gpxe/src/drivers/infiniband/ib_packet.c)36
-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.c (renamed from gpxe/src/drivers/infiniband/ib_smc.c)31
-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.c41
-rw-r--r--gpxe/src/net/mii.c147
-rw-r--r--gpxe/src/net/netdev_settings.c38
-rw-r--r--gpxe/src/net/netdevice.c66
-rw-r--r--gpxe/src/net/nullnet.c2
-rw-r--r--gpxe/src/net/rarp.c2
-rw-r--r--gpxe/src/net/retry.c3
-rw-r--r--gpxe/src/net/tcp.c141
-rw-r--r--gpxe/src/net/tcp/ftp.c30
-rw-r--r--gpxe/src/net/tcp/http.c64
-rw-r--r--gpxe/src/net/tcp/https.c2
-rw-r--r--gpxe/src/net/tcp/iscsi.c79
-rw-r--r--gpxe/src/net/tcpip.c17
-rw-r--r--gpxe/src/net/tls.c4
-rw-r--r--gpxe/src/net/udp.c4
-rw-r--r--gpxe/src/net/udp/dhcp.c419
-rw-r--r--gpxe/src/net/udp/dns.c4
-rw-r--r--gpxe/src/net/udp/slam.c6
-rw-r--r--gpxe/src/net/udp/tftp.c139
-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/uri_test.c7
-rw-r--r--gpxe/src/usr/autoboot.c64
-rw-r--r--gpxe/src/usr/dhcpmgmt.c23
-rw-r--r--gpxe/src/usr/ifmgmt.c42
-rw-r--r--gpxe/src/usr/imgmgmt.c4
-rw-r--r--gpxe/src/usr/iwmgmt.c244
-rw-r--r--gpxe/src/usr/pxemenu.c4
-rw-r--r--gpxe/src/usr/route.c4
-rw-r--r--gpxe/src/util/.gitignore1
-rwxr-xr-xgpxe/src/util/diffsize.pl101
-rwxr-xr-xgpxe/src/util/dskpad.pl12
-rw-r--r--gpxe/src/util/elf2efi.c7
-rwxr-xr-xgpxe/src/util/geniso5
-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-xgpxe/src/util/modrom.pl4
-rwxr-xr-xgpxe/src/util/padimg.pl44
-rw-r--r--gpxe/src/util/parserom.pl3
-rw-r--r--gpxe/src/util/zbin.c144
-rw-r--r--libinstaller/syslxint.h1
-rw-r--r--libinstaller/syslxmod.c35
-rw-r--r--linux/Makefile2
-rw-r--r--memdisk/Makefile2
-rw-r--r--memdisk/inflate.c2
-rw-r--r--mtools/Makefile2
-rw-r--r--utils/Makefile2
-rw-r--r--utils/mkdiskimage.in16
-rw-r--r--win32/Makefile4
764 files changed, 65262 insertions, 10521 deletions
diff --git a/MCONFIG b/MCONFIG
index b84e6c56..72f7f525 100644
--- a/MCONFIG
+++ b/MCONFIG
@@ -62,6 +62,11 @@ 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
diff --git a/MCONFIG.embedded b/MCONFIG.embedded
index bb718963..e8879fc5 100644
--- a/MCONFIG.embedded
+++ b/MCONFIG.embedded
@@ -35,7 +35,7 @@ GCCOPT += $(call gcc_ok,-mpreferred-stack-boundary=2,)
LIBGCC := $(shell $(CC) $(GCCOPT) --print-libgcc)
LD += -m elf_i386
-CFLAGS = $(GCCOPT) -g -W -Wall -Wno-sign-compare $(OPTFLAGS) $(INCLUDES)
+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
diff --git a/NEWS b/NEWS
index be2987d1..5008c1fa 100644
--- a/NEWS
+++ b/NEWS
@@ -10,6 +10,8 @@ Changes in 3.85:
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.
Changes in 3.84:
* SYSLINUX: make the DOS installer work for MS-DOS 7.x/8.x
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/codepage/cptable.pl b/codepage/cptable.pl
index 05cfc3eb..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,15 +107,44 @@ 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.
#
diff --git a/com32/MCONFIG b/com32/MCONFIG
index 3af015e1..80f92f6c 100644
--- a/com32/MCONFIG
+++ b/com32/MCONFIG
@@ -44,11 +44,11 @@ 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 $(GPLINCLUDE)
-SFLAGS = $(GCCOPT) -W -Wall -march=i386 \
+SFLAGS = $(GCCOPT) $(GCCWARN) -march=i386 \
-fomit-frame-pointer -D__COM32__ \
-nostdinc -iwithprefix include \
-I$(com32)/libutil/include -I$(com32)/include $(GPLINCLUDE)
@@ -57,7 +57,7 @@ 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
LNXSFLAGS = -g
LNXLDFLAGS = -g
diff --git a/com32/cmenu/adv_menu.tpl b/com32/cmenu/adv_menu.tpl
index be3c558e..a1a5d96a 100644
--- a/com32/cmenu/adv_menu.tpl
+++ b/com32/cmenu/adv_menu.tpl
@@ -183,12 +183,12 @@ TIMEOUTCODE timeout(const char *cmd)
}
}
-TIMEOUTCODE ontimeout()
+TIMEOUTCODE ontimeout(void)
{
return timeout(timeoutcmd);
}
-TIMEOUTCODE ontotaltimeout()
+TIMEOUTCODE ontotaltimeout(void)
{
return timeout(totaltimeoutcmd);
}
diff --git a/com32/cmenu/complex.c b/com32/cmenu/complex.c
index 1ac51997..f5175fa9 100644
--- a/com32/cmenu/complex.c
+++ b/com32/cmenu/complex.c
@@ -54,7 +54,7 @@ char username[12]; // Name of user currently using the system
/* End globals */
-TIMEOUTCODE ontimeout()
+TIMEOUTCODE ontimeout(void)
{
beep();
return CODE_WAIT;
@@ -244,7 +244,7 @@ t_handler_return checkbox_handler(t_menusystem * ms, t_menuitem * mi)
return rv;
}
-int main()
+int main(void)
{
t_menuitem *curr;
char cmd[160];
diff --git a/com32/cmenu/libmenu/menu.c b/com32/cmenu/libmenu/menu.c
index de4a1ee2..13754768 100644
--- a/com32/cmenu/libmenu/menu.c
+++ b/com32/cmenu/libmenu/menu.c
@@ -40,7 +40,7 @@ int isvisible(pt_menu menu, int first, int curr);
// 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()
+static int getch(void)
{
t_timeout_handler th;
int key;
@@ -615,7 +615,7 @@ uchar find_menu_num(const char *name)
// 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 fix_submenus(void)
{
int i, j;
pt_menu m;
@@ -874,7 +874,7 @@ void reg_ontimeout(t_timeout_handler handler, unsigned int numsteps,
ms->tm_stepsize = stepsize;
}
-void unreg_ontimeout()
+void unreg_ontimeout(void)
{
ms->ontimeout = NULL;
}
@@ -889,7 +889,7 @@ void reg_ontotaltimeout(t_timeout_handler handler,
}
}
-void unreg_ontotaltimeout()
+void unreg_ontotaltimeout(void)
{
ms->ontotaltimeout = NULL;
}
@@ -1084,7 +1084,7 @@ void set_menu_pos(uchar row, uchar col) // Set the position of this menu.
m->col = col;
}
-pt_menuitem add_sep() // Add a separator to current menu
+pt_menuitem add_sep(void) // Add a separator to current menu
{
pt_menuitem mi;
pt_menu m;
diff --git a/com32/cmenu/libmenu/menu.h b/com32/cmenu/libmenu/menu.h
index a1356020..141d2ef0 100644
--- a/com32/cmenu/libmenu/menu.h
+++ b/com32/cmenu/libmenu/menu.h
@@ -225,7 +225,7 @@ pt_menuitem showmenus(uchar startmenu);
pt_menusystem init_menusystem(const char *title);
-void close_menusystem(); // Deallocate memory used
+void close_menusystem(void); // Deallocate memory used
void set_normal_attr(uchar normal, uchar selected, uchar inactivenormal,
uchar inactiveselected);
@@ -253,10 +253,10 @@ 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 unreg_ontimeout(void);
void reg_ontotaltimeout(t_timeout_handler, unsigned long numcentiseconds);
-void unreg_ontotaltimeout();
+void unreg_ontotaltimeout(void);
// Find the number of the menu given the name
// Returns -1 if not found
@@ -284,7 +284,7 @@ static inline void set_shortcut(uchar shortcut)
}
// Add a separator to the "current" menu
-pt_menuitem add_sep();
+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"
diff --git a/com32/cmenu/libmenu/passwords.c b/com32/cmenu/libmenu/passwords.c
index 06f4cfb3..44ce461f 100644
--- a/com32/cmenu/libmenu/passwords.c
+++ b/com32/cmenu/libmenu/passwords.c
@@ -148,7 +148,7 @@ void init_passwords(const char *filename)
fclose(f);
}
-void close_passwords()
+void close_passwords(void)
{
int i;
diff --git a/com32/gfxboot/gfxboot.c b/com32/gfxboot/gfxboot.c
index 3937e305..bfdd8cce 100644
--- a/com32/gfxboot/gfxboot.c
+++ b/com32/gfxboot/gfxboot.c
@@ -573,7 +573,7 @@ int gfx_init(char *file)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-int gfx_menu_init()
+int gfx_menu_init(void)
{
com32sys_t r;
@@ -585,7 +585,7 @@ int gfx_menu_init()
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-void gfx_done()
+void gfx_done(void)
{
com32sys_t r;
@@ -599,7 +599,7 @@ void gfx_done()
// return:
// boot menu index (-1: go to text mode prompt)
//
-int gfx_input()
+int gfx_input(void)
{
com32sys_t r;
@@ -688,7 +688,7 @@ void *load_one(char *file, ssize_t *file_size)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// Locate menu entry and boot.
//
-void boot()
+void boot(void)
{
char *label, *arg, *s;
menu_t *menu_ptr;
diff --git a/com32/gplinclude/disk/bootloaders.h b/com32/gplinclude/disk/bootloaders.h
index 5a6ff9d9..56a0f4e3 100644
--- a/com32/gplinclude/disk/bootloaders.h
+++ b/com32/gplinclude/disk/bootloaders.h
@@ -14,6 +14,6 @@
#include <disk/geom.h>
#include <disk/partition.h>
-int get_bootloader_string(const struct driveinfo *, const struct part_entry *,
+int get_bootloader_string(struct driveinfo *, const struct part_entry *,
char *, const int);
#endif /* __BOOTLOADERS_H_ */
diff --git a/com32/gpllib/disk/ata.c b/com32/gpllib/disk/ata.c
index b0c2b63c..78f669ec 100644
--- a/com32/gpllib/disk/ata.c
+++ b/com32/gpllib/disk/ata.c
@@ -55,7 +55,7 @@ void ata_id_c_string(const uint16_t * id, unsigned char *s,
ata_id_string(id, s, ofs, len - 1);
- p = s + strnlen(s, len - 1);
+ p = s + strnlen((const char *)s, len - 1);
while (p > s && p[-1] == ' ')
p--;
*p = '\0';
diff --git a/com32/gpllib/disk/bootloaders.c b/com32/gpllib/disk/bootloaders.c
index 29aecbd4..188dd64b 100644
--- a/com32/gpllib/disk/bootloaders.c
+++ b/com32/gpllib/disk/bootloaders.c
@@ -22,7 +22,7 @@
* @buffer: pre-allocated buffer
* @buffer_size: @buffer size
**/
-int get_bootloader_string(const struct driveinfo *d, const struct part_entry *p,
+int get_bootloader_string(struct driveinfo *d, const struct part_entry *p,
char *buffer, const int buffer_size)
{
char boot_sector[SECTOR * sizeof(char)];
diff --git a/com32/gpllib/dmi/dmi_processor.c b/com32/gpllib/dmi/dmi_processor.c
index fd007da3..1cd9d1ba 100644
--- a/com32/gpllib/dmi/dmi_processor.c
+++ b/com32/gpllib/dmi/dmi_processor.c
@@ -49,7 +49,7 @@ const char *dmi_processor_type(uint8_t code)
const char *dmi_processor_family(uint8_t code, char *manufacturer)
{
/* 3.3.5.2 */
- static const char *family[] = {
+ static const char *family[256] = {
NULL, /* 0x00 */
"Other",
"Unknown",
@@ -306,54 +306,6 @@ const char *dmi_processor_family(uint8_t code, char *manufacturer)
NULL,
NULL,
NULL, /* 0xFF */
- NULL,
- NULL,
- NULL,
- NULL,
- "SH-3",
- "SH-4",
- NULL, /*0x106*/
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL, /*0x110*/
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- "ARM",
- "StrongARM",
- NULL, /*0x19A*/
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL, /*0x120*/
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL, /*0x12A*/
- NULL,
- "6x86",
- "MediaGX",
- "MII" /*0x12E*/
- /* master.mif has values beyond that, but they can't be used for DMI */
};
/* Special case for ambiguous value 0xBE */
if (code == 0xBE) {
@@ -367,7 +319,7 @@ const char *dmi_processor_family(uint8_t code, char *manufacturer)
return "Core 2 or K7";
}
- if ((code<=0x12E) && (family[code] != NULL)) {
+ if (family[code] != NULL) {
return family[code];
}
return out_of_spec;
diff --git a/com32/hdt/hdt-cli.c b/com32/hdt/hdt-cli.c
index 69a2b61f..76aed784 100644
--- a/com32/hdt/hdt-cli.c
+++ b/com32/hdt/hdt-cli.c
@@ -96,7 +96,7 @@ static void autocomplete_add_token_to_list(const char *token)
autocomplete_tail = new;
}
-static void autocomplete_destroy_list()
+static void autocomplete_destroy_list(void)
{
struct autocomplete_list *tmp = NULL;
@@ -727,7 +727,7 @@ out:
free(argv);
}
-static void reset_prompt()
+static void reset_prompt(void)
{
/* No need to display the prompt if we exit */
if (hdt_cli.mode != EXIT_MODE) {
@@ -779,7 +779,7 @@ void start_auto_mode(struct s_hardware *hardware)
more_printf("\n");
}
-void print_history()
+void print_history(void)
{
reset_more_printf();
for (int i = 1; i <= MAX_HISTORY_SIZE; i++) {
diff --git a/com32/hdt/hdt-cli.h b/com32/hdt/hdt-cli.h
index 898b53f8..b55d108a 100644
--- a/com32/hdt/hdt-cli.h
+++ b/com32/hdt/hdt-cli.h
@@ -160,7 +160,7 @@ void start_auto_mode(struct s_hardware *hardware);
void main_show(char *item, struct s_hardware *hardware);
#define CLI_HISTORY "history"
-void print_history();
+void print_history(void);
// DMI STUFF
#define CLI_DMI_BASE_BOARD "base_board"
diff --git a/com32/hdt/hdt-common.c b/com32/hdt/hdt-common.c
index 59175cec..736d9b6e 100644
--- a/com32/hdt/hdt-common.c
+++ b/com32/hdt/hdt-common.c
@@ -649,7 +649,7 @@ char *del_multi_spaces(char *p)
}
/* Reset the more_printf counter */
-void reset_more_printf()
+void reset_more_printf(void)
{
display_line_nb = 0;
}
diff --git a/com32/hdt/hdt-common.h b/com32/hdt/hdt-common.h
index d7a58e2f..0a0c8c4e 100644
--- a/com32/hdt/hdt-common.h
+++ b/com32/hdt/hdt-common.h
@@ -201,7 +201,7 @@ struct s_hardware {
char vesa_background[255];
};
-void reset_more_printf();
+void reset_more_printf(void);
const char *find_argument(const char **argv, const char *argument);
char *remove_spaces(char *p);
char *remove_trailing_lf(char *p);
diff --git a/com32/hdt/hdt-menu.c b/com32/hdt/hdt-menu.c
index 1aa0906f..4629ee58 100644
--- a/com32/hdt/hdt-menu.c
+++ b/com32/hdt/hdt-menu.c
@@ -79,7 +79,7 @@ int start_menu_mode(struct s_hardware *hardware, char *version_string)
}
/* In the menu system, what to do on keyboard timeout */
-TIMEOUTCODE ontimeout()
+TIMEOUTCODE ontimeout(void)
{
// beep();
return CODE_WAIT;
diff --git a/com32/hdt/hdt-menu.h b/com32/hdt/hdt-menu.h
index f10e5290..c8c91243 100644
--- a/com32/hdt/hdt-menu.h
+++ b/com32/hdt/hdt-menu.h
@@ -82,7 +82,7 @@ struct s_hdt_menu {
int total_menu_count; // Sum of all menus we have
};
-TIMEOUTCODE ontimeout();
+TIMEOUTCODE ontimeout(void);
void keys_handler(t_menusystem * ms
__attribute__ ((unused)), t_menuitem * mi, int scancode);
diff --git a/com32/lib/MCONFIG b/com32/lib/MCONFIG
index 7e092df3..44278bd1 100644
--- a/com32/lib/MCONFIG
+++ b/com32/lib/MCONFIG
@@ -33,8 +33,9 @@ LIBFLAGS = -DDYNAMIC_CRC_TABLE -DPNG_NO_CONSOLE_IO \
REQFLAGS = $(GCCOPT) -g -mregparm=3 -DREGPARM=3 -D__COM32__ \
-nostdinc -iwithprefix include -I. -I./sys -I../include
-OPTFLAGS = -Os -march=i386 -ffast-math -fomit-frame-pointer
-WARNFLAGS = -W -Wall -Wpointer-arith -Wwrite-strings -Wstrict-prototypes -Winline
+OPTFLAGS = -Os -march=i386 -falign-functions=0 -falign-jumps=0 \
+ -falign-labels=0 -ffast-math -fomit-frame-pointer
+WARNFLAGS = $(GCCWARN) -Wpointer-arith -Wwrite-strings -Wstrict-prototypes -Winline
CFLAGS = $(OPTFLAGS) $(REQFLAGS) $(WARNFLAGS) $(LIBFLAGS)
LDFLAGS = -m elf32_i386
diff --git a/com32/lib/chdir.c b/com32/lib/chdir.c
index 6f92d668..6a365f3b 100644
--- a/com32/lib/chdir.c
+++ b/com32/lib/chdir.c
@@ -8,6 +8,10 @@
int chdir(const char *path)
{
+ /* Actually implement something here... */
+
+ (void)path;
+
errno = ENOSYS;
return -1;
}
diff --git a/com32/lib/closedir.c b/com32/lib/closedir.c
index b3f55642..f4de67ae 100644
--- a/com32/lib/closedir.c
+++ b/com32/lib/closedir.c
@@ -10,6 +10,7 @@
#include <string.h>
#include <unistd.h>
#include <fcntl.h>
+#include <stdlib.h>
int closedir(DIR * dir)
{
diff --git a/com32/lib/fdopendir.c b/com32/lib/fdopendir.c
index 5fe11617..4fc31388 100644
--- a/com32/lib/fdopendir.c
+++ b/com32/lib/fdopendir.c
@@ -8,6 +8,8 @@
DIR *fdopendir(int __fd)
{
+ (void)__fd;
+
errno = ENOSYS;
return NULL;
}
diff --git a/com32/lib/libgcc/__moddi3.c b/com32/lib/libgcc/__moddi3.c
index ac8d3af7..4fc55884 100644
--- a/com32/lib/libgcc/__moddi3.c
+++ b/com32/lib/libgcc/__moddi3.c
@@ -21,7 +21,7 @@ int64_t __moddi3(int64_t num, int64_t den)
minus ^= 1;
}
- (void)__udivmoddi4(num, den, &v);
+ (void)__udivmoddi4(num, den, (uint64_t *)&v);
if (minus)
v = -v;
diff --git a/com32/lib/opendir.c b/com32/lib/opendir.c
index 6f91032b..c5e9aa05 100644
--- a/com32/lib/opendir.c
+++ b/com32/lib/opendir.c
@@ -10,6 +10,7 @@
#include <string.h>
#include <unistd.h>
#include <fcntl.h>
+#include <stdlib.h>
DIR *opendir(const char *pathname)
{
diff --git a/com32/lib/readdir.c b/com32/lib/readdir.c
index 07ca3955..d59ad3a2 100644
--- a/com32/lib/readdir.c
+++ b/com32/lib/readdir.c
@@ -10,6 +10,7 @@
#include <string.h>
#include <unistd.h>
#include <fcntl.h>
+#include <stdlib.h>
struct dirent *readdir(DIR * dir)
{
@@ -21,6 +22,6 @@ struct dirent *readdir(DIR * dir)
regs.esi.l = (uint32_t)dir;
__com32.cs_intcall(0x22, &regs, &regs);
newde = (struct dirent *)(regs.eax.l);
-
+
return newde;
}
diff --git a/com32/lib/strcasecmp.c b/com32/lib/strcasecmp.c
index 849c21fd..30949a09 100644
--- a/com32/lib/strcasecmp.c
+++ b/com32/lib/strcasecmp.c
@@ -7,7 +7,8 @@
int strcasecmp(const char *s1, const char *s2)
{
- const unsigned char *c1 = s1, *c2 = s2;
+ const unsigned char *c1 = (const unsigned char *)s1;
+ const unsigned char *c2 = (const unsigned char *)s2;
unsigned char ch;
int d = 0;
diff --git a/com32/lib/strcmp.c b/com32/lib/strcmp.c
index 77bb2b41..47a4aad8 100644
--- a/com32/lib/strcmp.c
+++ b/com32/lib/strcmp.c
@@ -6,7 +6,8 @@
int strcmp(const char *s1, const char *s2)
{
- const unsigned char *c1 = s1, *c2 = s2;
+ const unsigned char *c1 = (const unsigned char *)s1;
+ const unsigned char *c2 = (const unsigned char *)s2;
unsigned char ch;
int d = 0;
diff --git a/com32/lib/strncasecmp.c b/com32/lib/strncasecmp.c
index 8b8b967a..2caac0a5 100644
--- a/com32/lib/strncasecmp.c
+++ b/com32/lib/strncasecmp.c
@@ -7,7 +7,8 @@
int strncasecmp(const char *s1, const char *s2, size_t n)
{
- const unsigned char *c1 = s1, *c2 = s2;
+ const unsigned char *c1 = (const unsigned char *)s1;
+ const unsigned char *c2 = (const unsigned char *)s2;
unsigned char ch;
int d = 0;
diff --git a/com32/lib/strncmp.c b/com32/lib/strncmp.c
index f2f2f022..e41b9e36 100644
--- a/com32/lib/strncmp.c
+++ b/com32/lib/strncmp.c
@@ -6,7 +6,8 @@
int strncmp(const char *s1, const char *s2, size_t n)
{
- const unsigned char *c1 = s1, *c2 = s2;
+ const unsigned char *c1 = (const unsigned char *)s1;
+ const unsigned char *c2 = (const unsigned char *)s2;
unsigned char ch;
int d = 0;
diff --git a/com32/lib/sys/argv.c b/com32/lib/sys/argv.c
index b325f26d..8e9aabdb 100644
--- a/com32/lib/sys/argv.c
+++ b/com32/lib/sys/argv.c
@@ -75,7 +75,7 @@ int __parse_argv(char ***argv, const char *str)
}
/* Now create argv */
- arg = ALIGN_UP_FOR(q, char *);
+ arg = (char **)ALIGN_UP_FOR(q, char *);
*argv = arg;
*arg++ = argv0; /* argv[0] */
diff --git a/com32/lib/sys/colortable.c b/com32/lib/sys/colortable.c
index df6d9782..ab1c4246 100644
--- a/com32/lib/sys/colortable.c
+++ b/com32/lib/sys/colortable.c
@@ -4,6 +4,6 @@ static struct color_table default_color_table[] = {
{"default", "0", 0xffffffff, 0x00000000, SHADOW_NORMAL}
};
-struct color_table *console_color_table = &default_color_table;
+struct color_table *console_color_table = default_color_table;
int console_color_table_size =
(sizeof default_color_table / sizeof(struct color_table));
diff --git a/com32/lib/sys/libansi.c b/com32/lib/sys/libansi.c
index 5bc0026e..a011cb87 100644
--- a/com32/lib/sys/libansi.c
+++ b/com32/lib/sys/libansi.c
@@ -46,18 +46,21 @@ void display_cursor(bool status)
}
}
-void clear_end_of_line() {
+void clear_end_of_line(void)
+{
fputs(CSI "0K", stdout);
}
-void move_cursor_left(int count) {
+void move_cursor_left(int count)
+{
char buffer[10];
memset(buffer,0,sizeof(buffer));
sprintf(buffer,CSI "%dD",count);
fputs(buffer, stdout);
}
-void move_cursor_right(int count) {
+void move_cursor_right(int count)
+{
char buffer[10];
memset(buffer,0,sizeof(buffer));
sprintf(buffer, CSI "%dC", count);
@@ -71,38 +74,45 @@ void set_cursor_blink(bool status) {
fputs("\033[0m",stdout);
}
-void clear_line() {
+void clear_line(void)
+{
fputs(CSI "2K", stdout);
}
-void clear_beginning_of_line() {
+void clear_beginning_of_line(void)
+{
fputs(CSI "1K", stdout);
}
-void move_cursor_to_column(int count) {
+void move_cursor_to_column(int count)
+{
char buffer[10];
memset(buffer,0,sizeof(buffer));
sprintf(buffer, CSI "%dG", count);
fputs(buffer, stdout);
}
-void move_cursor_to_next_line() {
+void move_cursor_to_next_line(void)
+{
fputs("\033e", stdout);
}
-void disable_utf8() {
+void disable_utf8(void)
+{
fputs("\033%@", stdout);
}
-void set_g1_special_char(){
+void set_g1_special_char(void){
fputs("\033)0", stdout);
}
-void set_us_g0_charset() {
+void set_us_g0_charset(void)
+{
fputs("\033(B\1#0", stdout);
}
-void clear_entire_screen() {
+void clear_entire_screen(void)
+{
fputs(CSI "2J", stdout);
}
@@ -186,7 +196,7 @@ void cls(void)
cprint_vga2ansi('0', '0');
}
-void reset_colors()
+void reset_colors(void)
{
csprint(CSI "1D", 0x07);
}
diff --git a/com32/lib/sys/openmem.c b/com32/lib/sys/openmem.c
index 13a45c2a..33b8de0d 100644
--- a/com32/lib/sys/openmem.c
+++ b/com32/lib/sys/openmem.c
@@ -42,7 +42,6 @@ const struct input_dev __file_dev;
int openmem(const void *base, size_t len, int flags)
{
- com32sys_t regs;
int fd;
struct file_info *fp;
@@ -51,6 +50,8 @@ int openmem(const void *base, size_t len, int flags)
if (fd < 0)
return -1;
+ fp = &__file_info[fd];
+
fp->i.length = fp->i.nbytes = len;
fp->i.datap = (void *)base;
fp->i.filedes = 0; /* No actual file */
diff --git a/com32/lib/sys/vesaserial_write.c b/com32/lib/sys/vesaserial_write.c
index 47527c3a..775ca19e 100644
--- a/com32/lib/sys/vesaserial_write.c
+++ b/com32/lib/sys/vesaserial_write.c
@@ -38,7 +38,7 @@
#include <console.h>
#include "file.h"
-extern int __vesacon_open(void);
+extern int __vesacon_open(struct file_info *);
extern int __vesacon_close(struct file_info *);
extern ssize_t __vesacon_write(struct file_info *, const void *, size_t);
extern ssize_t __xserial_write(struct file_info *, const void *, size_t);
diff --git a/com32/lib/syslinux/getadv.c b/com32/lib/syslinux/getadv.c
index 456084b0..5578313e 100644
--- a/com32/lib/syslinux/getadv.c
+++ b/com32/lib/syslinux/getadv.c
@@ -39,7 +39,7 @@
const void *syslinux_getadv(int tag, size_t * size)
{
const uint8_t *p;
- size_t left, len;
+ size_t left;
p = syslinux_adv_ptr();
left = syslinux_adv_size();
diff --git a/com32/lib/syslinux/load_linux.c b/com32/lib/syslinux/load_linux.c
index db985163..df793625 100644
--- a/com32/lib/syslinux/load_linux.c
+++ b/com32/lib/syslinux/load_linux.c
@@ -253,6 +253,9 @@ int syslinux_boot_linux(void *kernel_buf, size_t kernel_size,
case 'n': /* "normal" */
video_mode = 0xffff;
break;
+ case 'c': /* "current" */
+ video_mode = 0x0f04;
+ break;
default:
video_mode = strtoul(arg, NULL, 0);
break;
diff --git a/com32/lib/zlib/crc32.c b/com32/lib/zlib/crc32.c
index 447f138e..67e6f31e 100644
--- a/com32/lib/zlib/crc32.c
+++ b/com32/lib/zlib/crc32.c
@@ -100,7 +100,7 @@ local void make_crc_table()
/* make exclusive-or pattern from polynomial (0xedb88320UL) */
poly = 0UL;
- for (n = 0; n < sizeof(p)/sizeof(unsigned char); n++)
+ for (n = 0; n < (int)(sizeof(p)/sizeof(unsigned char)); n++)
poly |= 1UL << (31 - p[n]);
/* generate a crc for every 8-bit value */
diff --git a/com32/menu/menu.h b/com32/menu/menu.h
index 52b4e4dc..1e596e1d 100644
--- a/com32/menu/menu.h
+++ b/com32/menu/menu.h
@@ -180,6 +180,7 @@ extern struct menu *root_menu, *start_menu, *hide_menu, *menu_list;
/* These are global parameters regardless of which menu we're displaying */
extern int shiftkey;
extern int hiddenmenu;
+extern int clearmenu;
extern long long totaltimeout;
void parse_configs(char **argv);
diff --git a/com32/menu/menumain.c b/com32/menu/menumain.c
index cbeb9a18..0c392646 100644
--- a/com32/menu/menumain.c
+++ b/com32/menu/menumain.c
@@ -1,7 +1,7 @@
/* ----------------------------------------------------------------------- *
*
* Copyright 2004-2008 H. Peter Anvin - All Rights Reserved
- * Copyright 2009 Intel Corporation; author: H. Peter Anvin
+ * Copyright 2009-2010 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
@@ -616,8 +616,9 @@ static inline int shift_is_held(void)
static void print_timeout_message(int tol, int row, const char *msg)
{
+ static int last_msg_len = 0;
char buf[256];
- int nc = 0, nnc;
+ int nc = 0, nnc, padc;
const char *tp = msg;
char tc;
char *tq = buf;
@@ -686,9 +687,17 @@ static void print_timeout_message(int tol, int row, const char *msg)
}
*tq = '\0';
- /* Let's hope 4 spaces on each side is enough... */
- printf("\033[%d;%dH\2#14 %s ", row,
- HSHIFT + 1 + ((WIDTH - nc - 8) >> 1), buf);
+ if (nc >= last_msg_len) {
+ padc = 0;
+ } else {
+ padc = (last_msg_len - nc + 1) >> 1;
+ }
+
+ printf("\033[%d;%dH\2#14%*s%s%*s", row,
+ HSHIFT + 1 + ((WIDTH - nc) >> 1) - padc,
+ padc, "", buf, padc, "");
+
+ last_msg_len = nc;
}
/* Set the background screen, etc. */
@@ -724,6 +733,9 @@ static const char *do_hidden_menu(void)
}
}
+ /* Clear the message from the screen */
+ print_timeout_message(0, HIDDEN_ROW, "");
+
if (cm->ontimeout)
return cm->ontimeout;
else
@@ -1118,6 +1130,9 @@ int main(int argc, char *argv[])
local_cursor_enable(true);
cmdline = run_menu();
+ if (clearmenu)
+ clear_screen();
+
local_cursor_enable(false);
printf("\033[?25h\033[%d;1H\033[0m", END_ROW);
diff --git a/com32/menu/readconfig.c b/com32/menu/readconfig.c
index a248721e..d4c8848c 100644
--- a/com32/menu/readconfig.c
+++ b/com32/menu/readconfig.c
@@ -1,7 +1,7 @@
/* ----------------------------------------------------------------------- *
*
* Copyright 2004-2009 H. Peter Anvin - All Rights Reserved
- * Copyright 2009 Intel Corporation; author: H. Peter Anvin
+ * Copyright 2009-2010 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
@@ -34,6 +34,7 @@ struct menu *root_menu, *start_menu, *hide_menu, *menu_list;
/* These are global parameters regardless of which menu we're displaying */
int shiftkey = 0; /* Only display menu if shift key pressed */
int hiddenmenu = 0;
+int clearmenu = 0;
long long totaltimeout = 0;
/* Keep track of global default */
@@ -690,6 +691,8 @@ static void parse_config_file(FILE * f)
m->menu_background = refdup_word(&p);
} else if ((ep = looking_at(p, "hidden"))) {
hiddenmenu = 1;
+ } else if ((ep = looking_at(p, "clear"))) {
+ clearmenu = 1;
} else if ((ep = is_message_name(p, &msgnr))) {
refstr_put(m->messages[msgnr]);
m->messages[msgnr] = refstrdup(skipspace(ep));
diff --git a/com32/modules/chain.c b/com32/modules/chain.c
index da64707f..458ea890 100644
--- a/com32/modules/chain.c
+++ b/com32/modules/chain.c
@@ -1,7 +1,7 @@
/* ----------------------------------------------------------------------- *
*
* Copyright 2003-2009 H. Peter Anvin - All Rights Reserved
- * Copyright 2009 Intel Corporation; author: H. Peter Anvin
+ * Copyright 2009-2010 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
@@ -394,10 +394,13 @@ static struct part_entry *find_logical_partition(int whichpart, char *table,
/* Adjust the offset to account for the extended partition itself */
ptab[i].start_lba += self->start_lba;
- /* Sanity check entry: must not extend outside the extended partition.
- This is necessary since some OSes put crap in some entries. */
- if (ptab[i].start_lba + ptab[i].length <= self->start_lba ||
- ptab[i].start_lba >= self->start_lba + self->length)
+ /*
+ * Sanity check entry: must not extend outside the
+ * extended partition. This is necessary since some OSes
+ * put crap in some entries. Note that root is non-NULL here.
+ */
+ if (ptab[i].start_lba + ptab[i].length <= root->start_lba ||
+ ptab[i].start_lba >= root->start_lba + root->length)
continue;
/* OK, it's a data partition. Is it the one we're looking for? */
@@ -781,7 +784,6 @@ int main(int argc, char *argv[])
regs.ebx.b[0] = regs.edx.b[0] = drive;
whichpart = 0; /* Default */
-
if (partition)
whichpart = strtoul(partition, NULL, 0);
@@ -789,6 +791,14 @@ int main(int argc, char *argv[])
error("Warning: Partitions of floppy devices may not work\n");
}
+ /*
+ * grldr of Grub4dos wants the partition number in DH:
+ * -1: whole drive (default)
+ * 0-3: primary partitions
+ * 4-*: logical partitions
+ */
+ regs.edx.b[1] = whichpart-1;
+
/* Get the disk geometry and disk access setup */
if (get_disk_params(drive)) {
error("Cannot get disk parameters\n");
diff --git a/com32/rosh/MCONFIG b/com32/rosh/MCONFIG
index 30029d15..25c41396 100644
--- a/com32/rosh/MCONFIG
+++ b/com32/rosh/MCONFIG
@@ -17,11 +17,11 @@
## Include the COM32 common configurables
include ../MCONFIG
-# 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
# -g3 -dD
-# LNXCFLAGS = -I$(com32)/libutil/include -W -Wall -O -g3 -D_GNU_SOURCE -dD
+# LNXCFLAGS = -I$(com32)/libutil/include $(GCCWARN) -O -g3 -D_GNU_SOURCE -dD
# -U__GNUC__
diff --git a/com32/rosh/rosh.c b/com32/rosh/rosh.c
index 2221bb0a..13e8ffbd 100644
--- a/com32/rosh/rosh.c
+++ b/com32/rosh/rosh.c
@@ -37,7 +37,7 @@
#define APP_YEAR "2008"
#define APP_VER "beta-b032"
-void rosh_version()
+void rosh_version(void)
{
printf("%s v %s; (c) %s %s.\n", APP_LONGNAME, APP_VER, APP_YEAR,
APP_AUTHOR);
@@ -224,7 +224,7 @@ void rosh_print_tc(struct termios *tio)
* Switches console over to raw input mode. Allows get_key to get just
* 1 key sequence (without delay or display)
*/
-void rosh_console_raw()
+void rosh_console_raw(void)
{
// struct termios itio, ntio;
// tcgetattr(0, &itio);
@@ -241,7 +241,7 @@ void rosh_console_raw()
/*
* Switches back to standard getline mode.
*/
-void rosh_console_std()
+void rosh_console_std(void)
{
// struct termios itio, ntio;
console_ansi_std();
@@ -252,7 +252,7 @@ void rosh_console_std()
* Attempts to get a single key from the console
* returns key pressed
*/
-int rosh_getkey()
+int rosh_getkey(void)
{
int inc;
diff --git a/core/Makefile b/core/Makefile
index d35390f4..707aad79 100644
--- a/core/Makefile
+++ b/core/Makefile
@@ -112,12 +112,11 @@ extlinux.bss: extlinux.bin
extlinux.sys: extlinux.bin
dd if=$< of=$@ bs=512 skip=1
-# NASM prior to 2.03 wouldn't auto-generate this dependency...
-ldlinux.o: codepage.cp
-
codepage.cp: ../codepage/$(CODEPAGE).cp
cp -f $< $@
+codepage.o: codepage.S codepage.cp
+
install: installer
install-lib: installer
diff --git a/core/bootsect.inc b/core/bootsect.inc
index 23b4fdb4..b8102cd5 100644
--- a/core/bootsect.inc
+++ b/core/bootsect.inc
@@ -120,6 +120,12 @@ replace_bootstrap:
; Prepare for shutting down
;
call vgaclearmode
+
+;
+; We jump here when loading a kernel image, so that we don't reset
+; the screen mode in "quiet" mode
+;
+replace_bootstrap_noclearmode:
call cleanup_hardware
;
diff --git a/core/codepage.S b/core/codepage.S
new file mode 100644
index 00000000..4f1d4836
--- /dev/null
+++ b/core/codepage.S
@@ -0,0 +1,5 @@
+ .section ".rodata","a"
+ .globl codepage
+codepage:
+ .incbin "codepage.cp"
+ .size codepage, .-codepage
diff --git a/core/dir.c b/core/dir.c
index 37d92ed2..4013280a 100644
--- a/core/dir.c
+++ b/core/dir.c
@@ -1,10 +1,8 @@
#include <stdio.h>
#include <string.h>
#include <sys/dirent.h>
-#include <fs.h>
-#include <core.h>
-
-extern struct fs_info *this_fs;
+#include "fs.h"
+#include "core.h"
/*
* open dir, return the file structure pointer in _eax_, or NULL if failed
diff --git a/core/fs.c b/core/fs.c
index 37808812..0eac0f26 100644
--- a/core/fs.c
+++ b/core/fs.c
@@ -13,6 +13,19 @@ struct inode *this_inode = NULL;
struct file files[MAX_OPEN];
/*
+ * Get a new inode structure
+ */
+struct inode *alloc_inode(struct fs_info *fs, uint32_t ino, size_t data)
+{
+ struct inode *inode = zalloc(sizeof(struct inode) + data);
+ if (inode) {
+ inode->fs = fs;
+ inode->ino = ino;
+ }
+ return inode;
+}
+
+/*
* Get an empty file structure
*/
static struct file *alloc_file(void)
@@ -152,7 +165,7 @@ void searchdir(com32sys_t *regs)
/* else, try the generic-path-lookup method */
if (*name == '/') {
- inode = this_fs->fs_ops->iget_root();
+ inode = this_fs->fs_ops->iget_root(this_fs);
while(*name == '/')
name++;
} else {
@@ -162,37 +175,40 @@ void searchdir(com32sys_t *regs)
while (*name) {
p = part;
- while(*name && *name != '/')
+ while (*name && *name != '/')
*p++ = *name++;
*p = '\0';
- inode = this_fs->fs_ops->iget(part, parent);
- if (!inode)
- goto err;
- if (inode->mode == I_SYMLINK) {
- if (!this_fs->fs_ops->follow_symlink ||
- --symlink_count == 0 || /* limit check */
- inode->size >= BLOCK_SIZE(this_fs))
+ if (strcmp(part, ".")) {
+ inode = this_fs->fs_ops->iget(part, parent);
+ if (!inode)
goto err;
- name = this_fs->fs_ops->follow_symlink(inode, name);
- free_inode(inode);
- continue;
- }
+ if (inode->mode == I_SYMLINK) {
+ if (!this_fs->fs_ops->follow_symlink ||
+ --symlink_count == 0 || /* limit check */
+ inode->size >= BLOCK_SIZE(this_fs))
+ goto err;
+ name = this_fs->fs_ops->follow_symlink(inode, name);
+ free_inode(inode);
+ continue;
+ }
- /*
- * For the relative path searching used in FAT and ISO fs.
- */
- if ((this_fs->fs_ops->fs_flags & FS_THISIND) && (this_inode != parent)){
+ /*
+ * For the relative path searching used in FAT and ISO fs.
+ */
+ if ((this_fs->fs_ops->fs_flags & FS_THISIND) &&
+ (this_inode != parent)){
if (this_inode)
free_inode(this_inode);
this_inode = parent;
+ }
+
+ if (parent != this_inode)
+ free_inode(parent);
+ parent = inode;
}
-
- if (parent != this_inode)
- free_inode(parent);
- parent = inode;
- if (! *name)
+ if (!*name)
break;
- while(*name == '/')
+ while (*name == '/')
name++;
}
@@ -280,5 +296,5 @@ void fs_init(com32sys_t *regs)
cache_init(fs.fs_dev, blk_shift);
if (fs.fs_ops->iget_current)
- this_inode = fs.fs_ops->iget_current();
+ this_inode = fs.fs_ops->iget_current(&fs);
}
diff --git a/core/fs/ext2/bmap.c b/core/fs/ext2/bmap.c
index e38bcd2c..e4698d0c 100644
--- a/core/fs/ext2/bmap.c
+++ b/core/fs/ext2/bmap.c
@@ -51,7 +51,7 @@ static uint64_t bmap_extent(struct fs_info *fs,
int i;
block_t start;
- leaf = ext4_find_leaf(fs, (struct ext4_extent_header *)inode->data, block);
+ leaf = ext4_find_leaf(fs, (struct ext4_extent_header *)inode->pvt, block);
if (!leaf) {
printf("ERROR, extent leaf not found\n");
return 0;
@@ -95,12 +95,12 @@ static unsigned int bmap_traditional(struct fs_info *fs,
/* direct blocks */
if (block < direct_blocks)
- return inode->data[block];
+ return ((uint32_t *)inode->pvt)[block];
/* indirect blocks */
block -= direct_blocks;
if (block < indirect_blocks) {
- block_t ind_block = inode->data[EXT2_IND_BLOCK];
+ block_t ind_block = ((uint32_t *)inode->pvt)[EXT2_IND_BLOCK];
if (!ind_block)
return 0;
@@ -113,7 +113,7 @@ static unsigned int bmap_traditional(struct fs_info *fs,
/* double indirect blocks */
block -= indirect_blocks;
if (block < double_blocks) {
- block_t dou_block = inode->data[EXT2_DIND_BLOCK];
+ block_t dou_block = ((uint32_t *)inode->pvt)[EXT2_DIND_BLOCK];
if (!dou_block)
return 0;
@@ -131,7 +131,7 @@ static unsigned int bmap_traditional(struct fs_info *fs,
/* triple indirect block */
block -= double_blocks;
if (block < triple_blocks) {
- block_t tri_block = inode->data[EXT2_TIND_BLOCK];
+ block_t tri_block = ((uint32_t *)inode->pvt)[EXT2_TIND_BLOCK];
if (!tri_block)
return 0;
diff --git a/core/fs/ext2/ext2.c b/core/fs/ext2/ext2.c
index a978677a..fbb57be0 100644
--- a/core/fs/ext2/ext2.c
+++ b/core/fs/ext2/ext2.c
@@ -34,10 +34,14 @@ static void ext2_close_file(struct file *file)
/*
* get the group's descriptor of group_num
*/
-struct ext2_group_desc * ext2_get_group_desc(uint32_t group_num)
+struct ext2_group_desc * ext2_get_group_desc(struct fs_info *fs,
+ uint32_t group_num)
{
- struct ext2_sb_info *sbi = EXT2_SB(this_fs);
-
+ struct ext2_sb_info *sbi = EXT2_SB(fs);
+ uint32_t desc_block, desc_index;
+ struct ext2_group_desc *desc_data_block;
+ struct cache_struct *cs;
+
if (group_num >= sbi->s_groups_count) {
printf ("ext2_get_group_desc"
"block_group >= groups_count - "
@@ -46,8 +50,16 @@ struct ext2_group_desc * ext2_get_group_desc(uint32_t group_num)
return NULL;
}
-
- return sbi->s_group_desc[group_num];
+
+ desc_block = group_num / sbi->s_desc_per_block;
+ desc_index = group_num % sbi->s_desc_per_block;
+
+ desc_block += sbi->s_first_data_block + 1;
+
+ cs = get_cache_block(fs->fs_dev, desc_block);
+ desc_data_block = cs->data;
+
+ return &desc_data_block[desc_index];
}
@@ -64,10 +76,9 @@ struct ext2_group_desc * ext2_get_group_desc(uint32_t group_num)
*
* @return: physic sector number
*/
-static sector_t linsector(struct fs_info *fs,
- struct inode *inode,
- uint32_t lin_sector)
+static sector_t linsector(struct inode *inode, uint32_t lin_sector)
{
+ struct fs_info *fs = inode->fs;
int blk_bits = fs->block_shift - fs->sector_shift;
block_t block = bmap(fs, inode, lin_sector >> blk_bits);
@@ -129,7 +140,7 @@ static uint32_t ext2_getfssec(struct file *file, char *buf,
/*
* get the frament
*/
- next_sector = frag_start = linsector(fs, inode, sector_idx);
+ next_sector = frag_start = linsector(inode, sector_idx);
con_sec_cnt = 0;
/* get the consective sectors count */
@@ -143,9 +154,9 @@ static uint32_t ext2_getfssec(struct file *file, char *buf,
if (sectors >= (((~(uint32_t)buf&0xffff)|((uint32_t)buf&0xffff0000)) + 1))
break;
- sector_idx ++;
- next_sector ++;
- } while (next_sector == linsector(fs, inode, sector_idx));
+ sector_idx++;
+ next_sector++;
+ } while (next_sector == linsector(inode, sector_idx));
#if 0
printf("You are reading data stored at sector --0x%x--0x%x\n",
@@ -225,7 +236,7 @@ ext2_find_entry(struct fs_info *fs, struct inode *inode, char *dname)
return NULL;
}
-static struct ext2_inode * get_inode(int inr)
+static struct ext2_inode * get_inode(struct fs_info *fs, int inr)
{
struct ext2_group_desc *desc;
struct cache_struct *cs;
@@ -233,19 +244,19 @@ static struct ext2_inode * get_inode(int inr)
uint32_t block_num, block_off;
inr--;
- inode_group = inr / EXT2_INODES_PER_GROUP(this_fs);
- inode_offset = inr % EXT2_INODES_PER_GROUP(this_fs);
- desc = ext2_get_group_desc (inode_group);
+ inode_group = inr / EXT2_INODES_PER_GROUP(fs);
+ inode_offset = inr % EXT2_INODES_PER_GROUP(fs);
+ desc = ext2_get_group_desc(fs, inode_group);
if (!desc)
return NULL;
block_num = desc->bg_inode_table +
- inode_offset / EXT2_INODES_PER_BLOCK(this_fs);
- block_off = inode_offset % EXT2_INODES_PER_BLOCK(this_fs);
-
- cs = get_cache_block(this_fs->fs_dev, block_num);
+ inode_offset / EXT2_INODES_PER_BLOCK(fs);
+ block_off = inode_offset % EXT2_INODES_PER_BLOCK(fs);
- return cs->data + block_off * EXT2_SB(this_fs)->s_inode_size;
+ cs = get_cache_block(fs->fs_dev, block_num);
+
+ return cs->data + block_off * EXT2_SB(fs)->s_inode_size;
}
static inline int get_inode_mode(int mode)
@@ -261,7 +272,7 @@ static inline int get_inode_mode(int mode)
}
static void fill_inode(struct inode *inode, struct ext2_inode *e_inode)
-{
+{
inode->mode = get_inode_mode(e_inode->i_mode);
inode->size = e_inode->i_size;
inode->atime = e_inode->i_atime;
@@ -271,78 +282,73 @@ static void fill_inode(struct inode *inode, struct ext2_inode *e_inode)
inode->blocks = e_inode->i_blocks;
inode->flags = e_inode->i_flags;
inode->file_acl = e_inode->i_file_acl;
-
- inode->data = malloc(EXT2_N_BLOCKS * sizeof(uint32_t *));
- if (!inode->data) {
- malloc_error("inode data filed");
- return ;
- }
- memcpy(inode->data, e_inode->i_block, EXT2_N_BLOCKS * sizeof(uint32_t *));
+ memcpy(inode->pvt, e_inode->i_block, EXT2_N_BLOCKS * sizeof(uint32_t *));
}
-static struct inode *ext2_iget_by_inr(uint32_t inr)
+static struct inode *ext2_iget_by_inr(struct fs_info *fs, uint32_t inr)
{
struct ext2_inode *e_inode;
struct inode *inode;
- e_inode = get_inode(inr);
- if (!(inode = malloc(sizeof(*inode))))
+ e_inode = get_inode(fs, inr);
+ if (!(inode = alloc_inode(fs, inr, EXT2_N_BLOCKS*sizeof(uint32_t *))))
return NULL;
fill_inode(inode, e_inode);
- inode->ino = inr;
return inode;
}
-static struct inode *ext2_iget_root(void)
+static struct inode *ext2_iget_root(struct fs_info *fs)
{
- return ext2_iget_by_inr(EXT2_ROOT_INO);
+ return ext2_iget_by_inr(fs, EXT2_ROOT_INO);
}
-static struct inode *ext2_iget_current(void)
+static struct inode *ext2_iget_current(struct fs_info *fs)
{
static int CurrentDir = 2;
- return ext2_iget_by_inr(CurrentDir);
+ return ext2_iget_by_inr(fs, CurrentDir);
}
static struct inode *ext2_iget(char *dname, struct inode *parent)
{
struct ext2_dir_entry *de;
+ struct fs_info *fs = parent->fs;
- de = ext2_find_entry(this_fs, parent, dname);
+ de = ext2_find_entry(fs, parent, dname);
if (!de)
return NULL;
- return ext2_iget_by_inr(de->d_inode);
+ return ext2_iget_by_inr(fs, de->d_inode);
}
static char * ext2_follow_symlink(struct inode *inode, const char *name_left)
{
- int sec_per_block = 1 << (this_fs->block_shift - this_fs->sector_shift);
+ struct fs_info *fs = inode->fs;
+ int sec_per_block = 1 << (fs->block_shift - fs->sector_shift);
int fast_symlink;
char *symlink_buf;
char *p;
struct cache_struct *cs;
- symlink_buf = malloc(BLOCK_SIZE(this_fs));
+ symlink_buf = malloc(BLOCK_SIZE(fs));
if (!symlink_buf) {
malloc_error("symlink buffer");
return NULL;
}
fast_symlink = (inode->file_acl ? sec_per_block : 0) == inode->blocks;
if (fast_symlink) {
- memcpy(symlink_buf, inode->data, inode->size);
+ memcpy(symlink_buf, inode->pvt, inode->size);
} else {
- cs = get_cache_block(this_fs->fs_dev, *(uint32_t *)inode->data);
+ cs = get_cache_block(fs->fs_dev, *(uint32_t *)inode->pvt);
memcpy(symlink_buf, cs->data, inode->size);
}
p = symlink_buf + inode->size;
if (*name_left)
*p++ = '/';
- if (strecpy(p, name_left, symlink_buf + BLOCK_SIZE(this_fs))) {
+ if (strecpy(p, name_left, symlink_buf + BLOCK_SIZE(fs))) {
free(symlink_buf);
return NULL;
}
@@ -412,11 +418,6 @@ static int ext2_fs_init(struct fs_info *fs)
struct disk *disk = fs->fs_dev->disk;
struct ext2_sb_info *sbi;
struct ext2_super_block sb;
- int blk_bits;
- int db_count;
- int i;
- int desc_block;
- char *desc_buffer;
/* read the super block */
disk->rdwr_sectors(disk, &sb, 2, 2, 0);
@@ -439,6 +440,8 @@ static int ext2_fs_init(struct fs_info *fs)
fs->sector_shift = disk->sector_shift;
fs->block_shift = sb.s_log_block_size + 10;
+ fs->sector_size = 1 << fs->sector_shift;
+ fs->block_size = 1 << fs->block_shift;
sbi->s_inodes_per_group = sb.s_inodes_per_group;
sbi->s_blocks_per_group = sb.s_blocks_per_group;
@@ -449,31 +452,9 @@ static int ext2_fs_init(struct fs_info *fs)
sbi->s_groups_count = (sb.s_blocks_count - sb.s_first_data_block
+ EXT2_BLOCKS_PER_GROUP(fs) - 1)
/ EXT2_BLOCKS_PER_GROUP(fs);
- db_count = (sbi->s_groups_count + EXT2_DESC_PER_BLOCK(fs) - 1) /
- EXT2_DESC_PER_BLOCK(fs);
+ sbi->s_first_data_block = sb.s_first_data_block;
sbi->s_inode_size = sb.s_inode_size;
-
- /* read the descpritors */
- desc_block = sb.s_first_data_block + 1;
- desc_buffer = malloc(db_count * BLOCK_SIZE(fs));
- if (!desc_buffer) {
- malloc_error("desc_buffer");
- return -1;
- }
- blk_bits = fs->block_shift - fs->sector_shift;
- disk->rdwr_sectors(disk, desc_buffer, desc_block << blk_bits,
- db_count << blk_bits, 0);
- sbi->s_group_desc = malloc(sizeof(struct ext2_group_desc *)
- * sbi->s_groups_count);
- if (!sbi->s_group_desc) {
- malloc_error("sbi->s_group_desc");
- return -1;
- }
- for (i = 0; i < (int)sbi->s_groups_count; i++) {
- sbi->s_group_desc[i] = (struct ext2_group_desc *)desc_buffer;
- desc_buffer += sb.s_desc_size;
- }
-
+
return fs->block_shift;
}
diff --git a/core/fs/ext2/ext2_fs.h b/core/fs/ext2/ext2_fs.h
index 0249ee16..b74038ea 100644
--- a/core/fs/ext2/ext2_fs.h
+++ b/core/fs/ext2/ext2_fs.h
@@ -275,14 +275,8 @@ struct ext2_sb_info {
uint32_t s_blocks_per_group;/* Number of blocks in a group */
uint32_t s_desc_per_block; /* Number of group descriptors per block */
uint32_t s_groups_count; /* Number of groups in the fs */
+ uint32_t s_first_data_block; /* First Data Block */
int s_inode_size;
-
- /*
- * Here did not like Linux Kernel did; the group descriptor cache
- * here is based on ext2_group_desc structure, instead of buffer
- * head structure in Linux Kernel, where cache one block data.
- */
- struct ext2_group_desc ** s_group_desc;
};
static inline struct ext2_sb_info *EXT2_SB(struct fs_info *fs)
diff --git a/core/fs/fat/fat.c b/core/fs/fat/fat.c
index d77fcb12..13cf674d 100644
--- a/core/fs/fat/fat.c
+++ b/core/fs/fat/fat.c
@@ -5,24 +5,16 @@
#include <core.h>
#include <disk.h>
#include <fs.h>
+#include <klibc/compiler.h>
+#include "codepage.h"
#include "fat_fs.h"
-
-static struct inode * new_fat_inode(void)
+static struct inode * new_fat_inode(struct fs_info *fs)
{
- struct inode *inode = malloc(sizeof(*inode));
- if (!inode)
+ struct inode *inode = alloc_inode(fs, 0, sizeof(struct fat_pvt_inode));
+ if (!inode)
malloc_error("inode structure");
- memset(inode, 0, sizeof(*inode));
-
- /*
- * We just need allocate one uint32_t data to store the
- * first cluster number.
- */
- inode->data = malloc(sizeof(uint32_t));
- if (!inode->data)
- malloc_error("inode->data");
-
+
return inode;
}
@@ -51,16 +43,18 @@ static uint32_t get_next_cluster(struct fs_info *fs, uint32_t clust_num)
uint32_t offset;
int lo, hi;
struct cache_struct *cs;
+ uint32_t sector_mask = SECTOR_SIZE(fs) - 1;
switch(FAT_SB(fs)->fat_type) {
case FAT12:
- fat_sector = (clust_num + clust_num / 2) >> SECTOR_SHIFT;
+ offset = clust_num + (clust_num >> 1);
+ fat_sector = offset >> SECTOR_SHIFT(fs);
+ offset &= sector_mask;
cs = get_fat_sector(fs, fat_sector);
- offset = (clust_num * 3 / 2) & ((1 << SECTOR_SHIFT) - 1);
- if (offset == 0x1ff) {
+ if (offset == sector_mask) {
/*
* we got the end of the one fat sector,
- * but we don't got we have(just one byte, we need two),
+ * but we have just one byte and we need two,
* so store the low part, then read the next fat
* sector, read the high part, then combine it.
*/
@@ -76,62 +70,59 @@ static uint32_t get_next_cluster(struct fs_info *fs, uint32_t clust_num)
next_cluster >>= 4; /* cluster number is ODD */
else
next_cluster &= 0x0fff; /* cluster number is EVEN */
- if (next_cluster > 0x0ff0)
- goto fail;
break;
case FAT16:
- fat_sector = clust_num >> (SECTOR_SHIFT - 1);
- offset = clust_num & ((1 << (SECTOR_SHIFT-1)) -1);
+ offset = clust_num << 1;
+ fat_sector = offset >> SECTOR_SHIFT(fs);
+ offset &= sector_mask;
cs = get_fat_sector(fs, fat_sector);
- next_cluster = ((uint16_t *)cs->data)[offset];
- if (next_cluster > 0xfff0)
- goto fail;
+ next_cluster = *(uint16_t *)(cs->data + offset);
break;
case FAT32:
- fat_sector = clust_num >> (SECTOR_SHIFT - 2);
- offset = clust_num & ((1 << (SECTOR_SHIFT-2)) -1);
+ offset = clust_num << 2;
+ fat_sector = offset >> SECTOR_SHIFT(fs);
+ offset &= sector_mask;
cs = get_fat_sector(fs, fat_sector);
- next_cluster = ((uint32_t *)cs->data)[offset] & 0x0fffffff;
- if (next_cluster > 0x0ffffff0)
- goto fail;
+ next_cluster = *(uint32_t *)(cs->data + offset);
+ next_cluster &= 0x0fffffff;
break;
}
return next_cluster;
-
-fail:
- /* got an unexcepted cluster number, so return ZERO */
- return 0;
}
static sector_t get_next_sector(struct fs_info* fs, uint32_t sector)
{
- sector_t data_area = FAT_SB(fs)->data;
+ struct fat_sb_info *sbi = FAT_SB(fs);
+ sector_t data_area = sbi->data;
sector_t data_sector;
uint32_t cluster;
+ int clust_shift = sbi->clust_shift;
if (sector < data_area) {
+ /* Root directory sector... */
sector++;
- /* if we reached the end of root area */
- if (sector == data_area)
- sector = 0; /* return 0 */
+ if (sector >= data_area)
+ sector = 0; /* Ran out of root directory, return EOF */
return sector;
}
data_sector = sector - data_area;
- if ((data_sector + 1) & FAT_SB(fs)->clust_mask) /* in a cluster */
- return ++sector;
-
+ if ((data_sector + 1) & sbi->clust_mask) /* Still in the same cluster */
+ return sector + 1; /* Next sector inside cluster */
+
/* get a new cluster */
- cluster = get_next_cluster(fs, (data_sector >> FAT_SB(fs)->clust_shift) + 2);
- if (!cluster )
+ cluster = data_sector >> clust_shift;
+ cluster = get_next_cluster(fs, cluster + 2) - 2;
+
+ if (cluster >= sbi->clusters)
return 0;
/* return the start of the new cluster */
- sector = ((cluster - 2) << FAT_SB(fs)->clust_shift) + data_area;
+ sector = (cluster << clust_shift) + data_area;
return sector;
}
@@ -145,16 +136,44 @@ static sector_t get_next_sector(struct fs_info* fs, uint32_t sector)
*/
static sector_t get_the_right_sector(struct file *file)
{
- int i = 0;
- int sector_pos = file->offset >> SECTOR_SHIFT;
- sector_t sector = *file->inode->data;
-
- for (; i < sector_pos; i++)
+ struct inode *inode = file->inode;
+ uint32_t sector_pos = file->offset >> SECTOR_SHIFT(file->fs);
+ uint32_t where;
+ sector_t sector;
+
+ if (sector_pos < PVT(inode)->offset) {
+ /* Reverse seek */
+ where = 0;
+ sector = PVT(inode)->start;
+ } else {
+ where = PVT(inode)->offset;
+ sector = PVT(inode)->here;
+ }
+
+ while (where < sector_pos) {
sector = get_next_sector(file->fs, sector);
+ where++;
+ }
+
+ PVT(inode)->offset = sector_pos;
+ PVT(inode)->here = sector;
return sector;
}
+/*
+ * Get the next sector in sequence
+ */
+static sector_t next_sector(struct file *file)
+{
+ struct inode *inode = file->inode;
+ sector_t sector = get_next_sector(file->fs, PVT(inode)->here);
+ PVT(inode)->offset++;
+ PVT(inode)->here = sector;
+
+ return sector;
+}
+
/**
* __getfssec:
*
@@ -180,31 +199,21 @@ static void __getfssec(struct fs_info *fs, char *buf,
do {
/* get consective sector count */
- con_sec_cnt ++;
- sectors --;
- if (sectors == 0)
- break;
-
+ con_sec_cnt++;
+ sectors--;
next_sector = get_next_sector(fs, curr_sector);
- if (!next_sector)
- break;
- }while(next_sector == (++curr_sector));
+ curr_sector++;
+ } while (sectors && next_sector == curr_sector);
-#if 0
- printf("You are reading data stored at sector --0x%x--0x%x\n",
- frag_start, frag_start + con_sec_cnt -1);
-#endif
+ PVT(file->inode)->offset += con_sec_cnt;
+ PVT(file->inode)->here = next_sector;
/* do read */
disk->rdwr_sectors(disk, buf, frag_start, con_sec_cnt, 0);
- buf += con_sec_cnt << SECTOR_SHIFT;/* adjust buffer pointer */
-
- if (!sectors)
- break;
+ buf += con_sec_cnt << SECTOR_SHIFT(fs);/* adjust buffer pointer */
curr_sector = next_sector;
}
-
}
@@ -298,68 +307,116 @@ static void vfat_mangle_name(char *dst, const char *src)
*/
static void mangle_dos_name(char *mangle_buf, char *src)
{
- char *dst = mangle_buf;
- int i = 0;
+ int i;
unsigned char c;
- for (; i < 11; i ++)
- mangle_buf[i] = ' ';
-
- for (i = 0; i < 11; i++) {
- c = *src ++;
+ i = 0;
+ while (i < 11) {
+ c = *src++;
if ((c <= ' ') || (c == '/'))
break;
if (c == '.') {
- dst = &mangle_buf[8];
- i = 7;
+ while (i < 8)
+ mangle_buf[i++] = ' ';
+ i = 8;
continue;
}
+
+ c = codepage.upper[c];
+ if (i == 0 && c == 0xe5)
+ c = 0x05; /* Special hack for the first byte only! */
- if (c >= 'a' && c <= 'z')
- c -= 32;
- if ((c == 0xe5) && (i == 11))
- c = 0x05;
-
- *dst++ = c;
+ mangle_buf[i++] = c;
}
- mangle_buf[11] = '\0';
-}
-
+ while (i < 11)
+ mangle_buf[i++] = ' ';
-/* try with the biggest long name */
-static char long_name[0x40 * 13];
-static char entry_name[14];
+ mangle_buf[i] = '\0';
+}
-static void unicode_to_ascii(char *entry_name, uint16_t *unicode_buf)
+/*
+ * Match a string name against a longname. "len" is the number of
+ * codepoints in the input; including padding.
+ *
+ * Returns true on match.
+ */
+static bool vfat_match_longname(const char *str, const uint16_t *match,
+ int len)
{
- int i = 0;
-
- for (; i < 13; i++) {
- if (unicode_buf[i] == 0xffff) {
- entry_name[i] = '\0';
- return;
- }
- entry_name[i] = (char)unicode_buf[i];
+ unsigned char c;
+ uint16_t cp;
+
+ while (len) {
+ cp = *match++;
+ c = *str++;
+ if (cp != codepage.uni[0][c] && cp != codepage.uni[1][c])
+ return false;
+ if (!c)
+ break;
}
+
+ if (c)
+ return false;
+
+ /* Any padding entries must be FFFF */
+ while (len)
+ if (*match++ != 0xffff)
+ return false;
+
+ return true;
}
/*
- * get the long entry name
- *
+ * Convert an UTF-16 longname to the system codepage; return
+ * the length on success or -1 on failure.
*/
-static void long_entry_name(struct fat_long_name_entry *dir)
+static int vfat_cvt_longname(char *entry_name, const uint16_t *long_name)
{
- uint16_t unicode_buf[13];
-
- memcpy(unicode_buf, dir->name1, 5 * 2);
- memcpy(unicode_buf + 5, dir->name2, 6 * 2);
- memcpy(unicode_buf + 11, dir->name3, 2 * 2);
-
- unicode_to_ascii(entry_name, unicode_buf);
+ struct unicache {
+ uint16_t utf16;
+ uint8_t cp;
+ };
+ static struct unicache unicache[256];
+ struct unicache *uc;
+ uint16_t cp;
+ unsigned int c;
+ char *p = entry_name;
+
+ do {
+ cp = *long_name++;
+ uc = &unicache[cp % 256];
+
+ if (__likely(uc->utf16 == cp)) {
+ *p++ = uc->cp;
+ } else {
+ for (c = 0; c < 512; c++) {
+ /* This is a bit hacky... */
+ if (codepage.uni[0][c] == cp) {
+ uc->utf16 = cp;
+ *p++ = uc->cp = (uint8_t)c;
+ goto found;
+ }
+ }
+ return -1; /* Impossible character */
+ found:
+ ;
+ }
+ } while (cp);
+
+ return (p-entry_name)-1;
}
+static void copy_long_chunk(uint16_t *buf, const struct fat_dir_entry *de)
+{
+ const struct fat_long_name_entry *le =
+ (const struct fat_long_name_entry *)de;
+
+ memcpy(buf, le->name1, 5 * 2);
+ memcpy(buf + 5, le->name2, 6 * 2);
+ memcpy(buf + 11, le->name3, 2 * 2);
+}
static uint8_t get_checksum(char *dir_name)
{
@@ -373,15 +430,16 @@ static uint8_t get_checksum(char *dir_name)
/* compute the first sector number of one dir where the data stores */
-static inline sector_t first_sector(struct fat_dir_entry *dir)
+static inline sector_t first_sector(struct fs_info *fs,
+ const struct fat_dir_entry *dir)
{
- struct fat_sb_info *sbi = FAT_SB(this_fs);
- uint32_t first_clust;
+ const struct fat_sb_info *sbi = FAT_SB(fs);
+ sector_t first_clust;
sector_t sector;
first_clust = (dir->first_cluster_high << 16) + dir->first_cluster_low;
sector = ((first_clust - 2) << sbi->clust_shift) + sbi->data;
-
+
return sector;
}
@@ -396,14 +454,17 @@ static inline int get_inode_mode(uint8_t attr)
static struct inode *vfat_find_entry(char *dname, struct inode *dir)
{
- struct inode *inode = new_fat_inode();
+ struct fs_info *fs = dir->fs;
+ struct inode *inode;
struct fat_dir_entry *de;
struct fat_long_name_entry *long_de;
struct cache_struct *cs;
- char mangled_name[12] = {0, };
- sector_t dir_sector = *dir->data;
-
+ char mangled_name[12];
+ uint16_t long_name[260]; /* == 20*13 */
+ int long_len;
+
+ sector_t dir_sector = PVT(dir)->start;
uint8_t vfat_init, vfat_next, vfat_csum = 0;
uint8_t id;
int slots;
@@ -411,16 +472,23 @@ static struct inode *vfat_find_entry(char *dname, struct inode *dir)
int checksum;
int long_match = 0;
- slots = (strlen(dname) + 12) / 13 ;
+ slots = (strlen(dname) + 12) / 13;
+ if (slots > 20)
+ return NULL; /* Name too long */
+
slots |= 0x40;
vfat_init = vfat_next = slots;
+ long_len = slots*13;
- while (1) {
- cs = get_cache_block(this_fs->fs_dev, dir_sector);
+ /* Produce the shortname version, in case we need it. */
+ mangle_dos_name(mangled_name, dname);
+
+ while (dir_sector) {
+ cs = get_cache_block(fs->fs_dev, dir_sector);
de = (struct fat_dir_entry *)cs->data;
- entries = 1 << (this_fs->sector_shift - 5);
+ entries = 1 << (fs->sector_shift - 5);
- while(entries--) {
+ while (entries--) {
if (de->name[0] == 0)
return NULL;
@@ -437,6 +505,7 @@ static struct inode *vfat_find_entry(char *dname, struct inode *dir)
/* get the initial checksum value */
vfat_csum = long_de->checksum;
id &= 0x3f;
+ long_len = id * 13;
/* ZERO the long_name buffer */
memset(long_name, 0, sizeof long_name);
@@ -448,19 +517,17 @@ static struct inode *vfat_find_entry(char *dname, struct inode *dir)
vfat_next = --id;
/* got the long entry name */
- long_entry_name(long_de);
- memcpy(long_name + id * 13, entry_name, 13);
+ copy_long_chunk(long_name + id*13, de);
/*
* If we got the last entry, check it.
* Or, go on with the next entry.
*/
if (id == 0) {
- if (strcmp(long_name, dname))
+ if (!vfat_match_longname(dname, long_name, long_len))
goto not_match;
long_match = 1;
}
-
de++;
continue; /* Try the next entry */
} else {
@@ -470,55 +537,52 @@ static struct inode *vfat_find_entry(char *dname, struct inode *dir)
if (de->attr & 0x08) /* ignore volume labels */
goto not_match;
- if (long_match == 1) {
+ if (long_match) {
/*
* We already have a VFAT long name match. However, the
* match is only valid if the checksum matches.
- *
- * Well, let's trun the long_match flag off first.
*/
- long_match = 0;
checksum = get_checksum(de->name);
if (checksum == vfat_csum)
goto found; /* Got it */
} else {
- if (mangled_name[0] == 0) {
- /* We haven't mangled it, mangle it first. */
- mangle_dos_name(mangled_name, dname);
- }
-
- if (!strncmp(mangled_name, de->name, 11))
+ if (!memcmp(mangled_name, de->name, 11))
goto found;
}
}
not_match:
vfat_next = vfat_init;
+ long_match = 0;
de++;
}
/* Try with the next sector */
- dir_sector = get_next_sector(this_fs, dir_sector);
- if (!dir_sector)
- return NULL;
+ dir_sector = get_next_sector(fs, dir_sector);
}
+ return NULL; /* Nothing found... */
found:
+ inode = new_fat_inode(fs);
inode->size = de->file_size;
- *inode->data = first_sector(de);
+ PVT(inode)->start = PVT(inode)->here = first_sector(fs, de);
inode->mode = get_inode_mode(de->attr);
return inode;
}
-static struct inode *vfat_iget_root(void)
+static struct inode *vfat_iget_root(struct fs_info *fs)
{
- struct inode *inode = new_fat_inode();
- int root_size = FAT_SB(this_fs)->root_size;
+ struct inode *inode = new_fat_inode(fs);
+ int root_size = FAT_SB(fs)->root_size;
- inode->size = root_size << this_fs->sector_shift;
- *inode->data = FAT_SB(this_fs)->root;
+ /*
+ * For FAT32, the only way to get the root directory size is to
+ * follow the entire FAT chain to the end... which seems pointless.
+ */
+ inode->size = root_size ? root_size << fs->sector_shift : ~0;
+ PVT(inode)->start = PVT(inode)->here = FAT_SB(fs)->root;
inode->mode = I_DIR;
return inode;
@@ -539,6 +603,9 @@ static struct dirent * vfat_readdir(struct file *file)
sector_t sector = get_the_right_sector(file);
+ uint16_t long_name[261]; /* == 20*13 + 1 (to guarantee null) */
+ char filename[261];
+
uint8_t vfat_init, vfat_next, vfat_csum;
uint8_t id;
int entries_left;
@@ -549,6 +616,8 @@ static struct dirent * vfat_readdir(struct file *file)
cs = get_cache_block(fs->fs_dev, sector);
de = (struct fat_dir_entry *)(cs->data + sec_off);
entries_left = ((1 << fs->sector_shift) - sec_off) >> 5;
+
+ vfat_next = vfat_csum = 0xff;
while (1) {
while(entries_left--) {
@@ -568,6 +637,9 @@ static struct dirent * vfat_readdir(struct file *file)
/* init vfat_csum and vfat_init */
vfat_csum = long_de->checksum;
id &= 0x3f;
+ if (id >= 20)
+ goto invalid; /* Too long! */
+
vfat_init = id;
/* ZERO the long_name buffer */
@@ -581,11 +653,14 @@ static struct dirent * vfat_readdir(struct file *file)
vfat_next = --id;
/* got the long entry name */
- long_entry_name(long_de);
- memcpy(long_name + id * 13, entry_name, 13);
-
- if (id == 0)
- long_entry = 1;
+ copy_long_chunk(long_name + id*13, de);
+
+ if (id == 0) {
+ int longlen =
+ vfat_cvt_longname(filename, long_name);
+ if (longlen > 0 && longlen < sizeof(dirent->d_name))
+ long_entry = 1;
+ }
de++;
file->offset += sizeof(struct fat_dir_entry);
@@ -603,26 +678,31 @@ static struct dirent * vfat_readdir(struct file *file)
if (checksum == vfat_csum)
goto got;
} else {
- /* Use the long_name buffer to store a short one. */
+ /* Use the shortname */
int i;
- char *p = long_name;
+ uint8_t c;
+ char *p = filename;
for (i = 0; i < 8; i++) {
- if (de->name[i] == ' ')
+ c = de->name[i];
+ if (c == ' ')
break;
- *p++ = de->name[i];
+ if (de->lcase & LCASE_BASE)
+ c = codepage.lower[c];
+ *p++ = c;
}
- *p++ = '.';
- if (de->name[8] == ' ') {
- *--p = '\0';
- } else {
+ if (de->name[8] != ' ') {
+ *p++ = '.';
for (i = 8; i < 11; i++) {
- if (de->name[i] == ' ')
+ c = de->name[i];
+ if (c == ' ')
break;
- *p++ = de->name[i];
+ if (de->lcase & LCASE_EXT)
+ c = codepage.lower[c];
+ *p++ = c;
}
- *p = '\0';
}
+ *p = '\0';
goto got;
}
@@ -634,7 +714,7 @@ static struct dirent * vfat_readdir(struct file *file)
}
/* Try with the next sector */
- sector = get_next_sector(fs, sector);
+ sector = next_sector(file);
if (!sector)
return NULL;
cs = get_cache_block(fs->fs_dev, sector);
@@ -647,12 +727,12 @@ got:
malloc_error("dirent structure in vfat_readdir");
return NULL;
}
- dirent->d_ino = 0; /* Inode number is invalid to FAT fs */
+ dirent->d_ino = de->first_cluster_low | (de->first_cluster_high << 16);
dirent->d_off = file->offset;
dirent->d_reclen = 0;
dirent->d_type = get_inode_mode(de->attr);
- strcpy(dirent->d_name, long_name);
-
+ strcpy(dirent->d_name, filename);
+
file->offset += sizeof(*de); /* Update for next reading */
return dirent;
@@ -710,24 +790,26 @@ static int vfat_fs_init(struct fs_info *fs)
struct fat_sb_info *sbi;
struct disk *disk = fs->fs_dev->disk;
int sectors_per_fat;
- uint32_t clust_num;
+ uint32_t clusters;
sector_t total_sectors;
fs->sector_shift = fs->block_shift = disk->sector_shift;
+ fs->sector_size = 1 << fs->sector_shift;
+ fs->block_size = 1 << fs->block_shift;
+
disk->rdwr_sectors(disk, &fat, 0, 1, 0);
sbi = malloc(sizeof(*sbi));
if (!sbi)
malloc_error("fat_sb_info structure");
fs->fs_info = sbi;
- this_fs = fs;
- sectors_per_fat = fat.bxFATsecs ? : fat.u.fat32.bxFATsecs_32;
+ sectors_per_fat = fat.bxFATsecs ? : fat.fat32.bxFATsecs_32;
total_sectors = fat.bxSectors ? : fat.bsHugeSectors;
sbi->fat = fat.bxResSectors;
sbi->root = sbi->fat + sectors_per_fat * fat.bxFATs;
- sbi->root_size = root_dir_size(&fat);
+ sbi->root_size = root_dir_size(fs, &fat);
sbi->data = sbi->root + sbi->root_size;
sbi->clust_shift = bsr(fat.bxSecPerClust);
@@ -735,13 +817,27 @@ static int vfat_fs_init(struct fs_info *fs)
sbi->clust_mask = fat.bxSecPerClust - 1;
sbi->clust_size = fat.bxSecPerClust << fs->sector_shift;
- clust_num = (total_sectors - sbi->data) >> sbi->clust_shift;
- if (clust_num < 4085)
+ clusters = (total_sectors - sbi->data) >> sbi->clust_shift;
+ if (clusters <= 0xff4) {
sbi->fat_type = FAT12;
- else if (clust_num < 65525)
+ } else if (clusters <= 0xfff4) {
sbi->fat_type = FAT16;
- else
+ } else {
sbi->fat_type = FAT32;
+
+ if (clusters > 0x0ffffff4)
+ clusters = 0x0ffffff4; /* Maximum possible */
+
+ if (fat.fat32.extended_flags & 0x80) {
+ /* Non-mirrored FATs, we need to read the active one */
+ sbi->fat += (fat.fat32.extended_flags & 0x0f) * sectors_per_fat;
+ }
+
+ /* FAT32: root directory is a cluster chain */
+ sbi->root = sbi->data
+ + ((fat.fat32.root_cluster-2) << sbi->clust_shift);
+ }
+ sbi->clusters = clusters;
/* for SYSLINUX, the cache is based on sector size */
return fs->sector_shift;
diff --git a/core/fs/fat/fat_fs.h b/core/fs/fat/fat_fs.h
index 9453a67f..60b5aee1 100644
--- a/core/fs/fat/fat_fs.h
+++ b/core/fs/fat/fat_fs.h
@@ -74,7 +74,7 @@ struct fat_bpb {
uint8_t fstype[8];
} __attribute__ ((packed)) fat32;
- } __attribute__ ((packed)) u;
+ } __attribute__ ((packed));
uint8_t pad[422]; /* padding to 512 Bytes (one sector) */
@@ -86,8 +86,10 @@ struct fat_bpb {
struct fat_sb_info {
sector_t fat; /* The FAT region */
sector_t root; /* The root dir region */
- int root_size; /* The root dir size in sectores */
sector_t data; /* The data region */
+
+ uint32_t clusters; /* Total number of clusters */
+ int root_size; /* The root dir size in sectores */
int clust_shift; /* based on sectors */
int clust_byte_shift; /* based on bytes */
@@ -100,7 +102,7 @@ struct fat_sb_info {
struct fat_dir_entry {
char name[11];
uint8_t attr;
- uint8_t nt_reserved;
+ uint8_t lcase;
uint8_t c_time_tenth;
uint16_t c_time;
uint16_t c_date;
@@ -112,7 +114,8 @@ struct fat_dir_entry {
uint32_t file_size;
} __attribute__ ((packed));
-
+#define LCASE_BASE 8 /* basename is lower case */
+#define LCASE_EXT 16 /* extension is lower case */
struct fat_long_name_entry {
uint8_t id;
@@ -133,13 +136,21 @@ static inline struct fat_sb_info *FAT_SB(struct fs_info *fs)
/*
* Count the root dir size in sectors
*/
-static inline int root_dir_size(struct fat_bpb *fat)
+static inline int root_dir_size(struct fs_info *fs, struct fat_bpb *fat)
{
- int sector_size = 1 << SECTOR_SHIFT;
-
- return (fat->bxRootDirEnts + sector_size / sizeof(struct fat_dir_entry)
- - 1) >> (SECTOR_SHIFT - 5);
+ return (fat->bxRootDirEnts + SECTOR_SIZE(fs)/32 - 1)
+ >> (SECTOR_SHIFT(fs) - 5);
}
+/*
+ * FAT private inode information
+ */
+struct fat_pvt_inode {
+ sector_t start; /* Starting sector */
+ sector_t offset; /* Current sector offset */
+ sector_t here; /* Sector corresponding to offset */
+};
+
+#define PVT(i) ((struct fat_pvt_inode *)((i)->pvt))
#endif /* fat_fs.h */
diff --git a/core/fs/iso9660/iso9660.c b/core/fs/iso9660/iso9660.c
index 1670e607..e6911644 100644
--- a/core/fs/iso9660/iso9660.c
+++ b/core/fs/iso9660/iso9660.c
@@ -7,24 +7,9 @@
#include <fs.h>
#include "iso9660_fs.h"
-static struct inode *new_iso_inode(void)
+static struct inode *new_iso_inode(struct fs_info *fs)
{
- struct inode *inode = malloc(sizeof(*inode));
-
- if (!inode) {
- malloc_error("inode structure in new_iso_inode");
- return NULL;
- }
- memset(inode, 0, sizeof(*inode));
-
- inode->data = malloc(sizeof(uint32_t));
- if (!inode) {
- malloc_error("inode->data in new_iso_inode");
- free(inode);
- return NULL;
- }
-
- return inode;
+ return alloc_inode(fs, 0, sizeof(uint32_t));
}
@@ -165,8 +150,9 @@ static uint32_t iso_getfssec(struct file *file, char *buf,
uint32_t bytes_left = file->inode->size - file->offset;
uint32_t blocks_left = (bytes_left + BLOCK_SIZE(file->fs) - 1)
>> file->fs->block_shift;
- block_t block = *file->inode->data + (file->offset >> fs->block_shift);
-
+ block_t block = *(uint32_t *)file->inode->pvt
+ + (file->offset >> fs->block_shift);
+
if (blocks > blocks_left)
blocks = blocks_left;
cdrom_read_blocks(disk, buf, block, blocks);
@@ -187,7 +173,8 @@ static uint32_t iso_getfssec(struct file *file, char *buf,
*/
static struct iso_dir_entry *iso_find_entry(char *dname, struct inode *inode)
{
- block_t dir_block = *inode->data;
+ struct fs_info *fs = inode->fs;
+ block_t dir_block = *(uint32_t *)inode->pvt;
int i = 0, offset = 0;
char *de_name;
int de_name_len, de_len;
@@ -199,7 +186,7 @@ static struct iso_dir_entry *iso_find_entry(char *dname, struct inode *inode)
if (!cs) {
if (++i > inode->blocks)
return NULL;
- cs = get_cache_block(this_fs->fs_dev, dir_block++);
+ cs = get_cache_block(fs->fs_dev, dir_block++);
de = (struct iso_dir_entry *)cs->data;
offset = 0;
}
@@ -213,15 +200,15 @@ static struct iso_dir_entry *iso_find_entry(char *dname, struct inode *inode)
offset += de_len;
/* Make sure we have a full directory entry */
- if (offset >= BLOCK_SIZE(this_fs)) {
- int slop = de_len + BLOCK_SIZE(this_fs) - offset;
+ if (offset >= BLOCK_SIZE(fs)) {
+ int slop = de_len + BLOCK_SIZE(fs) - offset;
memcpy(&tmpde, de, slop);
- offset &= BLOCK_SIZE(this_fs) - 1;
+ offset &= BLOCK_SIZE(fs) - 1;
if (offset) {
if (++i > inode->blocks)
return NULL;
- cs = get_cache_block(this_fs->fs_dev, dir_block++);
+ cs = get_cache_block(fs->fs_dev, dir_block++);
memcpy((void *)&tmpde + slop, cs->data, offset);
}
de = &tmpde;
@@ -255,35 +242,36 @@ static inline int get_inode_mode(uint8_t flags)
return I_FILE;
}
-static struct inode *iso_get_inode(struct iso_dir_entry *de)
+static struct inode *iso_get_inode(struct fs_info *fs,
+ struct iso_dir_entry *de)
{
- struct inode *inode = new_iso_inode();
-
+ struct inode *inode = new_iso_inode(fs);
if (!inode)
return NULL;
+
inode->mode = get_inode_mode(de->flags);
inode->size = *(uint32_t *)de->size;
- *inode->data = *(uint32_t *)de->extent;
- inode->blocks = (inode->size + BLOCK_SIZE(this_fs) - 1)
- >> this_fs->block_shift;
+ *(uint32_t *)inode->pvt = *(uint32_t *)de->extent;
+ inode->blocks = (inode->size + BLOCK_SIZE(fs) - 1)
+ >> fs->block_shift;
return inode;
}
-static struct inode *iso_iget_root(void)
+static struct inode *iso_iget_root(struct fs_info *fs)
{
- struct inode *inode = new_iso_inode();
- struct iso_dir_entry *root = &ISO_SB(this_fs)->root;
+ struct inode *inode = new_iso_inode(fs);
+ struct iso_dir_entry *root = &ISO_SB(fs)->root;
if (!inode)
return NULL;
inode->mode = I_DIR;
inode->size = *(uint32_t *)root->size;
- *inode->data = *(uint32_t *)root->extent;
- inode->blocks = (inode->size + BLOCK_SIZE(this_fs) - 1)
- >> this_fs->block_shift;
+ *(uint32_t *)inode->pvt = *(uint32_t *)root->extent;
+ inode->blocks = (inode->size + BLOCK_SIZE(fs) - 1)
+ >> fs->block_shift;
return inode;
}
@@ -296,7 +284,7 @@ static struct inode *iso_iget(char *dname, struct inode *parent)
if (!de)
return NULL;
- return iso_get_inode(de);
+ return iso_get_inode(parent->fs, de);
}
/* Convert to lower case string */
@@ -316,7 +304,8 @@ static struct dirent *iso_readdir(struct file *file)
struct iso_dir_entry *de, tmpde;
struct dirent *dirent;
struct cache_struct *cs = NULL;
- block_t block = *file->inode->data + (file->offset >> fs->block_shift);
+ block_t block = *(uint32_t *)file->inode->pvt
+ + (file->offset >> fs->block_shift);
int offset = file->offset & (BLOCK_SIZE(fs) - 1);
int i = 0;
int de_len, de_name_len;
@@ -427,8 +416,6 @@ static int iso_fs_init(struct fs_info *fs)
{
struct iso_sb_info *sbi;
- this_fs = fs;
-
sbi = malloc(sizeof(*sbi));
if (!sbi) {
malloc_error("iso_sb_info structure");
@@ -438,8 +425,12 @@ static int iso_fs_init(struct fs_info *fs)
cdrom_read_blocks(fs->fs_dev->disk, trackbuf, 16, 1);
memcpy(&sbi->root, trackbuf + ROOT_DIR_OFFSET, sizeof(sbi->root));
-
- fs->block_shift = 11;
+
+ fs->sector_shift = fs->fs_dev->disk->sector_shift;
+ fs->block_shift = 11;
+ fs->sector_size = 1 << fs->sector_shift;
+ fs->block_size = 1 << fs->block_shift;
+
return fs->block_shift;
}
diff --git a/core/fs/pxe/pxe.c b/core/fs/pxe/pxe.c
index 1bbb6b0a..ea26ef61 100644
--- a/core/fs/pxe/pxe.c
+++ b/core/fs/pxe/pxe.c
@@ -24,7 +24,8 @@ char path_prefix[256];
char dot_quad_buf[16];
static struct open_file_t Files[MAX_OPEN];
-static int has_gpxe;
+static bool has_gpxe;
+static uint32_t gpxe_funcs;
static uint8_t uuid_dashes[] = {4, 2, 2, 2, 6, 0};
int have_uuid = 0;
@@ -35,7 +36,7 @@ const uint8_t TimeoutTable[] = {
/* PXE unload sequences */
const uint8_t new_api_unload[] = {
- PXENV_UDP_CLOSE, PXENV_UNDI_SHUTDOWN,
+ PXENV_UDP_CLOSE, PXENV_UNDI_SHUTDOWN,
PXENV_UNLOAD_STACK, PXENV_STOP_UNDI, 0
};
const uint8_t old_api_unload[] = {
@@ -79,20 +80,20 @@ static void files_init(void)
/*
* Allocate a local UDP port structure.
* return the socket pointer if success, or null if failure
- *
+ *
*/
static struct open_file_t *allocate_socket(void)
{
int i;
struct open_file_t *socket = Files;
uint16_t nextport;
-
+
for (i = 0; i < MAX_OPEN; i++) {
if (!socket->tftp_localport)
break;
socket++;
}
-
+
if (i == MAX_OPEN)
return NULL;
@@ -128,7 +129,7 @@ static void pxe_close_file(struct file *file)
}
/**
- * Take a nubmer of bytes in memory and convert to lower-case hxeadecimal
+ * Take a nubmer of bytes in memory and convert to lower-case hxeadecimal
*
* @param: dst, output buffer
* @param: src, input buffer
@@ -140,12 +141,12 @@ static void lchexbytes(char *dst, const void *src, int count)
uint8_t half;
uint8_t c;
const uint8_t *s = src;
-
+
for(; count > 0; count--) {
c = *s++;
half = ((c >> 4) & 0x0f) + '0';
*dst++ = half > '9' ? (half + 'a' - '9' - 1) : half;
-
+
half = (c & 0x0f) + '0';
*dst++ = half > '9' ? (half + 'a' - '9' - 1) : half;
}
@@ -160,12 +161,12 @@ static void uchexbytes(char *dst, const void *src, int count)
uint8_t half;
uint8_t c;
const uint8_t *s = src;
-
+
for(; count > 0; count--) {
c = *s++;
half = ((c >> 4) & 0x0f) + '0';
*dst++ = half > '9' ? (half + 'A' - '9' - 1) : half;
-
+
half = (c & 0x0f) + '0';
*dst++ = half > '9' ? (half + 'A' - '9' - 1) : half;
}
@@ -201,7 +202,7 @@ static int gendotquad(char *dst, uint32_t ip)
int i = 0, j;
char temp[4];
char *p = dst;
-
+
for (; i < 4; i++) {
j = 0;
part = ip & 0xff;
@@ -211,12 +212,12 @@ static int gendotquad(char *dst, uint32_t ip)
for (; j > 0; j--)
*p++ = temp[j-1];
*p++ = '.';
-
+
ip >>= 8;
}
/* drop the last dot '.' and zero-terminate string*/
*(--p) = 0;
-
+
return p - dst;
}
@@ -231,44 +232,44 @@ static const char *parse_dotquad(const char *ip_str, uint32_t *res)
int i = 0;
uint8_t part = 0;
uint32_t ip = 0;
-
+
for (; i < 4; i++) {
while (is_digit(*p)) {
part = part * 10 + *p - '0';
p++;
}
- if (i != 3 && *p != '.')
+ if (i != 3 && *p != '.')
return NULL;
-
+
ip = (ip << 8) | part;
part = 0;
p++;
}
p --;
-
+
*res = ip;
- return p;
+ return p;
}
-
+
/*
* the ASM pxenv function wrapper, return 1 if error, or 0
*
- */
+ */
int pxe_call(int opcode, void *data)
{
extern void pxenv(void);
com32sys_t regs;
-
+
#if 0
printf("pxe_call op %04x data %p\n", opcode, data);
#endif
- memset(&regs, 0, sizeof regs);
+ memset(&regs, 0, sizeof regs);
regs.ebx.w[0] = opcode;
regs.es = SEG(data);
regs.edi.w[0] = OFFS(data);
call16(pxenv, &regs, &regs);
-
+
return regs.eflags.l & EFLAGS_CF; /* CF SET if fail */
}
@@ -294,7 +295,7 @@ static void tftp_error(struct open_file_t *file, uint16_t errnum,
err_buf.err_num = errnum;
memcpy(err_buf.err_msg, errstr, len);
err_buf.err_msg[len] = '\0';
-
+
udp_write.src_port = file->tftp_localport;
udp_write.dst_port = file->tftp_remoteport;
udp_write.ip = file->tftp_remoteip;
@@ -304,7 +305,7 @@ static void tftp_error(struct open_file_t *file, uint16_t errnum,
/* If something goes wrong, there is nothing we can do, anyway... */
pxe_call(PXENV_UDP_WRITE, &udp_write);
-}
+}
/**
@@ -312,14 +313,14 @@ static void tftp_error(struct open_file_t *file, uint16_t errnum,
*
* @param: file, TFTP block pointer
* @param: ack_num, Packet # to ack (network byte order)
- *
+ *
*/
static void ack_packet(struct open_file_t *file, uint16_t ack_num)
{
int err;
static __lowmem uint16_t ack_packet_buf[2];
- static __lowmem struct s_PXENV_UDP_WRITE udp_write;
-
+ static __lowmem struct s_PXENV_UDP_WRITE udp_write;
+
/* Packet number to ack */
ack_packet_buf[0] = TFTP_ACK;
ack_packet_buf[1] = ack_num;
@@ -342,14 +343,14 @@ static void ack_packet(struct open_file_t *file, uint16_t ack_num)
*
* @param: type, packet type
* @return: buffer size
- *
+ *
*/
static int pxe_get_cached_info(int type)
{
int err;
static __lowmem struct s_PXENV_GET_CACHED_INFO get_cached_info;
printf(" %02x", type);
-
+
get_cached_info.Status = 0;
get_cached_info.PacketType = type;
get_cached_info.BufferSize = 8192;
@@ -359,61 +360,45 @@ static int pxe_get_cached_info(int type)
printf("PXE API call failed, error %04x\n", err);
kaboom();
}
-
+
return get_cached_info.BufferSize;
}
-
+
#if GPXE
/*
- * Return 1 if and only if the buffer pointed to by
- * url is a URL (contains ://)
- *
+ * Return true if and only if the buffer pointed to by
+ * url is a URL -- it must contain :// and it must be the
+ * first colon.
*/
-static int is_url(const char *url)
+static inline bool is_url(const char *url)
{
- while (*url) {
- if (!strncmp(url, "://", 3))
- return 1;
-
- url++;
- }
- return 0;
+ const char *p = strchr(url, ':');
+
+ return p && p[1] == '/' && p[2] == '/';
}
/*
- * Return CF=0 if and only if the buffer pointed to by DS:SI is a URL
- * (contains ://) *and* the gPXE extensions API is available. No
+ * Return CF=0 if and only if the buffer pointed to by DS:SI is a URL
+ * (contains ://) *and* the gPXE extensions API is available. No
* registers modified.
*/
-static int is_gpxe(char *url)
+static bool is_gpxe(const char *url)
{
- int err;
- static __lowmem struct s_PXENV_FILE_API_CHECK api_check;
- char *gpxe_warning_msg =
- "URL syntax, but gPXE extensions not detected, tring plain TFTP...\n";
-
- if (! is_url(url))
- return 0;
-
- api_check.Size = sizeof api_check;
- api_check.Magic = 0x91d447b2;
- /* If has_gpxe is greater than one, means the gpxe status is unknow */
- while (has_gpxe > 1) {
- err = pxe_call(PXENV_FILE_API_CHECK, &api_check);
- if (err || api_check.Magic != 0xe9c17b20)
- printf("%s\n", gpxe_warning_msg);
- else
- has_gpxe = (~api_check.Provider & 0xffff) & 0x4b ? 0 : 1;
-
- if (!has_gpxe)
- printf("%s\n", gpxe_warning_msg);
+ static bool already;
+
+ if (!is_url(url))
+ return false;
+
+ if (!has_gpxe && !already) {
+ fputs("URL syntax, but gPXE extensions not detected, tring plain TFTP...\n", stdout);
+ already = true;
}
-
- return has_gpxe == 1;
+
+ return has_gpxe;
}
/**
@@ -425,7 +410,7 @@ static void get_packet_gpxe(struct open_file_t *file)
{
static __lowmem struct s_PXENV_FILE_READ file_read;
int err;
-
+
while (1) {
file_read.FileHandle = file->tftp_remoteport;
file_read.Buffer.offs = file->tftp_pktbuf;
@@ -439,14 +424,15 @@ static void get_packet_gpxe(struct open_file_t *file)
kaboom();
}
+ file->tftp_dataptr = file->tftp_pktbuf;
file->tftp_bytesleft = file_read.BufferSize;
file->tftp_filepos += file_read.BufferSize;
-
+
if (file->tftp_bytesleft == 0)
file->tftp_filesize = file->tftp_filepos;
-
+
/* if we're done here, close the file */
- if (file->tftp_filesize > file->tftp_filepos)
+ if (file->tftp_filesize > file->tftp_filepos)
return;
/* Got EOF, close it */
@@ -469,7 +455,7 @@ static void pxe_mangle_name(char *dst, const char *src)
const char *p = src;
uint32_t ip = server_ip;
int i = 0;
-
+
#if GPXE
if (is_url(src)) {
ip = -1;
@@ -503,9 +489,9 @@ static void pxe_mangle_name(char *dst, const char *src)
}
}
}
-
+
store:
- *(uint32_t *)dst = ip;
+ *(uint32_t *)dst = ip;
dst += 4;
i = FILENAME_MAX - 5;
@@ -525,14 +511,14 @@ static void pxe_mangle_name(char *dst, const char *src)
/*
* Does the opposite of mangle_name; converts a DOS-mangled
- * filename to the conventional representation. This is
+ * filename to the conventional representation. This is
* needed for the BOOT_IMAGE= parameter for the kernel.
*/
static char *pxe_unmangle_name(char *dst, const char *src)
{
uint32_t ip = *(uint32_t *)src;
int ip_len = 0;
-
+
if (ip != 0 && ip != -1) {
ip_len = gendotquad(dst, *(uint32_t *)src);
dst += ip_len;
@@ -540,7 +526,7 @@ static char *pxe_unmangle_name(char *dst, const char *src)
src += 4;
return stpcpy(dst, src);
}
-
+
/*
* Get a fresh packet if the buffer is drained, and we haven't hit
* EOF yet. The buffer should be filled immediately after draining!
@@ -555,7 +541,7 @@ static void fill_buffer(struct open_file_t *file)
uint32_t oldtime;
void *data = NULL;
static __lowmem struct s_PXENV_UDP_READ udp_read;
-
+
if (file->tftp_bytesleft || file->tftp_goteof)
return;
@@ -571,10 +557,10 @@ static void fill_buffer(struct open_file_t *file)
* Start by ACKing the previous packet; this should cause
* the next packet to be sent.
*/
- ack_again:
+ ack_again:
ack_packet(file, file->tftp_lastpkt);
-
- timeout_ptr = TimeoutTable;
+
+ timeout_ptr = TimeoutTable;
timeout = *timeout_ptr++;
oldtime = jiffies();
while (timeout) {
@@ -597,14 +583,14 @@ static void fill_buffer(struct open_file_t *file)
}
continue;
}
-
+
if (udp_read.buffer_size < 4) /* Bad size for a DATA packet */
- continue;
+ continue;
data = MK_PTR(PKTBUF_SEG, file->tftp_pktbuf);
if (*(uint16_t *)data != TFTP_DATA) /* Not a data packet */
continue;
-
+
/* If goes here, recevie OK, break */
break;
}
@@ -612,7 +598,7 @@ static void fill_buffer(struct open_file_t *file)
/* time runs out */
if (timeout == 0)
kaboom();
-
+
last_pkt = file->tftp_lastpkt;
last_pkt = ntohs(last_pkt); /* Host byte order */
last_pkt++;
@@ -629,7 +615,7 @@ static void fill_buffer(struct open_file_t *file)
#endif
goto ack_again;
}
-
+
/* It's the packet we want. We're also EOF if the size < blocksize */
file->tftp_lastpkt = last_pkt; /* Update last packet number */
buffersize = udp_read.buffer_size - 4; /* Skip TFTP header */
@@ -655,11 +641,11 @@ static void fill_buffer(struct open_file_t *file)
* @param: buf, buffer to store the read data
* @param: openfile, TFTP socket pointer
* @param: blocks, 512-byte block count; 0FFFFh = until end of file
- *
+ *
* @return: the bytes read
*
*/
-static uint32_t pxe_getfssec(struct file *gfile, char *buf,
+static uint32_t pxe_getfssec(struct file *gfile, char *buf,
int blocks, bool *have_more)
{
struct open_file_t *file = gfile->open_file;
@@ -672,7 +658,7 @@ static uint32_t pxe_getfssec(struct file *gfile, char *buf,
fill_buffer(file); /* If we have no 'fresh' buffer, get it */
if (!file->tftp_bytesleft)
break;
-
+
chunk = count;
if (chunk > file->tftp_bytesleft)
chunk = file->tftp_bytesleft;
@@ -684,22 +670,22 @@ static uint32_t pxe_getfssec(struct file *gfile, char *buf,
count -= chunk;
}
-
+
if (file->tftp_bytesleft || (file->tftp_filepos < file->tftp_filesize)) {
fill_buffer(file);
*have_more = 1;
} else if (file->tftp_goteof) {
- /*
+ /*
* The socket is closed and the buffer drained; the caller will
* call close_file and therefore free the socket.
*/
*have_more = 0;
}
-
+
return bytes_read;
}
-
+
/*
* Fill the packet tail with the tftp informations then retures the lenght
@@ -707,7 +693,7 @@ static uint32_t pxe_getfssec(struct file *gfile, char *buf,
static int fill_tail(char *dst)
{
static const char tail[] = "octet\0""tsize\0""0\0""blksize\0""1408";
-
+
memcpy(dst, tail, sizeof tail);
return sizeof tail;
}
@@ -732,7 +718,6 @@ static void pxe_searchdir(char *filename, struct file *file)
static __lowmem struct s_PXENV_UDP_WRITE udp_write;
static __lowmem struct s_PXENV_UDP_READ udp_read;
static __lowmem struct s_PXENV_FILE_OPEN file_open;
- static __lowmem struct s_PXENV_GET_FILE_SIZE get_file_size;
const struct tftp_options *tftp_opt;
int i = 0;
int err;
@@ -745,14 +730,14 @@ static void pxe_searchdir(char *filename, struct file *file)
uint16_t blk_num;
uint32_t ip;
uint32_t opdata, *opdata_ptr;
-
+
open_file = allocate_socket();
if (!open_file) {
file->file_len = 0;
file->open_file = NULL;
return;
}
-
+
timeout_ptr = TimeoutTable; /* Reset timeout */
sendreq:
@@ -760,7 +745,7 @@ static void pxe_searchdir(char *filename, struct file *file)
udp_write.buffer.seg = 0;
*(uint16_t *)buf = TFTP_RRQ; /* TFTP opcode */
buf += 2;
-
+
ip = *(uint32_t *)p; /* ip <- server override (if any) */
p += 4;
if (ip == 0) {
@@ -772,31 +757,23 @@ static void pxe_searchdir(char *filename, struct file *file)
strcpy(buf, p); /* Copy the filename */
buf += strlen(p) + 1; /* advance the pointer, null char included */
-
+
#if GPXE
if (is_gpxe(packet_buf + 2)) {
file_open.Status = PXENV_STATUS_BAD_FUNC;
- file_open.FileName.offs = OFFS_WRT(packet_buf + 2, 0);
- file_open.FileName.seg = 0;
+ file_open.FileName.offs = OFFS(packet_buf + 2);
+ file_open.FileName.seg = SEG(packet_buf + 2);
err = pxe_call(PXENV_FILE_OPEN, &file_open);
- if (err)
+ if (err)
goto done;
-
+
open_file->tftp_localport = -1;
open_file->tftp_remoteport = file_open.FileHandle;
- get_file_size.FileHandle = file_open.FileHandle;
-
-#if 0
- err = pxe_call(PXENV_GET_FILE_SIZE, &get_file_size);
- if (!err)
- open_file->tftp_filesize = get_file_size.FileSize;
- else
-#endif
- open_file->tftp_filesize = -1;
+ open_file->tftp_filesize = -1;
goto done;
}
#endif /* GPXE */
-
+
open_file->tftp_remoteip = ip;
tid = open_file->tftp_localport; /* TID(local port No) */
udp_write.ip = ip;
@@ -807,7 +784,7 @@ static void pxe_searchdir(char *filename, struct file *file)
udp_write.buffer_size = buf - packet_buf;
err = pxe_call(PXENV_UDP_WRITE, &udp_write);
if (err || udp_write.status != 0)
- goto failure; /*
+ goto failure; /*
* In fact, the 'failure' target will not do
* a failure thing; it will move on to the
* next timeout, then tries again until
@@ -818,7 +795,7 @@ static void pxe_searchdir(char *filename, struct file *file)
* Danger, Will Robinson! We need to support tiemout
* and retry lest we just lost a packet ...
*/
-
+
/* Packet transmitted OK, now we need to receive */
timeout = *timeout_ptr++;
oldtime = jiffies();
@@ -841,11 +818,11 @@ static void pxe_searchdir(char *filename, struct file *file)
if (udp_read.src_ip == open_file->tftp_remoteip)
break;
}
-
+
/* Got packet; reset timeout */
timeout_ptr = TimeoutTable;
open_file->tftp_remoteport = udp_read.s_port;
-
+
/* filesize <- -1 == unknown */
open_file->tftp_filesize = -1;
/* Default blksize unless blksize option negotiated */
@@ -853,9 +830,9 @@ static void pxe_searchdir(char *filename, struct file *file)
buffersize = udp_read.buffer_size - 2; /* bytes after opcode */
if (buffersize < 0)
goto failure; /* Garbled reply */
-
+
/*
- * Get the opcode type, and parse it
+ * Get the opcode type, and parse it
*/
opcode = *(uint16_t *)packet_buf;
switch (opcode) {
@@ -870,9 +847,9 @@ static void pxe_searchdir(char *filename, struct file *file)
* buffer and go with the default value for all options...
*
* We got a DATA packet, meaning no options are
- * suported. Save the data away and consider the
- * length undefined, *unless* this is the only
- * data packet...
+ * suported. Save the data away and consider the
+ * length undefined, *unless* this is the only
+ * data packet...
*/
buffersize -= 2;
if (buffersize < 0)
@@ -886,9 +863,9 @@ static void pxe_searchdir(char *filename, struct file *file)
if (buffersize > TFTP_BLOCKSIZE)
goto err_reply; /* Corrupt */
else if (buffersize < TFTP_BLOCKSIZE) {
- /*
+ /*
* This is the final EOF packet, already...
- * We know the filesize, but we also want to
+ * We know the filesize, but we also want to
* ack the packet and set the EOF flag.
*/
open_file->tftp_filesize = buffersize;
@@ -902,14 +879,14 @@ static void pxe_searchdir(char *filename, struct file *file)
break;
case TFTP_OACK:
- /*
+ /*
* Now we need to parse the OACK packet to get the transfer
* and packet sizes.
*/
options = packet_buf + 2;
p = options;
-
+
while (buffersize) {
char *opt = p;
@@ -940,7 +917,7 @@ static void pxe_searchdir(char *filename, struct file *file)
if (!buffersize)
break; /* No option data */
- /*
+ /*
* Parse option pointed to by options; guaranteed to be
* null-terminated
*/
@@ -953,11 +930,11 @@ static void pxe_searchdir(char *filename, struct file *file)
if (i == tftp_nopts)
goto err_reply; /* Non-negotitated option returned,
no idea what it means ...*/
-
+
/* get the address of the filed that we want to write on */
opdata_ptr = (uint32_t *)((char *)open_file + tftp_opt->offset);
opdata = 0;
-
+
/* do convert a number-string to decimal number, just like atoi */
while (buffersize--) {
uint8_t d = *p++;
@@ -971,12 +948,12 @@ static void pxe_searchdir(char *filename, struct file *file)
*opdata_ptr = opdata;
}
break;
-
+
default:
printf("TFTP unknown opcode %d\n", ntohs(opcode));
goto err_reply;
}
-
+
done:
if (!open_file->tftp_filesize) {
free_socket(open_file);
@@ -993,13 +970,13 @@ err_reply:
tftp_error(open_file, TFTP_EOPTNEG, "TFTP protocol error");
printf("TFTP server sent an incomprehesible reply\n");
kaboom();
-
+
failure:
timeout_ptr++;
if (*timeout_ptr)
goto sendreq; /* Try again */
}
-
+
/*
* Store standard filename prefix
@@ -1009,30 +986,30 @@ static void get_prefix(void)
int len;
char *p;
char c;
-
+
if (DHCPMagic & 0x04) /* Did we get a path prefix option */
goto got_prefix;
-
+
strcpy(path_prefix, boot_file);
len = strlen(path_prefix);
- p = &path_prefix[len - 1];
+ p = &path_prefix[len - 1];
while (len--) {
c = *p--;
c |= 0x20;
-
- c = (c >= '0' && c <= '9') ||
- (c >= 'a' && c <= 'z') ||
+
+ c = (c >= '0' && c <= '9') ||
+ (c >= 'a' && c <= 'z') ||
(c == '.' || c == '-');
if (!c)
break;
};
-
+
if (len < 0)
p --;
*(p + 2) = 0; /* Zero-terminate after delimiter */
-
+
got_prefix:
printf("TFTP prefix: %s\n", path_prefix);
strcpy(CurrentDirName, path_prefix);
@@ -1041,14 +1018,14 @@ static void get_prefix(void)
/*
* try to load a config file, if found, return 1, or return 0
*
- */
+ */
static int try_load(char *config_name)
{
com32sys_t regs;
-
+
printf("Trying to load: %-50s ", config_name);
pxe_mangle_name(KernelName, config_name);
-
+
memset(&regs, 0, sizeof regs);
regs.edi.w[0] = OFFS_WRT(KernelName, 0);
call16(core_open, &regs, &regs);
@@ -1069,23 +1046,23 @@ static int pxe_load_config(void)
const char *default_str = "default";
char *config_file;
char *last;
- char *p;
+ char *p;
uint8_t *uuid_ptr;
int tries = 8;
-
+
get_prefix();
if (DHCPMagic & 0x02) {
/* We got a DHCP option, try it first */
if (try_load(boot_file))
return 0;
}
-
+
/*
* Have to guess config file name ...
- */
+ */
memcpy(ConfigName, cfgprefix, strlen(cfgprefix));
config_file = ConfigName + strlen(cfgprefix);
-
+
/* Try loading by UUID */
if (have_uuid) {
uuid_ptr = uuid_dashes;
@@ -1093,7 +1070,7 @@ static int pxe_load_config(void)
while (*uuid_ptr) {
int len = *uuid_ptr;
char *src = uuid;
-
+
lchexbytes(p, src, len);
p += len * 2;
src += len;
@@ -1110,7 +1087,7 @@ static int pxe_load_config(void)
strcpy(config_file, MAC_str);
if (try_load(ConfigName))
return 0;
-
+
/* Nope, try hexadecimal IP prefixes... */
uchexbytes(config_file, (uint8_t *)&MyIP, 4); /* Convet to hex string */
last = &config_file[8];
@@ -1121,7 +1098,7 @@ static int pxe_load_config(void)
last--; /* Drop one character */
tries--;
};
-
+
/* Final attempt: "default" string */
strcpy(config_file, default_str);
if (try_load(ConfigName))
@@ -1132,7 +1109,7 @@ static int pxe_load_config(void)
}
/*
- * Generate the botif string, and the hardware-based config string
+ * Generate the botif string, and the hardware-based config string
*/
static void make_bootif_string(void)
{
@@ -1140,7 +1117,7 @@ static void make_bootif_string(void)
char *src = mac;
char *dst = MAC_str;
int i = MAC_len + 1;
-
+
*(uint8_t *)src++ = MAC_type;
memcpy(src, MAC, MAC_len);
src = mac;
@@ -1167,10 +1144,10 @@ static void genipopt(void)
{
char *p = IPOption;
int ip_len;
-
+
strcpy(p, "ip=");
p += 3;
-
+
ip_len = gendotquad(p, MyIP);
p += ip_len;
*p++ = ':';
@@ -1182,19 +1159,19 @@ static void genipopt(void)
ip_len = gendotquad(p, gate_way);
p += ip_len;
*p++ = ':';
-
+
ip_len = gendotquad(p, net_mask);
}
-
+
/* Generate ip= option and print the ip adress */
static void ip_init(void)
{
uint32_t ip = MyIP;
-
+
genipopt();
gendotquad(dot_quad_buf, ip);
-
+
ip = ntohl(ip);
printf("My IP address seems to be %08X %s\n", ip, dot_quad_buf);
printf("%s\n", IPOption);
@@ -1232,7 +1209,7 @@ static int is_pxenv(const void *buf)
const uint8_t *p = buf;
int i = pxenv->length;
uint8_t sum = 0;
-
+
/* The pxeptr field isn't present in old versions */
if (i < offsetof(struct pxenv_t, pxeptr) ||
memcmp(pxenv->signature, "PXENV+", 6))
@@ -1243,7 +1220,7 @@ static int is_pxenv(const void *buf)
return sum == 0;
}
-
+
/*
@@ -1267,14 +1244,14 @@ static const void *memory_scan(uintptr_t start, int (*func)(const void *))
}
return NULL;
}
-
+
static const struct pxe_t *memory_scan_for_pxe_struct(void)
{
extern uint16_t BIOS_fbm; /* Starting segment */
return memory_scan(BIOS_fbm << 10, is_pxe);
}
-
+
static const struct pxenv_t *memory_scan_for_pxenv_struct(void)
{
return memory_scan(0x10000, is_pxenv);
@@ -1289,8 +1266,8 @@ static const struct pxenv_t *memory_scan_for_pxenv_struct(void)
* d. Search memory for !PXE
* e. Search memory for PXENV+
*
- * If we find a PXENV+ structure, we try to find a !PXE structure from
- * if if the API version is 2.1 or later
+ * If we find a PXENV+ structure, we try to find a !PXE structure from
+ * if if the API version is 2.1 or later
*
*/
static int pxe_init(void)
@@ -1300,7 +1277,7 @@ static int pxe_init(void)
uint16_t seg, off;
uint16_t code_seg, code_len;
uint16_t data_seg, data_len;
- char *base = GET_PTR(InitStack);
+ const char *base = GET_PTR(InitStack);
com32sys_t regs;
const char *type;
const struct pxenv_t *pxenv;
@@ -1308,18 +1285,18 @@ static int pxe_init(void)
/* Assume API version 2.1 */
APIVer = 0x201;
-
+
/* Plan A: !PXE structure as SS:[SP + 4] */
- off = *(uint16_t *)(base + 48);
- seg = *(uint16_t *)(base + 50);
+ off = *(const uint16_t *)(base + 48);
+ seg = *(const uint16_t *)(base + 50);
pxe = MK_PTR(seg, off);
- if (is_pxe(pxe))
+ if (is_pxe(pxe))
goto have_pxe;
/* Plan B: PXENV+ structure at [ES:BX] */
plan++;
- off = *(uint16_t *)(base + 24); /* Original BX */
- seg = *(uint16_t *)(base + 4); /* Original ES */
+ off = *(const uint16_t *)(base + 24); /* Original BX */
+ seg = *(const uint16_t *)(base + 4); /* Original ES */
pxenv = MK_PTR(seg, off);
if (is_pxenv(pxenv))
goto have_pxenv;
@@ -1339,7 +1316,7 @@ static int pxe_init(void)
plan++;
if ((pxe = memory_scan_for_pxe_struct()))
goto have_pxe;
-
+
/* Plan E: PXENV+ memory scan */
plan++;
if ((pxenv = memory_scan_for_pxenv_struct()))
@@ -1348,7 +1325,7 @@ static int pxe_init(void)
/* Found nothing at all !! */
printf("No !PXE or PXENV+ API found; we're dead...\n");
kaboom();
-
+
have_pxenv:
APIVer = pxenv->version;
printf("Found PXENV+ structure\nPXE API version is %04x\n", APIVer);
@@ -1358,7 +1335,7 @@ static int pxe_init(void)
if (pxenv->length >= sizeof(struct pxenv_t)) {
pxe = GET_PTR(pxenv->pxeptr);
if (is_pxe(pxe))
- goto have_pxe;
+ goto have_pxe;
/*
* Nope, !PXE structure missing despite API 2.1+, or at least
* the pointer is missing. Do a last-ditch attempt to find it
@@ -1366,8 +1343,9 @@ static int pxe_init(void)
if ((pxe = memory_scan_for_pxe_struct()))
goto have_pxe;
}
+ APIVer = 0x200; /* PXENV+ only, assume version 2.00 */
}
-
+
/* Otherwise, no dice, use PXENV+ structure */
data_len = pxenv->undidatasize;
data_seg = pxenv->undidataseg;
@@ -1394,13 +1372,33 @@ static int pxe_init(void)
code_seg = code_seg + ((code_len + 15) >> 4);
data_seg = data_seg + ((data_len + 15) >> 4);
- real_base_mem = max(code_seg,data_seg) >> 6; /* Convert to kilobytes */
+ real_base_mem = max(code_seg, data_seg) >> 6; /* Convert to kilobytes */
return 0;
-}
+}
/*
- * Initialize UDP stack
+ * See if we have gPXE
+ */
+static void gpxe_init(void)
+{
+ int err;
+ static __lowmem struct s_PXENV_FILE_API_CHECK api_check;
+
+ if (APIVer >= 0x201) {
+ api_check.Size = sizeof api_check;
+ api_check.Magic = 0x91d447b2;
+ err = pxe_call(PXENV_FILE_API_CHECK, &api_check);
+ if (!err && api_check.Magic == 0xe9c17b20)
+ gpxe_funcs = api_check.APIMask;
+ }
+
+ /* Necessary functions for us to use the gPXE file API */
+ has_gpxe = (~gpxe_funcs & 0x4b) == 0;
+}
+
+/*
+ * Initialize UDP stack
*
*/
static void udp_init(void)
@@ -1415,18 +1413,18 @@ static void udp_init(void)
kaboom();
}
}
-
-
+
+
/*
* Network-specific initialization
- */
+ */
static void network_init(void)
-{
+{
struct bootp_t *bp = (struct bootp_t *)trackbuf;
int pkt_len;
*LocalDomain = 0; /* No LocalDomain received */
-
+
/*
* Get the DHCP client identifiers (query info 1)
*/
@@ -1443,7 +1441,7 @@ static void network_init(void)
* it in the future for vendor encapsulated options.
*/
*(char *)&DHCPMagic = 1;
-
+
/*
* Get the BOOTP/DHCP packet that brought us file (and an IP
* address). This lives in the DHCPACK packet (query info 2)
@@ -1451,20 +1449,20 @@ static void network_init(void)
pkt_len = pxe_get_cached_info(2);
parse_dhcp(pkt_len);
/*
- * Save away MAC address (assume this is in query info 2. If this
+ * Save away MAC address (assume this is in query info 2. If this
* turns out to be problematic it might be better getting it from
* the query info 1 packet
*/
MAC_len = bp->hardlen > 16 ? 0 : bp->hardlen;
MAC_type = bp->hardware;
- memcpy(MAC, bp->macaddr, MAC_len);
+ memcpy(MAC, bp->macaddr, MAC_len);
/*
* Get the boot file and other info. This lives in the CACHED_REPLY
* packet (query info 3)
*/
pkt_len = pxe_get_cached_info(3);
- parse_dhcp(pkt_len);
+ parse_dhcp(pkt_len);
printf("\n");
make_bootif_string();
@@ -1487,13 +1485,16 @@ static void network_init(void)
static int pxe_fs_init(struct fs_info *fs)
{
(void)fs; /* drop the compile warning message */
-
+
/* Initialize the Files structure */
files_init();
- /* do the pxe initialize */
+ /* Find the PXE stack */
pxe_init();
+ /* See if we also have a gPXE stack */
+ gpxe_init();
+
/* Network-specific initialization */
network_init();
@@ -1503,14 +1504,98 @@ static int pxe_fs_init(struct fs_info *fs)
return 0;
}
-inline void reset_pxe(void)
+/*
+ * Look to see if we are on an EFI CSM system. Some EFI
+ * CSM systems put the BEV stack in low memory, which means
+ * a return to the PXE stack will crash the system. However,
+ * INT 18h works reliably, so in that case hack the stack and
+ * point the "return address" to an INT 18h instruction.
+ *
+ * Hack the stack instead of the much simpler "just invoke INT 18h
+ * if we want to reset", so that chainloading other NBPs will work.
+ *
+ * This manipulates the real-mode InitStack directly. It relies on this
+ * *not* being a currently active stack, i.e. the former
+ * USE_PXE_PROVIDED_STACK no longer works.
+ */
+extern far_ptr_t InitStack;
+
+struct efi_struct {
+ uint32_t magic;
+ uint8_t csum;
+ uint8_t len;
+} __attribute__((packed));
+#define EFI_MAGIC (('$' << 24)+('E' << 16)+('F' << 8)+'I')
+
+static inline bool is_efi(const struct efi_struct *efi)
+{
+ /*
+ * We don't verify the checksum, because it seems some CSMs leave
+ * it at zero, sigh...
+ */
+ return (efi->magic == EFI_MAGIC) && (efi->len >= 83);
+}
+
+static void install_efi_csm_hack(void)
+{
+ static const uint8_t efi_csm_hack[] =
+ {
+ 0xcd, 0x18, /* int $0x18 */
+ 0xea, 0xf0, 0xff, 0x00, 0xf0, /* ljmpw $0xf000,$0xfff0 */
+ 0xf4 /* hlt */
+ };
+ uint16_t *retcode;
+
+ retcode = GET_PTR(*(far_ptr_t *)((char *)GET_PTR(InitStack) + 44));
+
+ /* Don't do this if the return already points to int $0x18 */
+ if (*retcode != 0x18cd) {
+ uint32_t efi_ptr;
+ bool efi = false;
+
+ for (efi_ptr = 0xe0000 ; efi_ptr < 0x100000 ; efi_ptr += 16) {
+ if (is_efi((const struct efi_struct *)efi_ptr)) {
+ efi = true;
+ break;
+ }
+ }
+
+ if (efi) {
+ uint8_t *src = GET_PTR(InitStack);
+ uint8_t *dst = src - sizeof efi_csm_hack;
+
+ memmove(dst, src, 52);
+ memcpy(dst+52, efi_csm_hack, sizeof efi_csm_hack);
+ InitStack.offs -= sizeof efi_csm_hack;
+
+ /* Clobber the return address */
+ *(uint16_t *)(dst+44) = OFFS_WRT(dst+52, InitStack.seg);
+ *(uint16_t *)(dst+46) = InitStack.seg;
+ }
+ }
+}
+
+void reset_pxe(void)
{
static __lowmem struct s_PXENV_UDP_CLOSE udp_close;
+ extern void gpxe_unload(void);
+
+ pxe_idle_cleanup();
+
+ printf("reset_pxe\n");
+
pxe_call(PXENV_UDP_CLOSE, &udp_close);
+
+ if (gpxe_funcs & 0x80) {
+ /* gPXE special unload implemented */
+ call16(gpxe_unload, &zero_regs, NULL);
+ }
+
+ install_efi_csm_hack();
}
/*
- * This function unloads the PXE and UNDI stacks and
+ * This function unloads the PXE and UNDI stacks and
* unclaims the memory.
*/
void unload_pxe(void)
@@ -1522,8 +1607,6 @@ void unload_pxe(void)
int int_addr;
static __lowmem struct s_PXENV_UNLOAD_STACK unload_stack;
- pxe_idle_cleanup();
-
if (KeepPXE) {
/*
* We want to keep PXE around, but still we should reset
@@ -1533,6 +1616,8 @@ void unload_pxe(void)
return;
}
+ pxe_idle_cleanup();
+
api_ptr = major_ver(APIVer) >= 2 ? new_api_unload : old_api_unload;
while((api = *api_ptr++)) {
memset(&unload_stack, 0, sizeof unload_stack);
@@ -1540,12 +1625,12 @@ void unload_pxe(void)
if (err || unload_stack.Status != PXENV_STATUS_SUCCESS)
goto cant_free;
}
-
+
flag = 0xff00;
if (real_base_mem <= BIOS_fbm) /* Santiy check */
goto cant_free;
flag ++;
-
+
/* Check that PXE actually unhooked the INT 0x1A chain */
int_addr = (int)MK_PTR(*(uint16_t *)(4*0x1a+2), *(uint16_t *)(4*0x1a));
int_addr >>= 10;
@@ -1553,15 +1638,15 @@ void unload_pxe(void)
BIOS_fbm = real_base_mem;
return;
}
-
+
cant_free:
- printf("Failed to free base memory error %04x-%08x\n",
+ printf("Failed to free base memory error %04x-%08x\n",
flag, *(uint32_t *)(4 * 0x1a));
return;
}
-
-
+
+
const struct fs_ops pxe_fs_ops = {
.fs_name = "pxe",
.fs_flags = FS_NODEV,
diff --git a/core/include/codepage.h b/core/include/codepage.h
new file mode 100644
index 00000000..a24d90f5
--- /dev/null
+++ b/core/include/codepage.h
@@ -0,0 +1,27 @@
+/*
+ * Codepage data structure as generated by cptable.pl
+ */
+#ifndef CODEPAGE_H
+#define CODEPAGE_H
+
+#include <stdint.h>
+
+#define CODEPAGE_MAGIC UINT64_C(0x51d21eb158a8b3d4)
+
+struct codepage {
+ uint64_t magic;
+ uint32_t reserved[6];
+
+ uint8_t upper[256]; /* Codepage upper case table */
+ uint8_t lower[256]; /* Codepage lower case table */
+
+ /*
+ * The primary Unicode match is the same case, i.e. A -> A,
+ * the secondary Unicode match is the opposite case, i.e. A -> a.
+ */
+ uint16_t uni[2][256]; /* Primary and alternate Unicode matches */
+};
+
+extern const struct codepage codepage;
+
+#endif /* CODEPAGE_H */
diff --git a/core/include/core.h b/core/include/core.h
index f54fcf8f..88ced70d 100644
--- a/core/include/core.h
+++ b/core/include/core.h
@@ -25,7 +25,8 @@ extern void (*idle_hook_func)(void);
extern void myputs(const char*);
/* malloc.c */
-extern void *malloc(int);
+extern void *malloc(size_t);
+extern void *zalloc(size_t);
extern void free(void *);
extern void mem_init(void);
diff --git a/core/include/disk.h b/core/include/disk.h
index 55d24fbc..da6555ae 100644
--- a/core/include/disk.h
+++ b/core/include/disk.h
@@ -5,12 +5,9 @@
#include <stdint.h>
#include <stdbool.h>
-#define SECTOR_SHIFT 9
-
typedef uint64_t sector_t;
typedef uint64_t block_t;
-
/*
* struct disk: contains the information about a specific disk and also
* contains the I/O function.
diff --git a/core/include/fs.h b/core/include/fs.h
index f0fe5347..394b2ae1 100644
--- a/core/include/fs.h
+++ b/core/include/fs.h
@@ -21,15 +21,17 @@
#define FILENAME_MAX_LG2 8
#define FILENAME_MAX (1 << FILENAME_MAX_LG2)
-#define BLOCK_SIZE(fs) (1 << fs->block_shift)
-#define SECTOR_SIZE(fs) (1 << fs->sector_shift)
+#define BLOCK_SIZE(fs) ((fs)->block_size)
+#define BLOCK_SHIFT(fs) ((fs)->block_shift)
+#define SECTOR_SIZE(fs) ((fs)->sector_size)
+#define SECTOR_SHIFT(fs) ((fs)->sector_shift)
struct fs_info {
const struct fs_ops *fs_ops;
struct device *fs_dev;
void *fs_info; /* The fs-specific information */
- int sector_shift;
- int block_shift;
+ int sector_shift, sector_size;
+ int block_shift, block_size;
};
extern struct fs_info *this_fs;
@@ -58,10 +60,10 @@ struct fs_ops {
void (*close_file)(struct file *);
void (*mangle_name)(char *, const char *);
char * (*unmangle_name)(char *, const char *);
- int (*load_config)();
+ int (*load_config)(void);
- struct inode * (*iget_root)(void);
- struct inode * (*iget_current)(void);
+ struct inode * (*iget_root)(struct fs_info *);
+ struct inode * (*iget_current)(struct fs_info *);
struct inode * (*iget)(char *, struct inode *);
char * (*follow_symlink)(struct inode *, const char *);
@@ -75,6 +77,7 @@ enum inode_mode {I_FILE, I_DIR, I_SYMLINK};
* The inode structure, including the detail file information
*/
struct inode {
+ struct fs_info *fs; /* The filesystem this inode is associated with */
int mode; /* FILE , DIR or SYMLINK */
uint32_t size;
uint32_t ino; /* Inode number */
@@ -83,9 +86,9 @@ struct inode {
uint32_t ctime; /* Create time */
uint32_t dtime; /* Delete time */
int blocks; /* How many blocks the file take */
- uint32_t * data; /* The block address array where the file stored */
uint32_t flags;
uint32_t file_acl;
+ char pvt[0]; /* Private filesystem data */
};
extern struct inode *this_inode;
@@ -142,13 +145,13 @@ static inline bool not_whitespace(char c)
return (unsigned char)c > ' ';
}
+/*
+ * Inode allocator/deallocator
+ */
+struct inode *alloc_inode(struct fs_info *fs, uint32_t ino, size_t data);
static inline void free_inode(struct inode * inode)
{
- if (inode) {
- if (inode->data)
- free(inode->data);
- free(inode);
- }
+ free(inode);
}
static inline void malloc_error(char *obj)
diff --git a/core/kernel.inc b/core/kernel.inc
index 9b888cc8..5e1c7a39 100644
--- a/core/kernel.inc
+++ b/core/kernel.inc
@@ -85,6 +85,8 @@ HEADER_ID equ 'HdrS' ; HdrS (in littleendian hex)
; Flags for the su_loadflags field
;
LOAD_HIGH equ 01h ; Large kernel, load high
+QUIET_FLAG equ 20h ; Quiet the kernel
+KEEP_SEGMENTS equ 40h ; Don't reload segments
CAN_USE_HEAP equ 80h ; Boot loader reports heap size
;
diff --git a/core/malloc.c b/core/malloc.c
index a033ff03..da4a3430 100644
--- a/core/malloc.c
+++ b/core/malloc.c
@@ -104,7 +104,7 @@ static inline struct mem_struct * try_merge_back(struct mem_struct *mm)
* of size _size_. Returns NULL if failed, or the address newly allocated.
*
*/
-void *malloc(int size)
+void *malloc(size_t size)
{
struct mem_struct *next = next_start;
struct mem_struct *good = next, *prev;
@@ -164,6 +164,14 @@ out:
return (void *)((uint32_t)good + sizeof(struct mem_struct));
}
+void *zalloc(size_t size)
+{
+ void *p = malloc(size);
+ if (p)
+ memset(p, 0, size);
+ return p;
+}
+
void free(void *ptr)
{
struct mem_struct *mm = ptr - sizeof(*mm);
diff --git a/core/pxe.inc b/core/pxe.inc
index 7471c4f0..2fd1edb7 100644
--- a/core/pxe.inc
+++ b/core/pxe.inc
@@ -71,6 +71,7 @@
%define PXENV_GET_FILE_SIZE 0x00e4
%define PXENV_FILE_EXEC 0x00e5
%define PXENV_FILE_API_CHECK 0x00e6
+%define PXENV_FILE_EXIT_HOOK 0x00e7
; Exit codes
%define PXENV_EXIT_SUCCESS 0x0000
diff --git a/core/pxelinux.asm b/core/pxelinux.asm
index 7f5da49c..58f76ce9 100644
--- a/core/pxelinux.asm
+++ b/core/pxelinux.asm
@@ -231,82 +231,6 @@ adhcp_copy:
call writestr_early
;
-; Look to see if we are on an EFI CSM system. Some EFI
-; CSM systems put the BEV stack in low memory, which means
-; a return to the PXE stack will crash the system. However,
-; INT 18h works reliably, so in that case hack the stack and
-; point the "return address" to an INT 18h instruction.
-;
-; Hack the stack instead of the much simpler "just invoke INT 18h
-; if we want to reset", so that chainloading other NBPs will work.
-;
-efi_csm_workaround:
- push es
- les bp,[InitStack] ; GS:SP -> original stack
- les bx,[es:bp+44] ; Return address
- cmp word [es:bx],18CDh ; Already pointing to INT 18h?
- je .skip
-
- ; Search memory from E0000 to FFFFF for a $EFI structure
- mov bx,0E000h
-.scan_mem:
- mov es,bx
- cmp dword [es:0],'IFE$' ; $EFI is byte-reversed...
- jne .not_here
- ;
- ; Verify the table. We don't check the checksum because
- ; it seems some CSMs leave it at zero.
- ;
- movzx cx,byte [es:5] ; Table length
- cmp cx,83 ; 83 bytes is the current length...
- jae .found_it
-
-.not_here:
- inc bx
- jnz .scan_mem
- jmp .skip ; No $EFI structure found
-
- ;
- ; Found a $EFI structure. Move down the original stack
- ; and put an INT 18h instruction there instead.
- ;
-.found_it:
-%if USE_PXE_PROVIDED_STACK
- mov cx,efi_csm_hack_size
- mov si,sp
- sub sp,cx
- mov di,sp
- mov ax,ss
- mov es,ax
- sub [InitStack],cx
- sub [BaseStack],cx
-%else
- les si,[InitStack]
- lea di,[si-efi_csm_hack_size]
- mov [InitStack],di
-%endif
- lea cx,[bp+52] ; End of the stack we care about
- sub cx,si
- es rep movsb
- mov [es:di-8],di ; Clobber the return address
- mov [es:di-6],es
- mov si,efi_csm_hack
- mov cx,efi_csm_hack_size
- rep movsb
-
-.skip:
- pop es ; Restore CS == DS == ES
-
- section .data16
- alignz 4
-efi_csm_hack:
- int 18h
- jmp 0F000h:0FFF0h
- hlt
-efi_csm_hack_size equ $-efi_csm_hack
-
- section .text16
-;
; do fs initialize
;
mov eax,ROOT_FS_OPS
@@ -376,6 +300,7 @@ local_boot:
mov si,localboot_msg
call writestr_early
; Restore the environment we were called with
+ pm_call reset_pxe
call cleanup_hardware
lss sp,[InitStack]
pop gs
@@ -503,6 +428,68 @@ pxe_int1a:
%endif
ret
+;
+; Special unload for gPXE: this switches the InitStack from
+; gPXE to the ROM PXE stack.
+;
+%if GPXE
+ global gpxe_unload
+gpxe_unload:
+ mov bx,PXENV_FILE_EXIT_HOOK
+ mov di,pxe_file_exit_hook
+ call pxenv
+ jc .plain
+
+ ; Now we actually need to exit back to gPXE, which will
+ ; give control back to us on the *new* "original stack"...
+ pushfd
+ push ds
+ push es
+ mov [PXEStack],sp
+ mov [PXEStack+2],ss
+ lss sp,[InitStack]
+ pop gs
+ pop fs
+ pop es
+ pop ds
+ popad
+ popfd
+ xor ax,ax
+ retf
+.resume:
+ cli
+
+ ; gPXE will have a stack frame looking much like our
+ ; InitStack, except it has a magic cookie at the top,
+ ; and the segment registers are in reverse order.
+ pop eax
+ pop ax
+ pop bx
+ pop cx
+ pop dx
+ push ax
+ push bx
+ push cx
+ push dx
+ mov [cs:InitStack],sp
+ mov [cs:InitStack+2],ss
+ lss sp,[cs:PXEStack]
+ pop es
+ pop ds
+ popfd
+
+.plain:
+ ret
+
+ section .data16
+ alignz 4
+pxe_file_exit_hook:
+.status: dw 0
+.offset: dw gpxe_unload.resume
+.seg: dw 0
+%endif
+
+ section .text16
; -----------------------------------------------------------------------------
; Common modules
diff --git a/core/runkernel.inc b/core/runkernel.inc
index 68ab9fac..74f23c45 100644
--- a/core/runkernel.inc
+++ b/core/runkernel.inc
@@ -1,7 +1,7 @@
;; -----------------------------------------------------------------------
;;
;; Copyright 1994-2009 H. Peter Anvin - All Rights Reserved
-;; Copyright 2009 Intel Corporation; author: H. Peter Anvin
+;; Copyright 2009-2010 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
@@ -138,15 +138,18 @@ parse_cmdline:
jmp .next_opt
opt_vga:
- mov eax,[es:di-1]
+ mov ax,[es:di-1]
mov bx,-1
- cmp eax,'=nor' ; vga=normal
+ cmp ax,'=n' ; vga=normal
je .vc0
dec bx ; bx <- -2
- cmp eax,'=ext' ; vga=ext
+ cmp ax,'=e' ; vga=ext
je .vc0
dec bx ; bx <- -3
- cmp eax,'=ask' ; vga=ask
+ cmp ax,'=a' ; vga=ask
+ je .vc0
+ mov bx,0x0f04 ; bx <- 0x0f04 (current mode)
+ cmp ax,'=c' ; vga=current
je .vc0
call parseint_esdi ; vga=<number>
jc .skip ; Not an integer
@@ -165,7 +168,7 @@ opt_mem:
ret
opt_quiet:
- mov byte [QuietBoot],1
+ mov byte [QuietBoot],QUIET_FLAG
ret
%if IS_PXELINUX
@@ -225,6 +228,8 @@ new_kernel:
; we were provided.
;
mov al,[es:su_loadflags]
+ or al,[QuietBoot] ; Set QUIET_FLAG if needed
+ mov [es:su_loadflags],al
mov [LoadFlags],al
any_kernel:
@@ -454,7 +459,10 @@ setup_move:
; BX points to the final real mode segment, and will be loaded
; into DS.
- jmp replace_bootstrap
+
+ test byte [QuietBoot],QUIET_FLAG
+ jz replace_bootstrap
+ jmp replace_bootstrap_noclearmode
run_linux_kernel:
;
@@ -625,7 +633,7 @@ loadinitrd:
; assumes CS == DS
;
writestr_qchk:
- test byte [QuietBoot],01h
+ test byte [QuietBoot],QUIET_FLAG
jz writestr
ret
diff --git a/doc/memdisk.txt b/doc/memdisk.txt
index 254cb7c9..c7244abc 100644
--- a/doc/memdisk.txt
+++ b/doc/memdisk.txt
@@ -132,15 +132,22 @@ g) The following option can be used to set the real-mode stack size.
stack=size Set the stack to "size" bytes
+h) Some systems without a floppy drive have been known to have
+ problems with floppy images. To avoid that those problems, first
+ of all make sure you don't have a floppy drive configured on the
+ BIOS screen. If there is no option to configure that, or that
+ doesn't work, you can use the option:
+
+ nopass Hide all real drives of the same type (floppy or hard disk)
+
Some interesting things to note:
If you're using MEMDISK to boot DOS from a CD-ROM (using ISOLINUX),
you might find the generic El Torito CD-ROM driver by Gary Tong and
-Bart Lagerweij useful:
-
- http://www.nu2.nu/eltorito/
-
+Bart Lagerweij useful. It is now included with the Syslinux
+distribution, in the dosutil directory. See the file
+dosutil/eltorito.txt for more information.
Similarly, if you're booting DOS over the network using PXELINUX, you
can use the "keeppxe" option and use the generic PXE (UNDI) NDIS
diff --git a/doc/menu.txt b/doc/menu.txt
index e1601249..c912c1df 100644
--- a/doc/menu.txt
+++ b/doc/menu.txt
@@ -48,6 +48,14 @@ MENU HIDDEN
All that is displayed is a timeout message.
+MENU CLEAR
+
+ Clear the screen when exiting the menu, instead of leaving the
+ menu displayed. For vesamenu, this means the graphical
+ background is still displayed without the menu itself for as
+ long as the screen remains in graphics mode.
+
+
MENU SHIFTKEY
Exit the menu system immediately unless either the Shift or Alt
diff --git a/extlinux/Makefile b/extlinux/Makefile
index 48105338..23ffd400 100644
--- a/extlinux/Makefile
+++ b/extlinux/Makefile
@@ -19,7 +19,7 @@ include $(topdir)/MCONFIG
OPTFLAGS = -g -Os
INCLUDES = -I. -I.. -I../libinstaller
-CFLAGS = -W -Wall -Wno-sign-compare -D_FILE_OFFSET_BITS=64 \
+CFLAGS = $(GCCWARN) -Wno-sign-compare -D_FILE_OFFSET_BITS=64 \
$(OPTFLAGS) $(INCLUDES)
LDFLAGS = # -s
diff --git a/gpxe/gpxe.diff b/gpxe/gpxe.diff
new file mode 100644
index 00000000..57e5f416
--- /dev/null
+++ b/gpxe/gpxe.diff
@@ -0,0 +1,73 @@
+diff --git a/gpxe/src/config/general.h b/gpxe/src/config/general.h
+index 0a9e625..de51f9f 100644
+--- a/gpxe/src/config/general.h
++++ b/gpxe/src/config/general.h
+@@ -55,8 +55,8 @@ FILE_LICENCE ( GPL2_OR_LATER );
+
+ #define DOWNLOAD_PROTO_TFTP /* Trivial File Transfer Protocol */
+ #define DOWNLOAD_PROTO_HTTP /* Hypertext Transfer Protocol */
+-#undef DOWNLOAD_PROTO_HTTPS /* Secure Hypertext Transfer Protocol */
+-#undef DOWNLOAD_PROTO_FTP /* File Transfer Protocol */
++#define DOWNLOAD_PROTO_HTTPS /* Secure Hypertext Transfer Protocol */
++#define DOWNLOAD_PROTO_FTP /* File Transfer Protocol */
+ #undef DOWNLOAD_PROTO_TFTM /* Multicast Trivial File Transfer Protocol */
+ #undef DOWNLOAD_PROTO_SLAM /* Scalable Local Area Multicast */
+
+diff --git a/gpxe/src/config/general.h b/gpxe/src/config/general.h
+index de51f9f..2f5a938 100644
+--- a/gpxe/src/config/general.h
++++ b/gpxe/src/config/general.h
+@@ -31,7 +31,7 @@ FILE_LICENCE ( GPL2_OR_LATER );
+ * Timer configuration
+ *
+ */
+-#define BANNER_TIMEOUT 20 /* Tenths of a second for which the shell
++#define BANNER_TIMEOUT 0 /* Tenths of a second for which the shell
+ banner should appear */
+
+ /*
+diff --git a/gpxe/src/hci/shell_banner.c b/gpxe/src/hci/shell_banner.c
+index 8afefe3..b92e08e 100644
+--- a/gpxe/src/hci/shell_banner.c
++++ b/gpxe/src/hci/shell_banner.c
+@@ -41,6 +41,9 @@ int shell_banner ( void ) {
+ int wait_count;
+ int key;
+
++ if ( BANNER_TIMEOUT <= 0 )
++ return enter_shell;
++
+ printf ( "\nPress Ctrl-B for the gPXE command line..." );
+
+ /* Wait for key */
+diff --git a/gpxe/src/include/gpxe/tcp.h b/gpxe/src/include/gpxe/tcp.h
+index 7ae7eab..9dc39fc 100644
+--- a/gpxe/src/include/gpxe/tcp.h
++++ b/gpxe/src/include/gpxe/tcp.h
+@@ -286,8 +286,8 @@ struct tcp_options {
+ * actually use 65536, we use a window size of (65536-4) to ensure
+ * that payloads remain dword-aligned.
+ */
+-//#define TCP_MAX_WINDOW_SIZE ( 65536 - 4 )
+-#define TCP_MAX_WINDOW_SIZE 4096
++#define TCP_MAX_WINDOW_SIZE ( 65536 - 4 )
++//#define TCP_MAX_WINDOW_SIZE 4096
+
+ /**
+ * Path MTU
+diff --git a/gpxe/src/core/malloc.c b/gpxe/src/core/malloc.c
+index 8b0bc24..0153748 100644
+--- a/gpxe/src/core/malloc.c
++++ b/gpxe/src/core/malloc.c
+@@ -78,9 +78,9 @@ size_t freemem;
+ /**
+ * Heap size
+ *
+- * Currently fixed at 128kB.
++ * Currently fixed at 512kB.
+ */
+-#define HEAP_SIZE ( 128 * 1024 )
++#define HEAP_SIZE ( 512 * 1024 )
+
+ /** The heap itself */
+ static char heap[HEAP_SIZE] __attribute__ (( aligned ( __alignof__(void *) )));
diff --git a/gpxe/pxelinux.gpxe b/gpxe/pxelinux.gpxe
index 51fe222e..c267d136 100644
--- a/gpxe/pxelinux.gpxe
+++ b/gpxe/pxelinux.gpxe
@@ -1,4 +1,5 @@
#!gpxe
+set use-cached 1
dhcp net0
imgload pxelinux.0
boot pxelinux.0
diff --git a/gpxe/src/Makefile b/gpxe/src/Makefile
index a627d967..cc91d78f 100644
--- a/gpxe/src/Makefile
+++ b/gpxe/src/Makefile
@@ -22,7 +22,7 @@ ECHO := echo
PRINTF := printf
PERL := /usr/bin/perl
CC := $(CROSS_COMPILE)gcc
-CPP := $(CROSS_COMPILE)gcc -E -Wp,-Wall
+CPP := $(CC) -E
AS := $(CROSS_COMPILE)as
LD := $(CROSS_COMPILE)ld
SIZE := $(CROSS_COMPILE)size
@@ -35,12 +35,17 @@ PARSEROM := $(PERL) ./util/parserom.pl
MAKEROM := $(PERL) ./util/makerom.pl
SYMCHECK := $(PERL) ./util/symcheck.pl
SORTOBJDUMP := $(PERL) ./util/sortobjdump.pl
+PADIMG := $(PERL) ./util/padimg.pl
+LICENCE := $(PERL) ./util/licence.pl
NRV2B := ./util/nrv2b
ZBIN := ./util/zbin
ELF2EFI32 := ./util/elf2efi32
ELF2EFI64 := ./util/elf2efi64
EFIROM := ./util/efirom
+ICCFIX := ./util/iccfix
DOXYGEN := doxygen
+BINUTILS_DIR := /usr
+BFD_DIR := $(BINUTILS_DIR)
###############################################################################
#
@@ -49,13 +54,14 @@ DOXYGEN := doxygen
SRCDIRS :=
SRCDIRS += libgcc
SRCDIRS += core
-SRCDIRS += proto
-SRCDIRS += net net/tcp net/udp
+SRCDIRS += net net/tcp net/udp net/infiniband net/80211
SRCDIRS += image
SRCDIRS += drivers/bus
SRCDIRS += drivers/net
SRCDIRS += drivers/net/e1000
SRCDIRS += drivers/net/phantom
+SRCDIRS += drivers/net/rtl818x
+SRCDIRS += drivers/net/ath5k
SRCDIRS += drivers/block
SRCDIRS += drivers/nvs
SRCDIRS += drivers/bitbash
@@ -66,6 +72,7 @@ SRCDIRS += crypto crypto/axtls crypto/matrixssl
SRCDIRS += hci hci/commands hci/tui
SRCDIRS += hci/mucurses hci/mucurses/widgets
SRCDIRS += usr
+SRCDIRS += config
# NON_AUTO_SRCS lists files that are excluded from the normal
# automatic build system.
@@ -73,6 +80,11 @@ SRCDIRS += usr
NON_AUTO_SRCS :=
NON_AUTO_SRCS += drivers/net/prism2.c
+# INCDIRS lists the include path
+#
+INCDIRS :=
+INCDIRS += include .
+
###############################################################################
#
# Default build target: build the most common targets and print out a
@@ -115,9 +127,9 @@ install :
#
# Version number calculations
#
-VERSION_MAJOR = 0
-VERSION_MINOR = 9
-VERSION_PATCH = 7
+VERSION_MAJOR = 1
+VERSION_MINOR = 0
+VERSION_PATCH = 0
EXTRAVERSION =
MM_VERSION = $(VERSION_MAJOR).$(VERSION_MINOR)
VERSION = $(MM_VERSION).$(VERSION_PATCH)$(EXTRAVERSION)
diff --git a/gpxe/src/Makefile.housekeeping b/gpxe/src/Makefile.housekeeping
index 2ab842e6..1f5e115f 100644
--- a/gpxe/src/Makefile.housekeeping
+++ b/gpxe/src/Makefile.housekeeping
@@ -54,6 +54,14 @@ echo :
###############################################################################
#
+# Generate a usable "seq" substitute
+#
+define seq
+ $(shell awk 'BEGIN { for ( i = $(1) ; i <= $(2) ; i++ ) print i }')
+endef
+
+###############################################################################
+#
# Determine host OS
#
HOST_OS := $(shell uname -s)
@@ -62,6 +70,22 @@ hostos :
###############################################################################
#
+# Determine compiler
+
+CCDEFS := $(shell $(CC) -E -x c -c /dev/null -dM | cut -d" " -f2)
+ccdefs:
+ @$(ECHO) $(CCDEFS)
+
+ifeq ($(filter __ICC,$(CCDEFS)),__ICC)
+CCTYPE := icc
+else
+CCTYPE := gcc
+endif
+cctype:
+ @$(ECHO) $(CCTYPE)
+
+###############################################################################
+#
# Check for tools that can cause failed builds
#
.toolcheck :
@@ -103,10 +127,30 @@ oldgas :
# default, even when -ffreestanding is specified. We therefore need
# to disable -fstack-protector if the compiler supports it.
#
+ifeq ($(CCTYPE),gcc)
SP_TEST = $(CC) -fno-stack-protector -x c -c /dev/null \
-o /dev/null >/dev/null 2>&1
SP_FLAGS := $(shell $(SP_TEST) && $(ECHO) '-fno-stack-protector')
CFLAGS += $(SP_FLAGS)
+endif
+
+# gcc 4.4 generates .eh_frame sections by default, which distort the
+# output of "size". Inhibit this.
+#
+ifeq ($(CCTYPE),gcc)
+CFI_TEST = $(CC) -fno-dwarf2-cfi-asm -x c -c /dev/null \
+ -o /dev/null >/dev/null 2>&1
+CFI_FLAGS := $(shell $(CFI_TEST) && $(ECHO) '-fno-dwarf2-cfi-asm')
+CFLAGS += $(CFI_FLAGS)
+endif
+
+# Some versions of gas choke on division operators, treating them as
+# comment markers. Specifying --divide will work around this problem,
+# but isn't available on older gas versions.
+#
+DIVIDE_TEST = $(AS) --divide /dev/null -o /dev/null 2>/dev/null
+DIVIDE_FLAGS := $(shell $(DIVIDE_TEST) && $(ECHO) '--divide')
+ASFLAGS += $(DIVIDE_FLAGS)
###############################################################################
#
@@ -248,6 +292,11 @@ MAKEDEPS += arch/$(ARCH)/Makefile
include arch/$(ARCH)/Makefile
endif
+# Include architecture-specific include path
+ifdef ARCH
+INCDIRS += arch/$(ARCH)/include
+endif
+
###############################################################################
#
# Source file handling
@@ -276,12 +325,45 @@ autosrcs :
ifdef BIN
+# INCDIRS lists the include path
+incdirs :
+ @$(ECHO) $(INCDIRS)
+
# Common flags
#
-CFLAGS += -I include -I arch/$(ARCH)/include -I .
-CFLAGS += -Os -ffreestanding
-CFLAGS += -Wall -W -Wformat-nonliteral
+CFLAGS += $(foreach INC,$(INCDIRS),-I$(INC))
+CFLAGS += -Os
CFLAGS += -g
+ifeq ($(CCTYPE),gcc)
+CFLAGS += -ffreestanding
+CFLAGS += -Wall -W -Wformat-nonliteral
+endif
+ifeq ($(CCTYPE),icc)
+CFLAGS += -fno-builtin
+CFLAGS += -no-ip
+CFLAGS += -no-gcc
+CFLAGS += -diag-disable 111 # Unreachable code
+CFLAGS += -diag-disable 128 # Unreachable loop
+CFLAGS += -diag-disable 170 # Array boundary checks
+CFLAGS += -diag-disable 177 # Unused functions
+CFLAGS += -diag-disable 181 # printf() format checks
+CFLAGS += -diag-disable 188 # enum strictness
+CFLAGS += -diag-disable 193 # Undefined preprocessor identifiers
+CFLAGS += -diag-disable 280 # switch ( constant )
+CFLAGS += -diag-disable 310 # K&R parameter lists
+CFLAGS += -diag-disable 424 # Extra semicolon
+CFLAGS += -diag-disable 589 # Declarations mid-code
+CFLAGS += -diag-disable 593 # Unused variables
+CFLAGS += -diag-disable 810 # Casting ints to smaller ints
+CFLAGS += -diag-disable 981 # Sequence point violations
+CFLAGS += -diag-disable 1292 # Ignored attributes
+CFLAGS += -diag-disable 1338 # void pointer arithmetic
+CFLAGS += -diag-disable 1361 # Variable-length arrays
+CFLAGS += -diag-disable 1418 # Missing prototypes
+CFLAGS += -diag-disable 1419 # Missing prototypes
+CFLAGS += -diag-disable 1599 # Hidden variables
+CFLAGS += -Wall -Wmissing-declarations
+endif
CFLAGS += $(EXTRA_CFLAGS)
ASFLAGS += $(EXTRA_ASFLAGS)
LDFLAGS += $(EXTRA_LDFLAGS)
@@ -314,11 +396,21 @@ OBJ_CFLAGS = $(CFLAGS_$(OBJECT)) -DOBJECT=$(subst -,_,$(OBJECT))
$(BIN)/%.flags :
@$(ECHO) $(OBJ_CFLAGS)
+# ICC requires postprocessing objects to fix up table alignments
+#
+ifeq ($(CCTYPE),icc)
+POST_O = && $(ICCFIX) $@
+POST_O_DEPS := $(ICCFIX)
+else
+POST_O :=
+POST_O_DEPS :=
+endif
+
# Rules for specific object types.
#
COMPILE_c = $(CC) $(CFLAGS) $(CFLAGS_c) $(OBJ_CFLAGS)
-RULE_c = $(Q)$(COMPILE_c) -c $< -o $@
-RULE_c_to_dbg%.o = $(Q)$(COMPILE_c) -Ddebug_$(OBJECT)=$* -c $< -o $@
+RULE_c = $(Q)$(COMPILE_c) -c $< -o $@ $(POST_O)
+RULE_c_to_dbg%.o = $(Q)$(COMPILE_c) -Ddebug_$(subst -,_,$(OBJECT))=$* -c $< -o $@ $(POST_O)
RULE_c_to_c = $(Q)$(COMPILE_c) -E -c $< > $@
RULE_c_to_s = $(Q)$(COMPILE_c) -S -g0 -c $< -o $@
@@ -346,39 +438,25 @@ define src_template
@$(MKDIR) -p $(dir $(2))
@$(RM) $(2)
@$(TOUCH) $(2)
- $(foreach OBJ,$(if $(OBJS_$(4)),$(OBJS_$(4)),$(4)), \
- $(call obj_template,$(1),$(2),$(3),$(OBJ)))
- @$(PARSEROM) $(1) >> $(2)
-
-endef
-
-# obj_template : generate Makefile rules for a given resultant object
-# of a particular source file. (We can have multiple objects per
-# source file via the OBJS_xxx list.)
-#
-# $(1) is the full path to the source file (e.g. "drivers/net/rtl8139.c")
-# $(2) is the full path to the .d file (e.g. "bin/deps/drivers/net/rtl8139.d")
-# $(3) is the source type (e.g. "c")
-# $(4) is the object name (e.g. "rtl8139")
-#
-define obj_template
-
@$(CPP) $(CFLAGS) $(CFLAGS_$(3)) $(CFLAGS_$(4)) -DOBJECT=$(4) \
- -Wno-error -MM $(1) -MT "$(4)_DEPS" -MG -MP | \
- sed 's/_DEPS\s*:/_DEPS =/' >> $(2)
- @$(ECHO_E) '\n$$(BIN)/$(4).o : $(1) $$(MAKEDEPS) $$($(4)_DEPS)' \
+ -Wno-error -MM $(1) -MG -MP | \
+ sed 's/\.o\s*:/_DEPS =/' >> $(2)
+ @$(ECHO_E) '\n$$(BIN)/$(4).o :' \
+ '$(1) $$(MAKEDEPS) $$(POST_O_DEPS) $$($(4)_DEPS)' \
'\n\t$$(QM)$(ECHO) " [BUILD] $$@"' \
'\n\t$$(RULE_$(3))\n' \
'\nBOBJS += $$(BIN)/$(4).o\n' \
$(foreach TGT,$(DEBUG_TARGETS), \
$(if $(RULE_$(3)_to_$(TGT)), \
- '\n$$(BIN)/$(4).$(TGT) : $(1) $$(MAKEDEPS) $$($(4)_DEPS)' \
+ '\n$$(BIN)/$(4).$(TGT) :' \
+ '$(1) $$(MAKEDEPS) $$(POST_O_DEPS) $$($(4)_DEPS)' \
'\n\t$$(QM)$(ECHO) " [BUILD] $$@"' \
'\n\t$$(RULE_$(3)_to_$(TGT))\n' \
'\n$(TGT)_OBJS += $$(BIN)/$(4).$(TGT)\n' ) ) \
'\n$(2) : $$($(4)_DEPS)\n' \
'\nTAGS : $$($(4)_DEPS)\n' \
>> $(2)
+ @$(PARSEROM) $(1) >> $(2)
endef
@@ -415,7 +493,7 @@ roms :
#
EMBEDDED_LIST := $(BIN)/.embedded.list
ifeq ($(wildcard $(EMBEDDED_LIST)),)
-EMBEDDED_LIST_IMAGE :=
+EMBEDDED_LIST_IMAGE := <invalid>
else
EMBEDDED_LIST_IMAGE := $(shell cat $(EMBEDDED_LIST))
endif
@@ -428,7 +506,7 @@ $(EMBEDDED_LIST) :
VERYCLEANUP += $(EMBEDDED_LIST)
EMBEDDED_FILES := $(subst $(COMMA), ,$(EMBEDDED_IMAGE))
-EMBED_ALL := $(foreach i,$(shell seq 1 $(words $(EMBEDDED_FILES))),\
+EMBED_ALL := $(foreach i,$(call seq,1,$(words $(EMBEDDED_FILES))),\
EMBED ( $(i), \"$(word $(i), $(EMBEDDED_FILES))\",\
\"$(notdir $(word $(i),$(EMBEDDED_FILES)))\" ))
@@ -550,7 +628,7 @@ $(BIN)/%.info :
#
BLIB_LIST := $(BIN)/.blib.list
ifeq ($(wildcard $(BLIB_LIST)),)
-BLIB_LIST_OBJS :=
+BLIB_LIST_OBJS := <invalid>
else
BLIB_LIST_OBJS := $(shell cat $(BLIB_LIST))
endif
@@ -589,6 +667,55 @@ $(BIN)/%.tmp : $(BLIB) $(MAKEDEPS) $(LDSCRIPT)
$(BIN)/%.map : $(BIN)/%.tmp
@less $(BIN)/$*.tmp.map
+# Get objects list for the specified target
+#
+define objs_list
+ $(sort $(foreach OBJ_SYMBOL,\
+ $(filter obj_%,$(shell $(NM) $(1) | cut -d" " -f3)),\
+ $(patsubst obj_%,%,$(OBJ_SYMBOL))))
+endef
+$(BIN)/%.objs : $(BIN)/%.tmp
+ $(Q)$(ECHO) $(call objs_list,$<)
+$(BIN)/%.sizes : $(BIN)/%.tmp
+ $(Q)$(SIZE) -t $(foreach OBJ,$(call objs_list,$<),$(wildcard $(BIN)/$(subst _,?,$(OBJ)).o)) | \
+ sort -g
+
+# Get dependency list for the specified target
+#
+define deps_list
+ $(sort $(foreach OBJ,$(call objs_list,$(1)),$($(OBJ)_DEPS)))
+endef
+$(BIN)/%.deps : $(BIN)/%.tmp
+ $(Q)$(ECHO) $(call deps_list,$<)
+
+# Get unneeded source files for the specified target
+#
+define nodeps_list
+ $(sort $(filter-out $(call deps_list,$(1)),\
+ $(foreach BOBJ,$(BOBJS),\
+ $($(basename $(notdir $(BOBJ)))_DEPS))))
+endef
+$(BIN)/%.nodeps : $(BIN)/%.tmp
+ $(Q)$(ECHO) $(call nodeps_list,$<)
+
+# Get licensing verdict for the specified target
+#
+define unlicensed_deps_list
+ $(shell grep -L FILE_LICENCE $(call deps_list,$(1)))
+endef
+define licence_list
+ $(patsubst __licence_%,%,\
+ $(filter __licence_%,$(shell $(NM) $(1) | cut -d" " -f3)))
+endef
+$(BIN)/%.licence : $(BIN)/%.tmp
+ $(QM)$(ECHO) " [LICENCE] $@"
+ $(Q)$(if $(strip $(call unlicensed_deps_list,$<)),\
+ echo -n "Unable to determine licence because the following " ;\
+ echo "files are missing a licence declaration:" ;\
+ echo $(call unlicensed_deps_list,$<);\
+ exit 1,\
+ $(LICENCE) $(call licence_list,$<))
+
# Extract compression information from intermediate object file
#
$(BIN)/%.zinfo : $(BIN)/%.tmp
@@ -649,6 +776,7 @@ define media_template
@$(ECHO_E) '$$(BIN)/%.$(1) : $$(BIN)/%.$(1).zbin' \
'\n\t$$(QM)$(ECHO) " [FINISH] $$@"' \
'\n\t$$(Q)$$(CP) $$< $$@' \
+ '\n\t$$(Q)$$(PAD_$(1))' \
'\n\t$$(Q)$$(FINALISE_$(1))' \
> $(2)
@@ -702,6 +830,9 @@ endif # defined(BIN)
#
FINALISE_rom = $(MAKEROM) $(MAKEROM_FLAGS) $(TGT_MAKEROM_FLAGS) \
-i$(IDENT) -s 0 $@
+FINALISE_hrom = $(FINALISE_rom)
+FINALISE_xrom = $(MAKEROM) $(MAKEROM_FLAGS) $(TGT_MAKEROM_FLAGS) \
+ -i$(IDENT) -n -s 0 $@
# Some ROMs require specific flags to be passed to makerom.pl
#
@@ -726,16 +857,18 @@ CLEANUP += $(ZBIN)
#
# The EFI image converter
#
+ELF2EFI_CFLAGS := -I$(BINUTILS_DIR)/include -I$(BFD_DIR)/include \
+ -idirafter include -L$(BINUTILS_DIR)/lib -L$(BFD_DIR)/lib \
+ -lbfd -liberty -lz
+
$(ELF2EFI32) : util/elf2efi.c $(MAKEDEPS)
$(QM)$(ECHO) " [HOSTCC] $@"
- $(Q)$(HOST_CC) -DMDE_CPU_IA32 -idirafter include -O2 \
- -o $@ $< -lbfd -liberty
+ $(Q)$(HOST_CC) $(ELF2EFI_CFLAGS) -DMDE_CPU_IA32 -O2 -o $@ $<
CLEANUP += $(ELF2EFI32)
$(ELF2EFI64) : util/elf2efi.c $(MAKEDEPS)
$(QM)$(ECHO) " [HOSTCC] $@"
- $(Q)$(HOST_CC) -DMDE_CPU_X64 -idirafter include -O2 \
- -o $@ $< -lbfd -liberty
+ $(Q)$(HOST_CC) $(ELF2EFI_CFLAGS) -DMDE_CPU_X64 -O2 -o $@ $<
CLEANUP += $(ELF2EFI64)
$(EFIROM) : util/efirom.c $(MAKEDEPS)
@@ -745,6 +878,15 @@ CLEANUP += $(EFIROM)
###############################################################################
#
+# The ICC fixup utility
+#
+$(ICCFIX) : util/iccfix.c $(MAKEDEPS)
+ $(QM)$(ECHO) " [HOSTCC] $@"
+ $(Q)$(HOST_CC) -idirafter include -O2 -o $@ $<
+CLEANUP += $(ICCFIX)
+
+###############################################################################
+#
# Auto-incrementing build serial number. Append "bs" to your list of
# build targets to get a serial number printed at the end of the
# build. Enable -DBUILD_SERIAL in order to see it when the code runs.
@@ -823,20 +965,24 @@ endif # defined(BIN)
ifdef BIN
$(BIN)/doxygen.cfg : doxygen.cfg $(MAKEDEPS)
- $(PERL) -pe 's{\@SRCDIRS\@}{$(SRCDIRS)}; ' \
+ $(Q)$(PERL) -pe 's{\@SRCDIRS\@}{$(SRCDIRS)}; ' \
+ -e 's{\@INCDIRS\@}{$(filter-out .,$(INCDIRS))}; ' \
-e 's{\@BIN\@}{$(BIN)}; ' \
-e 's{\@ARCH\@}{$(ARCH)}; ' \
$< > $@
$(BIN)/doc : $(BIN)/doxygen.cfg
- $(DOXYGEN) $<
+ $(Q)$(DOXYGEN) $<
.PHONY : $(BIN)/doc
-VERYCLEANUP += $(BIN)/doc
-
doc : $(BIN)/doc
+doc-clean :
+ $(Q)$(RM) -r $(BIN)/doc
+
+VERYCLEANUP += $(BIN)/doc
+
docview :
@[ -f $(BIN)/doc/html/index.html ] || $(MAKE) $(BIN)/doc
@if [ -n "$$BROWSER" ] ; then \
diff --git a/gpxe/src/README.pixify b/gpxe/src/README.pixify
deleted file mode 100644
index 9aef25d9..00000000
--- a/gpxe/src/README.pixify
+++ /dev/null
@@ -1,90 +0,0 @@
-This file documents the driver changes needed to support use as part
-of a PXE stack.
-
-PROPER WAY
-==========
-
-1. The probe() routine.
-
-There are three additional fields that need to be filled in the nic
-structure: ioaddr, irqno and irq.
-
- ioaddr is the base I/O address and seems to be for information only;
- no use will be made of this value other than displaying it on the
- screen.
-
- irqno must be the IRQ number for the NIC. For PCI NICs this can
- simply be copied from pci->irq.
-
- irq is a function pointer, like poll and transmit. It must point to
- the driver's irq() function.
-
-2. The poll() routine.
-
-This must take an additional parameter: "int retrieve". Calling
-poll() with retrieve!=0 should function exactly as before. Calling
-poll() with retrieve==0 indicates that poll() should check for the
-presence of a packet to read, but must *not* read the packet. The
-packet will be read by a subsequent call to poll() with retrieve!=0.
-
-The easiest way to implement this is to insert the line
- if ( ! retrieve ) return 1;
-between the "is there a packet ready" and the "fetch packet" parts of
-the existing poll() routine.
-
-Care must be taken that a call to poll() with retrieve==0 does not
-clear the NIC's "packet ready" status indicator, otherwise the
-subsequent call to poll() with retrieve!=0 will fail because it will
-think that there is no packet to read.
-
-poll() should also acknowledge and clear the NIC's "packet received"
-interrupt. It does not need to worry about enabling/disabling
-interrupts; this is taken care of by calls to the driver's irq()
-routine.
-
-Etherboot will forcibly regenerate an interrupt if a packet remains
-pending after all interrupts have been acknowledged. You can
-therefore get away with having poll() just acknolwedge and clear all
-NIC interrupts, without particularly worrying about exactly when this
-should be done.
-
-3. The irq() routine.
-
-This is a new routine, with prototype
- void DRIVER_irq ( struct nic *nic, irq_action_t action );
-"action" takes one of three possible values: ENABLE, DISABLE or FORCE.
-ENABLE and DISABLE mean to enable/disable the NIC's "packet received"
-interrupt. FORCE means that the NIC should be forced to generate a
-fake "packet received" interrupt.
-
-If you are unable to implement FORCE, your NIC will not work when
-being driven via the UNDI interface under heavy network traffic
-conditions. Since Etherboot's UNDI driver (make bin/undi.zpxe) is the
-only program known to use this interface, it probably doesn't really
-matter.
-
-
-QUICK AND DIRTY WAY
-===================
-
-It is possible to use the system timer interrupt (IRQ 0) rather than a
-genuine NIC interrupt. Since there is a constant stream of timer
-interrupts, the net upshot is a whole load of spurious "NIC"
-interrupts that have no effect other than to cause unnecessary PXE API
-calls. It's inefficient but it works.
-
-To achieve this, simply set nic->irqno=0 in probe() and point nic->irq
-to a dummy routine that does nothing. Add the line
- if ( ! retrieve ) return 1;
-at the beginning of poll(), to prevent the packet being read (and
-discarded) when poll() is called with retrieve==0;
-
-
-UNCONVERTED DRIVERS
-===================
-
-Drivers that have not yet been converted should continue to function
-when not used as part of a PXE stack, although there will be a
-harmless compile-time warning about assignment from an incompatible
-pointer type in the probe() function, since the prototype for the
-poll() function is missing the "int retrieve" parameter.
diff --git a/gpxe/src/arch/i386/Makefile b/gpxe/src/arch/i386/Makefile
index 1392bbac..dd8da802 100644
--- a/gpxe/src/arch/i386/Makefile
+++ b/gpxe/src/arch/i386/Makefile
@@ -4,22 +4,33 @@ CFLAGS += -march=i386
# Code size reduction.
#
-CFLAGS += -fstrength-reduce -fomit-frame-pointer
+CFLAGS += -fomit-frame-pointer
+
+# Code size reduction.
+#
+ifeq ($(CCTYPE),gcc)
+CFLAGS += -fstrength-reduce
+endif
# Code size reduction. gcc3 needs a different syntax to gcc2 if you
# want to avoid spurious warnings.
#
+ifeq ($(CCTYPE),gcc)
GCC_VERSION := $(subst ., ,$(shell $(CC) -dumpversion))
GCC_MAJOR := $(firstword $(GCC_VERSION))
ifeq ($(GCC_MAJOR),2)
CFLAGS += -malign-jumps=1 -malign-loops=1 -malign-functions=1
else
CFLAGS += -falign-jumps=1 -falign-loops=1 -falign-functions=1
-endif
+endif # gcc2
+endif # gcc
-# Code size reduction. This is almost always a win. The kernel uses it, too.
+# Code size reduction. This is almost always a win. The kernel uses
+# it, too.
#
+ifeq ($(CCTYPE),gcc)
CFLAGS += -mpreferred-stack-boundary=2
+endif
# Code size reduction. Use regparm for all functions - C functions
# called from assembly (or vice versa) need __asmcall now
@@ -27,7 +38,9 @@ CFLAGS += -mpreferred-stack-boundary=2
CFLAGS += -mregparm=3
# Code size reduction. Use -mrtd (same __asmcall requirements as above)
+ifeq ($(CCTYPE),gcc)
CFLAGS += -mrtd
+endif
# Code size reduction. This is the logical complement to -mregparm=3.
# It doesn't currently buy us anything, but if anything ever tries to
@@ -67,7 +80,9 @@ SRCDIRS += arch/i386/drivers
SRCDIRS += arch/i386/drivers/net
SRCDIRS += arch/i386/interface/pcbios
SRCDIRS += arch/i386/interface/pxe
+SRCDIRS += arch/i386/interface/pxeparent
SRCDIRS += arch/i386/interface/syslinux
+SRCDIRS += arch/i386/hci/commands
# The various xxx_loader.c files are #included into core/loader.c and
# should not be compiled directly.
@@ -76,11 +91,6 @@ NON_AUTO_SRCS += arch/i386/core/aout_loader.c
NON_AUTO_SRCS += arch/i386/core/freebsd_loader.c
NON_AUTO_SRCS += arch/i386/core/wince_loader.c
-# unnrv2b.S is used to generate a 16-bit as well as a 32-bit object.
-#
-OBJS_unnrv2b = unnrv2b unnrv2b16
-CFLAGS_unnrv2b16 = -DCODE16
-
# Include common x86 Makefile
#
MAKEDEPS += arch/x86/Makefile
@@ -101,13 +111,6 @@ NON_AUTO_MEDIA += fd0
$(Q)dd if=$< bs=512 conv=sync of=/dev/fd0
$(Q)sync
-# rule to create padded disk images
-NON_AUTO_MEDIA += pdsk
-%pdsk : %dsk
- $(QM)$(ECHO) " [DSKPAD] $@"
- $(Q)cp $< $@
- $(Q)$(PERL) ./util/dskpad.pl $@
-
# Add NON_AUTO_MEDIA to the media list, so that they show up in the
# output of "make"
#
diff --git a/gpxe/src/arch/i386/Makefile.pcbios b/gpxe/src/arch/i386/Makefile.pcbios
index 64b3dac2..e38fbca0 100644
--- a/gpxe/src/arch/i386/Makefile.pcbios
+++ b/gpxe/src/arch/i386/Makefile.pcbios
@@ -11,21 +11,24 @@ LDFLAGS += -N --no-check-sections
# Media types.
#
MEDIA += rom
+MEDIA += hrom
+MEDIA += xrom
MEDIA += pxe
MEDIA += kpxe
MEDIA += kkpxe
-MEDIA += elf
-MEDIA += elfd
-MEDIA += lmelf
-MEDIA += lmelfd
MEDIA += lkrn
-MEDIA += bImage
MEDIA += dsk
MEDIA += nbi
MEDIA += hd
MEDIA += raw
-MEDIA += com
-MEDIA += exe
+
+# Padding rules
+#
+PAD_rom = $(PADIMG) --blksize=512 --byte=0xff $@
+PAD_hrom = $(PAD_rom)
+PAD_xrom = $(PAD_rom)
+PAD_dsk = $(PADIMG) --blksize=512 $@
+PAD_hd = $(PADIMG) --blksize=32768 $@
# rule to make a non-emulation ISO boot image
NON_AUTO_MEDIA += iso
@@ -39,6 +42,12 @@ NON_AUTO_MEDIA += liso
$(QM)$(ECHO) " [GENLISO] $@"
$(Q)bash util/genliso $@ $<
+# rule to make a syslinux floppy image (mountable, bootable)
+NON_AUTO_MEDIA += sdsk
+%sdsk: %lkrn util/gensdsk
+ $(QM)$(ECHO) " [GENSDSK] $@"
+ $(Q)bash util/gensdsk $@ $<
+
# Special target for building Master Boot Record binary
$(BIN)/mbr.bin : $(BIN)/mbr.o
$(QM)$(ECHO) " [OBJCOPY] $@"
@@ -53,3 +62,9 @@ NON_AUTO_MEDIA += usb
%usb: $(BIN)/usbdisk.bin %hd
$(QM)$(ECHO) " [FINISH] $@"
$(Q)cat $^ > $@
+
+# Padded floppy image (e.g. for iLO)
+NON_AUTO_MEDIA += pdsk
+%pdsk : %dsk
+ $(Q)cp $< $@
+ $(Q)$(PADIMG) --blksize=1474560 $@
diff --git a/gpxe/src/arch/i386/core/basemem_packet.c b/gpxe/src/arch/i386/core/basemem_packet.c
index 64e0bcc1..d487cce3 100644
--- a/gpxe/src/arch/i386/core/basemem_packet.c
+++ b/gpxe/src/arch/i386/core/basemem_packet.c
@@ -16,6 +16,8 @@
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
+FILE_LICENCE ( GPL2_OR_LATER );
+
/**
* @file
*
diff --git a/gpxe/src/arch/i386/core/etherboot.prefix.lds b/gpxe/src/arch/i386/core/etherboot.prefix.lds
deleted file mode 100644
index 3550a2a3..00000000
--- a/gpxe/src/arch/i386/core/etherboot.prefix.lds
+++ /dev/null
@@ -1,100 +0,0 @@
-OUTPUT_FORMAT("elf32-i386", "elf32-i386", "elf32-i386")
-OUTPUT_ARCH(i386)
-
-ENTRY(_prefix_start)
-SECTIONS {
- /* Prefix */
- .prefix : {
- _verbatim_start = . ;
- _prefix_start = . ;
- *(.prefix)
- . = ALIGN(16);
- _prefix_end = . ;
- } = 0x9090
- _prefix_size = _prefix_end - _prefix_start;
-
- .text.nocompress : {
- *(.prefix.udata)
- } = 0x9090
-
- decompress_to = . ;
- .prefix.zdata : {
- _compressed = . ;
- *(.prefix.zdata)
- _compressed_end = . ;
- }
- _compressed_size = _compressed_end - _compressed;
-
- . = ALIGN(16);
- _verbatim_end = . ;
-
-
- /* Size of the core of etherboot in memory */
- _base_size = _end - _text;
-
- /* _prefix_size is the length of the non-core etherboot prefix */
- _prefix_size = _prefix_end - _prefix_start;
-
- /* _verbatim_size is the actual amount that has to be copied to base memory */
- _verbatim_size = _verbatim_end - _verbatim_start;
-
- /* _image_size is the amount of base memory needed to run */
- _image_size = _base_size + _prefix_size;
-
- /* Standard sizes rounded up to paragraphs */
- _prefix_size_pgh = (_prefix_size + 15) / 16;
- _verbatim_size_pgh = (_verbatim_size + 15) / 16;
- _image_size_pgh = (_image_size + 15) / 16 ;
-
- /* Standard sizes in sectors */
- _prefix_size_sct = (_prefix_size + 511) / 512;
- _verbatim_size_sct = (_verbatim_size + 511) / 512;
- _image_size_sct = (_image_size + 511) / 512;
-
- /* Symbol offsets and sizes for the exe prefix */
- _exe_hdr_size = 32;
- _exe_size = _verbatim_size; /* Should this be - 32 to exclude the header? */
- _exe_size_tail = (_exe_size) % 512;
- _exe_size_pages = ((_exe_size) + 511) / 512;
- _exe_bss_size = ((_image_size - _verbatim_size) + 15) / 16;
- _exe_ss_offset = (_stack_offset + _prefix_size - _exe_hdr_size + 15) / 16 ;
-
- /* This is where we copy the compressed image before decompression.
- * Prepare to decompress in place. The end mark is about 8.25 bytes long,
- * and the worst case symbol is about 16.5 bytes long. Therefore
- * We need to reserve at least 25 bytes of slack here.
- * Currently I reserve 2048 bytes of just slack to be safe :)
- * 2048 bytes easily falls within the BSS (the defualt stack is 4096 bytes)
- * so we really are decompressing in place.
- *
- * Hmm. I missed a trick. In the very worst case (no compression)
- * the encoded data is 9/8 the size as it started out so to be completely
- * safe I need to be 1/8 of the uncompressed code size past the end.
- * This will still fit compfortably into our bss in any conceivable scenario.
- */
- _compressed_copy = _edata + _prefix_size - _compressed_size +
- /* The amount to overflow _edata */
- MAX( ((_edata - _text + 7) / 8) , 2016 ) + 32;
- _assert = ASSERT( ( _compressed_copy - _prefix_size ) < _ebss , "Cannot decompress in place" ) ;
-
- decompress = DEFINED(decompress) ? decompress : 0;
- /DISCARD/ : {
- *(.comment)
- *(.note)
- }
-
- /* Symbols used by the prefixes whose addresses are inconvinient
- * to compute, at runtime in the code.
- */
- image_basemem_size = DEFINED(image_basemem_size)? image_basemem_size : 65536;
- image_basemem = DEFINED(image_basemem)? image_basemem : 65536;
- _prefix_real_to_prot = _real_to_prot + _prefix_size ;
- _prefix_prot_to_real = _prot_to_real + _prefix_size ;
- _prefix_image_basemem_size = image_basemem_size + _prefix_size ;
- _prefix_image_basemem = image_basemem + _prefix_size ;
- _prefix_rm_in_call = _rm_in_call + _prefix_size ;
- _prefix_in_call = _in_call + _prefix_size ;
- _prefix_rom = rom + _prefix_size ;
- _prefix_rm_etherboot_location = rm_etherboot_location + _prefix_size ;
- _prefix_stack_end = _stack_end + _prefix_size ;
-}
diff --git a/gpxe/src/arch/i386/core/pic8259.c b/gpxe/src/arch/i386/core/pic8259.c
index 8a0433dd..1e2d23c5 100644
--- a/gpxe/src/arch/i386/core/pic8259.c
+++ b/gpxe/src/arch/i386/core/pic8259.c
@@ -16,6 +16,8 @@
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
+FILE_LICENCE ( GPL2_OR_LATER );
+
#include <gpxe/io.h>
#include <pic8259.h>
diff --git a/gpxe/src/arch/i386/core/prefixudata.lds b/gpxe/src/arch/i386/core/prefixudata.lds
deleted file mode 100644
index 1c76128e..00000000
--- a/gpxe/src/arch/i386/core/prefixudata.lds
+++ /dev/null
@@ -1,8 +0,0 @@
-OUTPUT_FORMAT("elf32-i386", "elf32-i386", "elf32-i386")
-OUTPUT_ARCH(i386)
-
-SECTIONS {
- .prefix.udata : {
- *(*)
- }
-}
diff --git a/gpxe/src/arch/i386/core/prefixzdata.lds b/gpxe/src/arch/i386/core/prefixzdata.lds
deleted file mode 100644
index bf6ea977..00000000
--- a/gpxe/src/arch/i386/core/prefixzdata.lds
+++ /dev/null
@@ -1,8 +0,0 @@
-OUTPUT_FORMAT("elf32-i386", "elf32-i386", "elf32-i386")
-OUTPUT_ARCH(i386)
-
-SECTIONS {
- .prefix.zdata : {
- *(*)
- }
-}
diff --git a/gpxe/src/arch/i386/core/rdtsc_timer.c b/gpxe/src/arch/i386/core/rdtsc_timer.c
index 443c8ada..76679173 100644
--- a/gpxe/src/arch/i386/core/rdtsc_timer.c
+++ b/gpxe/src/arch/i386/core/rdtsc_timer.c
@@ -16,6 +16,8 @@
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
+FILE_LICENCE ( GPL2_OR_LATER );
+
/** @file
*
* RDTSC timer
diff --git a/gpxe/src/arch/i386/core/realmode.c b/gpxe/src/arch/i386/core/realmode.c
deleted file mode 100644
index 9a77bd8a..00000000
--- a/gpxe/src/arch/i386/core/realmode.c
+++ /dev/null
@@ -1,23 +0,0 @@
-/* Real-mode interface: C portions.
- *
- * Initial version by Michael Brown <mbrown@fensystems.co.uk>, January 2004.
- */
-
-#include "realmode.h"
-
-/*
- * Copy data to/from base memory.
- *
- */
-
-#ifdef KEEP_IT_REAL
-
-void memcpy_to_real ( segoff_t dest, void *src, size_t n ) {
-
-}
-
-void memcpy_from_real ( void *dest, segoff_t src, size_t n ) {
-
-}
-
-#endif /* KEEP_IT_REAL */
diff --git a/gpxe/src/arch/i386/core/relocate.c b/gpxe/src/arch/i386/core/relocate.c
index bdc8498e..44e764fe 100644
--- a/gpxe/src/arch/i386/core/relocate.c
+++ b/gpxe/src/arch/i386/core/relocate.c
@@ -9,6 +9,8 @@
*
*/
+FILE_LICENCE ( GPL2_OR_LATER );
+
/*
* The linker passes in the symbol _max_align, which is the alignment
* that we must preserve, in bytes.
diff --git a/gpxe/src/arch/i386/core/setjmp.S b/gpxe/src/arch/i386/core/setjmp.S
index 59a1b7cb..03727148 100644
--- a/gpxe/src/arch/i386/core/setjmp.S
+++ b/gpxe/src/arch/i386/core/setjmp.S
@@ -1,5 +1,7 @@
/* setjmp and longjmp. Use of these functions is deprecated. */
+FILE_LICENCE ( GPL2_OR_LATER )
+
.text
.arch i386
.code32
diff --git a/gpxe/src/arch/i386/core/stack.S b/gpxe/src/arch/i386/core/stack.S
index da66d239..737ec0ee 100644
--- a/gpxe/src/arch/i386/core/stack.S
+++ b/gpxe/src/arch/i386/core/stack.S
@@ -1,3 +1,5 @@
+FILE_LICENCE ( GPL2_OR_LATER )
+
.arch i386
/****************************************************************************
diff --git a/gpxe/src/arch/i386/core/stack16.S b/gpxe/src/arch/i386/core/stack16.S
index d1251f06..523f0288 100644
--- a/gpxe/src/arch/i386/core/stack16.S
+++ b/gpxe/src/arch/i386/core/stack16.S
@@ -1,3 +1,5 @@
+FILE_LICENCE ( GPL2_OR_LATER )
+
.arch i386
/****************************************************************************
diff --git a/gpxe/src/arch/i386/core/start16.lds b/gpxe/src/arch/i386/core/start16.lds
deleted file mode 100644
index 544fc78f..00000000
--- a/gpxe/src/arch/i386/core/start16.lds
+++ /dev/null
@@ -1,8 +0,0 @@
-/* When linking with an uncompressed image, these symbols are not
- * defined so we provide them here.
- */
-
-__decompressor_uncompressed = 0 ;
-__decompressor__start = 0 ;
-
-INCLUDE arch/i386/core/start16z.lds
diff --git a/gpxe/src/arch/i386/core/start16z.lds b/gpxe/src/arch/i386/core/start16z.lds
deleted file mode 100644
index 711bcf7b..00000000
--- a/gpxe/src/arch/i386/core/start16z.lds
+++ /dev/null
@@ -1,65 +0,0 @@
-OUTPUT_FORMAT("elf32-i386", "elf32-i386", "elf32-i386")
-OUTPUT_ARCH(i386)
-
-/* Linker-generated symbols are prefixed with a double underscore.
- * Decompressor symbols are prefixed with __decompressor_. All other
- * symbols are the same as in the original object file, i.e. the
- * runtime addresses.
- */
-
-ENTRY(_start16)
-
-SECTIONS {
- .text : {
- *(.text)
- }
- .payload : {
- __payload_start = .;
- *(.data)
- __payload_end = .;
- }
-
- /* _payload_size is the size of the binary image appended to
- * start16, in bytes.
- */
- __payload_size = __payload_end - __payload_start ;
-
- /* _size is the size of the runtime image
- * (start32 + the C code), in bytes.
- */
- __size = _end - _start ;
-
- /* _decompressor_size is the size of the decompressor, in
- * bytes. For a non-compressed image, start16.lds sets
- * _decompressor_uncompressed = _decompressor__start = 0.
- */
- __decompressor_size = __decompressor_uncompressed - __decompressor__start ;
-
- /* image__size is the total size of the image, after
- * decompression and including the decompressor if applicable.
- * It is therefore the amount of memory that start16's payload
- * needs in order to execute, in bytes.
- */
- __image_size = __size + __decompressor_size ;
-
- /* Amount to add to runtime symbols to obtain the offset of
- * that symbol within the image.
- */
- __offset_adjust = __decompressor_size - _start ;
-
- /* Calculations for the stack
- */
- __stack_size = _estack - _stack ;
- __offset_stack = _stack + __offset_adjust ;
-
- /* Some symbols will be larger than 16 bits but guaranteed to
- * be multiples of 16. We calculate them in paragraphs and
- * export these symbols which can be used in 16-bit code
- * without risk of overflow.
- */
- __image_size_pgh = ( __image_size / 16 );
- __start_pgh = ( _start / 16 );
- __decompressor_size_pgh = ( __decompressor_size / 16 );
- __offset_stack_pgh = ( __offset_stack / 16 );
-}
-
diff --git a/gpxe/src/arch/i386/core/timer2.c b/gpxe/src/arch/i386/core/timer2.c
index bb589ecc..6e76b2eb 100644
--- a/gpxe/src/arch/i386/core/timer2.c
+++ b/gpxe/src/arch/i386/core/timer2.c
@@ -11,6 +11,8 @@
* your option) any later version.
*/
+FILE_LICENCE ( GPL2_OR_LATER );
+
#include <stddef.h>
#include <gpxe/timer2.h>
#include <gpxe/io.h>
diff --git a/gpxe/src/arch/i386/core/virtaddr.S b/gpxe/src/arch/i386/core/virtaddr.S
index cf6da4f6..aae1e1ed 100644
--- a/gpxe/src/arch/i386/core/virtaddr.S
+++ b/gpxe/src/arch/i386/core/virtaddr.S
@@ -4,6 +4,8 @@
*
*/
+FILE_LICENCE ( GPL2_OR_LATER )
+
#include "librm.h"
.arch i386
diff --git a/gpxe/src/arch/i386/core/x86_io.c b/gpxe/src/arch/i386/core/x86_io.c
index 424a96cc..d2c363b9 100644
--- a/gpxe/src/arch/i386/core/x86_io.c
+++ b/gpxe/src/arch/i386/core/x86_io.c
@@ -16,6 +16,8 @@
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
+FILE_LICENCE ( GPL2_OR_LATER );
+
#include <gpxe/io.h>
#include <gpxe/x86_io.h>
diff --git a/gpxe/src/arch/i386/drivers/net/undi.c b/gpxe/src/arch/i386/drivers/net/undi.c
index 1090cc94..c6e253c0 100644
--- a/gpxe/src/arch/i386/drivers/net/undi.c
+++ b/gpxe/src/arch/i386/drivers/net/undi.c
@@ -16,6 +16,8 @@
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
+FILE_LICENCE ( GPL2_OR_LATER );
+
#include <stdint.h>
#include <stdlib.h>
#include <stdio.h>
@@ -135,7 +137,7 @@ static void undipci_remove ( struct pci_device *pci ) {
}
static struct pci_device_id undipci_nics[] = {
-PCI_ROM ( 0xffff, 0xffff, "undipci", "UNDI (PCI)" ),
+PCI_ROM ( 0xffff, 0xffff, "undipci", "UNDI (PCI)", 0 ),
};
struct pci_driver undipci_driver __pci_driver = {
diff --git a/gpxe/src/arch/i386/drivers/net/undiisr.S b/gpxe/src/arch/i386/drivers/net/undiisr.S
index 2b31b414..b27effe1 100644
--- a/gpxe/src/arch/i386/drivers/net/undiisr.S
+++ b/gpxe/src/arch/i386/drivers/net/undiisr.S
@@ -1,3 +1,5 @@
+FILE_LICENCE ( GPL2_OR_LATER )
+
#define PXENV_UNDI_ISR 0x0014
#define PXENV_UNDI_ISR_IN_START 1
#define PXENV_UNDI_ISR_OUT_OURS 0
@@ -29,7 +31,7 @@ undiisr:
movw %ax, %ds
/* Check that we have an UNDI entry point */
- cmpw $0, undinet_entry_point
+ cmpw $0, pxeparent_entry_point
je chain
/* Issue UNDI API call */
@@ -40,7 +42,7 @@ undiisr:
pushw %es
pushw %di
pushw %bx
- lcall *undinet_entry_point
+ lcall *pxeparent_entry_point
cli /* Just in case */
addw $6, %sp
cmpw $PXENV_UNDI_ISR_OUT_OURS, funcflag
diff --git a/gpxe/src/arch/i386/drivers/net/undiload.c b/gpxe/src/arch/i386/drivers/net/undiload.c
index dbd9e7c2..1d4e88d7 100644
--- a/gpxe/src/arch/i386/drivers/net/undiload.c
+++ b/gpxe/src/arch/i386/drivers/net/undiload.c
@@ -16,6 +16,8 @@
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
+FILE_LICENCE ( GPL2_OR_LATER );
+
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
@@ -90,11 +92,10 @@ int undi_load ( struct undi_device *undi, struct undi_rom *undirom ) {
undi_loader_entry = undirom->loader_entry;
__asm__ __volatile__ ( REAL_CODE ( "pushw %%ds\n\t"
"pushw %%ax\n\t"
- "lcall *%c2\n\t"
+ "lcall *undi_loader_entry\n\t"
"addw $4, %%sp\n\t" )
: "=a" ( exit )
- : "a" ( __from_data16 ( &undi_loader ) ),
- "p" ( __from_data16 ( &undi_loader_entry ) )
+ : "a" ( __from_data16 ( &undi_loader ) )
: "ebx", "ecx", "edx", "esi", "edi", "ebp" );
/* UNDI API calls may rudely change the status of A20 and not
diff --git a/gpxe/src/arch/i386/drivers/net/undinet.c b/gpxe/src/arch/i386/drivers/net/undinet.c
index d6db6f7c..83b79e7f 100644
--- a/gpxe/src/arch/i386/drivers/net/undinet.c
+++ b/gpxe/src/arch/i386/drivers/net/undinet.c
@@ -16,6 +16,8 @@
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
+FILE_LICENCE ( GPL2_OR_LATER );
+
#include <string.h>
#include <pxe.h>
#include <realmode.h>
@@ -30,6 +32,7 @@
#include <gpxe/ethernet.h>
#include <undi.h>
#include <undinet.h>
+#include <pxeparent.h>
/** @file
@@ -60,179 +63,8 @@ struct undi_nic {
static void undinet_close ( struct net_device *netdev );
-/*****************************************************************************
- *
- * UNDI API call
- *
- *****************************************************************************
- */
-
-/**
- * Name UNDI API call
- *
- * @v function API call number
- * @ret name API call name
- */
-static inline __attribute__ (( always_inline )) const char *
-undinet_function_name ( unsigned int function ) {
- switch ( function ) {
- case PXENV_START_UNDI:
- return "PXENV_START_UNDI";
- case PXENV_STOP_UNDI:
- return "PXENV_STOP_UNDI";
- case PXENV_UNDI_STARTUP:
- return "PXENV_UNDI_STARTUP";
- case PXENV_UNDI_CLEANUP:
- return "PXENV_UNDI_CLEANUP";
- case PXENV_UNDI_INITIALIZE:
- return "PXENV_UNDI_INITIALIZE";
- case PXENV_UNDI_RESET_ADAPTER:
- return "PXENV_UNDI_RESET_ADAPTER";
- case PXENV_UNDI_SHUTDOWN:
- return "PXENV_UNDI_SHUTDOWN";
- case PXENV_UNDI_OPEN:
- return "PXENV_UNDI_OPEN";
- case PXENV_UNDI_CLOSE:
- return "PXENV_UNDI_CLOSE";
- case PXENV_UNDI_TRANSMIT:
- return "PXENV_UNDI_TRANSMIT";
- case PXENV_UNDI_SET_MCAST_ADDRESS:
- return "PXENV_UNDI_SET_MCAST_ADDRESS";
- case PXENV_UNDI_SET_STATION_ADDRESS:
- return "PXENV_UNDI_SET_STATION_ADDRESS";
- case PXENV_UNDI_SET_PACKET_FILTER:
- return "PXENV_UNDI_SET_PACKET_FILTER";
- case PXENV_UNDI_GET_INFORMATION:
- return "PXENV_UNDI_GET_INFORMATION";
- case PXENV_UNDI_GET_STATISTICS:
- return "PXENV_UNDI_GET_STATISTICS";
- case PXENV_UNDI_CLEAR_STATISTICS:
- return "PXENV_UNDI_CLEAR_STATISTICS";
- case PXENV_UNDI_INITIATE_DIAGS:
- return "PXENV_UNDI_INITIATE_DIAGS";
- case PXENV_UNDI_FORCE_INTERRUPT:
- return "PXENV_UNDI_FORCE_INTERRUPT";
- case PXENV_UNDI_GET_MCAST_ADDRESS:
- return "PXENV_UNDI_GET_MCAST_ADDRESS";
- case PXENV_UNDI_GET_NIC_TYPE:
- return "PXENV_UNDI_GET_NIC_TYPE";
- case PXENV_UNDI_GET_IFACE_INFO:
- return "PXENV_UNDI_GET_IFACE_INFO";
- /*
- * Duplicate case value; this is a bug in the PXE specification.
- *
- * case PXENV_UNDI_GET_STATE:
- * return "PXENV_UNDI_GET_STATE";
- */
- case PXENV_UNDI_ISR:
- return "PXENV_UNDI_ISR";
- default:
- return "UNKNOWN API CALL";
- }
-}
-
-/**
- * UNDI parameter block
- *
- * Used as the paramter block for all UNDI API calls. Resides in base
- * memory.
- */
-static union u_PXENV_ANY __bss16 ( undinet_params );
-#define undinet_params __use_data16 ( undinet_params )
-
-/** UNDI entry point
- *
- * Used as the indirection vector for all UNDI API calls. Resides in
- * base memory.
- */
-SEGOFF16_t __bss16 ( undinet_entry_point );
-#define undinet_entry_point __use_data16 ( undinet_entry_point )
-
-/**
- * Issue UNDI API call
- *
- * @v undinic UNDI NIC
- * @v function API call number
- * @v params UNDI parameter block
- * @v params_len Length of UNDI parameter block
- * @ret rc Return status code
- */
-static int undinet_call ( struct undi_nic *undinic, unsigned int function,
- void *params, size_t params_len ) {
- PXENV_EXIT_t exit;
- int discard_b, discard_D;
- int rc;
-
- /* Copy parameter block and entry point */
- assert ( params_len <= sizeof ( undinet_params ) );
- memcpy ( &undinet_params, params, params_len );
-
- /* Call real-mode entry point. This calling convention will
- * work with both the !PXE and the PXENV+ entry points.
- */
- __asm__ __volatile__ ( REAL_CODE ( "pushw %%es\n\t"
- "pushw %%di\n\t"
- "pushw %%bx\n\t"
- "lcall *%c3\n\t"
- "addw $6, %%sp\n\t" )
- : "=a" ( exit ), "=b" ( discard_b ),
- "=D" ( discard_D )
- : "p" ( __from_data16 ( &undinet_entry_point )),
- "b" ( function ),
- "D" ( __from_data16 ( &undinet_params ) )
- : "ecx", "edx", "esi", "ebp" );
-
- /* UNDI API calls may rudely change the status of A20 and not
- * bother to restore it afterwards. Intel is known to be
- * guilty of this.
- *
- * Note that we will return to this point even if A20 gets
- * screwed up by the UNDI driver, because Etherboot always
- * resides in an even megabyte of RAM.
- */
- gateA20_set();
-
- /* Determine return status code based on PXENV_EXIT and
- * PXENV_STATUS
- */
- if ( exit == PXENV_EXIT_SUCCESS ) {
- rc = 0;
- } else {
- rc = -undinet_params.Status;
- /* Paranoia; don't return success for the combination
- * of PXENV_EXIT_FAILURE but PXENV_STATUS_SUCCESS
- */
- if ( rc == 0 )
- rc = -EIO;
- }
-
- /* If anything goes wrong, print as much debug information as
- * it's possible to give.
- */
- if ( rc != 0 ) {
- SEGOFF16_t rm_params = {
- .segment = rm_ds,
- .offset = __from_data16 ( &undinet_params ),
- };
-
- DBGC ( undinic, "UNDINIC %p %s failed: %s\n", undinic,
- undinet_function_name ( function ), strerror ( rc ) );
- DBGC ( undinic, "UNDINIC %p parameters at %04x:%04x length "
- "%#02zx, entry point at %04x:%04x\n", undinic,
- rm_params.segment, rm_params.offset, params_len,
- undinet_entry_point.segment,
- undinet_entry_point.offset );
- DBGC ( undinic, "UNDINIC %p parameters provided:\n", undinic );
- DBGC_HDA ( undinic, rm_params, params, params_len );
- DBGC ( undinic, "UNDINIC %p parameters returned:\n", undinic );
- DBGC_HDA ( undinic, rm_params, &undinet_params, params_len );
- }
-
- /* Copy parameter block back */
- memcpy ( params, &undinet_params, params_len );
-
- return rc;
-}
+/** Address of UNDI entry point */
+static SEGOFF16_t undinet_entry;
/*****************************************************************************
*
@@ -335,7 +167,6 @@ static struct s_PXENV_UNDI_TBD __data16 ( undinet_tbd );
*/
static int undinet_transmit ( struct net_device *netdev,
struct io_buffer *iobuf ) {
- struct undi_nic *undinic = netdev->priv;
struct s_PXENV_UNDI_TRANSMIT undi_transmit;
size_t len = iob_len ( iobuf );
int rc;
@@ -368,9 +199,9 @@ static int undinet_transmit ( struct net_device *netdev,
undinet_tbd.Xmit.offset = __from_data16 ( basemem_packet );
/* Issue PXE API call */
- if ( ( rc = undinet_call ( undinic, PXENV_UNDI_TRANSMIT,
- &undi_transmit,
- sizeof ( undi_transmit ) ) ) != 0 )
+ if ( ( rc = pxeparent_call ( undinet_entry, PXENV_UNDI_TRANSMIT,
+ &undi_transmit,
+ sizeof ( undi_transmit ) ) ) != 0 )
goto done;
/* Free I/O buffer */
@@ -440,8 +271,9 @@ static void undinet_poll ( struct net_device *netdev ) {
/* Run through the ISR loop */
while ( 1 ) {
- if ( ( rc = undinet_call ( undinic, PXENV_UNDI_ISR, &undi_isr,
- sizeof ( undi_isr ) ) ) != 0 )
+ if ( ( rc = pxeparent_call ( undinet_entry, PXENV_UNDI_ISR,
+ &undi_isr,
+ sizeof ( undi_isr ) ) ) != 0 )
break;
switch ( undi_isr.FuncFlag ) {
case PXENV_UNDI_ISR_OUT_TRANSMIT:
@@ -537,8 +369,8 @@ static int undinet_open ( struct net_device *netdev ) {
*/
memcpy ( undi_set_address.StationAddress, netdev->ll_addr,
sizeof ( undi_set_address.StationAddress ) );
- undinet_call ( undinic, PXENV_UNDI_SET_STATION_ADDRESS,
- &undi_set_address, sizeof ( undi_set_address ) );
+ pxeparent_call ( undinet_entry, PXENV_UNDI_SET_STATION_ADDRESS,
+ &undi_set_address, sizeof ( undi_set_address ) );
/* Open NIC. We ask for promiscuous operation, since it's the
* only way to ask for all multicast addresses. On any
@@ -547,8 +379,8 @@ static int undinet_open ( struct net_device *netdev ) {
*/
memset ( &undi_open, 0, sizeof ( undi_open ) );
undi_open.PktFilter = ( FLTR_DIRECTED | FLTR_BRDCST | FLTR_PRMSCS );
- if ( ( rc = undinet_call ( undinic, PXENV_UNDI_OPEN, &undi_open,
- sizeof ( undi_open ) ) ) != 0 )
+ if ( ( rc = pxeparent_call ( undinet_entry, PXENV_UNDI_OPEN,
+ &undi_open, sizeof ( undi_open ) ) ) != 0 )
goto err;
DBGC ( undinic, "UNDINIC %p opened\n", undinic );
@@ -573,8 +405,9 @@ static void undinet_close ( struct net_device *netdev ) {
/* Ensure ISR has exited cleanly */
while ( undinic->isr_processing ) {
undi_isr.FuncFlag = PXENV_UNDI_ISR_IN_GET_NEXT;
- if ( ( rc = undinet_call ( undinic, PXENV_UNDI_ISR, &undi_isr,
- sizeof ( undi_isr ) ) ) != 0 )
+ if ( ( rc = pxeparent_call ( undinet_entry, PXENV_UNDI_ISR,
+ &undi_isr,
+ sizeof ( undi_isr ) ) ) != 0 )
break;
switch ( undi_isr.FuncFlag ) {
case PXENV_UNDI_ISR_OUT_TRANSMIT:
@@ -589,8 +422,8 @@ static void undinet_close ( struct net_device *netdev ) {
}
/* Close NIC */
- undinet_call ( undinic, PXENV_UNDI_CLOSE, &undi_close,
- sizeof ( undi_close ) );
+ pxeparent_call ( undinet_entry, PXENV_UNDI_CLOSE,
+ &undi_close, sizeof ( undi_close ) );
/* Disable interrupt and unhook ISR */
disable_irq ( undinic->irq );
@@ -650,7 +483,7 @@ int undinet_probe ( struct undi_device *undi ) {
undi_set_drvdata ( undi, netdev );
netdev->dev = &undi->dev;
memset ( undinic, 0, sizeof ( *undinic ) );
- undinet_entry_point = undi->entry;
+ undinet_entry = undi->entry;
DBGC ( undinic, "UNDINIC %p using UNDI %p\n", undinic, undi );
/* Hook in UNDI stack */
@@ -661,9 +494,9 @@ int undinet_probe ( struct undi_device *undi ) {
start_undi.DX = undi->isapnp_read_port;
start_undi.ES = BIOS_SEG;
start_undi.DI = find_pnp_bios();
- if ( ( rc = undinet_call ( undinic, PXENV_START_UNDI,
- &start_undi,
- sizeof ( start_undi ) ) ) != 0 )
+ if ( ( rc = pxeparent_call ( undinet_entry, PXENV_START_UNDI,
+ &start_undi,
+ sizeof ( start_undi ) ) ) != 0 )
goto err_start_undi;
}
undi->flags |= UNDI_FL_STARTED;
@@ -671,24 +504,25 @@ int undinet_probe ( struct undi_device *undi ) {
/* Bring up UNDI stack */
if ( ! ( undi->flags & UNDI_FL_INITIALIZED ) ) {
memset ( &undi_startup, 0, sizeof ( undi_startup ) );
- if ( ( rc = undinet_call ( undinic, PXENV_UNDI_STARTUP,
- &undi_startup,
- sizeof ( undi_startup ) ) ) != 0 )
+ if ( ( rc = pxeparent_call ( undinet_entry, PXENV_UNDI_STARTUP,
+ &undi_startup,
+ sizeof ( undi_startup ) ) ) != 0 )
goto err_undi_startup;
memset ( &undi_initialize, 0, sizeof ( undi_initialize ) );
- if ( ( rc = undinet_call ( undinic, PXENV_UNDI_INITIALIZE,
- &undi_initialize,
- sizeof ( undi_initialize ))) != 0 )
+ if ( ( rc = pxeparent_call ( undinet_entry,
+ PXENV_UNDI_INITIALIZE,
+ &undi_initialize,
+ sizeof ( undi_initialize ))) != 0 )
goto err_undi_initialize;
}
undi->flags |= UNDI_FL_INITIALIZED;
/* Get device information */
memset ( &undi_info, 0, sizeof ( undi_info ) );
- if ( ( rc = undinet_call ( undinic, PXENV_UNDI_GET_INFORMATION,
- &undi_info, sizeof ( undi_info ) ) ) != 0 )
+ if ( ( rc = pxeparent_call ( undinet_entry, PXENV_UNDI_GET_INFORMATION,
+ &undi_info, sizeof ( undi_info ) ) ) != 0 )
goto err_undi_get_information;
- memcpy ( netdev->ll_addr, undi_info.PermNodeAddress, ETH_ALEN );
+ memcpy ( netdev->hw_addr, undi_info.PermNodeAddress, ETH_ALEN );
undinic->irq = undi_info.IntNumber;
if ( undinic->irq > IRQ_MAX ) {
DBGC ( undinic, "UNDINIC %p invalid IRQ %d\n",
@@ -696,16 +530,17 @@ int undinet_probe ( struct undi_device *undi ) {
goto err_bad_irq;
}
DBGC ( undinic, "UNDINIC %p is %s on IRQ %d\n",
- undinic, eth_ntoa ( netdev->ll_addr ), undinic->irq );
+ undinic, eth_ntoa ( netdev->hw_addr ), undinic->irq );
/* Get interface information */
memset ( &undi_iface, 0, sizeof ( undi_iface ) );
- if ( ( rc = undinet_call ( undinic, PXENV_UNDI_GET_IFACE_INFO,
- &undi_iface,
- sizeof ( undi_iface ) ) ) != 0 )
+ if ( ( rc = pxeparent_call ( undinet_entry, PXENV_UNDI_GET_IFACE_INFO,
+ &undi_iface,
+ sizeof ( undi_iface ) ) ) != 0 )
goto err_undi_get_iface_info;
- DBGC ( undinic, "UNDINIC %p has type %s and link speed %d\n",
- undinic, undi_iface.IfaceType, undi_iface.LinkSpeed );
+ DBGC ( undinic, "UNDINIC %p has type %s, speed %d, flags %08x\n",
+ undinic, undi_iface.IfaceType, undi_iface.LinkSpeed,
+ undi_iface.ServiceFlags );
if ( strncmp ( ( ( char * ) undi_iface.IfaceType ), "Etherboot",
sizeof ( undi_iface.IfaceType ) ) == 0 ) {
DBGC ( undinic, "UNDINIC %p Etherboot 5.4 workaround enabled\n",
@@ -730,17 +565,17 @@ int undinet_probe ( struct undi_device *undi ) {
err_undi_initialize:
/* Shut down UNDI stack */
memset ( &undi_shutdown, 0, sizeof ( undi_shutdown ) );
- undinet_call ( undinic, PXENV_UNDI_SHUTDOWN, &undi_shutdown,
- sizeof ( undi_shutdown ) );
+ pxeparent_call ( undinet_entry, PXENV_UNDI_SHUTDOWN, &undi_shutdown,
+ sizeof ( undi_shutdown ) );
memset ( &undi_cleanup, 0, sizeof ( undi_cleanup ) );
- undinet_call ( undinic, PXENV_UNDI_CLEANUP, &undi_cleanup,
- sizeof ( undi_cleanup ) );
+ pxeparent_call ( undinet_entry, PXENV_UNDI_CLEANUP, &undi_cleanup,
+ sizeof ( undi_cleanup ) );
undi->flags &= ~UNDI_FL_INITIALIZED;
err_undi_startup:
/* Unhook UNDI stack */
memset ( &stop_undi, 0, sizeof ( stop_undi ) );
- undinet_call ( undinic, PXENV_STOP_UNDI, &stop_undi,
- sizeof ( stop_undi ) );
+ pxeparent_call ( undinet_entry, PXENV_STOP_UNDI, &stop_undi,
+ sizeof ( stop_undi ) );
undi->flags &= ~UNDI_FL_STARTED;
err_start_undi:
netdev_nullify ( netdev );
@@ -771,22 +606,22 @@ void undinet_remove ( struct undi_device *undi ) {
/* Shut down UNDI stack */
memset ( &undi_shutdown, 0, sizeof ( undi_shutdown ) );
- undinet_call ( undinic, PXENV_UNDI_SHUTDOWN, &undi_shutdown,
- sizeof ( undi_shutdown ) );
+ pxeparent_call ( undinet_entry, PXENV_UNDI_SHUTDOWN,
+ &undi_shutdown, sizeof ( undi_shutdown ) );
memset ( &undi_cleanup, 0, sizeof ( undi_cleanup ) );
- undinet_call ( undinic, PXENV_UNDI_CLEANUP, &undi_cleanup,
- sizeof ( undi_cleanup ) );
+ pxeparent_call ( undinet_entry, PXENV_UNDI_CLEANUP,
+ &undi_cleanup, sizeof ( undi_cleanup ) );
undi->flags &= ~UNDI_FL_INITIALIZED;
/* Unhook UNDI stack */
memset ( &stop_undi, 0, sizeof ( stop_undi ) );
- undinet_call ( undinic, PXENV_STOP_UNDI, &stop_undi,
- sizeof ( stop_undi ) );
+ pxeparent_call ( undinet_entry, PXENV_STOP_UNDI, &stop_undi,
+ sizeof ( stop_undi ) );
undi->flags &= ~UNDI_FL_STARTED;
}
/* Clear entry point */
- memset ( &undinet_entry_point, 0, sizeof ( undinet_entry_point ) );
+ memset ( &undinet_entry, 0, sizeof ( undinet_entry ) );
/* Free network device */
netdev_nullify ( netdev );
diff --git a/gpxe/src/arch/i386/drivers/net/undionly.c b/gpxe/src/arch/i386/drivers/net/undionly.c
index 4cdce677..7dfb5d15 100644
--- a/gpxe/src/arch/i386/drivers/net/undionly.c
+++ b/gpxe/src/arch/i386/drivers/net/undionly.c
@@ -16,6 +16,8 @@
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
+FILE_LICENCE ( GPL2_OR_LATER );
+
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
diff --git a/gpxe/src/arch/i386/drivers/net/undipreload.c b/gpxe/src/arch/i386/drivers/net/undipreload.c
index e29d150a..a4b2f4ac 100644
--- a/gpxe/src/arch/i386/drivers/net/undipreload.c
+++ b/gpxe/src/arch/i386/drivers/net/undipreload.c
@@ -16,6 +16,8 @@
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
+FILE_LICENCE ( GPL2_OR_LATER );
+
#include <realmode.h>
#include <undipreload.h>
diff --git a/gpxe/src/arch/i386/drivers/net/undirom.c b/gpxe/src/arch/i386/drivers/net/undirom.c
index e5782781..2463d969 100644
--- a/gpxe/src/arch/i386/drivers/net/undirom.c
+++ b/gpxe/src/arch/i386/drivers/net/undirom.c
@@ -16,6 +16,8 @@
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
+FILE_LICENCE ( GPL2_OR_LATER );
+
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
diff --git a/gpxe/src/arch/i386/firmware/pcbios/basemem.c b/gpxe/src/arch/i386/firmware/pcbios/basemem.c
index b126d2a7..1ba7d1f6 100644
--- a/gpxe/src/arch/i386/firmware/pcbios/basemem.c
+++ b/gpxe/src/arch/i386/firmware/pcbios/basemem.c
@@ -16,6 +16,8 @@
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
+FILE_LICENCE ( GPL2_OR_LATER );
+
#include <stdint.h>
#include <realmode.h>
#include <bios.h>
diff --git a/gpxe/src/arch/i386/firmware/pcbios/bios_console.c b/gpxe/src/arch/i386/firmware/pcbios/bios_console.c
index 91363772..1d18e54c 100644
--- a/gpxe/src/arch/i386/firmware/pcbios/bios_console.c
+++ b/gpxe/src/arch/i386/firmware/pcbios/bios_console.c
@@ -16,6 +16,8 @@
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
+FILE_LICENCE ( GPL2_OR_LATER );
+
#include <assert.h>
#include <realmode.h>
#include <console.h>
diff --git a/gpxe/src/arch/i386/firmware/pcbios/e820mangler.S b/gpxe/src/arch/i386/firmware/pcbios/e820mangler.S
index decb0835..99ca519b 100644
--- a/gpxe/src/arch/i386/firmware/pcbios/e820mangler.S
+++ b/gpxe/src/arch/i386/firmware/pcbios/e820mangler.S
@@ -15,7 +15,9 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
-
+
+FILE_LICENCE ( GPL2_OR_LATER )
+
.text
.arch i386
.code16
@@ -235,6 +237,7 @@ get_underlying_e820:
popw %di
incw %bx
movl %edx, %eax
+ clc
ret
2:
/* If the requested region is earlier than the cached region,
diff --git a/gpxe/src/arch/i386/firmware/pcbios/fakee820.c b/gpxe/src/arch/i386/firmware/pcbios/fakee820.c
index 552bf41d..ea116fe5 100644
--- a/gpxe/src/arch/i386/firmware/pcbios/fakee820.c
+++ b/gpxe/src/arch/i386/firmware/pcbios/fakee820.c
@@ -15,6 +15,8 @@
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
+FILE_LICENCE ( GPL2_OR_LATER );
+
#include <realmode.h>
#include <biosint.h>
diff --git a/gpxe/src/arch/i386/firmware/pcbios/gateA20.c b/gpxe/src/arch/i386/firmware/pcbios/gateA20.c
index 34e3ac52..1a71472d 100644
--- a/gpxe/src/arch/i386/firmware/pcbios/gateA20.c
+++ b/gpxe/src/arch/i386/firmware/pcbios/gateA20.c
@@ -1,3 +1,5 @@
+FILE_LICENCE ( GPL2_OR_LATER );
+
#include <stdio.h>
#include <realmode.h>
#include <bios.h>
diff --git a/gpxe/src/arch/i386/firmware/pcbios/hidemem.c b/gpxe/src/arch/i386/firmware/pcbios/hidemem.c
index 620b62e0..17082c35 100644
--- a/gpxe/src/arch/i386/firmware/pcbios/hidemem.c
+++ b/gpxe/src/arch/i386/firmware/pcbios/hidemem.c
@@ -15,6 +15,8 @@
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
+FILE_LICENCE ( GPL2_OR_LATER );
+
#include <assert.h>
#include <realmode.h>
#include <biosint.h>
diff --git a/gpxe/src/arch/i386/firmware/pcbios/memmap.c b/gpxe/src/arch/i386/firmware/pcbios/memmap.c
index ff387d93..8a30dbae 100644
--- a/gpxe/src/arch/i386/firmware/pcbios/memmap.c
+++ b/gpxe/src/arch/i386/firmware/pcbios/memmap.c
@@ -16,6 +16,8 @@
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
+FILE_LICENCE ( GPL2_OR_LATER );
+
#include <stdint.h>
#include <errno.h>
#include <realmode.h>
diff --git a/gpxe/src/arch/i386/firmware/pcbios/pnpbios.c b/gpxe/src/arch/i386/firmware/pcbios/pnpbios.c
index 420d2ae8..c572914f 100644
--- a/gpxe/src/arch/i386/firmware/pcbios/pnpbios.c
+++ b/gpxe/src/arch/i386/firmware/pcbios/pnpbios.c
@@ -16,6 +16,8 @@
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
+FILE_LICENCE ( GPL2_OR_LATER );
+
#include <stdint.h>
#include <string.h>
#include <errno.h>
diff --git a/gpxe/src/arch/i386/hci/commands/pxe_cmd.c b/gpxe/src/arch/i386/hci/commands/pxe_cmd.c
new file mode 100644
index 00000000..b5df2d1b
--- /dev/null
+++ b/gpxe/src/arch/i386/hci/commands/pxe_cmd.c
@@ -0,0 +1,33 @@
+#include <gpxe/netdevice.h>
+#include <gpxe/command.h>
+#include <hci/ifmgmt_cmd.h>
+#include <pxe_call.h>
+
+FILE_LICENCE ( GPL2_OR_LATER );
+
+static int startpxe_payload ( struct net_device *netdev ) {
+ if ( netdev->state & NETDEV_OPEN )
+ pxe_activate ( netdev );
+ return 0;
+}
+
+static int startpxe_exec ( int argc, char **argv ) {
+ return ifcommon_exec ( argc, argv, startpxe_payload,
+ "Activate PXE on" );
+}
+
+static int stoppxe_exec ( int argc __unused, char **argv __unused ) {
+ pxe_deactivate();
+ return 0;
+}
+
+struct command pxe_commands[] __command = {
+ {
+ .name = "startpxe",
+ .exec = startpxe_exec,
+ },
+ {
+ .name = "stoppxe",
+ .exec = stoppxe_exec,
+ },
+};
diff --git a/gpxe/src/arch/i386/image/bootsector.c b/gpxe/src/arch/i386/image/bootsector.c
index 0f297a26..f96cf201 100644
--- a/gpxe/src/arch/i386/image/bootsector.c
+++ b/gpxe/src/arch/i386/image/bootsector.c
@@ -16,6 +16,8 @@
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
+FILE_LICENCE ( GPL2_OR_LATER );
+
/**
* @file
*
diff --git a/gpxe/src/arch/i386/image/bzimage.c b/gpxe/src/arch/i386/image/bzimage.c
index 47d46ca4..19450990 100644
--- a/gpxe/src/arch/i386/image/bzimage.c
+++ b/gpxe/src/arch/i386/image/bzimage.c
@@ -16,6 +16,8 @@
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
+FILE_LICENCE ( GPL2_OR_LATER );
+
/**
* @file
*
@@ -42,9 +44,11 @@ FEATURE ( FEATURE_IMAGE, "bzImage", DHCP_EB_FEATURE_BZIMAGE, 1 );
struct image_type bzimage_image_type __image_type ( PROBE_NORMAL );
/**
- * bzImage load context
+ * bzImage context
*/
-struct bzimage_load_context {
+struct bzimage_context {
+ /** Boot protocol version */
+ unsigned int version;
/** Real-mode kernel portion load segment address */
unsigned int rm_kernel_seg;
/** Real-mode kernel portion load address */
@@ -55,28 +59,14 @@ struct bzimage_load_context {
size_t rm_heap;
/** Command line (offset from rm_kernel) */
size_t rm_cmdline;
+ /** Command line maximum length */
+ size_t cmdline_size;
/** Real-mode kernel portion total memory size */
size_t rm_memsz;
/** Non-real-mode kernel portion load address */
userptr_t pm_kernel;
/** Non-real-mode kernel portion file and memory size */
size_t pm_sz;
-};
-
-/**
- * bzImage execution context
- */
-struct bzimage_exec_context {
- /** Real-mode kernel portion load segment address */
- unsigned int rm_kernel_seg;
- /** Real-mode kernel portion load address */
- userptr_t rm_kernel;
- /** Real-mode heap top (offset from rm_kernel) */
- size_t rm_heap;
- /** Command line (offset from rm_kernel) */
- size_t rm_cmdline;
- /** Command line maximum length */
- size_t cmdline_size;
/** Video mode */
unsigned int vid_mode;
/** Memory limit */
@@ -85,18 +75,178 @@ struct bzimage_exec_context {
physaddr_t ramdisk_image;
/** Initrd size */
physaddr_t ramdisk_size;
+
+ /** Command line magic block */
+ struct bzimage_cmdline cmdline_magic;
+ /** bzImage header */
+ struct bzimage_header bzhdr;
};
/**
+ * Parse bzImage header
+ *
+ * @v image bzImage file
+ * @v bzimg bzImage context
+ * @v src bzImage to parse
+ * @ret rc Return status code
+ */
+static int bzimage_parse_header ( struct image *image,
+ struct bzimage_context *bzimg,
+ userptr_t src ) {
+ unsigned int syssize;
+ int is_bzimage;
+
+ /* Sanity check */
+ if ( image->len < ( BZI_HDR_OFFSET + sizeof ( bzimg->bzhdr ) ) ) {
+ DBGC ( image, "bzImage %p too short for kernel header\n",
+ image );
+ return -ENOEXEC;
+ }
+
+ /* Read in header structures */
+ memset ( bzimg, 0, sizeof ( *bzimg ) );
+ copy_from_user ( &bzimg->cmdline_magic, src, BZI_CMDLINE_OFFSET,
+ sizeof ( bzimg->cmdline_magic ) );
+ copy_from_user ( &bzimg->bzhdr, src, BZI_HDR_OFFSET,
+ sizeof ( bzimg->bzhdr ) );
+
+ /* Calculate size of real-mode portion */
+ bzimg->rm_filesz =
+ ( ( bzimg->bzhdr.setup_sects ? bzimg->bzhdr.setup_sects : 4 ) + 1 ) << 9;
+ if ( bzimg->rm_filesz > image->len ) {
+ DBGC ( image, "bzImage %p too short for %zd byte of setup\n",
+ image, bzimg->rm_filesz );
+ return -ENOEXEC;
+ }
+ bzimg->rm_memsz = BZI_ASSUMED_RM_SIZE;
+
+ /* Calculate size of protected-mode portion */
+ bzimg->pm_sz = ( image->len - bzimg->rm_filesz );
+ syssize = ( ( bzimg->pm_sz + 15 ) / 16 );
+
+ /* Check for signatures and determine version */
+ if ( bzimg->bzhdr.boot_flag != BZI_BOOT_FLAG ) {
+ DBGC ( image, "bzImage %p missing 55AA signature\n", image );
+ return -ENOEXEC;
+ }
+ if ( bzimg->bzhdr.header == BZI_SIGNATURE ) {
+ /* 2.00+ */
+ bzimg->version = bzimg->bzhdr.version;
+ } else {
+ /* Pre-2.00. Check that the syssize field is correct,
+ * as a guard against accepting arbitrary binary data,
+ * since the 55AA check is pretty lax. Note that the
+ * syssize field is unreliable for protocols between
+ * 2.00 and 2.03 inclusive, so we should not always
+ * check this field.
+ */
+ bzimg->version = 0x0100;
+ if ( bzimg->bzhdr.syssize != syssize ) {
+ DBGC ( image, "bzImage %p bad syssize %x (expected "
+ "%x)\n", image, bzimg->bzhdr.syssize, syssize );
+ return -ENOEXEC;
+ }
+ }
+
+ /* Determine image type */
+ is_bzimage = ( ( bzimg->version >= 0x0200 ) ?
+ ( bzimg->bzhdr.loadflags & BZI_LOAD_HIGH ) : 0 );
+
+ /* Calculate load address of real-mode portion */
+ bzimg->rm_kernel_seg = ( is_bzimage ? 0x1000 : 0x9000 );
+ bzimg->rm_kernel = real_to_user ( bzimg->rm_kernel_seg, 0 );
+
+ /* Allow space for the stack and heap */
+ bzimg->rm_memsz += BZI_STACK_SIZE;
+ bzimg->rm_heap = bzimg->rm_memsz;
+
+ /* Allow space for the command line */
+ bzimg->rm_cmdline = bzimg->rm_memsz;
+ bzimg->rm_memsz += BZI_CMDLINE_SIZE;
+
+ /* Calculate load address of protected-mode portion */
+ bzimg->pm_kernel = phys_to_user ( is_bzimage ? BZI_LOAD_HIGH_ADDR
+ : BZI_LOAD_LOW_ADDR );
+
+ /* Extract video mode */
+ bzimg->vid_mode = bzimg->bzhdr.vid_mode;
+
+ /* Extract memory limit */
+ bzimg->mem_limit = ( ( bzimg->version >= 0x0203 ) ?
+ bzimg->bzhdr.initrd_addr_max : BZI_INITRD_MAX );
+
+ /* Extract command line size */
+ bzimg->cmdline_size = ( ( bzimg->version >= 0x0206 ) ?
+ bzimg->bzhdr.cmdline_size : BZI_CMDLINE_SIZE );
+
+ DBGC ( image, "bzImage %p version %04x RM %#lx+%#zx PM %#lx+%#zx "
+ "cmdlen %zd\n", image, bzimg->version,
+ user_to_phys ( bzimg->rm_kernel, 0 ), bzimg->rm_filesz,
+ user_to_phys ( bzimg->pm_kernel, 0 ), bzimg->pm_sz,
+ bzimg->cmdline_size );
+
+ return 0;
+}
+
+/**
+ * Update bzImage header in loaded kernel
+ *
+ * @v image bzImage file
+ * @v bzimg bzImage context
+ * @v dst bzImage to update
+ */
+static void bzimage_update_header ( struct image *image,
+ struct bzimage_context *bzimg,
+ userptr_t dst ) {
+
+ /* Set loader type */
+ if ( bzimg->version >= 0x0200 )
+ bzimg->bzhdr.type_of_loader = BZI_LOADER_TYPE_GPXE;
+
+ /* Set heap end pointer */
+ if ( bzimg->version >= 0x0201 ) {
+ bzimg->bzhdr.heap_end_ptr = ( bzimg->rm_heap - 0x200 );
+ bzimg->bzhdr.loadflags |= BZI_CAN_USE_HEAP;
+ }
+
+ /* Set command line */
+ if ( bzimg->version >= 0x0202 ) {
+ bzimg->bzhdr.cmd_line_ptr = user_to_phys ( bzimg->rm_kernel,
+ bzimg->rm_cmdline );
+ } else {
+ bzimg->cmdline_magic.magic = BZI_CMDLINE_MAGIC;
+ bzimg->cmdline_magic.offset = bzimg->rm_cmdline;
+ bzimg->bzhdr.setup_move_size = bzimg->rm_memsz;
+ }
+
+ /* Set video mode */
+ bzimg->bzhdr.vid_mode = bzimg->vid_mode;
+
+ /* Set initrd address */
+ if ( bzimg->version >= 0x0200 ) {
+ bzimg->bzhdr.ramdisk_image = bzimg->ramdisk_image;
+ bzimg->bzhdr.ramdisk_size = bzimg->ramdisk_size;
+ }
+
+ /* Write out header structures */
+ copy_to_user ( dst, BZI_CMDLINE_OFFSET, &bzimg->cmdline_magic,
+ sizeof ( bzimg->cmdline_magic ) );
+ copy_to_user ( dst, BZI_HDR_OFFSET, &bzimg->bzhdr,
+ sizeof ( bzimg->bzhdr ) );
+
+ DBGC ( image, "bzImage %p vidmode %d\n", image, bzimg->vid_mode );
+}
+
+/**
* Parse kernel command line for bootloader parameters
*
* @v image bzImage file
- * @v exec_ctx Execution context
+ * @v bzimg bzImage context
* @v cmdline Kernel command line
* @ret rc Return status code
*/
static int bzimage_parse_cmdline ( struct image *image,
- struct bzimage_exec_context *exec_ctx,
+ struct bzimage_context *bzimg,
const char *cmdline ) {
char *vga;
char *mem;
@@ -105,13 +255,13 @@ static int bzimage_parse_cmdline ( struct image *image,
if ( ( vga = strstr ( cmdline, "vga=" ) ) ) {
vga += 4;
if ( strcmp ( vga, "normal" ) == 0 ) {
- exec_ctx->vid_mode = BZI_VID_MODE_NORMAL;
+ bzimg->vid_mode = BZI_VID_MODE_NORMAL;
} else if ( strcmp ( vga, "ext" ) == 0 ) {
- exec_ctx->vid_mode = BZI_VID_MODE_EXT;
+ bzimg->vid_mode = BZI_VID_MODE_EXT;
} else if ( strcmp ( vga, "ask" ) == 0 ) {
- exec_ctx->vid_mode = BZI_VID_MODE_ASK;
+ bzimg->vid_mode = BZI_VID_MODE_ASK;
} else {
- exec_ctx->vid_mode = strtoul ( vga, &vga, 0 );
+ bzimg->vid_mode = strtoul ( vga, &vga, 0 );
if ( *vga && ( *vga != ' ' ) ) {
DBGC ( image, "bzImage %p strange \"vga=\""
"terminator '%c'\n", image, *vga );
@@ -122,17 +272,17 @@ static int bzimage_parse_cmdline ( struct image *image,
/* Look for "mem=" */
if ( ( mem = strstr ( cmdline, "mem=" ) ) ) {
mem += 4;
- exec_ctx->mem_limit = strtoul ( mem, &mem, 0 );
+ bzimg->mem_limit = strtoul ( mem, &mem, 0 );
switch ( *mem ) {
case 'G':
case 'g':
- exec_ctx->mem_limit <<= 10;
+ bzimg->mem_limit <<= 10;
case 'M':
case 'm':
- exec_ctx->mem_limit <<= 10;
+ bzimg->mem_limit <<= 10;
case 'K':
case 'k':
- exec_ctx->mem_limit <<= 10;
+ bzimg->mem_limit <<= 10;
break;
case '\0':
case ' ':
@@ -142,7 +292,7 @@ static int bzimage_parse_cmdline ( struct image *image,
"terminator '%c'\n", image, *mem );
break;
}
- exec_ctx->mem_limit -= 1;
+ bzimg->mem_limit -= 1;
}
return 0;
@@ -152,20 +302,20 @@ static int bzimage_parse_cmdline ( struct image *image,
* Set command line
*
* @v image bzImage image
- * @v exec_ctx Execution context
+ * @v bzimg bzImage context
* @v cmdline Kernel command line
* @ret rc Return status code
*/
static int bzimage_set_cmdline ( struct image *image,
- struct bzimage_exec_context *exec_ctx,
+ struct bzimage_context *bzimg,
const char *cmdline ) {
size_t cmdline_len;
/* Copy command line down to real-mode portion */
cmdline_len = ( strlen ( cmdline ) + 1 );
- if ( cmdline_len > exec_ctx->cmdline_size )
- cmdline_len = exec_ctx->cmdline_size;
- copy_to_user ( exec_ctx->rm_kernel, exec_ctx->rm_cmdline,
+ if ( cmdline_len > bzimg->cmdline_size )
+ cmdline_len = bzimg->cmdline_size;
+ copy_to_user ( bzimg->rm_kernel, bzimg->rm_cmdline,
cmdline, cmdline_len );
DBGC ( image, "bzImage %p command line \"%s\"\n", image, cmdline );
@@ -217,14 +367,16 @@ static size_t bzimage_load_initrd ( struct image *image,
}
/* Copy in initrd image body */
+ if ( address )
+ memcpy_user ( address, offset, initrd->data, 0, initrd->len );
+ offset += initrd->len;
if ( address ) {
DBGC ( image, "bzImage %p has initrd %p at [%lx,%lx)\n",
- image, initrd, address, ( address + offset ) );
- memcpy_user ( address, offset, initrd->data, 0,
- initrd->len );
+ image, initrd, user_to_phys ( address, 0 ),
+ user_to_phys ( address, offset ) );
}
- offset += initrd->len;
+ /* Round up to 4-byte boundary */
offset = ( ( offset + 0x03 ) & ~0x03 );
return offset;
}
@@ -233,20 +385,19 @@ static size_t bzimage_load_initrd ( struct image *image,
* Load initrds, if any
*
* @v image bzImage image
- * @v exec_ctx Execution context
+ * @v bzimg bzImage context
* @ret rc Return status code
*/
static int bzimage_load_initrds ( struct image *image,
- struct bzimage_exec_context *exec_ctx ) {
+ struct bzimage_context *bzimg ) {
struct image *initrd;
size_t total_len = 0;
physaddr_t address;
int rc;
/* Add up length of all initrd images */
- for_each_image ( initrd ) {
+ for_each_image ( initrd )
total_len += bzimage_load_initrd ( image, initrd, UNULL );
- }
/* Give up if no initrd images found */
if ( ! total_len )
@@ -268,7 +419,7 @@ static int bzimage_load_initrds ( struct image *image,
return -ENOBUFS;
}
/* Check that we are within the kernel's range */
- if ( ( address + total_len - 1 ) > exec_ctx->mem_limit )
+ if ( ( address + total_len - 1 ) > bzimg->mem_limit )
continue;
/* Prepare and verify segment */
if ( ( rc = prep_segment ( phys_to_user ( address ), 0,
@@ -279,8 +430,8 @@ static int bzimage_load_initrds ( struct image *image,
}
/* Record initrd location */
- exec_ctx->ramdisk_image = address;
- exec_ctx->ramdisk_size = total_len;
+ bzimg->ramdisk_image = address;
+ bzimg->ramdisk_size = total_len;
/* Construct initrd */
DBGC ( image, "bzImage %p constructing initrd at [%lx,%lx)\n",
@@ -300,60 +451,37 @@ static int bzimage_load_initrds ( struct image *image,
* @ret rc Return status code
*/
static int bzimage_exec ( struct image *image ) {
- struct bzimage_exec_context exec_ctx;
- struct bzimage_header bzhdr;
+ struct bzimage_context bzimg;
const char *cmdline = ( image->cmdline ? image->cmdline : "" );
int rc;
- /* Initialise context */
- memset ( &exec_ctx, 0, sizeof ( exec_ctx ) );
-
- /* Retrieve kernel header */
- exec_ctx.rm_kernel_seg = image->priv.ul;
- exec_ctx.rm_kernel = real_to_user ( exec_ctx.rm_kernel_seg, 0 );
- copy_from_user ( &bzhdr, exec_ctx.rm_kernel, BZI_HDR_OFFSET,
- sizeof ( bzhdr ) );
- exec_ctx.rm_cmdline = exec_ctx.rm_heap =
- ( bzhdr.heap_end_ptr + 0x200 );
- exec_ctx.vid_mode = bzhdr.vid_mode;
- if ( bzhdr.version >= 0x0203 ) {
- exec_ctx.mem_limit = bzhdr.initrd_addr_max;
- } else {
- exec_ctx.mem_limit = BZI_INITRD_MAX;
- }
- if ( bzhdr.version >= 0x0206 ) {
- exec_ctx.cmdline_size = bzhdr.cmdline_size;
- } else {
- exec_ctx.cmdline_size = BZI_CMDLINE_SIZE;
- }
- DBG ( "cmdline_size = %zd\n", exec_ctx.cmdline_size );
+ /* Read and parse header from loaded kernel */
+ if ( ( rc = bzimage_parse_header ( image, &bzimg,
+ image->priv.user ) ) != 0 )
+ return rc;
+ assert ( bzimg.rm_kernel == image->priv.user );
/* Parse command line for bootloader parameters */
- if ( ( rc = bzimage_parse_cmdline ( image, &exec_ctx, cmdline ) ) != 0)
+ if ( ( rc = bzimage_parse_cmdline ( image, &bzimg, cmdline ) ) != 0)
return rc;
/* Store command line */
- if ( ( rc = bzimage_set_cmdline ( image, &exec_ctx, cmdline ) ) != 0 )
+ if ( ( rc = bzimage_set_cmdline ( image, &bzimg, cmdline ) ) != 0 )
return rc;
/* Load any initrds */
- if ( ( rc = bzimage_load_initrds ( image, &exec_ctx ) ) != 0 )
+ if ( ( rc = bzimage_load_initrds ( image, &bzimg ) ) != 0 )
return rc;
- /* Update and store kernel header */
- bzhdr.vid_mode = exec_ctx.vid_mode;
- bzhdr.ramdisk_image = exec_ctx.ramdisk_image;
- bzhdr.ramdisk_size = exec_ctx.ramdisk_size;
- copy_to_user ( exec_ctx.rm_kernel, BZI_HDR_OFFSET, &bzhdr,
- sizeof ( bzhdr ) );
+ /* Update kernel header */
+ bzimage_update_header ( image, &bzimg, bzimg.rm_kernel );
/* Prepare for exiting */
shutdown ( SHUTDOWN_BOOT );
DBGC ( image, "bzImage %p jumping to RM kernel at %04x:0000 "
- "(stack %04x:%04zx)\n", image,
- ( exec_ctx.rm_kernel_seg + 0x20 ),
- exec_ctx.rm_kernel_seg, exec_ctx.rm_heap );
+ "(stack %04x:%04zx)\n", image, ( bzimg.rm_kernel_seg + 0x20 ),
+ bzimg.rm_kernel_seg, bzimg.rm_heap );
/* Jump to the kernel */
__asm__ __volatile__ ( REAL_CODE ( "movw %w0, %%ds\n\t"
@@ -365,9 +493,9 @@ static int bzimage_exec ( struct image *image ) {
"pushw %w2\n\t"
"pushw $0\n\t"
"lret\n\t" )
- : : "r" ( exec_ctx.rm_kernel_seg ),
- "r" ( exec_ctx.rm_heap ),
- "r" ( exec_ctx.rm_kernel_seg + 0x20 ) );
+ : : "r" ( bzimg.rm_kernel_seg ),
+ "r" ( bzimg.rm_heap ),
+ "r" ( bzimg.rm_kernel_seg + 0x20 ) );
/* There is no way for the image to return, since we provide
* no return address.
@@ -378,192 +506,49 @@ static int bzimage_exec ( struct image *image ) {
}
/**
- * Load and parse bzImage header
- *
- * @v image bzImage file
- * @v load_ctx Load context
- * @v bzhdr Buffer for bzImage header
- * @ret rc Return status code
- */
-static int bzimage_load_header ( struct image *image,
- struct bzimage_load_context *load_ctx,
- struct bzimage_header *bzhdr ) {
-
- /* Sanity check */
- if ( image->len < ( BZI_HDR_OFFSET + sizeof ( *bzhdr ) ) ) {
- DBGC ( image, "bzImage %p too short for kernel header\n",
- image );
- return -ENOEXEC;
- }
-
- /* Read and verify header */
- copy_from_user ( bzhdr, image->data, BZI_HDR_OFFSET,
- sizeof ( *bzhdr ) );
- if ( bzhdr->header != BZI_SIGNATURE ) {
- DBGC ( image, "bzImage %p bad signature %08x\n",
- image, bzhdr->header );
- return -ENOEXEC;
- }
-
- /* We don't support ancient kernels */
- if ( bzhdr->version < 0x0200 ) {
- DBGC ( image, "bzImage %p version %04x not supported\n",
- image, bzhdr->version );
- return -ENOTSUP;
- }
-
- /* Calculate load address and size of real-mode portion */
- load_ctx->rm_kernel_seg = ( ( bzhdr->loadflags & BZI_LOAD_HIGH ) ?
- 0x1000 : /* 1000:0000 (bzImage) */
- 0x9000 ); /* 9000:0000 (zImage) */
- load_ctx->rm_kernel = real_to_user ( load_ctx->rm_kernel_seg, 0 );
- load_ctx->rm_filesz =
- ( ( bzhdr->setup_sects ? bzhdr->setup_sects : 4 ) + 1 ) << 9;
- load_ctx->rm_memsz = BZI_ASSUMED_RM_SIZE;
- if ( load_ctx->rm_filesz > image->len ) {
- DBGC ( image, "bzImage %p too short for %zd byte of setup\n",
- image, load_ctx->rm_filesz );
- return -ENOEXEC;
- }
-
- /* Calculate load address and size of non-real-mode portion */
- load_ctx->pm_kernel = ( ( bzhdr->loadflags & BZI_LOAD_HIGH ) ?
- phys_to_user ( BZI_LOAD_HIGH_ADDR ) :
- phys_to_user ( BZI_LOAD_LOW_ADDR ) );
- load_ctx->pm_sz = ( image->len - load_ctx->rm_filesz );
-
- DBGC ( image, "bzImage %p version %04x RM %#zx bytes PM %#zx bytes\n",
- image, bzhdr->version, load_ctx->rm_filesz, load_ctx->pm_sz );
- return 0;
-}
-
-/**
- * Load real-mode portion of bzImage
+ * Load bzImage image into memory
*
* @v image bzImage file
- * @v load_ctx Load context
* @ret rc Return status code
*/
-static int bzimage_load_real ( struct image *image,
- struct bzimage_load_context *load_ctx ) {
+int bzimage_load ( struct image *image ) {
+ struct bzimage_context bzimg;
int rc;
- /* Allow space for the stack and heap */
- load_ctx->rm_memsz += BZI_STACK_SIZE;
- load_ctx->rm_heap = load_ctx->rm_memsz;
+ /* Read and parse header from image */
+ if ( ( rc = bzimage_parse_header ( image, &bzimg,
+ image->data ) ) != 0 )
+ return rc;
- /* Allow space for the command line */
- load_ctx->rm_cmdline = load_ctx->rm_memsz;
- load_ctx->rm_memsz += BZI_CMDLINE_SIZE;
+ /* This is a bzImage image, valid or otherwise */
+ if ( ! image->type )
+ image->type = &bzimage_image_type;
- /* Prepare, verify, and load the real-mode segment */
- if ( ( rc = prep_segment ( load_ctx->rm_kernel, load_ctx->rm_filesz,
- load_ctx->rm_memsz ) ) != 0 ) {
+ /* Prepare segments */
+ if ( ( rc = prep_segment ( bzimg.rm_kernel, bzimg.rm_filesz,
+ bzimg.rm_memsz ) ) != 0 ) {
DBGC ( image, "bzImage %p could not prepare RM segment: %s\n",
image, strerror ( rc ) );
return rc;
}
- memcpy_user ( load_ctx->rm_kernel, 0, image->data, 0,
- load_ctx->rm_filesz );
-
- return 0;
-}
-
-/**
- * Load non-real-mode portion of bzImage
- *
- * @v image bzImage file
- * @v load_ctx Load context
- * @ret rc Return status code
- */
-static int bzimage_load_non_real ( struct image *image,
- struct bzimage_load_context *load_ctx ) {
- int rc;
-
- /* Prepare, verify and load the non-real-mode segment */
- if ( ( rc = prep_segment ( load_ctx->pm_kernel, load_ctx->pm_sz,
- load_ctx->pm_sz ) ) != 0 ) {
+ if ( ( rc = prep_segment ( bzimg.pm_kernel, bzimg.pm_sz,
+ bzimg.pm_sz ) ) != 0 ) {
DBGC ( image, "bzImage %p could not prepare PM segment: %s\n",
image, strerror ( rc ) );
return rc;
}
- memcpy_user ( load_ctx->pm_kernel, 0, image->data, load_ctx->rm_filesz,
- load_ctx->pm_sz );
-
- return 0;
-}
-
-/**
- * Update and store bzImage header
- *
- * @v image bzImage file
- * @v load_ctx Load context
- * @v bzhdr Original bzImage header
- * @ret rc Return status code
- */
-static int bzimage_write_header ( struct image *image __unused,
- struct bzimage_load_context *load_ctx,
- struct bzimage_header *bzhdr ) {
- struct bzimage_cmdline cmdline;
-
- /* Update the header and copy it into the loaded kernel */
- bzhdr->type_of_loader = BZI_LOADER_TYPE_GPXE;
- if ( bzhdr->version >= 0x0201 ) {
- bzhdr->heap_end_ptr = ( load_ctx->rm_heap - 0x200 );
- bzhdr->loadflags |= BZI_CAN_USE_HEAP;
- }
- if ( bzhdr->version >= 0x0202 ) {
- bzhdr->cmd_line_ptr = user_to_phys ( load_ctx->rm_kernel,
- load_ctx->rm_cmdline );
- } else {
- cmdline.magic = BZI_CMDLINE_MAGIC;
- cmdline.offset = load_ctx->rm_cmdline;
- copy_to_user ( load_ctx->rm_kernel, BZI_CMDLINE_OFFSET,
- &cmdline, sizeof ( cmdline ) );
- bzhdr->setup_move_size = load_ctx->rm_memsz;
- }
- copy_to_user ( load_ctx->rm_kernel, BZI_HDR_OFFSET,
- bzhdr, sizeof ( *bzhdr ) );
-
- return 0;
-}
-
-/**
- * Load bzImage image into memory
- *
- * @v image bzImage file
- * @ret rc Return status code
- */
-int bzimage_load ( struct image *image ) {
- struct bzimage_load_context load_ctx;
- struct bzimage_header bzhdr;
- int rc;
-
- /* Initialise context */
- memset ( &load_ctx, 0, sizeof ( load_ctx ) );
- /* Load and verify header */
- if ( ( rc = bzimage_load_header ( image, &load_ctx, &bzhdr ) ) != 0 )
- return rc;
-
- /* This is a bzImage image, valid or otherwise */
- if ( ! image->type )
- image->type = &bzimage_image_type;
-
- /* Load real-mode portion */
- if ( ( rc = bzimage_load_real ( image, &load_ctx ) ) != 0 )
- return rc;
-
- /* Load non-real-mode portion */
- if ( ( rc = bzimage_load_non_real ( image, &load_ctx ) ) != 0 )
- return rc;
+ /* Load segments */
+ memcpy_user ( bzimg.rm_kernel, 0, image->data,
+ 0, bzimg.rm_filesz );
+ memcpy_user ( bzimg.pm_kernel, 0, image->data,
+ bzimg.rm_filesz, bzimg.pm_sz );
/* Update and write out header */
- if ( ( rc = bzimage_write_header ( image, &load_ctx, &bzhdr ) ) != 0 )
- return rc;
+ bzimage_update_header ( image, &bzimg, bzimg.rm_kernel );
/* Record real-mode segment in image private data field */
- image->priv.ul = load_ctx.rm_kernel_seg;
+ image->priv.user = bzimg.rm_kernel;
return 0;
}
diff --git a/gpxe/src/arch/i386/image/com32.c b/gpxe/src/arch/i386/image/com32.c
index d1b9a59f..6ab347c1 100644
--- a/gpxe/src/arch/i386/image/com32.c
+++ b/gpxe/src/arch/i386/image/com32.c
@@ -23,6 +23,8 @@
*
*/
+FILE_LICENCE ( GPL2_OR_LATER );
+
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
diff --git a/gpxe/src/arch/i386/image/comboot.c b/gpxe/src/arch/i386/image/comboot.c
index 40e32185..a00b2b95 100644
--- a/gpxe/src/arch/i386/image/comboot.c
+++ b/gpxe/src/arch/i386/image/comboot.c
@@ -23,6 +23,8 @@
*
*/
+FILE_LICENCE ( GPL2_OR_LATER );
+
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
diff --git a/gpxe/src/arch/i386/image/elfboot.c b/gpxe/src/arch/i386/image/elfboot.c
index c8daf72b..a41040e8 100644
--- a/gpxe/src/arch/i386/image/elfboot.c
+++ b/gpxe/src/arch/i386/image/elfboot.c
@@ -16,6 +16,8 @@
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
+FILE_LICENCE ( GPL2_OR_LATER );
+
#include <errno.h>
#include <elf.h>
#include <gpxe/image.h>
diff --git a/gpxe/src/arch/i386/image/eltorito.c b/gpxe/src/arch/i386/image/eltorito.c
index 9d573106..53eb2c02 100644
--- a/gpxe/src/arch/i386/image/eltorito.c
+++ b/gpxe/src/arch/i386/image/eltorito.c
@@ -16,6 +16,8 @@
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
+FILE_LICENCE ( GPL2_OR_LATER );
+
/**
* @file
*
diff --git a/gpxe/src/arch/i386/image/multiboot.c b/gpxe/src/arch/i386/image/multiboot.c
index 52bb10f6..5b620956 100644
--- a/gpxe/src/arch/i386/image/multiboot.c
+++ b/gpxe/src/arch/i386/image/multiboot.c
@@ -16,6 +16,8 @@
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
+FILE_LICENCE ( GPL2_OR_LATER );
+
/**
* @file
*
@@ -139,10 +141,11 @@ static void multiboot_build_memmap ( struct image *image,
/**
* Add command line in base memory
*
+ * @v imgname Image name
* @v cmdline Command line
* @ret physaddr Physical address of command line
*/
-physaddr_t multiboot_add_cmdline ( const char *cmdline ) {
+physaddr_t multiboot_add_cmdline ( const char *imgname, const char *cmdline ) {
char *mb_cmdline;
if ( ! cmdline )
@@ -153,7 +156,7 @@ physaddr_t multiboot_add_cmdline ( const char *cmdline ) {
mb_cmdline_offset +=
( snprintf ( mb_cmdline,
( sizeof ( mb_cmdlines ) - mb_cmdline_offset ),
- "%s", cmdline ) + 1 );
+ "%s %s", imgname, cmdline ) + 1 );
/* Truncate to terminating NUL in buffer if necessary */
if ( mb_cmdline_offset > sizeof ( mb_cmdlines ) )
@@ -208,8 +211,8 @@ multiboot_build_module_list ( struct image *image,
( ( count - insert ) * sizeof ( *module ) ) );
module->mod_start = start;
module->mod_end = end;
- module->string =
- multiboot_add_cmdline ( module_image->cmdline );
+ module->string = multiboot_add_cmdline ( module_image->name,
+ module_image->cmdline );
module->reserved = 0;
/* We promise to page-align modules */
@@ -264,10 +267,8 @@ static int multiboot_exec ( struct image *image ) {
memset ( &mbinfo, 0, sizeof ( mbinfo ) );
mbinfo.flags = ( MBI_FLAG_LOADER | MBI_FLAG_MEM | MBI_FLAG_MMAP |
MBI_FLAG_CMDLINE | MBI_FLAG_MODS );
- multiboot_build_memmap ( image, &mbinfo, mbmemmap,
- ( sizeof(mbmemmap) / sizeof(mbmemmap[0]) ) );
mb_cmdline_offset = 0;
- mbinfo.cmdline = multiboot_add_cmdline ( image->cmdline );
+ mbinfo.cmdline = multiboot_add_cmdline ( image->name, image->cmdline );
mbinfo.mods_count = multiboot_build_module_list ( image, mbmodules,
( sizeof(mbmodules) / sizeof(mbmodules[0]) ) );
mbinfo.mods_addr = virt_to_phys ( mbmodules );
@@ -279,6 +280,12 @@ static int multiboot_exec ( struct image *image ) {
*/
shutdown ( SHUTDOWN_BOOT );
+ /* Build memory map after unhiding bootloader memory regions as part of
+ * shutting everything down.
+ */
+ multiboot_build_memmap ( image, &mbinfo, mbmemmap,
+ ( sizeof(mbmemmap) / sizeof(mbmemmap[0]) ) );
+
/* Jump to OS with flat physical addressing */
DBGC ( image, "MULTIBOOT %p starting execution at %lx\n",
image, entry );
@@ -360,6 +367,13 @@ static int multiboot_load_raw ( struct image *image,
userptr_t buffer;
int rc;
+ /* Sanity check */
+ if ( ! ( hdr->mb.flags & MB_FLAG_RAW ) ) {
+ DBGC ( image, "MULTIBOOT %p is not flagged as a raw image\n",
+ image );
+ return -EINVAL;
+ }
+
/* Verify and prepare segment */
offset = ( hdr->offset - hdr->mb.header_addr + hdr->mb.load_addr );
filesz = ( hdr->mb.load_end_addr ?
@@ -432,14 +446,14 @@ static int multiboot_load ( struct image *image ) {
return -ENOTSUP;
}
- /* Load the actual image */
- if ( hdr.mb.flags & MB_FLAG_RAW ) {
- if ( ( rc = multiboot_load_raw ( image, &hdr ) ) != 0 )
- return rc;
- } else {
- if ( ( rc = multiboot_load_elf ( image ) ) != 0 )
- return rc;
- }
+ /* There is technically a bit MB_FLAG_RAW to indicate whether
+ * this is an ELF or a raw image. In practice, grub will use
+ * the ELF header if present, and Solaris relies on this
+ * behaviour.
+ */
+ if ( ( ( rc = multiboot_load_elf ( image ) ) != 0 ) &&
+ ( ( rc = multiboot_load_raw ( image, &hdr ) ) != 0 ) )
+ return rc;
return 0;
}
diff --git a/gpxe/src/arch/i386/image/pxe_image.c b/gpxe/src/arch/i386/image/pxe_image.c
index 90550d83..63429f87 100644
--- a/gpxe/src/arch/i386/image/pxe_image.c
+++ b/gpxe/src/arch/i386/image/pxe_image.c
@@ -16,6 +16,8 @@
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
+FILE_LICENCE ( GPL2_OR_LATER );
+
/**
* @file
*
@@ -42,28 +44,24 @@ struct image_type pxe_image_type __image_type ( PROBE_PXE );
* @ret rc Return status code
*/
static int pxe_exec ( struct image *image ) {
+ struct net_device *netdev;
int rc;
- /* Ensure that PXE stack is ready to use */
- pxe_init_structures();
- pxe_hook_int1a();
-
/* Arbitrarily pick the most recently opened network device */
- pxe_set_netdev ( last_opened_netdev() );
-
- /* Many things will break if pxe_netdev is NULL */
- if ( ! pxe_netdev ) {
+ if ( ( netdev = last_opened_netdev() ) == NULL ) {
DBGC ( image, "IMAGE %p could not locate PXE net device\n",
image );
return -ENODEV;
}
+ /* Activate PXE */
+ pxe_activate ( netdev );
+
/* Start PXE NBP */
rc = pxe_start_nbp();
/* Deactivate PXE */
- pxe_set_netdev ( NULL );
- pxe_unhook_int1a();
+ pxe_deactivate();
return rc;
}
diff --git a/gpxe/src/arch/i386/include/basemem.h b/gpxe/src/arch/i386/include/basemem.h
index cd5668e0..c477c7fe 100644
--- a/gpxe/src/arch/i386/include/basemem.h
+++ b/gpxe/src/arch/i386/include/basemem.h
@@ -7,6 +7,8 @@
*
*/
+FILE_LICENCE ( GPL2_OR_LATER );
+
#include <stdint.h>
#include <realmode.h>
#include <bios.h>
diff --git a/gpxe/src/arch/i386/include/basemem_packet.h b/gpxe/src/arch/i386/include/basemem_packet.h
index e4d4f49c..3cb47767 100644
--- a/gpxe/src/arch/i386/include/basemem_packet.h
+++ b/gpxe/src/arch/i386/include/basemem_packet.h
@@ -1,6 +1,8 @@
#ifndef BASEMEM_PACKET_H
#define BASEMEM_PACKET_H
+FILE_LICENCE ( GPL2_OR_LATER );
+
#include <realmode.h>
/** Maximum length of base memory packet buffer */
diff --git a/gpxe/src/arch/i386/include/bios.h b/gpxe/src/arch/i386/include/bios.h
index 979a092c..70bb73da 100644
--- a/gpxe/src/arch/i386/include/bios.h
+++ b/gpxe/src/arch/i386/include/bios.h
@@ -1,6 +1,8 @@
#ifndef BIOS_H
#define BIOS_H
+FILE_LICENCE ( GPL2_OR_LATER );
+
#define BDA_SEG 0x0040
#define BDA_FBMS 0x0013
#define BDA_NUM_DRIVES 0x0075
diff --git a/gpxe/src/arch/i386/include/biosint.h b/gpxe/src/arch/i386/include/biosint.h
index d365cf01..ab466af3 100644
--- a/gpxe/src/arch/i386/include/biosint.h
+++ b/gpxe/src/arch/i386/include/biosint.h
@@ -6,6 +6,8 @@
*
*/
+FILE_LICENCE ( GPL2_OR_LATER );
+
#include <realmode.h>
struct segoff;
diff --git a/gpxe/src/arch/i386/include/bits/byteswap.h b/gpxe/src/arch/i386/include/bits/byteswap.h
index 98418c29..ddbd40ed 100644
--- a/gpxe/src/arch/i386/include/bits/byteswap.h
+++ b/gpxe/src/arch/i386/include/bits/byteswap.h
@@ -1,6 +1,8 @@
#ifndef ETHERBOOT_BITS_BYTESWAP_H
#define ETHERBOOT_BITS_BYTESWAP_H
+FILE_LICENCE ( GPL2_OR_LATER );
+
static inline __attribute__ ((always_inline, const)) uint16_t
__bswap_variable_16(uint16_t x)
{
diff --git a/gpxe/src/arch/i386/include/bits/compiler.h b/gpxe/src/arch/i386/include/bits/compiler.h
index 119a9a21..000db0c1 100644
--- a/gpxe/src/arch/i386/include/bits/compiler.h
+++ b/gpxe/src/arch/i386/include/bits/compiler.h
@@ -1,6 +1,8 @@
#ifndef _BITS_COMPILER_H
#define _BITS_COMPILER_H
+FILE_LICENCE ( GPL2_OR_LATER );
+
#ifndef ASSEMBLY
/** Declare a function with standard calling conventions */
diff --git a/gpxe/src/arch/i386/include/bits/endian.h b/gpxe/src/arch/i386/include/bits/endian.h
index 413e702d..84188542 100644
--- a/gpxe/src/arch/i386/include/bits/endian.h
+++ b/gpxe/src/arch/i386/include/bits/endian.h
@@ -1,6 +1,8 @@
#ifndef ETHERBOOT_BITS_ENDIAN_H
#define ETHERBOOT_BITS_ENDIAN_H
+FILE_LICENCE ( GPL2_OR_LATER );
+
#define __BYTE_ORDER __LITTLE_ENDIAN
#endif /* ETHERBOOT_BITS_ENDIAN_H */
diff --git a/gpxe/src/arch/i386/include/bits/errfile.h b/gpxe/src/arch/i386/include/bits/errfile.h
index 5ea8a318..32b8a085 100644
--- a/gpxe/src/arch/i386/include/bits/errfile.h
+++ b/gpxe/src/arch/i386/include/bits/errfile.h
@@ -1,6 +1,8 @@
#ifndef _BITS_ERRFILE_H
#define _BITS_ERRFILE_H
+FILE_LICENCE ( GPL2_OR_LATER );
+
/**
* @addtogroup errfile Error file identifiers
* @{
@@ -12,6 +14,7 @@
#define ERRFILE_bios_smbios ( ERRFILE_ARCH | ERRFILE_CORE | 0x00030000 )
#define ERRFILE_biosint ( ERRFILE_ARCH | ERRFILE_CORE | 0x00040000 )
#define ERRFILE_int13 ( ERRFILE_ARCH | ERRFILE_CORE | 0x00050000 )
+#define ERRFILE_pxeparent ( ERRFILE_ARCH | ERRFILE_CORE | 0x00060000 )
#define ERRFILE_bootsector ( ERRFILE_ARCH | ERRFILE_IMAGE | 0x00000000 )
#define ERRFILE_bzimage ( ERRFILE_ARCH | ERRFILE_IMAGE | 0x00010000 )
diff --git a/gpxe/src/arch/i386/include/bits/io.h b/gpxe/src/arch/i386/include/bits/io.h
index dd0ee444..eded9778 100644
--- a/gpxe/src/arch/i386/include/bits/io.h
+++ b/gpxe/src/arch/i386/include/bits/io.h
@@ -7,6 +7,8 @@
*
*/
+FILE_LICENCE ( GPL2_OR_LATER );
+
#include <gpxe/x86_io.h>
#endif /* _BITS_IO_H */
diff --git a/gpxe/src/arch/i386/include/bits/nap.h b/gpxe/src/arch/i386/include/bits/nap.h
index f8ba7a7c..1354f6bb 100644
--- a/gpxe/src/arch/i386/include/bits/nap.h
+++ b/gpxe/src/arch/i386/include/bits/nap.h
@@ -7,6 +7,8 @@
*
*/
+FILE_LICENCE ( GPL2_OR_LATER );
+
#include <gpxe/bios_nap.h>
#include <gpxe/efi/efix86_nap.h>
diff --git a/gpxe/src/arch/i386/include/bits/smbios.h b/gpxe/src/arch/i386/include/bits/smbios.h
index 647ea19e..a68413aa 100644
--- a/gpxe/src/arch/i386/include/bits/smbios.h
+++ b/gpxe/src/arch/i386/include/bits/smbios.h
@@ -7,6 +7,8 @@
*
*/
+FILE_LICENCE ( GPL2_OR_LATER );
+
#include <gpxe/bios_smbios.h>
#endif /* _BITS_SMBIOS_H */
diff --git a/gpxe/src/arch/i386/include/bits/stdint.h b/gpxe/src/arch/i386/include/bits/stdint.h
index 6ccf0971..8edf1319 100644
--- a/gpxe/src/arch/i386/include/bits/stdint.h
+++ b/gpxe/src/arch/i386/include/bits/stdint.h
@@ -1,8 +1,10 @@
#ifndef _BITS_STDINT_H
#define _BITS_STDINT_H
-typedef unsigned int size_t;
-typedef signed int ssize_t;
+FILE_LICENCE ( GPL2_OR_LATER );
+
+typedef __SIZE_TYPE__ size_t;
+typedef signed long ssize_t;
typedef signed long off_t;
typedef unsigned char uint8_t;
diff --git a/gpxe/src/arch/i386/include/bits/timer.h b/gpxe/src/arch/i386/include/bits/timer.h
index 99666d84..32e6bd47 100644
--- a/gpxe/src/arch/i386/include/bits/timer.h
+++ b/gpxe/src/arch/i386/include/bits/timer.h
@@ -7,6 +7,8 @@
*
*/
+FILE_LICENCE ( GPL2_OR_LATER );
+
#include <gpxe/bios_timer.h>
#include <gpxe/rdtsc_timer.h>
diff --git a/gpxe/src/arch/i386/include/bits/uaccess.h b/gpxe/src/arch/i386/include/bits/uaccess.h
index 0ecc5028..2bb52e02 100644
--- a/gpxe/src/arch/i386/include/bits/uaccess.h
+++ b/gpxe/src/arch/i386/include/bits/uaccess.h
@@ -7,6 +7,8 @@
*
*/
+FILE_LICENCE ( GPL2_OR_LATER );
+
#include <librm.h>
#endif /* _BITS_UACCESS_H */
diff --git a/gpxe/src/arch/i386/include/bits/umalloc.h b/gpxe/src/arch/i386/include/bits/umalloc.h
index dcbd0a6b..17ba2cb2 100644
--- a/gpxe/src/arch/i386/include/bits/umalloc.h
+++ b/gpxe/src/arch/i386/include/bits/umalloc.h
@@ -7,6 +7,8 @@
*
*/
+FILE_LICENCE ( GPL2_OR_LATER );
+
#include <gpxe/memtop_umalloc.h>
#endif /* _BITS_UMALLOC_H */
diff --git a/gpxe/src/arch/i386/include/bootsector.h b/gpxe/src/arch/i386/include/bootsector.h
index e9071052..8730fbfc 100644
--- a/gpxe/src/arch/i386/include/bootsector.h
+++ b/gpxe/src/arch/i386/include/bootsector.h
@@ -6,6 +6,8 @@
* x86 bootsector image format
*/
+FILE_LICENCE ( GPL2_OR_LATER );
+
extern int call_bootsector ( unsigned int segment, unsigned int offset,
unsigned int drive );
diff --git a/gpxe/src/arch/i386/include/bzimage.h b/gpxe/src/arch/i386/include/bzimage.h
index aee058ae..42b31fe4 100644
--- a/gpxe/src/arch/i386/include/bzimage.h
+++ b/gpxe/src/arch/i386/include/bzimage.h
@@ -1,6 +1,8 @@
#ifndef _BZIMAGE_H
#define _BZIMAGE_H
+FILE_LICENCE ( GPL2_OR_LATER );
+
#include <stdint.h>
/**
@@ -75,6 +77,9 @@ struct bzimage_header {
/** Offset of bzImage header within kernel image */
#define BZI_HDR_OFFSET 0x1f1
+/** bzImage boot flag value */
+#define BZI_BOOT_FLAG 0xaa55
+
/** bzImage magic signature value */
#define BZI_SIGNATURE 0x53726448
diff --git a/gpxe/src/arch/i386/include/callbacks_arch.h b/gpxe/src/arch/i386/include/callbacks_arch.h
deleted file mode 100644
index f9cba488..00000000
--- a/gpxe/src/arch/i386/include/callbacks_arch.h
+++ /dev/null
@@ -1,243 +0,0 @@
-/* Callout/callback interface for Etherboot
- *
- * This file provides the mechanisms for making calls from Etherboot
- * to external programs and vice-versa.
- *
- * Initial version by Michael Brown <mbrown@fensystems.co.uk>, January 2004.
- *
- * $Id$
- */
-
-#ifndef CALLBACKS_ARCH_H
-#define CALLBACKS_ARCH_H
-
-/* Skip the definitions that won't make sense to the assembler */
-#ifndef ASSEMBLY
-
-/* Struct to hold general-purpose register values. PUSHAL and POPAL
- * can work directly with this structure; do not change the order of
- * registers.
- */
-typedef struct {
- union {
- uint16_t di;
- uint32_t edi;
- };
- union {
- uint16_t si;
- uint32_t esi;
- };
- union {
- uint16_t bp;
- uint32_t ebp;
- };
- union {
- uint16_t sp;
- uint32_t esp;
- };
- union {
- struct {
- uint8_t bl;
- uint8_t bh;
- } PACKED;
- uint16_t bx;
- uint32_t ebx;
- };
- union {
- struct {
- uint8_t dl;
- uint8_t dh;
- } PACKED;
- uint16_t dx;
- uint32_t edx;
- };
- union {
- struct {
- uint8_t cl;
- uint8_t ch;
- } PACKED;
- uint16_t cx;
- uint32_t ecx;
- };
- union {
- struct {
- uint8_t al;
- uint8_t ah;
- } PACKED;
- uint16_t ax;
- uint32_t eax;
- };
-} regs_t;
-
-/* Struct to hold segment register values. Don't change the order;
- * many bits of assembly code rely on it.
- */
-typedef struct {
- uint16_t cs;
- uint16_t ss;
- uint16_t ds;
- uint16_t es;
- uint16_t fs;
- uint16_t gs;
-} PACKED seg_regs_t;
-
-/* Struct for a GDT descriptor */
-typedef struct {
- uint16_t limit;
- uint32_t address;
- uint16_t padding;
-} PACKED gdt_descriptor_t;
-
-/* Struct for a GDT entry. Use GDT_SEGMENT() to fill it in.
- */
-typedef struct {
- uint16_t limit_0_15;
- uint16_t base_0_15;
- uint8_t base_16_23;
- uint8_t accessed__type__sflag__dpl__present;
- uint8_t limit_16_19__avl__size__granularity;
- uint8_t base_24_31;
-} PACKED gdt_segment_t;
-
-#define GDT_SEGMENT(base,limit,type,sflag,dpl,avl,size,granularity) \
- ( (gdt_segment_t) { \
- ( (limit) & 0xffff ), \
- ( (base) & 0xffff ), \
- ( ( (base) >> 16 ) & 0xff ), \
- ( ( 1 << 0 ) | ( (type) << 1 ) | \
- ( (sflag) << 4 ) | ( (dpl) << 5 ) | ( 1 << 7 ) ), \
- ( ( (limit) >> 16 ) | \
- ( (avl) << 4 ) | ( (size) << 5 ) | ( (granularity) << 7 ) ),\
- ( (base) >> 24 ) \
- } )
-#define GDT_SEGMENT_BASE(gdt_segment) \
- ( (gdt_segment)->base_0_15 | \
- (gdt_segment)->base_16_23 << 16 | \
- (gdt_segment)->base_24_31 << 24 )
-#define GDT_SEGMENT_LIMIT(gdt_segment) \
- ( (gdt_segment)->limit_0_15 | \
- ( ( (gdt_segment)->limit_16_19__avl__size__granularity \
- & 0xf ) << 16 ) )
-#define GDT_SEGMENT_GRANULARITY(gdt_segment) \
- ( ( (gdt_segment)->limit_16_19__avl__size__granularity \
- & 0x80 ) >> 7 )
-#define GDT_SEGMENT_TYPE(gdt_segment) \
- ( ( (gdt_segment)->accessed__type__sflag__dpl__present & 0x0e ) >> 1 )
-#define GDT_SEGMENT_SIZE(gdt_segment) \
- ( ( (gdt_segment)->limit_16_19__avl__size__granularity \
- & 0x60 ) >> 5 )
-
-#define GDT_TYPE_DATA (0x0)
-#define GDT_TYPE_STACK (0x2)
-#define GDT_TYPE_WRITEABLE (0x1)
-#define GDT_TYPE_CODE (0x6)
-#define GDT_TYPE_EXEC_ONLY_CODE (0x4)
-#define GDT_TYPE_CONFORMING (0x1)
-#define GDT_SFLAG_SYSTEM (0)
-#define GDT_SFLAG_NORMAL (1)
-#define GDT_AVL_NORMAL (0)
-#define GDT_SIZE_16BIT (0x0)
-#define GDT_SIZE_32BIT (0x2)
-#define GDT_SIZE_64BIT (0x1)
-#define GDT_SIZE_UNKNOWN (0x3)
-#define GDT_GRANULARITY_SMALL (0)
-#define GDT_GRANULARITY_LARGE (1)
-#define GDT_SEGMENT_NORMAL(base,limit,type,size,granularity) \
- GDT_SEGMENT ( base, limit, type, \
- GDT_SFLAG_NORMAL, 0, GDT_AVL_NORMAL, \
- size, granularity )
-
-/* Protected mode code segment */
-#define GDT_SEGMENT_PMCS(base) GDT_SEGMENT_NORMAL ( \
- base, 0xfffff, GDT_TYPE_CODE | GDT_TYPE_CONFORMING, \
- GDT_SIZE_32BIT, GDT_GRANULARITY_LARGE )
-#define GDT_SEGMENT_PMCS_PHYS GDT_SEGMENT_PMCS(0)
-/* Protected mode data segment */
-#define GDT_SEGMENT_PMDS(base) GDT_SEGMENT_NORMAL ( \
- base, 0xfffff, GDT_TYPE_DATA | GDT_TYPE_WRITEABLE, \
- GDT_SIZE_32BIT, GDT_GRANULARITY_LARGE )
-#define GDT_SEGMENT_PMDS_PHYS GDT_SEGMENT_PMDS(0)
-/* Real mode code segment */
-/* Not sure if there's any reason to use GDT_TYPE_EXEC_ONLY_CODE
- * instead of just GDT_TYPE_CODE, but that's what our old GDT did and
- * it worked, so I'm not changing it.
- */
-#define GDT_SEGMENT_RMCS(base) GDT_SEGMENT_NORMAL ( \
- base, 0xffff, GDT_TYPE_EXEC_ONLY_CODE | GDT_TYPE_CONFORMING, \
- GDT_SIZE_16BIT, GDT_GRANULARITY_SMALL )
-/* Real mode data segment */
-#define GDT_SEGMENT_RMDS(base) GDT_SEGMENT_NORMAL ( \
- base, 0xffff, GDT_TYPE_DATA | GDT_TYPE_WRITEABLE, \
- GDT_SIZE_16BIT, GDT_GRANULARITY_SMALL )
-/* Long mode code segment */
-#define GDT_SEGMENT_LMCS(base) GDT_SEGMENT_NORMAL ( \
- base, 0xfffff, GDT_TYPE_CODE | GDT_TYPE_CONFORMING, \
- GDT_SIZE_64BIT, GDT_GRANULARITY_LARGE )
-#define GDT_SEGMENT_LMCS_PHYS GDT_SEGMENT_LMCS(0)
-/* Long mode data segment */
-/* AFIACT, GDT_SIZE_64BIT applies only to code segments */
-#define GDT_SEGMENT_LMDS(base) GDT_SEGMENT_NORMAL ( \
- base, 0xfffff, GDT_TYPE_DATA | GDT_TYPE_WRITEABLE, \
- GDT_SIZE_32BIT, GDT_GRANULARITY_LARGE )
-#define GDT_SEGMENT_LMDS_PHYS GDT_SEGMENT_LMDS(0)
-
-/* Template for creating GDT structures (including segment register
- * lists), suitable for passing as parameters to external_call().
- */
-#define GDT_STRUCT_t(num_segments) \
- struct { \
- gdt_descriptor_t descriptor; \
- gdt_segment_t segments[num_segments]; \
- } PACKED
-/* And utility function for filling it in */
-#define GDT_ADJUST(structure) { \
- (structure)->descriptor.address = \
- virt_to_phys(&((structure)->descriptor.limit)); \
- (structure)->descriptor.limit = \
- sizeof((structure)->segments) + 8 - 1; \
- (structure)->descriptor.padding = 0; \
-}
-
-/* Data passed in to in_call() by assembly wrapper.
- */
-typedef struct {
- regs_t regs;
- seg_regs_t seg_regs;
- gdt_descriptor_t gdt_desc;
- uint32_t flags;
- struct {
- uint32_t offset;
- uint32_t segment;
- } ret_addr;
-} PACKED i386_pm_in_call_data_t;
-
-typedef struct {
- seg_regs_t seg_regs;
- union {
- uint16_t pad;
- uint16_t prefix_sp;
- };
- uint16_t flags;
- struct {
- uint16_t offset;
- uint16_t segment;
- } ret_addr;
- uint32_t orig_opcode;
-} PACKED i386_rm_in_call_data_t;
-
-typedef struct {
- i386_pm_in_call_data_t *pm;
- i386_rm_in_call_data_t *rm;
-} i386_in_call_data_t;
-#define in_call_data_t i386_in_call_data_t
-
-/* Function prototypes
- */
-extern int install_rm_callback_interface ( void *address, size_t available );
-
-#endif /* ASSEMBLY */
-
-#define RM_IN_CALL (0)
-#define RM_IN_CALL_FAR (2)
-
-#endif /* CALLBACKS_ARCH_H */
diff --git a/gpxe/src/arch/i386/include/comboot.h b/gpxe/src/arch/i386/include/comboot.h
index 56661a80..1232f0a7 100644
--- a/gpxe/src/arch/i386/include/comboot.h
+++ b/gpxe/src/arch/i386/include/comboot.h
@@ -7,6 +7,8 @@
* SYSLINUX COMBOOT
*/
+FILE_LICENCE ( GPL2_OR_LATER );
+
#include <stdint.h>
#include <setjmp.h>
#include <gpxe/in.h>
diff --git a/gpxe/src/arch/i386/include/fakee820.h b/gpxe/src/arch/i386/include/fakee820.h
index f1fe8aff..9d00fb67 100644
--- a/gpxe/src/arch/i386/include/fakee820.h
+++ b/gpxe/src/arch/i386/include/fakee820.h
@@ -1,6 +1,8 @@
#ifndef _FAKEE820_H
#define _FAKEE820_H
+FILE_LICENCE ( GPL2_OR_LATER );
+
extern void fake_e820 ( void );
extern void unfake_e820 ( void );
diff --git a/gpxe/src/arch/i386/include/gpxe/abft.h b/gpxe/src/arch/i386/include/gpxe/abft.h
index 1c651ef1..9065e61a 100644
--- a/gpxe/src/arch/i386/include/gpxe/abft.h
+++ b/gpxe/src/arch/i386/include/gpxe/abft.h
@@ -7,6 +7,8 @@
*
*/
+FILE_LICENCE ( GPL2_OR_LATER );
+
#include <stdint.h>
#include <gpxe/acpi.h>
#include <gpxe/if_ether.h>
diff --git a/gpxe/src/arch/i386/include/gpxe/bios_nap.h b/gpxe/src/arch/i386/include/gpxe/bios_nap.h
index f1c721e9..c32429b9 100644
--- a/gpxe/src/arch/i386/include/gpxe/bios_nap.h
+++ b/gpxe/src/arch/i386/include/gpxe/bios_nap.h
@@ -7,6 +7,8 @@
*
*/
+FILE_LICENCE ( GPL2_OR_LATER );
+
#ifdef NAP_PCBIOS
#define NAP_PREFIX_pcbios
#else
diff --git a/gpxe/src/arch/i386/include/gpxe/bios_smbios.h b/gpxe/src/arch/i386/include/gpxe/bios_smbios.h
index 0a6f277a..83726b11 100644
--- a/gpxe/src/arch/i386/include/gpxe/bios_smbios.h
+++ b/gpxe/src/arch/i386/include/gpxe/bios_smbios.h
@@ -7,6 +7,8 @@
*
*/
+FILE_LICENCE ( GPL2_OR_LATER );
+
#ifdef SMBIOS_PCBIOS
#define SMBIOS_PREFIX_pcbios
#else
diff --git a/gpxe/src/arch/i386/include/gpxe/bios_timer.h b/gpxe/src/arch/i386/include/gpxe/bios_timer.h
index 7e3caa3c..ed9df522 100644
--- a/gpxe/src/arch/i386/include/gpxe/bios_timer.h
+++ b/gpxe/src/arch/i386/include/gpxe/bios_timer.h
@@ -7,6 +7,8 @@
*
*/
+FILE_LICENCE ( GPL2_OR_LATER );
+
#ifdef TIMER_PCBIOS
#define TIMER_PREFIX_pcbios
#else
diff --git a/gpxe/src/arch/i386/include/gpxe/ibft.h b/gpxe/src/arch/i386/include/gpxe/ibft.h
index 5eef547b..c41e2e40 100644
--- a/gpxe/src/arch/i386/include/gpxe/ibft.h
+++ b/gpxe/src/arch/i386/include/gpxe/ibft.h
@@ -28,6 +28,8 @@
*
*/
+FILE_LICENCE ( BSD2 );
+
/** @file
*
* iSCSI boot firmware table
diff --git a/gpxe/src/arch/i386/include/gpxe/memtop_umalloc.h b/gpxe/src/arch/i386/include/gpxe/memtop_umalloc.h
index a3cd2c01..eaf7025b 100644
--- a/gpxe/src/arch/i386/include/gpxe/memtop_umalloc.h
+++ b/gpxe/src/arch/i386/include/gpxe/memtop_umalloc.h
@@ -7,6 +7,8 @@
*
*/
+FILE_LICENCE ( GPL2_OR_LATER );
+
#ifdef UMALLOC_MEMTOP
#define UMALLOC_PREFIX_memtop
#else
diff --git a/gpxe/src/arch/i386/include/gpxe/rdtsc_timer.h b/gpxe/src/arch/i386/include/gpxe/rdtsc_timer.h
index 0e03d707..67ba22f0 100644
--- a/gpxe/src/arch/i386/include/gpxe/rdtsc_timer.h
+++ b/gpxe/src/arch/i386/include/gpxe/rdtsc_timer.h
@@ -7,6 +7,8 @@
*
*/
+FILE_LICENCE ( GPL2_OR_LATER );
+
#ifdef TIMER_RDTSC
#define TIMER_PREFIX_rdtsc
#else
diff --git a/gpxe/src/arch/i386/include/gpxe/sbft.h b/gpxe/src/arch/i386/include/gpxe/sbft.h
new file mode 100644
index 00000000..30038436
--- /dev/null
+++ b/gpxe/src/arch/i386/include/gpxe/sbft.h
@@ -0,0 +1,125 @@
+#ifndef _GPXE_SBFT_H
+#define _GPXE_SBFT_H
+
+/*
+ * Copyright (C) 2009 Fen Systems Ltd <mbrown@fensystems.co.uk>.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT HOLDER 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.
+ */
+
+FILE_LICENCE ( BSD2 );
+
+/** @file
+ *
+ * SRP boot firmware table
+ *
+ * The working draft specification for the SRP boot firmware table can
+ * be found at
+ *
+ * http://etherboot.org/wiki/srp/sbft
+ *
+ */
+
+#include <stdint.h>
+#include <gpxe/acpi.h>
+#include <gpxe/scsi.h>
+#include <gpxe/srp.h>
+#include <gpxe/ib_srp.h>
+
+/** SRP Boot Firmware Table signature */
+#define SBFT_SIG "sBFT"
+
+/** An offset from the start of the sBFT */
+typedef uint16_t sbft_off_t;
+
+/**
+ * SRP Boot Firmware Table
+ */
+struct sbft_table {
+ /** ACPI header */
+ struct acpi_description_header acpi;
+ /** Offset to SCSI subtable */
+ sbft_off_t scsi_offset;
+ /** Offset to SRP subtable */
+ sbft_off_t srp_offset;
+ /** Offset to IB subtable, if present */
+ sbft_off_t ib_offset;
+ /** Reserved */
+ uint8_t reserved[6];
+} __attribute__ (( packed ));
+
+/**
+ * sBFT SCSI subtable
+ */
+struct sbft_scsi_subtable {
+ /** LUN */
+ struct scsi_lun lun;
+} __attribute__ (( packed ));
+
+/**
+ * sBFT SRP subtable
+ */
+struct sbft_srp_subtable {
+ /** Initiator and target ports */
+ struct srp_port_ids port_ids;
+} __attribute__ (( packed ));
+
+/**
+ * sBFT IB subtable
+ */
+struct sbft_ib_subtable {
+ /** Source GID */
+ struct ib_gid sgid;
+ /** Destination GID */
+ struct ib_gid dgid;
+ /** Service ID */
+ struct ib_gid_half service_id;
+ /** Partition key */
+ uint16_t pkey;
+ /** Reserved */
+ uint8_t reserved[6];
+} __attribute__ (( packed ));
+
+/**
+ * An sBFT created by gPXE
+ */
+struct gpxe_sbft {
+ /** The table header */
+ struct sbft_table table;
+ /** The SCSI subtable */
+ struct sbft_scsi_subtable scsi;
+ /** The SRP subtable */
+ struct sbft_srp_subtable srp;
+ /** The IB subtable */
+ struct sbft_ib_subtable ib;
+} __attribute__ (( packed, aligned ( 16 ) ));
+
+struct srp_device;
+
+extern int sbft_fill_data ( struct srp_device *srp );
+
+#endif /* _GPXE_SBFT_H */
diff --git a/gpxe/src/arch/i386/include/gpxe/timer2.h b/gpxe/src/arch/i386/include/gpxe/timer2.h
index 59705fa2..8f119515 100644
--- a/gpxe/src/arch/i386/include/gpxe/timer2.h
+++ b/gpxe/src/arch/i386/include/gpxe/timer2.h
@@ -7,6 +7,8 @@
*
*/
+FILE_LICENCE ( GPL2_OR_LATER );
+
extern void timer2_udelay ( unsigned long usecs );
#endif /* _GPXE_TIMER2_H */
diff --git a/gpxe/src/arch/i386/include/gpxe/x86_io.h b/gpxe/src/arch/i386/include/gpxe/x86_io.h
index b1ae3bac..beb5b22a 100644
--- a/gpxe/src/arch/i386/include/gpxe/x86_io.h
+++ b/gpxe/src/arch/i386/include/gpxe/x86_io.h
@@ -15,6 +15,8 @@
* into a machine with such an old CPU anyway.
*/
+FILE_LICENCE ( GPL2_OR_LATER );
+
#ifdef IOAPI_X86
#define IOAPI_PREFIX_x86
#else
diff --git a/gpxe/src/arch/i386/include/int13.h b/gpxe/src/arch/i386/include/int13.h
index bf6d0318..e1884d94 100644
--- a/gpxe/src/arch/i386/include/int13.h
+++ b/gpxe/src/arch/i386/include/int13.h
@@ -7,6 +7,8 @@
*
*/
+FILE_LICENCE ( GPL2_OR_LATER );
+
#include <stdint.h>
#include <gpxe/list.h>
#include <realmode.h>
diff --git a/gpxe/src/arch/i386/include/librm.h b/gpxe/src/arch/i386/include/librm.h
index 9eb2767a..f193f5e3 100755..100644
--- a/gpxe/src/arch/i386/include/librm.h
+++ b/gpxe/src/arch/i386/include/librm.h
@@ -1,6 +1,8 @@
#ifndef LIBRM_H
#define LIBRM_H
+FILE_LICENCE ( GPL2_OR_LATER );
+
/* Segment selectors as used in our protected-mode GDTs.
*
* Don't change these unless you really know what you're doing.
diff --git a/gpxe/src/arch/i386/include/limits.h b/gpxe/src/arch/i386/include/limits.h
index f13db267..031b6c57 100644
--- a/gpxe/src/arch/i386/include/limits.h
+++ b/gpxe/src/arch/i386/include/limits.h
@@ -1,6 +1,8 @@
#ifndef LIMITS_H
#define LIMITS_H 1
+FILE_LICENCE ( GPL2_OR_LATER );
+
/* Number of bits in a `char' */
#define CHAR_BIT 8
diff --git a/gpxe/src/arch/i386/include/memsizes.h b/gpxe/src/arch/i386/include/memsizes.h
index 6222fd66..7b217494 100644
--- a/gpxe/src/arch/i386/include/memsizes.h
+++ b/gpxe/src/arch/i386/include/memsizes.h
@@ -1,6 +1,8 @@
#ifndef _MEMSIZES_H
#define _MEMSIZES_H
+FILE_LICENCE ( GPL2_OR_LATER );
+
#include <basemem.h>
/**
diff --git a/gpxe/src/arch/i386/include/multiboot.h b/gpxe/src/arch/i386/include/multiboot.h
index 4ca7089b..44614c73 100644
--- a/gpxe/src/arch/i386/include/multiboot.h
+++ b/gpxe/src/arch/i386/include/multiboot.h
@@ -8,6 +8,8 @@
*
*/
+FILE_LICENCE ( GPL2_OR_LATER );
+
#include <stdint.h>
/** The magic number for the Multiboot header */
diff --git a/gpxe/src/arch/i386/include/pic8259.h b/gpxe/src/arch/i386/include/pic8259.h
index 0c501a9c..f8e20c4c 100644
--- a/gpxe/src/arch/i386/include/pic8259.h
+++ b/gpxe/src/arch/i386/include/pic8259.h
@@ -4,6 +4,8 @@
* Initially written by Michael Brown (mcb30).
*/
+FILE_LICENCE ( GPL2_OR_LATER );
+
#ifndef PIC8259_H
#define PIC8259_H
diff --git a/gpxe/src/arch/i386/include/pnpbios.h b/gpxe/src/arch/i386/include/pnpbios.h
index ab31c699..4c20e73e 100644
--- a/gpxe/src/arch/i386/include/pnpbios.h
+++ b/gpxe/src/arch/i386/include/pnpbios.h
@@ -7,6 +7,8 @@
*
*/
+FILE_LICENCE ( GPL2_OR_LATER );
+
/* BIOS segment address */
#define BIOS_SEG 0xf000
diff --git a/gpxe/src/arch/i386/include/pxe.h b/gpxe/src/arch/i386/include/pxe.h
index 6d332ac7..041ee7ba 100644
--- a/gpxe/src/arch/i386/include/pxe.h
+++ b/gpxe/src/arch/i386/include/pxe.h
@@ -1,6 +1,8 @@
#ifndef PXE_H
#define PXE_H
+FILE_LICENCE ( GPL2_OR_LATER );
+
#include "pxe_types.h"
#include "pxe_api.h"
#include <gpxe/device.h>
@@ -65,6 +67,7 @@ union u_PXENV_ANY {
struct s_PXENV_GET_FILE_SIZE get_file_size;
struct s_PXENV_FILE_EXEC file_exec;
struct s_PXENV_FILE_API_CHECK file_api_check;
+ struct s_PXENV_FILE_EXIT_HOOK file_exit_hook;
};
typedef union u_PXENV_ANY PXENV_ANY_t;
diff --git a/gpxe/src/arch/i386/include/pxe_api.h b/gpxe/src/arch/i386/include/pxe_api.h
index b3d4bca8..92f046f7 100644
--- a/gpxe/src/arch/i386/include/pxe_api.h
+++ b/gpxe/src/arch/i386/include/pxe_api.h
@@ -15,6 +15,31 @@
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ * As an alternative, at your option, you may use this file under the
+ * following terms, known as the "MIT license":
+ *
+ * Copyright (c) 2005-2009 Michael Brown <mbrown@fensystems.co.uk>
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation
+ * files (the "Software"), to deal in the Software without
+ * restriction, including without limitation the rights to use, copy,
+ * modify, merge, publish, distribute, sublicense, and/or sell copies
+ * of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
*/
/** @file
@@ -23,6 +48,8 @@
*
*/
+FILE_LICENCE ( GPL2_OR_LATER );
+
#include "pxe_types.h"
/** @addtogroup pxe Preboot eXecution Environment (PXE) API
@@ -1415,6 +1442,25 @@ extern PXENV_EXIT_t pxenv_undi_get_nic_type (
/** PXE API function code for pxenv_undi_get_iface_info() */
#define PXENV_UNDI_GET_IFACE_INFO 0x0013
+/** Broadcast supported */
+#define SUPPORTED_BROADCAST 0x0001
+/** Multicast supported */
+#define SUPPORTED_MULTICAST 0x0002
+/** Functional/group addressing supported */
+#define SUPPORTED_GROUP 0x0004
+/** Promiscuous mode supported */
+#define SUPPORTED_PROMISCUOUS 0x0008
+/** Software settable station address */
+#define SUPPORTED_SET_STATION_ADDRESS 0x0010
+/** InitiateDiagnostics supported */
+#define SUPPORTED_DIAGNOSTICS 0x0040
+/** Reset MAC supported */
+#define SUPPORTED_RESET 0x0400
+/** Open / Close Adapter supported */
+#define SUPPORTED_OPEN_CLOSE 0x0800
+/** Interrupt Request supported */
+#define SUPPORTED_IRQ 0x1000
+
/** Parameter block for pxenv_undi_get_iface_info() */
struct s_PXENV_UNDI_GET_IFACE_INFO {
PXENV_STATUS_t Status; /**< PXE status code */
@@ -1732,6 +1778,28 @@ extern PXENV_EXIT_t pxenv_file_api_check ( struct s_PXENV_FILE_API_CHECK *file_a
/** @} */ /* pxenv_file_api_check */
+/** @defgroup pxenv_file_exit_hook PXENV_FILE_EXIT_HOOK
+ *
+ * FILE EXIT HOOK
+ *
+ * @{
+ */
+
+/** PXE API function code for pxenv_file_exit_hook() */
+#define PXENV_FILE_EXIT_HOOK 0x00e7
+
+/** Parameter block for pxenv_file_exit_hook() */
+struct s_PXENV_FILE_EXIT_HOOK {
+ PXENV_STATUS_t Status; /**< PXE status code */
+ SEGOFF16_t Hook; /**< SEG16:OFF16 to jump to */
+} PACKED;
+
+typedef struct s_PXENV_FILE_EXIT_HOOK PXENV_FILE_EXIT_HOOK_t;
+
+extern PXENV_EXIT_t pxenv_file_exit_hook ( struct s_PXENV_FILE_EXIT_HOOK *file_exit_hook );
+
+/** @} */ /* pxenv_file_exit_hook */
+
/** @} */ /* pxe_file_api */
/** @defgroup pxe_loader_api PXE Loader API
diff --git a/gpxe/src/arch/i386/include/pxe_call.h b/gpxe/src/arch/i386/include/pxe_call.h
index 2f3ea15a..4d245616 100644
--- a/gpxe/src/arch/i386/include/pxe_call.h
+++ b/gpxe/src/arch/i386/include/pxe_call.h
@@ -6,9 +6,13 @@
* PXE API entry point
*/
+FILE_LICENCE ( GPL2_OR_LATER );
+
#include <pxe_api.h>
#include <realmode.h>
+struct net_device;
+
/** PXE load address segment */
#define PXE_LOAD_SEGMENT 0
@@ -26,10 +30,28 @@ extern struct s_PXE __text16 ( ppxe );
extern struct s_PXENV __text16 ( pxenv );
#define pxenv __use_text16 ( pxenv )
-extern void pxe_hook_int1a ( void );
-extern int pxe_unhook_int1a ( void );
-extern void pxe_init_structures ( void );
+extern void pxe_activate ( struct net_device *netdev );
+extern int pxe_deactivate ( void );
extern int pxe_start_nbp ( void );
extern __asmcall void pxe_api_call ( struct i386_all_regs *ix86 );
+extern int _pxe_api_call_weak ( struct i386_all_regs *ix86 )
+ __attribute__ (( weak ));
+
+/**
+ * Dispatch PXE API call weakly
+ *
+ * @v ix86 Registers for PXE call
+ * @ret present Zero if the PXE stack is present, nonzero if not
+ *
+ * A successful return only indicates that the PXE stack was available
+ * for dispatching the call; it says nothing about the success of
+ * whatever the call asked for.
+ */
+static inline int pxe_api_call_weak ( struct i386_all_regs *ix86 )
+{
+ if ( _pxe_api_call_weak != NULL )
+ return _pxe_api_call_weak ( ix86 );
+ return -1;
+}
#endif /* _PXE_CALL_H */
diff --git a/gpxe/src/arch/i386/include/pxe_types.h b/gpxe/src/arch/i386/include/pxe_types.h
index dd9092ef..a6516d25 100644
--- a/gpxe/src/arch/i386/include/pxe_types.h
+++ b/gpxe/src/arch/i386/include/pxe_types.h
@@ -7,6 +7,8 @@
*
*/
+FILE_LICENCE ( GPL2_OR_LATER );
+
#include <stdint.h>
#include <errno.h> /* PXE status codes */
diff --git a/gpxe/src/arch/i386/include/pxeparent.h b/gpxe/src/arch/i386/include/pxeparent.h
new file mode 100644
index 00000000..b31e24a7
--- /dev/null
+++ b/gpxe/src/arch/i386/include/pxeparent.h
@@ -0,0 +1,11 @@
+#ifndef PXEPARENT_H
+#define PXEPARENT_H
+
+FILE_LICENCE ( GPL2_OR_LATER );
+
+#include <pxe_types.h>
+
+extern int pxeparent_call ( SEGOFF16_t entry, unsigned int function,
+ void *params, size_t params_len );
+
+#endif
diff --git a/gpxe/src/arch/i386/include/realmode.h b/gpxe/src/arch/i386/include/realmode.h
index 26e6dd77..a0a830b9 100644
--- a/gpxe/src/arch/i386/include/realmode.h
+++ b/gpxe/src/arch/i386/include/realmode.h
@@ -10,6 +10,8 @@
*
*/
+FILE_LICENCE ( GPL2_OR_LATER );
+
/*
* Declaration of variables in .data16
*
diff --git a/gpxe/src/arch/i386/include/registers.h b/gpxe/src/arch/i386/include/registers.h
index e68fa85a..2839e2bd 100644
--- a/gpxe/src/arch/i386/include/registers.h
+++ b/gpxe/src/arch/i386/include/registers.h
@@ -10,6 +10,8 @@
*
*/
+FILE_LICENCE ( GPL2_OR_LATER );
+
#include <stdint.h>
/**
diff --git a/gpxe/src/arch/i386/include/setjmp.h b/gpxe/src/arch/i386/include/setjmp.h
index c18d03e1..5d3c11b6 100644
--- a/gpxe/src/arch/i386/include/setjmp.h
+++ b/gpxe/src/arch/i386/include/setjmp.h
@@ -1,6 +1,8 @@
#ifndef ETHERBOOT_SETJMP_H
#define ETHERBOOT_SETJMP_H
+FILE_LICENCE ( GPL2_OR_LATER );
+
#include <stdint.h>
#include <realmode.h>
diff --git a/gpxe/src/arch/i386/include/undi.h b/gpxe/src/arch/i386/include/undi.h
index c6253d0a..de6925b6 100644
--- a/gpxe/src/arch/i386/include/undi.h
+++ b/gpxe/src/arch/i386/include/undi.h
@@ -7,6 +7,8 @@
*
*/
+FILE_LICENCE ( GPL2_OR_LATER );
+
#ifndef ASSEMBLY
#include <gpxe/device.h>
diff --git a/gpxe/src/arch/i386/include/undiload.h b/gpxe/src/arch/i386/include/undiload.h
index bfc11874..426830e8 100644
--- a/gpxe/src/arch/i386/include/undiload.h
+++ b/gpxe/src/arch/i386/include/undiload.h
@@ -7,6 +7,8 @@
*
*/
+FILE_LICENCE ( GPL2_OR_LATER );
+
struct undi_device;
struct undi_rom;
diff --git a/gpxe/src/arch/i386/include/undinet.h b/gpxe/src/arch/i386/include/undinet.h
index 1a4a385e..c3c17c11 100644
--- a/gpxe/src/arch/i386/include/undinet.h
+++ b/gpxe/src/arch/i386/include/undinet.h
@@ -7,6 +7,8 @@
*
*/
+FILE_LICENCE ( GPL2_OR_LATER );
+
struct undi_device;
extern int undinet_probe ( struct undi_device *undi );
diff --git a/gpxe/src/arch/i386/include/undipreload.h b/gpxe/src/arch/i386/include/undipreload.h
index d9bc8cb9..de9b8fb5 100644
--- a/gpxe/src/arch/i386/include/undipreload.h
+++ b/gpxe/src/arch/i386/include/undipreload.h
@@ -7,6 +7,8 @@
*
*/
+FILE_LICENCE ( GPL2_OR_LATER );
+
#include <realmode.h>
#include <undi.h>
diff --git a/gpxe/src/arch/i386/include/undirom.h b/gpxe/src/arch/i386/include/undirom.h
index a2636007..86d7077b 100644
--- a/gpxe/src/arch/i386/include/undirom.h
+++ b/gpxe/src/arch/i386/include/undirom.h
@@ -7,6 +7,8 @@
*
*/
+FILE_LICENCE ( GPL2_OR_LATER );
+
#include <pxe_types.h>
/** An UNDI PCI device ID */
diff --git a/gpxe/src/arch/i386/interface/pcbios/abft.c b/gpxe/src/arch/i386/interface/pcbios/abft.c
index af28bbcf..86941728 100644
--- a/gpxe/src/arch/i386/interface/pcbios/abft.c
+++ b/gpxe/src/arch/i386/interface/pcbios/abft.c
@@ -16,6 +16,8 @@
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
+FILE_LICENCE ( GPL2_OR_LATER );
+
#include <realmode.h>
#include <gpxe/aoe.h>
#include <gpxe/netdevice.h>
diff --git a/gpxe/src/arch/i386/interface/pcbios/aoeboot.c b/gpxe/src/arch/i386/interface/pcbios/aoeboot.c
index 6e1e51cb..2670b15d 100644
--- a/gpxe/src/arch/i386/interface/pcbios/aoeboot.c
+++ b/gpxe/src/arch/i386/interface/pcbios/aoeboot.c
@@ -1,58 +1,74 @@
#include <stdint.h>
#include <string.h>
+#include <stdlib.h>
#include <stdio.h>
-#include <byteswap.h>
+#include <errno.h>
#include <gpxe/aoe.h>
#include <gpxe/ata.h>
#include <gpxe/netdevice.h>
-#include <gpxe/settings.h>
#include <gpxe/sanboot.h>
#include <gpxe/abft.h>
#include <int13.h>
+FILE_LICENCE ( GPL2_OR_LATER );
+
static int aoeboot ( const char *root_path ) {
- struct ata_device ata;
- struct int13_drive drive;
+ struct ata_device *ata;
+ struct int13_drive *drive;
int rc;
- memset ( &ata, 0, sizeof ( ata ) );
- memset ( &drive, 0, sizeof ( drive ) );
-
- printf ( "AoE booting from %s\n", root_path );
+ ata = zalloc ( sizeof ( *ata ) );
+ if ( ! ata ) {
+ rc = -ENOMEM;
+ goto err_alloc_ata;
+ }
+ drive = zalloc ( sizeof ( *drive ) );
+ if ( ! drive ) {
+ rc = -ENOMEM;
+ goto err_alloc_drive;
+ }
/* FIXME: ugly, ugly hack */
struct net_device *netdev = last_opened_netdev();
- if ( ( rc = aoe_attach ( &ata, netdev, root_path ) ) != 0 ) {
+ if ( ( rc = aoe_attach ( ata, netdev, root_path ) ) != 0 ) {
printf ( "Could not attach AoE device: %s\n",
strerror ( rc ) );
- goto error_attach;
+ goto err_attach;
}
- if ( ( rc = init_atadev ( &ata ) ) != 0 ) {
+ if ( ( rc = init_atadev ( ata ) ) != 0 ) {
printf ( "Could not initialise AoE device: %s\n",
strerror ( rc ) );
- goto error_init;
+ goto err_init;
}
/* FIXME: ugly, ugly hack */
struct aoe_session *aoe =
- container_of ( ata.backend, struct aoe_session, refcnt );
+ container_of ( ata->backend, struct aoe_session, refcnt );
abft_fill_data ( aoe );
- drive.blockdev = &ata.blockdev;
+ drive->blockdev = &ata->blockdev;
- register_int13_drive ( &drive );
- printf ( "Registered as BIOS drive %#02x\n", drive.drive );
- printf ( "Booting from BIOS drive %#02x\n", drive.drive );
- rc = int13_boot ( drive.drive );
+ register_int13_drive ( drive );
+ printf ( "Registered as BIOS drive %#02x\n", drive->drive );
+ printf ( "Booting from BIOS drive %#02x\n", drive->drive );
+ rc = int13_boot ( drive->drive );
printf ( "Boot failed\n" );
- printf ( "Unregistering BIOS drive %#02x\n", drive.drive );
- unregister_int13_drive ( &drive );
+ /* Leave drive registered, if instructed to do so */
+ if ( keep_san() )
+ return rc;
+
+ printf ( "Unregistering BIOS drive %#02x\n", drive->drive );
+ unregister_int13_drive ( drive );
- error_init:
- aoe_detach ( &ata );
- error_attach:
+ err_init:
+ aoe_detach ( ata );
+ err_attach:
+ free ( drive );
+ err_alloc_drive:
+ free ( ata );
+ err_alloc_ata:
return rc;
}
diff --git a/gpxe/src/arch/i386/interface/pcbios/bios_nap.c b/gpxe/src/arch/i386/interface/pcbios/bios_nap.c
index 2f4a0513..e38cac7a 100644
--- a/gpxe/src/arch/i386/interface/pcbios/bios_nap.c
+++ b/gpxe/src/arch/i386/interface/pcbios/bios_nap.c
@@ -1,6 +1,8 @@
#include <gpxe/nap.h>
#include <realmode.h>
+FILE_LICENCE ( GPL2_OR_LATER );
+
/**
* Save power by halting the CPU until the next interrupt
*
diff --git a/gpxe/src/arch/i386/interface/pcbios/bios_smbios.c b/gpxe/src/arch/i386/interface/pcbios/bios_smbios.c
index efaaef0d..094214bd 100644
--- a/gpxe/src/arch/i386/interface/pcbios/bios_smbios.c
+++ b/gpxe/src/arch/i386/interface/pcbios/bios_smbios.c
@@ -16,6 +16,8 @@
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
+FILE_LICENCE ( GPL2_OR_LATER );
+
#include <stdint.h>
#include <string.h>
#include <errno.h>
diff --git a/gpxe/src/arch/i386/interface/pcbios/bios_timer.c b/gpxe/src/arch/i386/interface/pcbios/bios_timer.c
index 0b475ea3..8ecf7c12 100644
--- a/gpxe/src/arch/i386/interface/pcbios/bios_timer.c
+++ b/gpxe/src/arch/i386/interface/pcbios/bios_timer.c
@@ -16,6 +16,8 @@
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
+FILE_LICENCE ( GPL2_OR_LATER );
+
/** @file
*
* BIOS timer
diff --git a/gpxe/src/arch/i386/interface/pcbios/biosint.c b/gpxe/src/arch/i386/interface/pcbios/biosint.c
index 1306f918..a193defa 100644
--- a/gpxe/src/arch/i386/interface/pcbios/biosint.c
+++ b/gpxe/src/arch/i386/interface/pcbios/biosint.c
@@ -7,6 +7,8 @@
*
*/
+FILE_LICENCE ( GPL2_OR_LATER );
+
/**
* Hook INT vector
*
diff --git a/gpxe/src/arch/i386/interface/pcbios/ib_srpboot.c b/gpxe/src/arch/i386/interface/pcbios/ib_srpboot.c
new file mode 100644
index 00000000..b1cbc337
--- /dev/null
+++ b/gpxe/src/arch/i386/interface/pcbios/ib_srpboot.c
@@ -0,0 +1,73 @@
+#include <stdint.h>
+#include <string.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <errno.h>
+#include <gpxe/sanboot.h>
+#include <int13.h>
+#include <gpxe/srp.h>
+#include <gpxe/sbft.h>
+
+FILE_LICENCE ( GPL2_OR_LATER );
+
+static int ib_srpboot ( const char *root_path ) {
+ struct scsi_device *scsi;
+ struct int13_drive *drive;
+ int rc;
+
+ scsi = zalloc ( sizeof ( *scsi ) );
+ if ( ! scsi ) {
+ rc = -ENOMEM;
+ goto err_alloc_scsi;
+ }
+ drive = zalloc ( sizeof ( *drive ) );
+ if ( ! drive ) {
+ rc = -ENOMEM;
+ goto err_alloc_drive;
+ }
+
+ if ( ( rc = srp_attach ( scsi, root_path ) ) != 0 ) {
+ printf ( "Could not attach IB_SRP device: %s\n",
+ strerror ( rc ) );
+ goto err_attach;
+ }
+ if ( ( rc = init_scsidev ( scsi ) ) != 0 ) {
+ printf ( "Could not initialise IB_SRP device: %s\n",
+ strerror ( rc ) );
+ goto err_init;
+ }
+
+ drive->blockdev = &scsi->blockdev;
+
+ /* FIXME: ugly, ugly hack */
+ struct srp_device *srp =
+ container_of ( scsi->backend, struct srp_device, refcnt );
+ sbft_fill_data ( srp );
+
+ register_int13_drive ( drive );
+ printf ( "Registered as BIOS drive %#02x\n", drive->drive );
+ printf ( "Booting from BIOS drive %#02x\n", drive->drive );
+ rc = int13_boot ( drive->drive );
+ printf ( "Boot failed\n" );
+
+ /* Leave drive registered, if instructed to do so */
+ if ( keep_san() )
+ return rc;
+
+ printf ( "Unregistering BIOS drive %#02x\n", drive->drive );
+ unregister_int13_drive ( drive );
+
+ err_init:
+ srp_detach ( scsi );
+ err_attach:
+ free ( drive );
+ err_alloc_drive:
+ free ( scsi );
+ err_alloc_scsi:
+ return rc;
+}
+
+struct sanboot_protocol ib_srp_sanboot_protocol __sanboot_protocol = {
+ .prefix = "ib_srp:",
+ .boot = ib_srpboot,
+};
diff --git a/gpxe/src/arch/i386/interface/pcbios/ibft.c b/gpxe/src/arch/i386/interface/pcbios/ibft.c
index 43d1f85f..adf8e6b9 100644
--- a/gpxe/src/arch/i386/interface/pcbios/ibft.c
+++ b/gpxe/src/arch/i386/interface/pcbios/ibft.c
@@ -25,6 +25,8 @@
*
*/
+FILE_LICENCE ( BSD2 );
+
#include <stdint.h>
#include <stdio.h>
#include <string.h>
@@ -35,6 +37,7 @@
#include <gpxe/acpi.h>
#include <gpxe/in.h>
#include <gpxe/netdevice.h>
+#include <gpxe/ethernet.h>
#include <gpxe/dhcp.h>
#include <gpxe/iscsi.h>
#include <gpxe/ibft.h>
@@ -234,7 +237,8 @@ static int ibft_set_string_option ( struct ibft_string_block *strings,
*/
static const char * ibft_string ( struct ibft_string_block *strings,
struct ibft_string *string ) {
- return ( ( ( char * ) strings->table ) + string->offset );
+ return ( string->offset ?
+ ( ( ( char * ) strings->table ) + string->offset ) : NULL );
}
/**
@@ -248,6 +252,7 @@ static const char * ibft_string ( struct ibft_string_block *strings,
static int ibft_fill_nic ( struct ibft_nic *nic,
struct ibft_string_block *strings,
struct net_device *netdev ) {
+ struct ll_protocol *ll_protocol = netdev->ll_protocol;
struct in_addr netmask_addr = { 0 };
unsigned int netmask_count = 0;
int rc;
@@ -276,10 +281,12 @@ static int ibft_fill_nic ( struct ibft_nic *nic,
DBG ( "iBFT NIC subnet = /%d\n", nic->subnet_mask_prefix );
/* Extract values from net-device configuration */
- memcpy ( nic->mac_address, netdev->ll_addr,
- sizeof ( nic->mac_address ) );
- DBG ( "iBFT NIC MAC = %s\n",
- netdev->ll_protocol->ntoa ( nic->mac_address ) );
+ if ( ( rc = ll_protocol->eth_addr ( netdev->ll_addr,
+ nic->mac_address ) ) != 0 ) {
+ DBG ( "Could not determine iBFT MAC: %s\n", strerror ( rc ) );
+ return rc;
+ }
+ DBG ( "iBFT NIC MAC = %s\n", eth_ntoa ( nic->mac_address ) );
nic->pci_bus_dev_func = netdev->dev->desc.location;
DBG ( "iBFT NIC PCI = %04x\n", nic->pci_bus_dev_func );
diff --git a/gpxe/src/arch/i386/interface/pcbios/int13.c b/gpxe/src/arch/i386/interface/pcbios/int13.c
index 2e9de5cb..87b613a8 100644
--- a/gpxe/src/arch/i386/interface/pcbios/int13.c
+++ b/gpxe/src/arch/i386/interface/pcbios/int13.c
@@ -16,6 +16,8 @@
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
+FILE_LICENCE ( GPL2_OR_LATER );
+
#include <stdint.h>
#include <limits.h>
#include <byteswap.h>
@@ -50,6 +52,48 @@ extern void int13_wrapper ( void );
static LIST_HEAD ( drives );
/**
+ * Number of BIOS drives
+ *
+ * Note that this is the number of drives in the system as a whole
+ * (i.e. a mirror of the counter at 40:75), rather than a count of the
+ * number of emulated drives.
+ */
+static uint8_t num_drives;
+
+/**
+ * Update BIOS drive count
+ */
+static void int13_set_num_drives ( void ) {
+ struct int13_drive *drive;
+
+ /* Get current drive count */
+ get_real ( num_drives, BDA_SEG, BDA_NUM_DRIVES );
+
+ /* Ensure count is large enough to cover all of our emulated drives */
+ list_for_each_entry ( drive, &drives, list ) {
+ if ( num_drives <= ( drive->drive & 0x7f ) )
+ num_drives = ( ( drive->drive & 0x7f ) + 1 );
+ }
+
+ /* Update current drive count */
+ put_real ( num_drives, BDA_SEG, BDA_NUM_DRIVES );
+}
+
+/**
+ * Check number of drives
+ */
+static void int13_check_num_drives ( void ) {
+ uint8_t check_num_drives;
+
+ get_real ( check_num_drives, BDA_SEG, BDA_NUM_DRIVES );
+ if ( check_num_drives != num_drives ) {
+ int13_set_num_drives();
+ DBG ( "INT13 fixing up number of drives from %d to %d\n",
+ check_num_drives, num_drives );
+ }
+}
+
+/**
* INT 13, 00 - Reset disk system
*
* @v drive Emulated drive
@@ -98,6 +142,7 @@ static int int13_rw_sectors ( struct int13_drive *drive,
unsigned long lba;
unsigned int count;
userptr_t buffer;
+ int rc;
/* Validate blocksize */
if ( blockdev->blksize != INT13_BLKSIZE ) {
@@ -122,8 +167,10 @@ static int int13_rw_sectors ( struct int13_drive *drive,
head, sector, lba, ix86->segs.es, ix86->regs.bx, count );
/* Read from / write to block device */
- if ( io ( blockdev, lba, count, buffer ) != 0 )
+ if ( ( rc = io ( blockdev, lba, count, buffer ) ) != 0 ) {
+ DBG ( "INT 13 failed: %s\n", strerror ( rc ) );
return -INT13_STATUS_READ_ERROR;
+ }
return 0;
}
@@ -202,9 +249,13 @@ static int int13_get_parameters ( struct int13_drive *drive,
*/
static int int13_get_disk_type ( struct int13_drive *drive,
struct i386_all_regs *ix86 ) {
+ uint32_t blocks;
+
DBG ( "Get disk type\n" );
- ix86->regs.cx = ( drive->cylinders >> 16 );
- ix86->regs.dx = ( drive->cylinders & 0xffff );
+ blocks = ( ( drive->blockdev->blocks <= 0xffffffffUL ) ?
+ drive->blockdev->blocks : 0xffffffffUL );
+ ix86->regs.cx = ( blocks >> 16 );
+ ix86->regs.dx = ( blocks & 0xffff );
return INT13_DISK_TYPE_HDD;
}
@@ -248,6 +299,7 @@ static int int13_extended_rw ( struct int13_drive *drive,
uint64_t lba;
unsigned long count;
userptr_t buffer;
+ int rc;
/* Read parameters from disk address structure */
copy_from_real ( &addr, ix86->segs.ds, ix86->regs.si, sizeof ( addr ));
@@ -259,8 +311,10 @@ static int int13_extended_rw ( struct int13_drive *drive,
addr.buffer.segment, addr.buffer.offset, count );
/* Read from / write to block device */
- if ( io ( blockdev, lba, count, buffer ) != 0 )
+ if ( ( rc = io ( blockdev, lba, count, buffer ) ) != 0 ) {
+ DBG ( "INT 13 failed: %s\n", strerror ( rc ) );
return -INT13_STATUS_READ_ERROR;
+ }
return 0;
}
@@ -328,6 +382,9 @@ static __asmcall void int13 ( struct i386_all_regs *ix86 ) {
struct int13_drive *drive;
int status;
+ /* Check BIOS hasn't killed off our drive */
+ int13_check_num_drives();
+
list_for_each_entry ( drive, &drives, list ) {
if ( bios_drive != drive->drive ) {
@@ -387,7 +444,7 @@ static __asmcall void int13 ( struct i386_all_regs *ix86 ) {
/* Negative status indicates an error */
if ( status < 0 ) {
status = -status;
- DBG ( "INT13 failed with status %x\n", status );
+ DBG ( "INT 13 returning failure status %x\n", status );
} else {
ix86->flags &= ~CF;
}
@@ -543,7 +600,6 @@ void register_int13_drive ( struct int13_drive *drive ) {
/* Assign natural drive number */
get_real ( num_drives, BDA_SEG, BDA_NUM_DRIVES );
drive->natural_drive = ( num_drives | 0x80 );
- num_drives++;
/* Assign drive number */
if ( ( drive->drive & 0xff ) == 0xff ) {
@@ -552,13 +608,8 @@ void register_int13_drive ( struct int13_drive *drive ) {
} else {
/* Use specified drive number (+0x80 if necessary) */
drive->drive |= 0x80;
- if ( num_drives <= ( drive->drive & 0x7f ) )
- num_drives = ( ( drive->drive & 0x7f ) + 1 );
}
- /* Update BIOS drive count */
- put_real ( num_drives, BDA_SEG, BDA_NUM_DRIVES );
-
DBG ( "Registered INT13 drive %02x (naturally %02x) with C/H/S "
"geometry %d/%d/%d\n", drive->drive, drive->natural_drive,
drive->cylinders, drive->heads, drive->sectors_per_track );
@@ -569,6 +620,9 @@ void register_int13_drive ( struct int13_drive *drive ) {
/* Add to list of emulated drives */
list_add ( &drive->list, &drives );
+
+ /* Update BIOS drive count */
+ int13_set_num_drives();
}
/**
@@ -652,7 +706,8 @@ int int13_boot ( unsigned int drive ) {
/* Jump to boot sector */
if ( ( rc = call_bootsector ( 0x0, 0x7c00, drive ) ) != 0 ) {
- DBG ( "INT 13 drive %02x boot returned\n", drive );
+ DBG ( "INT 13 drive %02x boot returned: %s\n",
+ drive, strerror ( rc ) );
return rc;
}
diff --git a/gpxe/src/arch/i386/interface/pcbios/iscsiboot.c b/gpxe/src/arch/i386/interface/pcbios/iscsiboot.c
index 02aec4ba..00efd8ff 100644
--- a/gpxe/src/arch/i386/interface/pcbios/iscsiboot.c
+++ b/gpxe/src/arch/i386/interface/pcbios/iscsiboot.c
@@ -4,26 +4,16 @@
#include <stdio.h>
#include <errno.h>
#include <gpxe/iscsi.h>
-#include <gpxe/settings.h>
-#include <gpxe/dhcp.h>
#include <gpxe/netdevice.h>
#include <gpxe/ibft.h>
-#include <gpxe/init.h>
#include <gpxe/sanboot.h>
#include <int13.h>
-#include <usr/autoboot.h>
-struct setting keep_san_setting __setting = {
- .name = "keep-san",
- .description = "Preserve SAN connection",
- .tag = DHCP_EB_KEEP_SAN,
- .type = &setting_type_int8,
-};
+FILE_LICENCE ( GPL2_OR_LATER );
static int iscsiboot ( const char *root_path ) {
struct scsi_device *scsi;
struct int13_drive *drive;
- int keep_san;
int rc;
scsi = zalloc ( sizeof ( *scsi ) );
@@ -37,8 +27,6 @@ static int iscsiboot ( const char *root_path ) {
goto err_alloc_drive;
}
- printf ( "iSCSI booting from %s\n", root_path );
-
if ( ( rc = iscsi_attach ( scsi, root_path ) ) != 0 ) {
printf ( "Could not attach iSCSI device: %s\n",
strerror ( rc ) );
@@ -65,12 +53,8 @@ static int iscsiboot ( const char *root_path ) {
printf ( "Boot failed\n" );
/* Leave drive registered, if instructed to do so */
- keep_san = fetch_intz_setting ( NULL, &keep_san_setting );
- if ( keep_san ) {
- printf ( "Preserving connection to SAN disk\n" );
- shutdown_exit_flags |= SHUTDOWN_KEEP_DEVICES;
+ if ( keep_san() )
return rc;
- }
printf ( "Unregistering BIOS drive %#02x\n", drive->drive );
unregister_int13_drive ( drive );
diff --git a/gpxe/src/arch/i386/interface/pcbios/keepsan.c b/gpxe/src/arch/i386/interface/pcbios/keepsan.c
new file mode 100644
index 00000000..904e017d
--- /dev/null
+++ b/gpxe/src/arch/i386/interface/pcbios/keepsan.c
@@ -0,0 +1,26 @@
+#include <stdint.h>
+#include <stdio.h>
+#include <gpxe/settings.h>
+#include <gpxe/dhcp.h>
+#include <gpxe/init.h>
+#include <gpxe/sanboot.h>
+#include <usr/autoboot.h>
+
+struct setting keep_san_setting __setting = {
+ .name = "keep-san",
+ .description = "Preserve SAN connection",
+ .tag = DHCP_EB_KEEP_SAN,
+ .type = &setting_type_int8,
+};
+
+int keep_san ( void ) {
+ int keep_san;
+
+ keep_san = fetch_intz_setting ( NULL, &keep_san_setting );
+ if ( ! keep_san )
+ return 0;
+
+ printf ( "Preserving connection to SAN disk\n" );
+ shutdown_exit_flags |= SHUTDOWN_KEEP_DEVICES;
+ return 1;
+}
diff --git a/gpxe/src/arch/i386/interface/pcbios/memtop_umalloc.c b/gpxe/src/arch/i386/interface/pcbios/memtop_umalloc.c
index 744d8e30..0645fe63 100644
--- a/gpxe/src/arch/i386/interface/pcbios/memtop_umalloc.c
+++ b/gpxe/src/arch/i386/interface/pcbios/memtop_umalloc.c
@@ -16,6 +16,8 @@
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
+FILE_LICENCE ( GPL2_OR_LATER );
+
/**
* @file
*
diff --git a/gpxe/src/arch/i386/interface/pcbios/pcibios.c b/gpxe/src/arch/i386/interface/pcbios/pcibios.c
index 81b4fd3c..f2c3880c 100644
--- a/gpxe/src/arch/i386/interface/pcbios/pcibios.c
+++ b/gpxe/src/arch/i386/interface/pcbios/pcibios.c
@@ -16,6 +16,8 @@
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
+FILE_LICENCE ( GPL2_OR_LATER );
+
#include <stdint.h>
#include <gpxe/pci.h>
#include <realmode.h>
diff --git a/gpxe/src/arch/i386/interface/pcbios/sbft.c b/gpxe/src/arch/i386/interface/pcbios/sbft.c
new file mode 100644
index 00000000..12927c77
--- /dev/null
+++ b/gpxe/src/arch/i386/interface/pcbios/sbft.c
@@ -0,0 +1,105 @@
+/*
+ * Copyright (C) 2009 Fen Systems Ltd <mbrown@fensystems.co.uk>.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT HOLDER 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.
+ */
+
+FILE_LICENCE ( BSD2 );
+
+/** @file
+ *
+ * SRP boot firmware table
+ *
+ */
+
+#include <assert.h>
+#include <realmode.h>
+#include <gpxe/srp.h>
+#include <gpxe/ib_srp.h>
+#include <gpxe/acpi.h>
+#include <gpxe/sbft.h>
+
+#define sbftab __use_data16 ( sbftab )
+/** The sBFT used by gPXE */
+struct gpxe_sbft __data16 ( sbftab ) = {
+ /* Table header */
+ .table = {
+ /* ACPI header */
+ .acpi = {
+ .signature = SBFT_SIG,
+ .length = sizeof ( sbftab ),
+ .revision = 1,
+ .oem_id = "FENSYS",
+ .oem_table_id = "gPXE",
+ },
+ .scsi_offset = offsetof ( typeof ( sbftab ), scsi ),
+ .srp_offset = offsetof ( typeof ( sbftab ), srp ),
+ .ib_offset = offsetof ( typeof ( sbftab ), ib ),
+ },
+};
+
+/**
+ * Fill in all variable portions of sBFT
+ *
+ * @v srp SRP device
+ * @ret rc Return status code
+ */
+int sbft_fill_data ( struct srp_device *srp ) {
+ struct sbft_scsi_subtable *sbft_scsi = &sbftab.scsi;
+ struct sbft_srp_subtable *sbft_srp = &sbftab.srp;
+ struct sbft_ib_subtable *sbft_ib = &sbftab.ib;
+ struct ib_srp_parameters *ib_params;
+ struct segoff rm_sbftab = {
+ .segment = rm_ds,
+ .offset = __from_data16 ( &sbftab ),
+ };
+
+ /* Fill in the SCSI subtable */
+ memcpy ( &sbft_scsi->lun, &srp->lun, sizeof ( sbft_scsi->lun ) );
+
+ /* Fill in the SRP subtable */
+ memcpy ( &sbft_srp->port_ids, &srp->port_ids,
+ sizeof ( sbft_srp->port_ids ) );
+
+ /* Fill in the IB subtable */
+ assert ( srp->transport == &ib_srp_transport );
+ ib_params = ib_srp_params ( srp );
+ memcpy ( &sbft_ib->sgid, &ib_params->sgid, sizeof ( sbft_ib->sgid ) );
+ memcpy ( &sbft_ib->dgid, &ib_params->dgid, sizeof ( sbft_ib->dgid ) );
+ memcpy ( &sbft_ib->service_id, &ib_params->service_id,
+ sizeof ( sbft_ib->service_id ) );
+ sbft_ib->pkey = ib_params->pkey;
+
+ /* Update checksum */
+ acpi_fix_checksum ( &sbftab.table.acpi );
+
+ DBGC ( &sbftab, "SRP Boot Firmware Table at %04x:%04x:\n",
+ rm_sbftab.segment, rm_sbftab.offset );
+ DBGC_HDA ( &sbftab, rm_sbftab, &sbftab, sizeof ( sbftab ) );
+
+ return 0;
+}
diff --git a/gpxe/src/arch/i386/interface/pxe/pxe_call.c b/gpxe/src/arch/i386/interface/pxe/pxe_call.c
index 06dee25c..66a9b1e2 100644
--- a/gpxe/src/arch/i386/interface/pxe/pxe_call.c
+++ b/gpxe/src/arch/i386/interface/pxe/pxe_call.c
@@ -16,7 +16,10 @@
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
+FILE_LICENCE ( GPL2_OR_LATER );
+
#include <gpxe/uaccess.h>
+#include <gpxe/init.h>
#include <registers.h>
#include <biosint.h>
#include <pxe.h>
@@ -34,6 +37,9 @@ extern struct segoff __text16 ( pxe_int_1a_vector );
/** INT 1A handler */
extern void pxe_int_1a ( void );
+/** INT 1A hooked flag */
+static int int_1a_hooked = 0;
+
/** A function pointer to hold any PXE API call
*
* Used by pxe_api_call() to avoid large swathes of duplicated code.
@@ -98,6 +104,7 @@ union pxenv_call {
PXENV_EXIT_t ( * get_file_size ) ( struct s_PXENV_GET_FILE_SIZE * );
PXENV_EXIT_t ( * file_exec ) ( struct s_PXENV_FILE_EXEC * );
PXENV_EXIT_t ( * file_api_check ) ( struct s_PXENV_FILE_API_CHECK * );
+ PXENV_EXIT_t ( * file_exit_hook ) ( struct s_PXENV_FILE_EXIT_HOOK * );
};
/**
@@ -304,6 +311,10 @@ __asmcall void pxe_api_call ( struct i386_all_regs *ix86 ) {
pxenv_call.file_api_check = pxenv_file_api_check;
param_len = sizeof ( pxenv_any.file_api_check );
break;
+ case PXENV_FILE_EXIT_HOOK:
+ pxenv_call.file_exit_hook = pxenv_file_exit_hook;
+ param_len = sizeof ( pxenv_any.file_exit_hook );
+ break;
default:
DBG ( "PXENV_UNKNOWN_%hx", opcode );
pxenv_call.unknown = pxenv_unknown;
@@ -334,6 +345,18 @@ __asmcall void pxe_api_call ( struct i386_all_regs *ix86 ) {
}
/**
+ * Dispatch weak PXE API call with PXE stack available
+ *
+ * @v ix86 Registers for PXE call
+ * @ret present Zero (PXE stack present)
+ */
+int _pxe_api_call_weak ( struct i386_all_regs *ix86 )
+{
+ pxe_api_call ( ix86 );
+ return 0;
+}
+
+/**
* Dispatch PXE loader call
*
* @v es:di Address of PXE parameter block
@@ -362,25 +385,6 @@ __asmcall void pxe_loader_call ( struct i386_all_regs *ix86 ) {
}
/**
- * Hook INT 1A for PXE
- *
- */
-void pxe_hook_int1a ( void ) {
- hook_bios_interrupt ( 0x1a, ( unsigned int ) pxe_int_1a,
- &pxe_int_1a_vector );
-}
-
-/**
- * Unhook INT 1A for PXE
- *
- * @ret rc Return status code
- */
-int pxe_unhook_int1a ( void ) {
- return unhook_bios_interrupt ( 0x1a, ( unsigned int ) pxe_int_1a,
- &pxe_int_1a_vector );
-}
-
-/**
* Calculate byte checksum as used by PXE
*
* @v data Data
@@ -401,7 +405,7 @@ static uint8_t pxe_checksum ( void *data, size_t size ) {
* Initialise !PXE and PXENV+ structures
*
*/
-void pxe_init_structures ( void ) {
+static void pxe_init_structures ( void ) {
uint32_t rm_cs_phys = ( rm_cs << 4 );
uint32_t rm_ds_phys = ( rm_ds << 4 );
@@ -427,6 +431,55 @@ void pxe_init_structures ( void ) {
pxenv.Checksum -= pxe_checksum ( &pxenv, sizeof ( pxenv ) );
}
+/** PXE structure initialiser */
+struct init_fn pxe_init_fn __init_fn ( INIT_NORMAL ) = {
+ .initialise = pxe_init_structures,
+};
+
+/**
+ * Activate PXE stack
+ *
+ * @v netdev Net device to use as PXE net device
+ */
+void pxe_activate ( struct net_device *netdev ) {
+
+ /* Ensure INT 1A is hooked */
+ if ( ! int_1a_hooked ) {
+ hook_bios_interrupt ( 0x1a, ( unsigned int ) pxe_int_1a,
+ &pxe_int_1a_vector );
+ int_1a_hooked = 1;
+ }
+
+ /* Set PXE network device */
+ pxe_set_netdev ( netdev );
+}
+
+/**
+ * Deactivate PXE stack
+ *
+ * @ret rc Return status code
+ */
+int pxe_deactivate ( void ) {
+ int rc;
+
+ /* Clear PXE network device */
+ pxe_set_netdev ( NULL );
+
+ /* Ensure INT 1A is unhooked, if possible */
+ if ( int_1a_hooked ) {
+ if ( ( rc = unhook_bios_interrupt ( 0x1a,
+ (unsigned int) pxe_int_1a,
+ &pxe_int_1a_vector ))!= 0){
+ DBG ( "Could not unhook INT 1A: %s\n",
+ strerror ( rc ) );
+ return rc;
+ }
+ int_1a_hooked = 0;
+ }
+
+ return 0;
+}
+
/**
* Start PXE NBP at 0000:7c00
*
diff --git a/gpxe/src/arch/i386/interface/pxe/pxe_entry.S b/gpxe/src/arch/i386/interface/pxe/pxe_entry.S
index 0e8c8e2d..0d3a57cd 100644
--- a/gpxe/src/arch/i386/interface/pxe/pxe_entry.S
+++ b/gpxe/src/arch/i386/interface/pxe/pxe_entry.S
@@ -17,6 +17,8 @@
*
*/
+FILE_LICENCE ( GPL2_OR_LATER )
+
.arch i386
/****************************************************************************
diff --git a/gpxe/src/arch/i386/interface/pxe/pxe_file.c b/gpxe/src/arch/i386/interface/pxe/pxe_file.c
index 41674588..8d832123 100644
--- a/gpxe/src/arch/i386/interface/pxe/pxe_file.c
+++ b/gpxe/src/arch/i386/interface/pxe/pxe_file.c
@@ -12,9 +12,12 @@
#include <gpxe/posix_io.h>
#include <gpxe/features.h>
#include <pxe.h>
+#include <realmode.h>
/*
* Copyright (C) 2007 Michael Brown <mbrown@fensystems.co.uk>.
+ * Portions (C) 2010 Shao Miller <shao.miller@yrdsb.edu.on.ca>.
+ * [PXE exit hook logic]
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
@@ -31,6 +34,8 @@
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
+FILE_LICENCE ( GPL2_OR_LATER );
+
FEATURE ( FEATURE_MISC, "PXEXT", DHCP_EB_FEATURE_PXE_EXT, 2 );
/**
@@ -228,6 +233,9 @@ PXENV_EXIT_t pxenv_file_exec ( struct s_PXENV_FILE_EXEC *file_exec ) {
return PXENV_EXIT_SUCCESS;
}
+segoff_t __data16 ( pxe_exit_hook ) = { 0, 0 };
+#define pxe_exit_hook __use_data16 ( pxe_exit_hook )
+
/**
* FILE API CHECK
*
@@ -258,7 +266,41 @@ PXENV_EXIT_t pxenv_file_api_check ( struct s_PXENV_FILE_API_CHECK *file_api_chec
file_api_check->Magic = 0xe9c17b20;
file_api_check->Provider = 0x45585067; /* "gPXE" */
file_api_check->APIMask = 0x0000007f; /* Functions e0-e6 */
+ /* Check to see if we have a PXE exit hook */
+ if ( pxe_exit_hook.segment | pxe_exit_hook.offset )
+ /* Function e7, also */
+ file_api_check->APIMask |= 0x00000080;
file_api_check->Flags = 0; /* None defined */
return PXENV_EXIT_SUCCESS;
}
}
+
+/**
+ * FILE EXIT HOOK
+ *
+ * @v file_exit_hook Pointer to a struct
+ * s_PXENV_FILE_EXIT_HOOK
+ * @v s_PXENV_FILE_EXIT_HOOK::Hook SEG16:OFF16 to jump to
+ * @ret #PXENV_EXIT_SUCCESS Successfully set hook
+ * @ret #PXENV_EXIT_FAILURE We're not an NBP build
+ * @ret s_PXENV_FILE_EXIT_HOOK::Status PXE status code
+ *
+ */
+PXENV_EXIT_t pxenv_file_exit_hook ( struct s_PXENV_FILE_EXIT_HOOK
+ *file_exit_hook ) {
+ DBG ( "PXENV_FILE_EXIT_HOOK" );
+
+ /* Check to see if we have a PXE exit hook */
+ if ( pxe_exit_hook.segment | pxe_exit_hook.offset ) {
+ /* We'll jump to the specified SEG16:OFF16 during exit */
+ pxe_exit_hook.segment = file_exit_hook->Hook.segment;
+ pxe_exit_hook.offset = file_exit_hook->Hook.offset;
+ file_exit_hook->Status = PXENV_STATUS_SUCCESS;
+ return PXENV_EXIT_SUCCESS;
+ }
+
+ DBG ( " not NBP" );
+ file_exit_hook->Status = PXENV_STATUS_UNSUPPORTED;
+ return PXENV_EXIT_FAILURE;
+}
+
diff --git a/gpxe/src/arch/i386/interface/pxe/pxe_loader.c b/gpxe/src/arch/i386/interface/pxe/pxe_loader.c
index d228a36d..b35caf77 100644
--- a/gpxe/src/arch/i386/interface/pxe/pxe_loader.c
+++ b/gpxe/src/arch/i386/interface/pxe/pxe_loader.c
@@ -16,6 +16,8 @@
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
+FILE_LICENCE ( GPL2_OR_LATER );
+
#include <gpxe/init.h>
#include "pxe.h"
#include "pxe_call.h"
@@ -37,9 +39,6 @@ PXENV_EXIT_t undi_loader ( struct s_UNDI_LOADER *undi_loader ) {
DBG ( "[PXENV_UNDI_LOADER to CS %04x DS %04x]",
undi_loader->UNDI_CS, undi_loader->UNDI_DS );
- /* Set up PXE data structures */
- pxe_init_structures();
-
/* Fill in UNDI loader structure */
undi_loader->PXEptr.segment = rm_cs;
undi_loader->PXEptr.offset = __from_text16 ( &ppxe );
diff --git a/gpxe/src/arch/i386/interface/pxe/pxe_preboot.c b/gpxe/src/arch/i386/interface/pxe/pxe_preboot.c
index 193abc3d..3939c7bf 100644
--- a/gpxe/src/arch/i386/interface/pxe/pxe_preboot.c
+++ b/gpxe/src/arch/i386/interface/pxe/pxe_preboot.c
@@ -23,6 +23,8 @@
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
+FILE_LICENCE ( GPL2_OR_LATER );
+
#include <stdint.h>
#include <string.h>
#include <stdlib.h>
@@ -35,6 +37,7 @@
#include <gpxe/init.h>
#include <gpxe/if_ether.h>
#include <basemem_packet.h>
+#include <biosint.h>
#include "pxe.h"
#include "pxe_call.h"
@@ -294,11 +297,8 @@ PXENV_EXIT_t pxenv_start_undi ( struct s_PXENV_START_UNDI *start_undi ) {
}
DBG ( " using netdev %s", netdev->name );
- /* Save as PXE net device */
- pxe_set_netdev ( netdev );
-
- /* Hook INT 1A */
- pxe_hook_int1a();
+ /* Activate PXE */
+ pxe_activate ( netdev );
start_undi->Status = PXENV_STATUS_SUCCESS;
return PXENV_EXIT_SUCCESS;
@@ -311,15 +311,20 @@ PXENV_EXIT_t pxenv_start_undi ( struct s_PXENV_START_UNDI *start_undi ) {
PXENV_EXIT_t pxenv_stop_undi ( struct s_PXENV_STOP_UNDI *stop_undi ) {
DBG ( "PXENV_STOP_UNDI" );
- /* Unhook INT 1A */
- pxe_unhook_int1a();
-
- /* Clear PXE net device */
- pxe_set_netdev ( NULL );
+ /* Deactivate PXE */
+ pxe_deactivate();
/* Prepare for unload */
shutdown ( SHUTDOWN_BOOT );
+ /* Check to see if we still have any hooked interrupts */
+ if ( hooked_bios_interrupts != 0 ) {
+ DBG ( "PXENV_STOP_UNDI failed: %d interrupts still hooked\n",
+ hooked_bios_interrupts );
+ stop_undi->Status = PXENV_STATUS_KEEP_UNDI;
+ return PXENV_EXIT_FAILURE;
+ }
+
stop_undi->Status = PXENV_STATUS_SUCCESS;
return PXENV_EXIT_SUCCESS;
}
diff --git a/gpxe/src/arch/i386/interface/pxe/pxe_tftp.c b/gpxe/src/arch/i386/interface/pxe/pxe_tftp.c
index 715a0b61..0e3ca3c5 100644
--- a/gpxe/src/arch/i386/interface/pxe/pxe_tftp.c
+++ b/gpxe/src/arch/i386/interface/pxe/pxe_tftp.c
@@ -22,6 +22,8 @@
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
+FILE_LICENCE ( GPL2_OR_LATER );
+
#include <stdlib.h>
#include <stdio.h>
#include <errno.h>
@@ -138,7 +140,7 @@ static void pxe_tftp_xfer_close ( struct xfer_interface *xfer __unused,
static struct xfer_interface_operations pxe_tftp_xfer_ops = {
.close = pxe_tftp_xfer_close,
- .vredirect = xfer_vopen,
+ .vredirect = xfer_vreopen,
.window = unlimited_xfer_window,
.alloc_iob = default_xfer_alloc_iob,
.deliver_iob = pxe_tftp_xfer_deliver_iob,
@@ -163,7 +165,8 @@ static struct xfer_interface_operations pxe_tftp_xfer_ops = {
* @ret rc Return status code
*/
static int pxe_tftp_open ( uint32_t ipaddress, unsigned int port,
- const unsigned char *filename, size_t blksize ) {
+ const unsigned char *filename, size_t blksize,
+ int sizeonly ) {
char uri_string[PXE_TFTP_URI_LEN];
struct in_addr address;
int rc;
@@ -183,7 +186,8 @@ static int pxe_tftp_open ( uint32_t ipaddress, unsigned int port,
if ( blksize < TFTP_DEFAULT_BLKSIZE )
blksize = TFTP_DEFAULT_BLKSIZE;
snprintf ( uri_string, sizeof ( uri_string ),
- "tftp://%s:%d%s%s?blksize=%zd",
+ "tftp%s://%s:%d%s%s?blksize=%zd",
+ sizeonly ? "size" : "",
inet_ntoa ( address ), ntohs ( port ),
( ( filename[0] == '/' ) ? "" : "/" ), filename, blksize );
DBG ( " %s", uri_string );
@@ -252,7 +256,8 @@ PXENV_EXIT_t pxenv_tftp_open ( struct s_PXENV_TFTP_OPEN *tftp_open ) {
if ( ( rc = pxe_tftp_open ( tftp_open->ServerIPAddress,
tftp_open->TFTPPort,
tftp_open->FileName,
- tftp_open->PacketSize ) ) != 0 ) {
+ tftp_open->PacketSize,
+ 0) ) != 0 ) {
tftp_open->Status = PXENV_STATUS ( rc );
return PXENV_EXIT_FAILURE;
}
@@ -486,7 +491,7 @@ PXENV_EXIT_t pxenv_tftp_read_file ( struct s_PXENV_TFTP_READ_FILE
/* Open TFTP file */
if ( ( rc = pxe_tftp_open ( tftp_read_file->ServerIPAddress, 0,
- tftp_read_file->FileName, 0 ) ) != 0 ) {
+ tftp_read_file->FileName, 0, 0 ) ) != 0 ) {
tftp_read_file->Status = PXENV_STATUS ( rc );
return PXENV_EXIT_FAILURE;
}
@@ -556,7 +561,7 @@ PXENV_EXIT_t pxenv_tftp_get_fsize ( struct s_PXENV_TFTP_GET_FSIZE
/* Open TFTP file */
if ( ( rc = pxe_tftp_open ( tftp_get_fsize->ServerIPAddress, 0,
- tftp_get_fsize->FileName, 0 ) ) != 0 ) {
+ tftp_get_fsize->FileName, 0, 1 ) ) != 0 ) {
tftp_get_fsize->Status = PXENV_STATUS ( rc );
return PXENV_EXIT_FAILURE;
}
diff --git a/gpxe/src/arch/i386/interface/pxe/pxe_udp.c b/gpxe/src/arch/i386/interface/pxe/pxe_udp.c
index 033b1ad9..f4702201 100644
--- a/gpxe/src/arch/i386/interface/pxe/pxe_udp.c
+++ b/gpxe/src/arch/i386/interface/pxe/pxe_udp.c
@@ -30,6 +30,8 @@
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
+FILE_LICENCE ( GPL2_OR_LATER );
+
/** A PXE UDP connection */
struct pxe_udp_connection {
/** Data transfer interface to UDP stack */
diff --git a/gpxe/src/arch/i386/interface/pxe/pxe_undi.c b/gpxe/src/arch/i386/interface/pxe/pxe_undi.c
index 4e4a3da0..c9b67c06 100644
--- a/gpxe/src/arch/i386/interface/pxe/pxe_undi.c
+++ b/gpxe/src/arch/i386/interface/pxe/pxe_undi.c
@@ -22,6 +22,8 @@
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
+FILE_LICENCE ( GPL2_OR_LATER );
+
#include <stdint.h>
#include <stdio.h>
#include <string.h>
@@ -88,12 +90,26 @@ static void pxe_netdev_close ( void ) {
undi_tx_count = 0;
}
+/**
+ * Dump multicast address list
+ *
+ * @v mcast PXE multicast address list
+ */
+static void pxe_dump_mcast_list ( struct s_PXENV_UNDI_MCAST_ADDRESS *mcast ) {
+ struct ll_protocol *ll_protocol = pxe_netdev->ll_protocol;
+ unsigned int i;
+
+ for ( i = 0 ; i < mcast->MCastAddrCount ; i++ ) {
+ DBG ( " %s", ll_protocol->ntoa ( mcast->McastAddr[i] ) );
+ }
+}
+
/* PXENV_UNDI_STARTUP
*
* Status: working
*/
PXENV_EXIT_t pxenv_undi_startup ( struct s_PXENV_UNDI_STARTUP *undi_startup ) {
- DBG ( "PXENV_UNDI_STARTUP" );
+ DBG ( "PXENV_UNDI_STARTUP\n" );
undi_startup->Status = PXENV_STATUS_SUCCESS;
return PXENV_EXIT_SUCCESS;
@@ -104,7 +120,7 @@ PXENV_EXIT_t pxenv_undi_startup ( struct s_PXENV_UNDI_STARTUP *undi_startup ) {
* Status: working
*/
PXENV_EXIT_t pxenv_undi_cleanup ( struct s_PXENV_UNDI_CLEANUP *undi_cleanup ) {
- DBG ( "PXENV_UNDI_CLEANUP" );
+ DBG ( "PXENV_UNDI_CLEANUP\n" );
pxe_netdev_close();
@@ -118,7 +134,8 @@ PXENV_EXIT_t pxenv_undi_cleanup ( struct s_PXENV_UNDI_CLEANUP *undi_cleanup ) {
*/
PXENV_EXIT_t pxenv_undi_initialize ( struct s_PXENV_UNDI_INITIALIZE
*undi_initialize ) {
- DBG ( "PXENV_UNDI_INITIALIZE" );
+ DBG ( "PXENV_UNDI_INITIALIZE protocolini %08x\n",
+ undi_initialize->ProtocolIni );
undi_initialize->Status = PXENV_STATUS_SUCCESS;
return PXENV_EXIT_SUCCESS;
@@ -133,9 +150,13 @@ PXENV_EXIT_t pxenv_undi_reset_adapter ( struct s_PXENV_UNDI_RESET
int rc;
DBG ( "PXENV_UNDI_RESET_ADAPTER" );
+ pxe_dump_mcast_list ( &undi_reset_adapter->R_Mcast_Buf );
+ DBG ( "\n" );
pxe_netdev_close();
if ( ( rc = pxe_netdev_open() ) != 0 ) {
+ DBG ( "PXENV_UNDI_RESET_ADAPTER could not reopen %s: %s\n",
+ pxe_netdev->name, strerror ( rc ) );
undi_reset_adapter->Status = PXENV_STATUS ( rc );
return PXENV_EXIT_FAILURE;
}
@@ -150,7 +171,7 @@ PXENV_EXIT_t pxenv_undi_reset_adapter ( struct s_PXENV_UNDI_RESET
*/
PXENV_EXIT_t pxenv_undi_shutdown ( struct s_PXENV_UNDI_SHUTDOWN
*undi_shutdown ) {
- DBG ( "PXENV_UNDI_SHUTDOWN" );
+ DBG ( "PXENV_UNDI_SHUTDOWN\n" );
pxe_netdev_close();
@@ -165,9 +186,14 @@ PXENV_EXIT_t pxenv_undi_shutdown ( struct s_PXENV_UNDI_SHUTDOWN
PXENV_EXIT_t pxenv_undi_open ( struct s_PXENV_UNDI_OPEN *undi_open ) {
int rc;
- DBG ( "PXENV_UNDI_OPEN" );
+ DBG ( "PXENV_UNDI_OPEN flag %04x filter %04x",
+ undi_open->OpenFlag, undi_open->PktFilter );
+ pxe_dump_mcast_list ( &undi_open->R_Mcast_Buf );
+ DBG ( "\n" );
if ( ( rc = pxe_netdev_open() ) != 0 ) {
+ DBG ( "PXENV_UNDI_OPEN could not open %s: %s\n",
+ pxe_netdev->name, strerror ( rc ) );
undi_open->Status = PXENV_STATUS ( rc );
return PXENV_EXIT_FAILURE;
}
@@ -181,7 +207,7 @@ PXENV_EXIT_t pxenv_undi_open ( struct s_PXENV_UNDI_OPEN *undi_open ) {
* Status: working
*/
PXENV_EXIT_t pxenv_undi_close ( struct s_PXENV_UNDI_CLOSE *undi_close ) {
- DBG ( "PXENV_UNDI_CLOSE" );
+ DBG ( "PXENV_UNDI_CLOSE\n" );
pxe_netdev_close();
@@ -207,7 +233,13 @@ PXENV_EXIT_t pxenv_undi_transmit ( struct s_PXENV_UNDI_TRANSMIT
unsigned int i;
int rc;
- DBG ( "PXENV_UNDI_TRANSMIT" );
+ DBG2 ( "PXENV_UNDI_TRANSMIT" );
+
+ /* Forcibly enable interrupts at this point, to work around
+ * callers that never call PXENV_UNDI_OPEN before attempting
+ * to use the UNDI API.
+ */
+ netdev_irq ( pxe_netdev, 1 );
/* Identify network-layer protocol */
switch ( undi_transmit->Protocol ) {
@@ -219,25 +251,29 @@ PXENV_EXIT_t pxenv_undi_transmit ( struct s_PXENV_UNDI_TRANSMIT
ll_hlen = 0;
break;
default:
+ DBG2 ( " %02x invalid protocol\n", undi_transmit->Protocol );
undi_transmit->Status = PXENV_STATUS_UNDI_INVALID_PARAMETER;
return PXENV_EXIT_FAILURE;
}
- DBG ( " %s", ( net_protocol ? net_protocol->name : "RAW" ) );
+ DBG2 ( " %s", ( net_protocol ? net_protocol->name : "RAW" ) );
/* Calculate total packet length */
copy_from_real ( &tbd, undi_transmit->TBD.segment,
undi_transmit->TBD.offset, sizeof ( tbd ) );
len = tbd.ImmedLength;
- DBG ( " %d", tbd.ImmedLength );
+ DBG2 ( " %04x:%04x+%x", tbd.Xmit.segment, tbd.Xmit.offset,
+ tbd.ImmedLength );
for ( i = 0 ; i < tbd.DataBlkCount ; i++ ) {
datablk = &tbd.DataBlock[i];
len += datablk->TDDataLen;
- DBG ( "+%d", datablk->TDDataLen );
+ DBG2 ( " %04x:%04x+%x", datablk->TDDataPtr.segment,
+ datablk->TDDataPtr.offset, datablk->TDDataLen );
}
/* Allocate and fill I/O buffer */
iobuf = alloc_iob ( ll_hlen + len );
if ( ! iobuf ) {
+ DBG2 ( " could not allocate iobuf\n" );
undi_transmit->Status = PXENV_STATUS_OUT_OF_RESOURCES;
return PXENV_EXIT_FAILURE;
}
@@ -262,45 +298,57 @@ PXENV_EXIT_t pxenv_undi_transmit ( struct s_PXENV_UNDI_TRANSMIT
undi_transmit->DestAddr.offset,
ll_protocol->ll_addr_len );
ll_dest = destaddr;
+ DBG2 ( " DEST %s", ll_protocol->ntoa ( ll_dest ) );
} else {
- DBG ( " BCAST" );
- ll_dest = ll_protocol->ll_broadcast;
+ ll_dest = pxe_netdev->ll_broadcast;
+ DBG2 ( " BCAST" );
}
/* Add link-layer header */
- if ( ( rc = ll_protocol->push ( iobuf, ll_dest,
+ if ( ( rc = ll_protocol->push ( pxe_netdev, iobuf, ll_dest,
pxe_netdev->ll_addr,
net_protocol->net_proto ))!=0){
+ DBG2 ( " could not add link-layer header: %s\n",
+ strerror ( rc ) );
free_iob ( iobuf );
undi_transmit->Status = PXENV_STATUS ( rc );
return PXENV_EXIT_FAILURE;
}
}
+ /* Flag transmission as in-progress. Do this before starting
+ * to transmit the packet, because the ISR may trigger before
+ * we return from netdev_tx().
+ */
+ undi_tx_count++;
+
/* Transmit packet */
+ DBG2 ( "\n" );
if ( ( rc = netdev_tx ( pxe_netdev, iobuf ) ) != 0 ) {
+ DBG2 ( "PXENV_UNDI_TRANSMIT could not transmit: %s\n",
+ strerror ( rc ) );
+ undi_tx_count--;
undi_transmit->Status = PXENV_STATUS ( rc );
return PXENV_EXIT_FAILURE;
}
- /* Flag transmission as in-progress */
- undi_tx_count++;
-
undi_transmit->Status = PXENV_STATUS_SUCCESS;
return PXENV_EXIT_SUCCESS;
}
/* PXENV_UNDI_SET_MCAST_ADDRESS
*
- * Status: stub (no PXE multicast support)
+ * Status: working (for NICs that support receive-all-multicast)
*/
PXENV_EXIT_t
pxenv_undi_set_mcast_address ( struct s_PXENV_UNDI_SET_MCAST_ADDRESS
*undi_set_mcast_address ) {
DBG ( "PXENV_UNDI_SET_MCAST_ADDRESS" );
+ pxe_dump_mcast_list ( &undi_set_mcast_address->R_Mcast_Buf );
+ DBG ( "\n" );
- undi_set_mcast_address->Status = PXENV_STATUS_UNSUPPORTED;
- return PXENV_EXIT_FAILURE;
+ undi_set_mcast_address->Status = PXENV_STATUS_SUCCESS;
+ return PXENV_EXIT_SUCCESS;
}
/* PXENV_UNDI_SET_STATION_ADDRESS
@@ -310,13 +358,16 @@ pxenv_undi_set_mcast_address ( struct s_PXENV_UNDI_SET_MCAST_ADDRESS
PXENV_EXIT_t
pxenv_undi_set_station_address ( struct s_PXENV_UNDI_SET_STATION_ADDRESS
*undi_set_station_address ) {
+ struct ll_protocol *ll_protocol = pxe_netdev->ll_protocol;
- DBG ( "PXENV_UNDI_SET_STATION_ADDRESS" );
+ DBG ( "PXENV_UNDI_SET_STATION_ADDRESS %s",
+ ll_protocol->ntoa ( undi_set_station_address->StationAddress ) );
/* If adapter is open, the change will have no effect; return
* an error
*/
if ( pxe_netdev->state & NETDEV_OPEN ) {
+ DBG ( " failed: netdev is open\n" );
undi_set_station_address->Status =
PXENV_STATUS_UNDI_INVALID_STATE;
return PXENV_EXIT_FAILURE;
@@ -325,8 +376,9 @@ pxenv_undi_set_station_address ( struct s_PXENV_UNDI_SET_STATION_ADDRESS
/* Update MAC address */
memcpy ( pxe_netdev->ll_addr,
&undi_set_station_address->StationAddress,
- pxe_netdev->ll_protocol->ll_addr_len );
+ ll_protocol->ll_addr_len );
+ DBG ( "\n" );
undi_set_station_address->Status = PXENV_STATUS_SUCCESS;
return PXENV_EXIT_SUCCESS;
}
@@ -339,10 +391,17 @@ pxenv_undi_set_station_address ( struct s_PXENV_UNDI_SET_STATION_ADDRESS
PXENV_EXIT_t
pxenv_undi_set_packet_filter ( struct s_PXENV_UNDI_SET_PACKET_FILTER
*undi_set_packet_filter ) {
- DBG ( "PXENV_UNDI_SET_PACKET_FILTER" );
- undi_set_packet_filter->Status = PXENV_STATUS_UNSUPPORTED;
- return PXENV_EXIT_FAILURE;
+ DBG ( "PXENV_UNDI_SET_PACKET_FILTER %02x\n",
+ undi_set_packet_filter->filter );
+
+ /* Pretend that we succeeded, otherwise the 3Com DOS UNDI
+ * driver refuses to load. (We ignore the filter value in the
+ * PXENV_UNDI_OPEN call anyway.)
+ */
+ undi_set_packet_filter->Status = PXENV_STATUS_SUCCESS;
+
+ return PXENV_EXIT_SUCCESS;
}
/* PXENV_UNDI_GET_INFORMATION
@@ -353,6 +412,7 @@ PXENV_EXIT_t pxenv_undi_get_information ( struct s_PXENV_UNDI_GET_INFORMATION
*undi_get_information ) {
struct device *dev = pxe_netdev->dev;
struct ll_protocol *ll_protocol = pxe_netdev->ll_protocol;
+ size_t ll_addr_len = ll_protocol->ll_addr_len;
DBG ( "PXENV_UNDI_GET_INFORMATION" );
@@ -361,17 +421,14 @@ PXENV_EXIT_t pxenv_undi_get_information ( struct s_PXENV_UNDI_GET_INFORMATION
/* Cheat: assume all cards can cope with this */
undi_get_information->MaxTranUnit = ETH_MAX_MTU;
undi_get_information->HwType = ntohs ( ll_protocol->ll_proto );
- undi_get_information->HwAddrLen = ll_protocol->ll_addr_len;
- /* Cheat: assume card is always configured with its permanent
- * node address. This is a valid assumption within Etherboot
- * at the time of writing.
- */
+ undi_get_information->HwAddrLen = ll_addr_len;
+ assert ( ll_addr_len <=
+ sizeof ( undi_get_information->CurrentNodeAddress ) );
memcpy ( &undi_get_information->CurrentNodeAddress,
pxe_netdev->ll_addr,
sizeof ( undi_get_information->CurrentNodeAddress ) );
- memcpy ( &undi_get_information->PermNodeAddress,
- pxe_netdev->ll_addr,
- sizeof ( undi_get_information->PermNodeAddress ) );
+ ll_protocol->init_addr ( pxe_netdev->hw_addr,
+ &undi_get_information->PermNodeAddress );
undi_get_information->ROMAddress = 0;
/* nic.rom_info->rom_segment; */
/* We only provide the ability to receive or transmit a single
@@ -380,6 +437,10 @@ PXENV_EXIT_t pxenv_undi_get_information ( struct s_PXENV_UNDI_GET_INFORMATION
undi_get_information->RxBufCt = 1;
undi_get_information->TxBufCt = 1;
+ DBG ( " io %04x irq %d mtu %d %s %s\n",
+ undi_get_information->BaseIo, undi_get_information->IntNumber,
+ undi_get_information->MaxTranUnit, ll_protocol->name,
+ ll_protocol->ntoa ( &undi_get_information->CurrentNodeAddress ));
undi_get_information->Status = PXENV_STATUS_SUCCESS;
return PXENV_EXIT_SUCCESS;
}
@@ -397,6 +458,11 @@ PXENV_EXIT_t pxenv_undi_get_statistics ( struct s_PXENV_UNDI_GET_STATISTICS
undi_get_statistics->RcvCRCErrors = pxe_netdev->rx_stats.bad;
undi_get_statistics->RcvResourceErrors = pxe_netdev->rx_stats.bad;
+ DBG ( " txok %d rxok %d rxcrc %d rxrsrc %d\n",
+ undi_get_statistics->XmtGoodFrames,
+ undi_get_statistics->RcvGoodFrames,
+ undi_get_statistics->RcvCRCErrors,
+ undi_get_statistics->RcvResourceErrors );
undi_get_statistics->Status = PXENV_STATUS_SUCCESS;
return PXENV_EXIT_SUCCESS;
}
@@ -407,7 +473,7 @@ PXENV_EXIT_t pxenv_undi_get_statistics ( struct s_PXENV_UNDI_GET_STATISTICS
*/
PXENV_EXIT_t pxenv_undi_clear_statistics ( struct s_PXENV_UNDI_CLEAR_STATISTICS
*undi_clear_statistics ) {
- DBG ( "PXENV_UNDI_CLEAR_STATISTICS" );
+ DBG ( "PXENV_UNDI_CLEAR_STATISTICS\n" );
memset ( &pxe_netdev->tx_stats, 0, sizeof ( pxe_netdev->tx_stats ) );
memset ( &pxe_netdev->rx_stats, 0, sizeof ( pxe_netdev->rx_stats ) );
@@ -423,7 +489,7 @@ PXENV_EXIT_t pxenv_undi_clear_statistics ( struct s_PXENV_UNDI_CLEAR_STATISTICS
*/
PXENV_EXIT_t pxenv_undi_initiate_diags ( struct s_PXENV_UNDI_INITIATE_DIAGS
*undi_initiate_diags ) {
- DBG ( "PXENV_UNDI_INITIATE_DIAGS" );
+ DBG ( "PXENV_UNDI_INITIATE_DIAGS failed: unsupported\n" );
undi_initiate_diags->Status = PXENV_STATUS_UNSUPPORTED;
return PXENV_EXIT_FAILURE;
@@ -436,7 +502,7 @@ PXENV_EXIT_t pxenv_undi_initiate_diags ( struct s_PXENV_UNDI_INITIATE_DIAGS
*/
PXENV_EXIT_t pxenv_undi_force_interrupt ( struct s_PXENV_UNDI_FORCE_INTERRUPT
*undi_force_interrupt ) {
- DBG ( "PXENV_UNDI_FORCE_INTERRUPT" );
+ DBG ( "PXENV_UNDI_FORCE_INTERRUPT failed: unsupported\n" );
undi_force_interrupt->Status = PXENV_STATUS_UNSUPPORTED;
return PXENV_EXIT_FAILURE;
@@ -444,15 +510,28 @@ PXENV_EXIT_t pxenv_undi_force_interrupt ( struct s_PXENV_UNDI_FORCE_INTERRUPT
/* PXENV_UNDI_GET_MCAST_ADDRESS
*
- * Status: stub (no PXE multicast support)
+ * Status: working
*/
PXENV_EXIT_t
pxenv_undi_get_mcast_address ( struct s_PXENV_UNDI_GET_MCAST_ADDRESS
*undi_get_mcast_address ) {
- DBG ( "PXENV_UNDI_GET_MCAST_ADDRESS" );
+ struct ll_protocol *ll_protocol = pxe_netdev->ll_protocol;
+ struct in_addr ip = { .s_addr = undi_get_mcast_address->InetAddr };
+ int rc;
- undi_get_mcast_address->Status = PXENV_STATUS_UNSUPPORTED;
- return PXENV_EXIT_FAILURE;
+ DBG ( "PXENV_UNDI_GET_MCAST_ADDRESS %s", inet_ntoa ( ip ) );
+
+ if ( ( rc = ll_protocol->mc_hash ( AF_INET, &ip,
+ undi_get_mcast_address->MediaAddr ))!=0){
+ DBG ( " failed: %s\n", strerror ( rc ) );
+ undi_get_mcast_address->Status = PXENV_STATUS ( rc );
+ return PXENV_EXIT_FAILURE;
+ }
+ DBG ( "=>%s\n",
+ ll_protocol->ntoa ( undi_get_mcast_address->MediaAddr ) );
+
+ undi_get_mcast_address->Status = PXENV_STATUS_SUCCESS;
+ return PXENV_EXIT_SUCCESS;
}
/* PXENV_UNDI_GET_NIC_TYPE
@@ -484,6 +563,13 @@ PXENV_EXIT_t pxenv_undi_get_nic_type ( struct s_PXENV_UNDI_GET_NIC_TYPE
*/
undi_get_nic_type->info.pci.SubVendor_ID = 0xffff;
undi_get_nic_type->info.pci.SubDevice_ID = 0xffff;
+ DBG ( " PCI %02x:%02x.%x %04x:%04x (%04x:%04x) %02x%02x%02x "
+ "rev %02x\n", PCI_BUS ( info->BusDevFunc ),
+ PCI_SLOT ( info->BusDevFunc ),
+ PCI_FUNC ( info->BusDevFunc ), info->Vendor_ID,
+ info->Dev_ID, info->SubVendor_ID, info->SubDevice_ID,
+ info->Base_Class, info->Sub_Class, info->Prog_Intf,
+ info->Rev );
break; }
case BUS_TYPE_ISAPNP: {
struct pnp_nic_info *info = &undi_get_nic_type->info.pnp;
@@ -495,8 +581,12 @@ PXENV_EXIT_t pxenv_undi_get_nic_type ( struct s_PXENV_UNDI_GET_NIC_TYPE
/* Cheat: remaining fields are probably unnecessary,
* and would require adding extra code to isapnp.c.
*/
+ DBG ( " ISAPnP CSN %04x %08x %02x%02x%02x\n",
+ info->CardSelNum, info->EISA_Dev_ID,
+ info->Base_Class, info->Sub_Class, info->Prog_Intf );
break; }
default:
+ DBG ( " failed: unknown bus type\n" );
undi_get_nic_type->Status = PXENV_STATUS_FAILURE;
return PXENV_EXIT_FAILURE;
}
@@ -517,12 +607,18 @@ PXENV_EXIT_t pxenv_undi_get_iface_info ( struct s_PXENV_UNDI_GET_IFACE_INFO
* Most PXE stacks seem to take this approach.
*/
snprintf ( ( char * ) undi_get_iface_info->IfaceType,
- sizeof ( undi_get_iface_info->IfaceType ), "gPXE" );
+ sizeof ( undi_get_iface_info->IfaceType ), "DIX+802.3" );
undi_get_iface_info->LinkSpeed = 10000000; /* 10 Mbps */
- undi_get_iface_info->ServiceFlags = 0;
+ undi_get_iface_info->ServiceFlags =
+ ( SUPPORTED_BROADCAST | SUPPORTED_MULTICAST |
+ SUPPORTED_SET_STATION_ADDRESS | SUPPORTED_RESET |
+ SUPPORTED_OPEN_CLOSE | SUPPORTED_IRQ );
memset ( undi_get_iface_info->Reserved, 0,
sizeof(undi_get_iface_info->Reserved) );
+ DBG ( " %s %dbps flags %08x\n", undi_get_iface_info->IfaceType,
+ undi_get_iface_info->LinkSpeed,
+ undi_get_iface_info->ServiceFlags );
undi_get_iface_info->Status = PXENV_STATUS_SUCCESS;
return PXENV_EXIT_SUCCESS;
}
@@ -533,7 +629,7 @@ PXENV_EXIT_t pxenv_undi_get_iface_info ( struct s_PXENV_UNDI_GET_IFACE_INFO
*/
PXENV_EXIT_t pxenv_undi_get_state ( struct s_PXENV_UNDI_GET_STATE
*undi_get_state ) {
- DBG ( "PXENV_UNDI_GET_STATE" );
+ DBG ( "PXENV_UNDI_GET_STATE failed: unsupported\n" );
undi_get_state->Status = PXENV_STATUS_UNSUPPORTED;
return PXENV_EXIT_FAILURE;
@@ -555,7 +651,10 @@ PXENV_EXIT_t pxenv_undi_isr ( struct s_PXENV_UNDI_ISR *undi_isr ) {
unsigned int prottype;
int rc;
- DBG ( "PXENV_UNDI_ISR" );
+ /* Use coloured debug, since UNDI ISR messages are likely to
+ * be interspersed amongst other UNDI messages.
+ */
+ DBGC2 ( &pxenv_undi_isr, "PXENV_UNDI_ISR" );
/* Just in case some idiot actually looks at these fields when
* we weren't meant to fill them in...
@@ -568,7 +667,7 @@ PXENV_EXIT_t pxenv_undi_isr ( struct s_PXENV_UNDI_ISR *undi_isr ) {
switch ( undi_isr->FuncFlag ) {
case PXENV_UNDI_ISR_IN_START :
- DBG ( " START" );
+ DBGC2 ( &pxenv_undi_isr, " START" );
/* Call poll(). This should acknowledge the device
* interrupt and queue up any received packet.
@@ -579,13 +678,14 @@ PXENV_EXIT_t pxenv_undi_isr ( struct s_PXENV_UNDI_ISR *undi_isr ) {
netdev_irq ( pxe_netdev, 0 );
/* Always say it was ours for the sake of simplicity */
+ DBGC2 ( &pxenv_undi_isr, " OURS" );
undi_isr->FuncFlag = PXENV_UNDI_ISR_OUT_OURS;
break;
case PXENV_UNDI_ISR_IN_PROCESS :
- DBG ( " PROCESS" );
- /* Fall through */
case PXENV_UNDI_ISR_IN_GET_NEXT :
- DBG ( " GET_NEXT" );
+ DBGC2 ( &pxenv_undi_isr, " %s",
+ ( ( undi_isr->FuncFlag == PXENV_UNDI_ISR_IN_PROCESS ) ?
+ "PROCESS" : "GET_NEXT" ) );
/* Some dumb NBPs (e.g. emBoot's winBoot/i) never call
* PXENV_UNDI_ISR with FuncFlag=PXENV_UNDI_ISR_START;
@@ -600,7 +700,7 @@ PXENV_EXIT_t pxenv_undi_isr ( struct s_PXENV_UNDI_ISR *undi_isr ) {
* netdev TX queue is empty, report the TX completion.
*/
if ( undi_tx_count && list_empty ( &pxe_netdev->tx_queue ) ) {
- DBG ( " TXC" );
+ DBGC2 ( &pxenv_undi_isr, " TXC" );
undi_tx_count--;
undi_isr->FuncFlag = PXENV_UNDI_ISR_OUT_TRANSMIT;
break;
@@ -609,7 +709,7 @@ PXENV_EXIT_t pxenv_undi_isr ( struct s_PXENV_UNDI_ISR *undi_isr ) {
/* Remove first packet from netdev RX queue */
iobuf = netdev_rx_dequeue ( pxe_netdev );
if ( ! iobuf ) {
- DBG ( " DONE" );
+ DBGC2 ( &pxenv_undi_isr, " DONE" );
/* No more packets remaining */
undi_isr->FuncFlag = PXENV_UNDI_ISR_OUT_DONE;
/* Re-enable interrupts */
@@ -619,17 +719,18 @@ PXENV_EXIT_t pxenv_undi_isr ( struct s_PXENV_UNDI_ISR *undi_isr ) {
/* Copy packet to base memory buffer */
len = iob_len ( iobuf );
- DBG ( " RX %zd", len );
+ DBGC2 ( &pxenv_undi_isr, " RX" );
if ( len > sizeof ( basemem_packet ) ) {
/* Should never happen */
+ DBGC2 ( &pxenv_undi_isr, " overlength (%zx)", len );
len = sizeof ( basemem_packet );
}
memcpy ( basemem_packet, iobuf->data, len );
/* Strip link-layer header */
ll_protocol = pxe_netdev->ll_protocol;
- if ( ( rc = ll_protocol->pull ( iobuf, &ll_dest, &ll_source,
- &net_proto ) ) != 0 ) {
+ if ( ( rc = ll_protocol->pull ( pxe_netdev, iobuf, &ll_dest,
+ &ll_source, &net_proto )) !=0){
/* Assume unknown net_proto and no ll_source */
net_proto = 0;
ll_source = NULL;
@@ -655,7 +756,6 @@ PXENV_EXIT_t pxenv_undi_isr ( struct s_PXENV_UNDI_ISR *undi_isr ) {
prottype = P_UNKNOWN;
break;
}
- DBG ( " %s", ( net_protocol ? net_protocol->name : "RAW" ) );
/* Fill in UNDI_ISR structure */
undi_isr->FuncFlag = PXENV_UNDI_ISR_OUT_RECEIVE;
@@ -666,12 +766,18 @@ PXENV_EXIT_t pxenv_undi_isr ( struct s_PXENV_UNDI_ISR *undi_isr ) {
undi_isr->Frame.offset = __from_data16 ( basemem_packet );
undi_isr->ProtType = prottype;
undi_isr->PktType = XMT_DESTADDR;
+ DBGC2 ( &pxenv_undi_isr, " %04x:%04x+%x(%x) %s hlen %d",
+ undi_isr->Frame.segment, undi_isr->Frame.offset,
+ undi_isr->BufferLength, undi_isr->FrameLength,
+ ( net_protocol ? net_protocol->name : "RAW" ),
+ undi_isr->FrameHeaderLength );
/* Free packet */
free_iob ( iobuf );
break;
default :
- DBG ( " INVALID(%04x)", undi_isr->FuncFlag );
+ DBGC2 ( &pxenv_undi_isr, " INVALID(%04x)\n",
+ undi_isr->FuncFlag );
/* Should never happen */
undi_isr->FuncFlag = PXENV_UNDI_ISR_OUT_DONE;
@@ -679,6 +785,7 @@ PXENV_EXIT_t pxenv_undi_isr ( struct s_PXENV_UNDI_ISR *undi_isr ) {
return PXENV_EXIT_FAILURE;
}
+ DBGC2 ( &pxenv_undi_isr, "\n" );
undi_isr->Status = PXENV_STATUS_SUCCESS;
return PXENV_EXIT_SUCCESS;
}
diff --git a/gpxe/src/arch/i386/interface/pxeparent/pxeparent.c b/gpxe/src/arch/i386/interface/pxeparent/pxeparent.c
new file mode 100644
index 00000000..582db5d2
--- /dev/null
+++ b/gpxe/src/arch/i386/interface/pxeparent/pxeparent.c
@@ -0,0 +1,201 @@
+/*
+ * Copyright (C) 2007 Michael Brown <mbrown@fensystems.co.uk>.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+FILE_LICENCE ( GPL2_OR_LATER );
+
+#include <gpxe/dhcp.h>
+#include <pxeparent.h>
+#include <pxe_api.h>
+#include <pxe_types.h>
+#include <pxe.h>
+
+/** @file
+ *
+ * Call interface to parent PXE stack
+ *
+ */
+
+/**
+ * Name PXE API call
+ *
+ * @v function API call number
+ * @ret name API call name
+ */
+static inline __attribute__ (( always_inline )) const char *
+pxeparent_function_name ( unsigned int function ) {
+ switch ( function ) {
+ case PXENV_START_UNDI:
+ return "PXENV_START_UNDI";
+ case PXENV_STOP_UNDI:
+ return "PXENV_STOP_UNDI";
+ case PXENV_UNDI_STARTUP:
+ return "PXENV_UNDI_STARTUP";
+ case PXENV_UNDI_CLEANUP:
+ return "PXENV_UNDI_CLEANUP";
+ case PXENV_UNDI_INITIALIZE:
+ return "PXENV_UNDI_INITIALIZE";
+ case PXENV_UNDI_RESET_ADAPTER:
+ return "PXENV_UNDI_RESET_ADAPTER";
+ case PXENV_UNDI_SHUTDOWN:
+ return "PXENV_UNDI_SHUTDOWN";
+ case PXENV_UNDI_OPEN:
+ return "PXENV_UNDI_OPEN";
+ case PXENV_UNDI_CLOSE:
+ return "PXENV_UNDI_CLOSE";
+ case PXENV_UNDI_TRANSMIT:
+ return "PXENV_UNDI_TRANSMIT";
+ case PXENV_UNDI_SET_MCAST_ADDRESS:
+ return "PXENV_UNDI_SET_MCAST_ADDRESS";
+ case PXENV_UNDI_SET_STATION_ADDRESS:
+ return "PXENV_UNDI_SET_STATION_ADDRESS";
+ case PXENV_UNDI_SET_PACKET_FILTER:
+ return "PXENV_UNDI_SET_PACKET_FILTER";
+ case PXENV_UNDI_GET_INFORMATION:
+ return "PXENV_UNDI_GET_INFORMATION";
+ case PXENV_UNDI_GET_STATISTICS:
+ return "PXENV_UNDI_GET_STATISTICS";
+ case PXENV_UNDI_CLEAR_STATISTICS:
+ return "PXENV_UNDI_CLEAR_STATISTICS";
+ case PXENV_UNDI_INITIATE_DIAGS:
+ return "PXENV_UNDI_INITIATE_DIAGS";
+ case PXENV_UNDI_FORCE_INTERRUPT:
+ return "PXENV_UNDI_FORCE_INTERRUPT";
+ case PXENV_UNDI_GET_MCAST_ADDRESS:
+ return "PXENV_UNDI_GET_MCAST_ADDRESS";
+ case PXENV_UNDI_GET_NIC_TYPE:
+ return "PXENV_UNDI_GET_NIC_TYPE";
+ case PXENV_UNDI_GET_IFACE_INFO:
+ return "PXENV_UNDI_GET_IFACE_INFO";
+ /*
+ * Duplicate case value; this is a bug in the PXE specification.
+ *
+ * case PXENV_UNDI_GET_STATE:
+ * return "PXENV_UNDI_GET_STATE";
+ */
+ case PXENV_UNDI_ISR:
+ return "PXENV_UNDI_ISR";
+ case PXENV_GET_CACHED_INFO:
+ return "PXENV_GET_CACHED_INFO";
+ default:
+ return "UNKNOWN API CALL";
+ }
+}
+
+/**
+ * PXE parent parameter block
+ *
+ * Used as the paramter block for all parent PXE API calls. Resides in base
+ * memory.
+ */
+static union u_PXENV_ANY __bss16 ( pxeparent_params );
+#define pxeparent_params __use_data16 ( pxeparent_params )
+
+/** PXE parent entry point
+ *
+ * Used as the indirection vector for all parent PXE API calls. Resides in
+ * base memory.
+ */
+SEGOFF16_t __bss16 ( pxeparent_entry_point );
+#define pxeparent_entry_point __use_data16 ( pxeparent_entry_point )
+
+/**
+ * Issue parent PXE API call
+ *
+ * @v entry Parent PXE stack entry point
+ * @v function API call number
+ * @v params PXE parameter block
+ * @v params_len Length of PXE parameter block
+ * @ret rc Return status code
+ */
+int pxeparent_call ( SEGOFF16_t entry, unsigned int function,
+ void *params, size_t params_len ) {
+ PXENV_EXIT_t exit;
+ int discard_b, discard_D;
+ int rc;
+
+ /* Copy parameter block and entry point */
+ assert ( params_len <= sizeof ( pxeparent_params ) );
+ memcpy ( &pxeparent_params, params, params_len );
+ memcpy ( &pxeparent_entry_point, &entry, sizeof ( entry ) );
+
+ /* Call real-mode entry point. This calling convention will
+ * work with both the !PXE and the PXENV+ entry points.
+ */
+ __asm__ __volatile__ ( REAL_CODE ( "pushw %%es\n\t"
+ "pushw %%di\n\t"
+ "pushw %%bx\n\t"
+ "lcall *pxeparent_entry_point\n\t"
+ "addw $6, %%sp\n\t" )
+ : "=a" ( exit ), "=b" ( discard_b ),
+ "=D" ( discard_D )
+ : "b" ( function ),
+ "D" ( __from_data16 ( &pxeparent_params ) )
+ : "ecx", "edx", "esi", "ebp" );
+
+ /* PXE API calls may rudely change the status of A20 and not
+ * bother to restore it afterwards. Intel is known to be
+ * guilty of this.
+ *
+ * Note that we will return to this point even if A20 gets
+ * screwed up by the parent PXE stack, because Etherboot always
+ * resides in an even megabyte of RAM.
+ */
+ gateA20_set();
+
+ /* Determine return status code based on PXENV_EXIT and
+ * PXENV_STATUS
+ */
+ if ( exit == PXENV_EXIT_SUCCESS ) {
+ rc = 0;
+ } else {
+ rc = -pxeparent_params.Status;
+ /* Paranoia; don't return success for the combination
+ * of PXENV_EXIT_FAILURE but PXENV_STATUS_SUCCESS
+ */
+ if ( rc == 0 )
+ rc = -EIO;
+ }
+
+ /* If anything goes wrong, print as much debug information as
+ * it's possible to give.
+ */
+ if ( rc != 0 ) {
+ SEGOFF16_t rm_params = {
+ .segment = rm_ds,
+ .offset = __from_data16 ( &pxeparent_params ),
+ };
+
+ DBG ( "PXEPARENT %s failed: %s\n",
+ pxeparent_function_name ( function ), strerror ( rc ) );
+ DBG ( "PXEPARENT parameters at %04x:%04x length "
+ "%#02zx, entry point at %04x:%04x\n",
+ rm_params.segment, rm_params.offset, params_len,
+ pxeparent_entry_point.segment,
+ pxeparent_entry_point.offset );
+ DBG ( "PXEPARENT parameters provided:\n" );
+ DBG_HDA ( rm_params, params, params_len );
+ DBG ( "PXEPARENT parameters returned:\n" );
+ DBG_HDA ( rm_params, &pxeparent_params, params_len );
+ }
+
+ /* Copy parameter block back */
+ memcpy ( params, &pxeparent_params, params_len );
+
+ return rc;
+}
+
diff --git a/gpxe/src/arch/i386/interface/pxeparent/pxeparent_dhcp.c b/gpxe/src/arch/i386/interface/pxeparent/pxeparent_dhcp.c
new file mode 100644
index 00000000..66059437
--- /dev/null
+++ b/gpxe/src/arch/i386/interface/pxeparent/pxeparent_dhcp.c
@@ -0,0 +1,69 @@
+/*
+ * Copyright (C) 2009 Joshua Oreman <oremanj@rwcr.net>.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+FILE_LICENCE ( GPL2_OR_LATER );
+
+#include <string.h>
+#include <gpxe/dhcp.h>
+#include <gpxe/netdevice.h>
+#include <undipreload.h>
+#include <pxeparent.h>
+#include <realmode.h>
+#include <pxe_api.h>
+
+/**
+ * Present cached DHCP packet if it exists
+ */
+void __weak_impl ( get_cached_dhcpack ) ( void ) {
+ struct undi_device *undi;
+ struct s_PXENV_GET_CACHED_INFO get_cached_info;
+ int rc;
+
+ /* Use preloaded UNDI device to get at PXE entry point */
+ undi = &preloaded_undi;
+ if ( ! undi->entry.segment ) {
+ DBG ( "PXEDHCP no preloaded UNDI device found\n" );
+ return;
+ }
+
+ /* Check that stack is available to get cached info */
+ if ( ! ( undi->flags & UNDI_FL_KEEP_ALL ) ) {
+ DBG ( "PXEDHCP stack was unloaded, no cache available\n" );
+ return;
+ }
+
+ /* Obtain cached DHCP packet */
+ memset ( &get_cached_info, 0, sizeof ( get_cached_info ) );
+ get_cached_info.PacketType = PXENV_PACKET_TYPE_DHCP_ACK;
+
+ if ( ( rc = pxeparent_call ( undi->entry, PXENV_GET_CACHED_INFO,
+ &get_cached_info,
+ sizeof ( get_cached_info ) ) ) != 0 ) {
+ DBG ( "PXEDHCP GET_CACHED_INFO failed: %s\n", strerror ( rc ) );
+ return;
+ }
+
+ DBG ( "PXEDHCP got cached info at %04x:%04x length %d\n",
+ get_cached_info.Buffer.segment, get_cached_info.Buffer.offset,
+ get_cached_info.BufferSize );
+
+ /* Present cached DHCP packet */
+ store_cached_dhcpack ( real_to_user ( get_cached_info.Buffer.segment,
+ get_cached_info.Buffer.offset ),
+ get_cached_info.BufferSize );
+}
diff --git a/gpxe/src/arch/i386/interface/syslinux/com32_call.c b/gpxe/src/arch/i386/interface/syslinux/com32_call.c
index 4a782dce..d2c3f918 100644
--- a/gpxe/src/arch/i386/interface/syslinux/com32_call.c
+++ b/gpxe/src/arch/i386/interface/syslinux/com32_call.c
@@ -21,6 +21,8 @@
*
*/
+FILE_LICENCE ( GPL2_OR_LATER );
+
#include <stdint.h>
#include <realmode.h>
#include <comboot.h>
diff --git a/gpxe/src/arch/i386/interface/syslinux/com32_wrapper.S b/gpxe/src/arch/i386/interface/syslinux/com32_wrapper.S
index 08d7398a..5c5bd139 100644
--- a/gpxe/src/arch/i386/interface/syslinux/com32_wrapper.S
+++ b/gpxe/src/arch/i386/interface/syslinux/com32_wrapper.S
@@ -16,6 +16,8 @@
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
+FILE_LICENCE ( GPL2_OR_LATER )
+
.text
.arch i386
.code32
diff --git a/gpxe/src/arch/i386/interface/syslinux/comboot_call.c b/gpxe/src/arch/i386/interface/syslinux/comboot_call.c
index bf6c4c66..0a17bf13 100644
--- a/gpxe/src/arch/i386/interface/syslinux/comboot_call.c
+++ b/gpxe/src/arch/i386/interface/syslinux/comboot_call.c
@@ -21,6 +21,8 @@
*
*/
+FILE_LICENCE ( GPL2_OR_LATER );
+
#include <errno.h>
#include <realmode.h>
#include <biosint.h>
@@ -37,6 +39,8 @@
#include <gpxe/init.h>
#include <gpxe/image.h>
#include <usr/imgmgmt.h>
+#include "config/console.h"
+#include "config/serial.h"
/** The "SYSLINUX" version string */
static char __data16_array ( syslinux_version, [] ) = "gPXE " VERSION;
@@ -324,7 +328,7 @@ static __asmcall void int22 ( struct i386_all_regs *ix86 ) {
case 0x0001: /* Get Version */
/* Number of INT 22h API functions available */
- ix86->regs.ax = 0x001B;
+ ix86->regs.ax = 0x001D;
/* SYSLINUX version number */
ix86->regs.ch = 0; /* major */
@@ -441,8 +445,10 @@ static __asmcall void int22 ( struct i386_all_regs *ix86 ) {
break;
case 0x0009: /* Call PXE Stack */
- pxe_api_call ( ix86 );
- ix86->flags &= ~CF;
+ if ( pxe_api_call_weak ( ix86 ) != 0 )
+ ix86->flags |= CF;
+ else
+ ix86->flags &= ~CF;
break;
case 0x000A: /* Get Derivative-Specific Information */
@@ -454,8 +460,14 @@ static __asmcall void int22 ( struct i386_all_regs *ix86 ) {
break;
case 0x000B: /* Get Serial Console Configuration */
- /* FIXME: stub */
+#if defined(CONSOLE_SERIAL) && !defined(COMPRESERVE)
+ ix86->regs.dx = COMCONSOLE;
+ ix86->regs.cx = 115200 / COMSPEED;
+ ix86->regs.bx = 0;
+#else
ix86->regs.dx = 0;
+#endif
+
ix86->flags &= ~CF;
break;
@@ -629,6 +641,17 @@ static __asmcall void int22 ( struct i386_all_regs *ix86 ) {
break;
+ case 0x001C: /* Get pointer to auxilliary data vector */
+ /* FIXME: stub */
+ ix86->regs.cx = 0; /* Size of the ADV */
+ ix86->flags &= ~CF;
+ break;
+
+ case 0x001D: /* Write auxilliary data vector */
+ /* FIXME: stub */
+ ix86->flags &= ~CF;
+ break;
+
default:
DBG ( "COMBOOT unknown int22 function %04x\n", ix86->regs.ax );
break;
diff --git a/gpxe/src/arch/i386/interface/syslinux/comboot_resolv.c b/gpxe/src/arch/i386/interface/syslinux/comboot_resolv.c
index 41c3af7a..30ac502e 100644
--- a/gpxe/src/arch/i386/interface/syslinux/comboot_resolv.c
+++ b/gpxe/src/arch/i386/interface/syslinux/comboot_resolv.c
@@ -5,6 +5,8 @@
#include <gpxe/process.h>
#include <gpxe/resolv.h>
+FILE_LICENCE ( GPL2_OR_LATER );
+
static int comboot_resolv_rc;
static struct in_addr comboot_resolv_addr;
diff --git a/gpxe/src/arch/i386/prefix/bImageprefix.S b/gpxe/src/arch/i386/prefix/bImageprefix.S
deleted file mode 100644
index 30020f73..00000000
--- a/gpxe/src/arch/i386/prefix/bImageprefix.S
+++ /dev/null
@@ -1,611 +0,0 @@
-/*
- Copyright (C) 2000, Entity Cyber, Inc.
-
- Authors: Gary Byers (gb@thinguin.org)
- Marty Connor (mdc@thinguin.org)
- Eric Biederman (ebiederman@lnxi.com)
-
- This code also derives a lot from arch/i386/boot/setup.S in
- the linux kernel.
-
- This software may be used and distributed according to the terms
- of the GNU Public License (GPL), incorporated herein by reference.
-
- Description:
-
- This is just a little bit of code and data that can get prepended
- to an Etherboot ROM image in order to allow LILO to load the
- result as if it were a Linux kernel image.
-
- A real Linux kernel image consists of a one-sector boot loader
- (to load the image from a floppy disk), followed a few sectors
- of setup code, followed by the kernel code itself. There's
- a table in the first sector (starting at offset 497) that indicates
- how many sectors of setup code follow the first sector and which
- contains some other parameters that aren't interesting in this
- case.
-
- When LILO loads the sectors that comprise a kernel image, it doesn't
- execute the code in the first sector (since that code would try to
- load the image from a floppy disk.) The code in the first sector
- below doesn't expect to get executed (and prints an error message
- if it ever -is- executed.) LILO's only interested in knowing the
- number of setup sectors advertised in the table (at offset 497 in
- the first sector.)
-
- Etherboot doesn't require much in the way of setup code.
- Historically, the Linux kernel required at least 4 sectors of
- setup code. Current versions of LILO look at the byte at
- offset 497 in the first sector to indicate how many sectors
- of setup code are contained in the image.
-
- The setup code that is present here does a lot of things
- exactly the way the linux kernel does them instead of in
- ways more typical of etherboot. Generally this is so
- the code can be strongly compatible with the linux kernel.
- In addition the general etherboot technique of enabling the a20
- after we switch into protected mode does not work if etherboot
- is being loaded at 1MB.
-*/
-
- .equ CR0_PE,1
-
-#ifdef GAS291
-#define DATA32 data32;
-#define ADDR32 addr32;
-#define LJMPI(x) ljmp x
-#else
-#define DATA32 data32
-#define ADDR32 addr32
-/* newer GAS295 require #define LJMPI(x) ljmp *x */
-#define LJMPI(x) ljmp x
-#endif
-
-/* Simple and small GDT entries for booting only */
-#define GDT_ENTRY_BOOT_CS 2
-#define GDT_ENTRY_BOOT_DS (GDT_ENTRY_BOOT_CS + 1)
-#define __BOOT_CS (GDT_ENTRY_BOOT_CS * 8)
-#define __BOOT_DS (GDT_ENTRY_BOOT_DS * 8)
-
-
-#define SETUPSECS 4 /* Minimal nr of setup-sectors */
-#define PREFIXSIZE ((SETUPSECS+1)*512)
-#define PREFIXPGH (PREFIXSIZE / 16 )
-#define BOOTSEG 0x07C0 /* original address of boot-sector */
-#define INITSEG 0x9000 /* we move boot here - out of the way */
-#define SETUPSEG 0x9020 /* setup starts here */
-#define SYSSEG 0x1000 /* system loaded at 0x10000 (65536). */
-
-#define DELTA_INITSEG (SETUPSEG - INITSEG) /* 0x0020 */
-
-/* Signature words to ensure LILO loaded us right */
-#define SIG1 0xAA55
-#define SIG2 0x5A5A
-
- .text
- .code16
- .arch i386
- .org 0
- .section ".prefix", "ax", @progbits
-_prefix:
-
-/*
- This is a minimal boot sector. If anyone tries to execute it (e.g., if
- a .lkrn file is dd'ed to a floppy), print an error message.
-*/
-
-bootsector:
- jmp $BOOTSEG, $go - _prefix /* reload cs:ip to match relocation addr */
-go:
- movw $0x2000, %di /* 0x2000 is arbitrary value >= length
- of bootsect + room for stack */
-
- movw $BOOTSEG, %ax
- movw %ax,%ds
- movw %ax,%es
-
- cli
- movw %ax, %ss /* put stack at BOOTSEG:0x2000. */
- movw %di,%sp
- sti
-
- movw $why_end-why, %cx
- movw $why - _prefix, %si
-
- movw $0x0007, %bx /* page 0, attribute 7 (normal) */
- movb $0x0e, %ah /* write char, tty mode */
-prloop:
- lodsb
- int $0x10
- loop prloop
-freeze: jmp freeze
-
-why: .ascii "This image cannot be loaded from a floppy disk.\r\n"
-why_end:
-
-
- .org 497
-setup_sects:
- .byte SETUPSECS
-root_flags:
- .word 0
-syssize:
- .word _verbatim_size_pgh - PREFIXPGH
-swap_dev:
- .word 0
-ram_size:
- .word 0
-vid_mode:
- .word 0
-root_dev:
- .word 0
-boot_flag:
- .word 0xAA55
-
-/*
- We're now at the beginning of the second sector of the image -
- where the setup code goes.
-
- We don't need to do too much setup for Etherboot.
-
- This code gets loaded at SETUPSEG:0. It wants to start
- executing the Etherboot image that's loaded at SYSSEG:0 and
- whose entry point is SYSSEG:0.
-*/
-setup_code:
- jmp trampoline
-# This is the setup header, and it must start at %cs:2 (old 0x9020:2)
-
- .ascii "HdrS" # header signature
- .word 0x0203 # header version number (>= 0x0105)
- # or else old loadlin-1.5 will fail)
-realmode_swtch: .word 0, 0 # default_switch, SETUPSEG
-start_sys_seg: .word SYSSEG # low load segment (obsolete)
- .word kernel_version - setup_code
- # pointing to kernel version string
- # above section of header is compatible
- # with loadlin-1.5 (header v1.5). Don't
- # change it.
-
-type_of_loader: .byte 0 # = 0, old one (LILO, Loadlin,
- # Bootlin, SYSLX, bootsect...)
- # See Documentation/i386/boot.txt for
- # assigned ids
-
-# flags, unused bits must be zero (RFU) bit within loadflags
-loadflags:
-LOADED_HIGH = 1 # If set, the kernel is loaded high
-CAN_USE_HEAP = 0x80 # If set, the loader also has set
- # heap_end_ptr to tell how much
- # space behind setup.S can be used for
- # heap purposes.
- # Only the loader knows what is free
- .byte LOADED_HIGH
-
-setup_move_size: .word 0x8000 # size to move, when setup is not
- # loaded at 0x90000. We will move setup
- # to 0x90000 then just before jumping
- # into the kernel. However, only the
- # loader knows how much data behind
- # us also needs to be loaded.
-
-code32_start: # here loaders can put a different
- # start address for 32-bit code.
- .long 0x100000 # 0x100000 = default for big kernel
-
-ramdisk_image: .long 0 # address of loaded ramdisk image
- # Here the loader puts the 32-bit
- # address where it loaded the image.
- # This only will be read by the kernel.
-
-ramdisk_size: .long 0 # its size in bytes
-
-bootsect_kludge:
- .long 0 # obsolete
-
-heap_end_ptr: .word 0 # (Header version 0x0201 or later)
- # space from here (exclusive) down to
- # end of setup code can be used by setup
- # for local heap purposes.
-
-pad1: .word 0
-cmd_line_ptr: .long 0 # (Header version 0x0202 or later)
- # If nonzero, a 32-bit pointer
- # to the kernel command line.
- # The command line should be
- # located between the start of
- # setup and the end of low
- # memory (0xa0000), or it may
- # get overwritten before it
- # gets read. If this field is
- # used, there is no longer
- # anything magical about the
- # 0x90000 segment; the setup
- # can be located anywhere in
- # low memory 0x10000 or higher.
-
-ramdisk_max: .long 0 # (Header version 0x0203 or later)
- # The highest safe address for
- # the contents of an initrd
-
-trampoline: call start_of_setup
-trampoline_end:
- .space 1024
-# End of setup header #####################################################
-
-start_of_setup:
-# Set %ds = %cs, we know that SETUPSEG = %cs at this point
- movw %cs, %ax # aka SETUPSEG
- movw %ax, %ds
-# Check signature at end of setup
- cmpw $SIG1, (setup_sig1 - setup_code)
- jne bad_sig
-
- cmpw $SIG2, (setup_sig2 - setup_code)
- jne bad_sig
-
- jmp good_sig1
-
-# Routine to print asciiz string at ds:si
-prtstr:
- lodsb
- andb %al, %al
- jz fin
-
- call prtchr
- jmp prtstr
-
-fin: ret
-
-# Part of above routine, this one just prints ascii al
-prtchr: pushw %ax
- pushw %cx
- movw $7,%bx
- movw $0x01, %cx
- movb $0x0e, %ah
- int $0x10
- popw %cx
- popw %ax
- ret
-
-no_sig_mess: .string "No setup signature found ..."
-
-good_sig1:
- jmp good_sig
-
-# We now have to find the rest of the setup code/data
-bad_sig:
- movw %cs, %ax # SETUPSEG
- subw $DELTA_INITSEG, %ax # INITSEG
- movw %ax, %ds
- xorb %bh, %bh
- movb (497), %bl # get setup sect from bootsect
- subw $4, %bx # LILO loads 4 sectors of setup
- shlw $8, %bx # convert to words (1sect=2^8 words)
- movw %bx, %cx
- shrw $3, %bx # convert to segment
- addw $SYSSEG, %bx
- movw %bx, %cs:(start_sys_seg - setup_code)
-# Move rest of setup code/data to here
- movw $2048, %di # four sectors loaded by LILO
- subw %si, %si
- pushw %cs
- popw %es
- movw $SYSSEG, %ax
- movw %ax, %ds
- rep
- movsw
- movw %cs, %ax # aka SETUPSEG
- movw %ax, %ds
- cmpw $SIG1, (setup_sig1 - setup_code)
- jne no_sig
-
- cmpw $SIG2, (setup_sig2 - setup_code)
- jne no_sig
-
- jmp good_sig
-
-no_sig:
- lea (no_sig_mess - setup_code), %si
- call prtstr
-
-no_sig_loop:
- hlt
- jmp no_sig_loop
-
-good_sig:
- cmpw $0, %cs:(realmode_swtch - setup_code)
- jz rmodeswtch_normal
-
- lcall *%cs:(realmode_swtch - setup_code)
- jmp rmodeswtch_end
-
-rmodeswtch_normal:
- pushw %cs
- call default_switch
-
-rmodeswtch_end:
-# we get the code32 start address and modify the below 'jmpi'
-# (loader may have changed it)
- movl %cs:(code32_start - setup_code), %eax
- movl %eax, %cs:(code32 - setup_code)
-
-# then we load the segment descriptors
- movw %cs, %ax # aka SETUPSEG
- movw %ax, %ds
-
-#
-# Enable A20. This is at the very best an annoying procedure.
-# A20 code ported from SYSLINUX 1.52-1.63 by H. Peter Anvin.
-#
-
-A20_TEST_LOOPS = 32 # Iterations per wait
-A20_ENABLE_LOOPS = 255 # Total loops to try
-
-a20_try_loop:
-
- # First, see if we are on a system with no A20 gate.
-a20_none:
- call a20_test
- jnz a20_done
-
- # Next, try the BIOS (INT 0x15, AX=0x2401)
-a20_bios:
- movw $0x2401, %ax
- pushfl # Be paranoid about flags
- int $0x15
- popfl
-
- call a20_test
- jnz a20_done
-
- # Try enabling A20 through the keyboard controller
-a20_kbc:
- call empty_8042
-
- call a20_test # Just in case the BIOS worked
- jnz a20_done # but had a delayed reaction.
-
- movb $0xD1, %al # command write
- outb %al, $0x64
- call empty_8042
-
- movb $0xDF, %al # A20 on
- outb %al, $0x60
- call empty_8042
-
- # Wait until a20 really *is* enabled; it can take a fair amount of
- # time on certain systems; Toshiba Tecras are known to have this
- # problem.
-a20_kbc_wait:
- xorw %cx, %cx
-a20_kbc_wait_loop:
- call a20_test
- jnz a20_done
- loop a20_kbc_wait_loop
-
- # Final attempt: use "configuration port A"
-a20_fast:
- inb $0x92, %al # Configuration Port A
- orb $0x02, %al # "fast A20" version
- andb $0xFE, %al # don't accidentally reset
- outb %al, $0x92
-
- # Wait for configuration port A to take effect
-a20_fast_wait:
- xorw %cx, %cx
-a20_fast_wait_loop:
- call a20_test
- jnz a20_done
- loop a20_fast_wait_loop
-
- # A20 is still not responding. Try frobbing it again.
- #
- decb (a20_tries - setup_code)
- jnz a20_try_loop
-
- movw $(a20_err_msg - setup_code), %si
- call prtstr
-
-a20_die:
- hlt
- jmp a20_die
-
-a20_tries:
- .byte A20_ENABLE_LOOPS
-
-a20_err_msg:
- .ascii "linux: fatal error: A20 gate not responding!"
- .byte 13, 10, 0
-
- # If we get here, all is good
-a20_done:
- # Leave the idt alone
-
- # set up gdt
- xorl %eax, %eax # Compute gdt_base
- movw %ds, %ax # (Convert %ds:gdt to a linear ptr)
- shll $4, %eax
- addl $(bImage_gdt - setup_code), %eax
- movl %eax, (bImage_gdt_48+2 - setup_code)
- DATA32 lgdt %ds:(bImage_gdt_48 - setup_code) # load gdt with whatever is
- # appropriate
-
- # Switch to protected mode
- movl %cr0, %eax
- orb $CR0_PE, %al
- movl %eax, %cr0
-
- DATA32 ljmp *%ds:(code32 - setup_code)
-code32:
- .long 0x100000
- .word __BOOT_CS, 0
-
-# Here's a bunch of information about your current kernel..
-kernel_version: .ascii "Etherboot "
- .ascii VERSION
- .byte 0
-
-# This is the default real mode switch routine.
-# to be called just before protected mode transition
-default_switch:
- cli # no interrupts allowed !
- movb $0x80, %al # disable NMI for bootup
- # sequence
- outb %al, $0x70
- lret
-
-# This routine tests whether or not A20 is enabled. If so, it
-# exits with zf = 0.
-#
-# The memory address used, 0x200, is the int $0x80 vector, which
-# should be safe.
-
-A20_TEST_ADDR = 4*0x80
-
-a20_test:
- pushw %cx
- pushw %ax
- xorw %cx, %cx
- movw %cx, %fs # Low memory
- decw %cx
- movw %cx, %gs # High memory area
- movw $A20_TEST_LOOPS, %cx
- movw %fs:(A20_TEST_ADDR), %ax
- pushw %ax
-a20_test_wait:
- incw %ax
- movw %ax, %fs:(A20_TEST_ADDR)
- call delay # Serialize and make delay constant
- cmpw %gs:(A20_TEST_ADDR+0x10), %ax
- loope a20_test_wait
-
- popw %fs:(A20_TEST_ADDR)
- popw %ax
- popw %cx
- ret
-
-
-# This routine checks that the keyboard command queue is empty
-# (after emptying the output buffers)
-#
-# Some machines have delusions that the keyboard buffer is always full
-# with no keyboard attached...
-#
-# If there is no keyboard controller, we will usually get 0xff
-# to all the reads. With each IO taking a microsecond and
-# a timeout of 100,000 iterations, this can take about half a
-# second ("delay" == outb to port 0x80). That should be ok,
-# and should also be plenty of time for a real keyboard controller
-# to empty.
-#
-
-empty_8042:
- pushl %ecx
- movl $100000, %ecx
-
-empty_8042_loop:
- decl %ecx
- jz empty_8042_end_loop
-
- call delay
-
- inb $0x64, %al # 8042 status port
- testb $1, %al # output buffer?
- jz no_output
-
- call delay
- inb $0x60, %al # read it
- jmp empty_8042_loop
-
-no_output:
- testb $2, %al # is input buffer full?
- jnz empty_8042_loop # yes - loop
-empty_8042_end_loop:
- popl %ecx
-
-
-# Delay is needed after doing I/O
-delay:
- outb %al,$0x80
- ret
-
-# Descriptor tables
-#
-# NOTE: The intel manual says gdt should be sixteen bytes aligned for
-# efficiency reasons. However, there are machines which are known not
-# to boot with misaligned GDTs, so alter this at your peril! If you alter
-# GDT_ENTRY_BOOT_CS (in asm/segment.h) remember to leave at least two
-# empty GDT entries (one for NULL and one reserved).
-#
-# NOTE: On some CPUs, the GDT must be 8 byte aligned. This is
-# true for the Voyager Quad CPU card which will not boot without
-# This directive. 16 byte aligment is recommended by intel.
-#
- .balign 16
-bImage_gdt:
- .fill GDT_ENTRY_BOOT_CS,8,0
-
- .word 0xFFFF # 4Gb - (0x100000*0x1000 = 4Gb)
- .word 0 # base address = 0
- .word 0x9A00 # code read/exec
- .word 0x00CF # granularity = 4096, 386
- # (+5th nibble of limit)
-
- .word 0xFFFF # 4Gb - (0x100000*0x1000 = 4Gb)
- .word 0 # base address = 0
- .word 0x9200 # data read/write
- .word 0x00CF # granularity = 4096, 386
- # (+5th nibble of limit)
-bImage_gdt_end:
- .balign 4
-
- .word 0 # alignment byte
-bImage_idt_48:
- .word 0 # idt limit = 0
- .long 0 # idt base = 0L
-
- .word 0 # alignment byte
-bImage_gdt_48:
- .word bImage_gdt_end - bImage_gdt - 1 # gdt limit
- .long bImage_gdt_48 - setup_code # gdt base (filled in later)
-
- .section ".text16", "ax", @progbits
-prefix_exit:
- int $0x19 /* should try to boot machine */
-prefix_exit_end:
- .previous
-
-
- .org (PREFIXSIZE - 4)
-# Setup signature -- must be last
-setup_sig1: .word SIG1
-setup_sig2: .word SIG2
- /* Etherboot expects to be contiguous in memory once loaded.
- * The linux bImage protocol does not do this, but since we
- * don't need any information that's left in the prefix, it
- * doesn't matter: we just have to ensure that we make it to _start
- *
- * protected_start will live at 0x100000 and it will be the
- * the first code called as we enter protected mode.
- */
- .code32
-protected_start:
- /* Load segment registers */
- movw $__BOOT_DS, %ax
- movw %ax, %ss
- movw %ax, %ds
- movw %ax, %es
- movw %ax, %fs
- movw %ax, %gs
-
- /* Use the internal etherboot stack */
- movl $(_prefix_stack_end - protected_start + 0x100000), %esp
-
- pushl $0 /* No parameters to preserve for exit path */
- pushl $0 /* Use prefix exit path mechanism */
-
- jmp _start
-/*
- That's about it.
-*/
diff --git a/gpxe/src/arch/i386/prefix/bootpart.S b/gpxe/src/arch/i386/prefix/bootpart.S
index d60fe9bc..968da1a3 100644
--- a/gpxe/src/arch/i386/prefix/bootpart.S
+++ b/gpxe/src/arch/i386/prefix/bootpart.S
@@ -1,3 +1,5 @@
+FILE_LICENCE ( GPL2_OR_LATER )
+
#define BOOT_SEG 0x07c0
#define EXEC_SEG 0x0100
#define STACK_SEG 0x0200
diff --git a/gpxe/src/arch/i386/prefix/comprefix.S b/gpxe/src/arch/i386/prefix/comprefix.S
deleted file mode 100644
index 2cbbca50..00000000
--- a/gpxe/src/arch/i386/prefix/comprefix.S
+++ /dev/null
@@ -1,46 +0,0 @@
-/* We need a real mode stack that won't be stomped on by Etherboot
- which starts at 0x20000. Choose something that's sufficiently high,
- but not in DOC territory. Note that we couldn't do this in a real
- .com program since stack variables are in the same segment as the
- code and data, but this isn't really a .com program, it just looks
- like one to make DOS load it into memory. It still has the 64kB
- limitation of .com files though. */
-#define STACK_SEG 0x7000
-#define STACK_SIZE 0x4000
-
- .text
- .code16
- .arch i386
- .section ".prefix", "ax", @progbits
-
-/* Cheat a little with the relocations: .COM files are loaded at 0x100 */
-_prefix:
- /* Set up temporary stack */
- movw $STACK_SEG, %ax
- movw %ax, %ss
- movw $STACK_SIZE, %sp
-
- pushl $0 /* No parameters to preserve for exit path */
- pushw $0 /* Dummy return address - use prefix_exit */
-
- /* Calculate segment address of image start */
- pushw %cs
- popw %ax
- addw $(0x100/16), %ax
- pushw %ax
- pushw $_start
- /* Calculated lcall to _start with %cs:0000 = image start */
- lret
-
- .section ".text16", "ax", @progbits
-prefix_exit:
- movw $0x4c00,%ax /* return to DOS */
- int $0x21 /* reach this on Quit */
-prefix_exit_end:
- .previous
-
-/* The body of etherboot is attached here at build time.
- * Force 16 byte alignment
- */
- .align 16,0
-_body:
diff --git a/gpxe/src/arch/i386/prefix/dskprefix.S b/gpxe/src/arch/i386/prefix/dskprefix.S
index 0156812a..60d351f7 100644
--- a/gpxe/src/arch/i386/prefix/dskprefix.S
+++ b/gpxe/src/arch/i386/prefix/dskprefix.S
@@ -16,6 +16,8 @@
* getting whole tracks at a time whenever possible.
*/
+FILE_LICENCE ( GPL2_ONLY )
+
.equ BOOTSEG, 0x07C0 /* original address of boot-sector */
.equ SYSSEG, 0x1000 /* system loaded at SYSSEG<<4 */
@@ -144,9 +146,9 @@ got_sectors:
/* Jump to loaded copy */
ljmp $SYSSEG, $start_runtime
-endseg: .word SYSSEG + _filesz_pgh
+endseg: .word SYSSEG
.section ".zinfo.fixup", "a", @progbits /* Compressor fixups */
- .ascii "SUBW"
+ .ascii "ADDW"
.long endseg
.long 16
.long 0
diff --git a/gpxe/src/arch/i386/prefix/elf_dprefix.S b/gpxe/src/arch/i386/prefix/elf_dprefix.S
deleted file mode 100644
index 0eac77e0..00000000
--- a/gpxe/src/arch/i386/prefix/elf_dprefix.S
+++ /dev/null
@@ -1,94 +0,0 @@
-#include "elf.h"
-
- .arch i386
- .section ".prefix", "a", @progbits
-
-#define LOAD_ADDR 0x10000
-
- /* ELF Header */
- .globl elf_header
-elf_header:
-e_ident: .byte 0x7f, 'E', 'L', 'F', 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0
-e_type: .short ET_DYN
-e_machine: .short EM_386
-e_version: .long 1
-e_entry: .long LOAD_ADDR + _start - elf_header
-e_phoff: .long elf_program_header - elf_header
-e_shoff: .long 0
-e_flags: .long 0
-e_ehsize: .short elf_header_end - elf_header
-e_phentsize: .short ELF32_PHDR_SIZE
-e_phnum: .short (elf_program_header_end - elf_program_header)/ELF32_PHDR_SIZE
-e_shentsize: .short 0
-e_shnum: .short 0
-e_shstrndx: .short 0
-elf_header_end:
-
-elf_program_header:
-phdr1_p_type: .long PT_NOTE
-phdr1_p_offset: .long elf_note - elf_header
-phdr1_p_vaddr: .long elf_note
-phdr1_p_paddr: .long elf_note
-phdr1_p_filesz: .long elf_note_end - elf_note
-phdr1_p_memsz: .long elf_note_end - elf_note
-phdr1_p_flags: .long PF_R | PF_W | PF_X
-phdr1_p_align: .long 0
-
-/* The decompressor */
-phdr2_p_type: .long PT_LOAD
-phdr2_p_offset: .long 0
-phdr2_p_vaddr: .long elf_header
-phdr2_p_paddr: .long LOAD_ADDR
-phdr2_p_filesz: .long _verbatim_size
-phdr2_p_memsz: .long _image_size
-phdr2_p_flags: .long PF_R | PF_W | PF_X
-phdr2_p_align: .long 16
-
-elf_program_header_end:
-
- .globl elf_note
-elf_note:
- .balign 4
- .int 2f - 1f
- .int 4f - 3f
- .int EIN_PROGRAM_NAME
-1: .asciz "ELFBoot"
-2:
- .balign 4
-3:
- .asciz "Etherboot"
-4:
-
-
- .balign 4
- .int 2f - 1f
- .int 4f - 3f
- .int EIN_PROGRAM_VERSION
-1: .asciz "ELFBoot"
-2:
- .balign 4
-3:
- .asciz VERSION
-4:
-
-#if 0
- .balign 4
- .int 2f - 1f
- .int 4f - 3f
- .int EIN_PROGRAM_CHECKSUM
-1: .asciz "ELFBoot"
-2:
- .balign 4
-3:
- .word 0
-4:
-#endif
- .balign 4
-elf_note_end:
-
- /* Dummy routines to satisfy the build */
- .section ".text16", "ax", @progbits
-prefix_exit:
-
-prefix_exit_end:
- .previous
diff --git a/gpxe/src/arch/i386/prefix/elfprefix.S b/gpxe/src/arch/i386/prefix/elfprefix.S
deleted file mode 100644
index d712753a..00000000
--- a/gpxe/src/arch/i386/prefix/elfprefix.S
+++ /dev/null
@@ -1,94 +0,0 @@
-#include "elf.h"
-
- .arch i386
- .section ".prefix", "a", @progbits
-
-#define LOAD_ADDR 0x10000
-
- /* ELF Header */
- .globl elf_header
-elf_header:
-e_ident: .byte 0x7f, 'E', 'L', 'F', 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0
-e_type: .short ET_EXEC
-e_machine: .short EM_386
-e_version: .long 1
-e_entry: .long LOAD_ADDR + _start - elf_header
-e_phoff: .long elf_program_header - elf_header
-e_shoff: .long 0
-e_flags: .long 0
-e_ehsize: .short elf_header_end - elf_header
-e_phentsize: .short ELF32_PHDR_SIZE
-e_phnum: .short (elf_program_header_end - elf_program_header)/ELF32_PHDR_SIZE
-e_shentsize: .short 0
-e_shnum: .short 0
-e_shstrndx: .short 0
-elf_header_end:
-
-elf_program_header:
-phdr1_p_type: .long PT_NOTE
-phdr1_p_offset: .long elf_note - elf_header
-phdr1_p_vaddr: .long elf_note
-phdr1_p_paddr: .long elf_note
-phdr1_p_filesz: .long elf_note_end - elf_note
-phdr1_p_memsz: .long elf_note_end - elf_note
-phdr1_p_flags: .long PF_R | PF_W | PF_X
-phdr1_p_align: .long 0
-
-/* The decompressor */
-phdr2_p_type: .long PT_LOAD
-phdr2_p_offset: .long 0
-phdr2_p_vaddr: .long elf_header
-phdr2_p_paddr: .long LOAD_ADDR
-phdr2_p_filesz: .long _verbatim_size
-phdr2_p_memsz: .long _image_size
-phdr2_p_flags: .long PF_R | PF_W | PF_X
-phdr2_p_align: .long 16
-
-elf_program_header_end:
-
- .globl elf_note
-elf_note:
- .balign 4
- .int 2f - 1f
- .int 4f - 3f
- .int EIN_PROGRAM_NAME
-1: .asciz "ELFBoot"
-2:
- .balign 4
-3:
- .asciz "Etherboot"
-4:
-
-
- .balign 4
- .int 2f - 1f
- .int 4f - 3f
- .int EIN_PROGRAM_VERSION
-1: .asciz "ELFBoot"
-2:
- .balign 4
-3:
- .asciz VERSION
-4:
-
-#if 0
- .balign 4
- .int 2f - 1f
- .int 4f - 3f
- .int EIN_PROGRAM_CHECKSUM
-1: .asciz "ELFBoot"
-2:
- .balign 4
-3:
- .word 0
-4:
-#endif
- .balign 4
-elf_note_end:
-
- /* Dummy routines to satisfy the build */
- .section ".text16", "ax", @progbits
-prefix_exit:
-
-prefix_exit_end:
- .previous
diff --git a/gpxe/src/arch/i386/prefix/exeprefix.S b/gpxe/src/arch/i386/prefix/exeprefix.S
deleted file mode 100755
index f1b402b7..00000000
--- a/gpxe/src/arch/i386/prefix/exeprefix.S
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- Prefix for .exe images
- Doesn't work yet, even though it starts off the same as a .com
- image as shown by DOS debug.
-*/
-
- .text
- .code16
- .arch i386
- .section ".prefix", "ax", @progbits
-
-_prefix:
- .byte 'M', 'Z'
- .short _exe_size_tail /* tail */
- .short _exe_size_pages /* pages */
- .short 0 /* relocations */
- .short 2 /* header paras */
- .short _exe_bss_size /* min */
- .short 0xFFFF /* max paras */
- .short _exe_ss_offset /* SS */
- .short _stack_size /* SP */
- .short 0 /* checksum */
- .short 0 /* IP */
- .short 0 /* CS */
- .short 0x1C /* reloc offset */
- .short 0 /* overlay number */
- .short 0 /* fill */
- .short 0 /* fill */
-
- .section ".text16", "ax", @progbits
-prefix_exit:
- movw $0x4c00,%ax /* return to DOS */
- int $0x21 /* reach this on Quit */
-prefix_exit_end:
- .previous
-
-/* The body of etherboot is attached here at build time.
- * Force 16 byte alignment
- */
- .align 16,0
-_body:
diff --git a/gpxe/src/arch/i386/prefix/hdprefix.S b/gpxe/src/arch/i386/prefix/hdprefix.S
index 086d7f45..05767567 100644
--- a/gpxe/src/arch/i386/prefix/hdprefix.S
+++ b/gpxe/src/arch/i386/prefix/hdprefix.S
@@ -1,3 +1,5 @@
+FILE_LICENCE ( GPL2_OR_LATER )
+
.text
.arch i386
.section ".prefix", "awx", @progbits
@@ -63,10 +65,10 @@ max_sector:
max_head:
.byte 0
load_length:
- .long _filesz_sect
+ .long 0
.section ".zinfo.fixup", "a", @progbits /* Compressor fixups */
- .ascii "SUBL"
+ .ascii "ADDL"
.long load_length
.long 512
.long 0
diff --git a/gpxe/src/arch/i386/prefix/hromprefix.S b/gpxe/src/arch/i386/prefix/hromprefix.S
new file mode 100644
index 00000000..03acf1e2
--- /dev/null
+++ b/gpxe/src/arch/i386/prefix/hromprefix.S
@@ -0,0 +1,12 @@
+/*****************************************************************************
+ * ROM prefix that relocates to HIGHMEM_LOADPOINT during POST if PMM allocation
+ * fails. Intended to be used, with caution, on BIOSes that support PCI3.00 but
+ * have limited PMM support, such as most AMI BIOSes.
+ *****************************************************************************
+ */
+
+FILE_LICENCE ( GPL2_OR_LATER )
+
+#define SHRINK_WITHOUT_PMM
+
+#include "romprefix.S"
diff --git a/gpxe/src/arch/i386/prefix/kkpxeprefix.S b/gpxe/src/arch/i386/prefix/kkpxeprefix.S
index e0bea0cd..02cc6fee 100644
--- a/gpxe/src/arch/i386/prefix/kkpxeprefix.S
+++ b/gpxe/src/arch/i386/prefix/kkpxeprefix.S
@@ -3,6 +3,11 @@
*****************************************************************************
*/
+FILE_LICENCE ( GPL2_OR_LATER )
+
+/* Since we have the whole stack, we can use cached DHCP information */
+REQUEST_OBJECT ( pxeparent_dhcp )
+
#define PXELOADER_KEEP_UNDI
#define PXELOADER_KEEP_PXE
#include "pxeprefix.S"
diff --git a/gpxe/src/arch/i386/prefix/kpxeprefix.S b/gpxe/src/arch/i386/prefix/kpxeprefix.S
index d708604b..923faccc 100644
--- a/gpxe/src/arch/i386/prefix/kpxeprefix.S
+++ b/gpxe/src/arch/i386/prefix/kpxeprefix.S
@@ -3,5 +3,7 @@
*****************************************************************************
*/
+FILE_LICENCE ( GPL2_OR_LATER )
+
#define PXELOADER_KEEP_UNDI
#include "pxeprefix.S"
diff --git a/gpxe/src/arch/i386/prefix/libprefix.S b/gpxe/src/arch/i386/prefix/libprefix.S
index 42189135..9e6ba6f0 100644
--- a/gpxe/src/arch/i386/prefix/libprefix.S
+++ b/gpxe/src/arch/i386/prefix/libprefix.S
@@ -17,6 +17,8 @@
*
*/
+FILE_LICENCE ( GPL2_OR_LATER )
+
.arch i386
/**
diff --git a/gpxe/src/arch/i386/prefix/lkrnprefix.S b/gpxe/src/arch/i386/prefix/lkrnprefix.S
index 094263d2..101d0388 100644
--- a/gpxe/src/arch/i386/prefix/lkrnprefix.S
+++ b/gpxe/src/arch/i386/prefix/lkrnprefix.S
@@ -34,6 +34,8 @@
*/
+FILE_LICENCE ( GPL_ANY )
+
#define SETUPSECS 4 /* Minimal nr of setup-sectors */
#define PREFIXSIZE ((SETUPSECS+1)*512)
#define PREFIXPGH (PREFIXSIZE / 16 )
@@ -92,10 +94,10 @@ setup_sects:
root_flags:
.word 0
syssize:
- .long _filesz_pgh - PREFIXPGH
+ .long -PREFIXPGH
.section ".zinfo.fixup", "a", @progbits /* Compressor fixups */
- .ascii "SUBL"
+ .ascii "ADDL"
.long syssize
.long 16
.long 0
diff --git a/gpxe/src/arch/i386/prefix/lmelf_dprefix.S b/gpxe/src/arch/i386/prefix/lmelf_dprefix.S
deleted file mode 100644
index 93534df5..00000000
--- a/gpxe/src/arch/i386/prefix/lmelf_dprefix.S
+++ /dev/null
@@ -1,161 +0,0 @@
-#include "elf.h"
- .arch sledgehammer
- .code32
- .equ FLAT_CODE_SEG,_pmcs-_gdt
- .equ FLAT_DATA_SEG,_pmds-_gdt
- .equ MSR_K6_EFER, 0xC0000080
- .equ EFER_LME, 0x00000100
- .equ X86_CR4_PAE, 0x00000020
- .equ CR0_PG, 0x80000000
-
- .section ".prefix", "ax", @progbits
-
-#define LOAD_ADDR 0x10000
-
- /* ELF Header */
- .globl elf_header
-elf_header:
-e_ident: .byte 0x7f, 'E', 'L', 'F', 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0
-e_type: .short ET_DYN
-e_machine: .short EM_X86_64
-e_version: .long 1
-e_entry: .long LOAD_ADDR + elf_start - elf_header
-e_phoff: .long elf_program_header - elf_header
-e_shoff: .long 0
-e_flags: .long 0
-e_ehsize: .short elf_header_end - elf_header
-e_phentsize: .short ELF32_PHDR_SIZE
-e_phnum: .short (elf_program_header_end - elf_program_header)/ELF32_PHDR_SIZE
-e_shentsize: .short 0
-e_shnum: .short 0
-e_shstrndx: .short 0
-elf_header_end:
-
-elf_program_header:
-phdr1_p_type: .long PT_NOTE
-phdr1_p_offset: .long elf_note - elf_header
-phdr1_p_vaddr: .long elf_note
-phdr1_p_paddr: .long elf_note
-phdr1_p_filesz: .long elf_note_end - elf_note
-phdr1_p_memsz: .long elf_note_end - elf_note
-phdr1_p_flags: .long PF_R | PF_W | PF_X
-phdr1_p_align: .long 0
-
-/* The decompressor */
-phdr2_p_type: .long PT_LOAD
-phdr2_p_offset: .long 0
-phdr2_p_vaddr: .long elf_header
-phdr2_p_paddr: .long LOAD_ADDR
-phdr2_p_filesz: .long _verbatim_size
-phdr2_p_memsz: .long _image_size
-phdr2_p_flags: .long PF_R | PF_W | PF_X
-phdr2_p_align: .long 16
-
-elf_program_header_end:
-
- .globl elf_note
-elf_note:
- .balign 4
- .int 2f - 1f
- .int 4f - 3f
- .int EIN_PROGRAM_NAME
-1: .asciz "ELFBoot"
-2:
- .balign 4
-3:
- .asciz "Etherboot"
-4:
-
-
- .balign 4
- .int 2f - 1f
- .int 4f - 3f
- .int EIN_PROGRAM_VERSION
-1: .asciz "ELFBoot"
-2:
- .balign 4
-3:
- .asciz VERSION
-4:
-
-#if 0
- .balign 4
- .int 2f - 1f
- .int 4f - 3f
- .int EIN_PROGRAM_CHECKSUM
-1: .asciz "ELFBoot"
-2:
- .balign 4
-3:
- .word 0
-4:
-#endif
- .balign 4
-elf_note_end:
-
-elf_start:
- .code64
- /* Reload the gdt to something I know */
- leaq _gdt(%rip), %rax
- movq %rax, 0x02 + gdtptr(%rip)
- lgdt gdtptr(%rip)
-
- /* Enter 32bit compatibility mode */
- leaq elf_start32(%rip), %rax
- movl %eax, 0x00 + elf_start32_addr(%rip)
- ljmp *elf_start32_addr(%rip)
-
-elf_start32:
- .code32
- /* Reload the data segments */
- movl $FLAT_DATA_SEG, %eax
- movl %eax, %ds
- movl %eax, %es
- movl %eax, %ss
-
- /* Disable paging */
- movl %cr0, %eax
- andl $~CR0_PG, %eax
- movl %eax, %cr0
-
- /* Disable long mode */
- movl $MSR_K6_EFER, %ecx
- rdmsr
- andl $~EFER_LME, %eax
- wrmsr
-
- /* Disable PAE */
- movl %cr4, %eax
- andl $~X86_CR4_PAE, %eax
- movl %eax, %cr4
-
- /* Save the first argument */
- pushl %ebx
- jmp _start
-
-gdtptr:
- .word _gdt_end - _gdt -1
- .long _gdt
- .long 0
-_gdt:
-elf_start32_addr:
- .long elf_start32
- .long FLAT_CODE_SEG
-_pmcs:
- /* 32 bit protected mode code segment, base 0 */
- .word 0xffff,0
- .byte 0,0x9f,0xcf,0
-
-_pmds:
- /* 32 bit protected mode data segment, base 0 */
- .word 0xffff,0
- .byte 0,0x93,0xcf,0
-_gdt_end:
-
-
- /* Dummy routines to satisfy the build */
- .section ".text16", "ax", @progbits
-prefix_exit:
-
-prefix_exit_end:
- .previous
diff --git a/gpxe/src/arch/i386/prefix/lmelf_prefix.S b/gpxe/src/arch/i386/prefix/lmelf_prefix.S
deleted file mode 100644
index 3c1e7251..00000000
--- a/gpxe/src/arch/i386/prefix/lmelf_prefix.S
+++ /dev/null
@@ -1,161 +0,0 @@
-#include "elf.h"
- .arch sledgehammer
- .code32
- .equ FLAT_CODE_SEG,_pmcs-_gdt
- .equ FLAT_DATA_SEG,_pmds-_gdt
- .equ MSR_K6_EFER, 0xC0000080
- .equ EFER_LME, 0x00000100
- .equ X86_CR4_PAE, 0x00000020
- .equ CR0_PG, 0x80000000
-
- .section ".prefix", "ax", @progbits
-
-#define LOAD_ADDR 0x10000
-
- /* ELF Header */
- .globl elf_header
-elf_header:
-e_ident: .byte 0x7f, 'E', 'L', 'F', 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0
-e_type: .short ET_EXEC
-e_machine: .short EM_X86_64
-e_version: .long 1
-e_entry: .long LOAD_ADDR + elf_start - elf_header
-e_phoff: .long elf_program_header - elf_header
-e_shoff: .long 0
-e_flags: .long 0
-e_ehsize: .short elf_header_end - elf_header
-e_phentsize: .short ELF32_PHDR_SIZE
-e_phnum: .short (elf_program_header_end - elf_program_header)/ELF32_PHDR_SIZE
-e_shentsize: .short 0
-e_shnum: .short 0
-e_shstrndx: .short 0
-elf_header_end:
-
-elf_program_header:
-phdr1_p_type: .long PT_NOTE
-phdr1_p_offset: .long elf_note - elf_header
-phdr1_p_vaddr: .long elf_note
-phdr1_p_paddr: .long elf_note
-phdr1_p_filesz: .long elf_note_end - elf_note
-phdr1_p_memsz: .long elf_note_end - elf_note
-phdr1_p_flags: .long PF_R | PF_W | PF_X
-phdr1_p_align: .long 0
-
-/* The decompressor */
-phdr2_p_type: .long PT_LOAD
-phdr2_p_offset: .long 0
-phdr2_p_vaddr: .long elf_header
-phdr2_p_paddr: .long LOAD_ADDR
-phdr2_p_filesz: .long _verbatim_size
-phdr2_p_memsz: .long _image_size
-phdr2_p_flags: .long PF_R | PF_W | PF_X
-phdr2_p_align: .long 16
-
-elf_program_header_end:
-
- .globl elf_note
-elf_note:
- .balign 4
- .int 2f - 1f
- .int 4f - 3f
- .int EIN_PROGRAM_NAME
-1: .asciz "ELFBoot"
-2:
- .balign 4
-3:
- .asciz "Etherboot"
-4:
-
-
- .balign 4
- .int 2f - 1f
- .int 4f - 3f
- .int EIN_PROGRAM_VERSION
-1: .asciz "ELFBoot"
-2:
- .balign 4
-3:
- .asciz VERSION
-4:
-
-#if 0
- .balign 4
- .int 2f - 1f
- .int 4f - 3f
- .int EIN_PROGRAM_CHECKSUM
-1: .asciz "ELFBoot"
-2:
- .balign 4
-3:
- .word 0
-4:
-#endif
- .balign 4
-elf_note_end:
-
-elf_start:
- .code64
- /* Reload the gdt to something I know */
- leaq _gdt(%rip), %rax
- movq %rax, 0x02 + gdtptr(%rip)
- lgdt gdtptr(%rip)
-
- /* Enter 32bit compatibility mode */
- leaq elf_start32(%rip), %rax
- movl %eax, 0x00 + elf_start32_addr(%rip)
- ljmp *elf_start32_addr(%rip)
-
-elf_start32:
- .code32
- /* Reload the data segments */
- movl $FLAT_DATA_SEG, %eax
- movl %eax, %ds
- movl %eax, %es
- movl %eax, %ss
-
- /* Disable paging */
- movl %cr0, %eax
- andl $~CR0_PG, %eax
- movl %eax, %cr0
-
- /* Disable long mode */
- movl $MSR_K6_EFER, %ecx
- rdmsr
- andl $~EFER_LME, %eax
- wrmsr
-
- /* Disable PAE */
- movl %cr4, %eax
- andl $~X86_CR4_PAE, %eax
- movl %eax, %cr4
-
- /* Save the first argument */
- pushl %ebx
- jmp _start
-
-gdtptr:
- .word _gdt_end - _gdt -1
- .long _gdt
- .long 0
-_gdt:
-elf_start32_addr:
- .long elf_start32
- .long FLAT_CODE_SEG
-_pmcs:
- /* 32 bit protected mode code segment, base 0 */
- .word 0xffff,0
- .byte 0,0x9f,0xcf,0
-
-_pmds:
- /* 32 bit protected mode data segment, base 0 */
- .word 0xffff,0
- .byte 0,0x93,0xcf,0
-_gdt_end:
-
-
- /* Dummy routines to satisfy the build */
- .section ".text16", "ax", @progbits
-prefix_exit:
-
-prefix_exit_end:
- .previous
diff --git a/gpxe/src/arch/i386/prefix/nbiprefix.S b/gpxe/src/arch/i386/prefix/nbiprefix.S
index 4fb4acb1..607d80fb 100644
--- a/gpxe/src/arch/i386/prefix/nbiprefix.S
+++ b/gpxe/src/arch/i386/prefix/nbiprefix.S
@@ -30,16 +30,16 @@ segment_header:
.byte 0
.byte 0x04 /* Last segment */
.long 0x00007e00
-imglen: .long _filesz - 512
-memlen: .long _filesz - 512
+imglen: .long -512
+memlen: .long -512
.size segment_header, . - segment_header
.section ".zinfo.fixup", "a", @progbits /* Compressor fixups */
- .ascii "SUBL"
+ .ascii "ADDL"
.long imglen
.long 1
.long 0
- .ascii "SUBL"
+ .ascii "ADDL"
.long memlen
.long 1
.long 0
diff --git a/gpxe/src/arch/i386/prefix/pxeprefix.S b/gpxe/src/arch/i386/prefix/pxeprefix.S
index b3b7947f..e728c482 100644
--- a/gpxe/src/arch/i386/prefix/pxeprefix.S
+++ b/gpxe/src/arch/i386/prefix/pxeprefix.S
@@ -1,8 +1,13 @@
+FILE_LICENCE ( GPL2_OR_LATER )
+
#define PXENV_UNDI_SHUTDOWN 0x0005
#define PXENV_UNDI_GET_NIC_TYPE 0x0012
+#define PXENV_UNDI_GET_IFACE_INFO 0x0013
#define PXENV_STOP_UNDI 0x0015
#define PXENV_UNLOAD_STACK 0x0070
+#define PXE_HACK_EB54 0x0001
+
.text
.arch i386
.org 0
@@ -11,6 +16,8 @@
#include <undi.h>
#define STACK_MAGIC ( 'L' + ( 'R' << 8 ) + ( 'E' << 16 ) + ( 'T' << 24 ) )
+#define EB_MAGIC_1 ( 'E' + ( 't' << 8 ) + ( 'h' << 16 ) + ( 'e' << 24 ) )
+#define EB_MAGIC_2 ( 'r' + ( 'b' << 8 ) + ( 'o' << 16 ) + ( 'o' << 24 ) )
/*****************************************************************************
* Entry point: set operating context, print welcome message
@@ -105,20 +112,13 @@ have_pxenv:
/* Record entry point and UNDI segments */
pushl %es:0x0a(%bx) /* Entry point */
- popl entry_segoff
pushw %es:0x24(%bx) /* UNDI code segment */
pushw %es:0x26(%bx) /* UNDI code size */
- popl undi_code_segoff
pushw %es:0x20(%bx) /* UNDI data segment */
pushw %es:0x22(%bx) /* UNDI data size */
- popl undi_data_segoff
/* Print "PXENV+ at <address>" */
movw $10f, %si
- call print_message
- call print_segoff
- movb $( ',' ), %al
- call print_character
jmp check_have_stack
.section ".prefix.data", "aw", @progbits
10: .asciz " PXENV+ at "
@@ -129,19 +129,13 @@ have_ppxe:
movw %es, ppxe_segment
pushl %es:0x10(%bx) /* Entry point */
- popl entry_segoff
pushw %es:0x30(%bx) /* UNDI code segment */
pushw %es:0x36(%bx) /* UNDI code size */
- popl undi_code_segoff
pushw %es:0x28(%bx) /* UNDI data segment */
pushw %es:0x2e(%bx) /* UNDI data size */
- popl undi_data_segoff
+
/* Print "!PXE at <address>" */
movw $10f, %si
- call print_message
- call print_segoff
- movb $( ',' ), %al
- call print_character
jmp check_have_stack
.section ".prefix.data", "aw", @progbits
10: .asciz " !PXE at "
@@ -201,6 +195,17 @@ memory_scan_common:
*****************************************************************************
*/
check_have_stack:
+ /* Save common values pushed onto the stack */
+ popl undi_data_segoff
+ popl undi_code_segoff
+ popl entry_segoff
+
+ /* Print have !PXE/PXENV+ message; structure pointer in %es:%bx */
+ call print_message
+ call print_segoff
+ movb $( ',' ), %al
+ call print_character
+
/* Check for entry point */
movl entry_segoff, %eax
testl %eax, %eax
@@ -309,8 +314,6 @@ pci_physical_device:
movw $10f, %si
call print_message
call print_pci_busdevfn
- movb $0x0a, %al
- call print_character
jmp 99f
.section ".prefix.data", "aw", @progbits
10: .asciz " UNDI device is PCI "
@@ -321,12 +324,47 @@ no_physical_device:
movw $10f, %si
call print_message
.section ".prefix.data", "aw", @progbits
-10: .asciz " Unable to determine UNDI physical device\n"
+10: .asciz " Unable to determine UNDI physical device"
.previous
99:
/*****************************************************************************
+ * Determine interface type
+ *****************************************************************************
+ */
+get_iface_type:
+ /* Issue PXENV_UNDI_GET_IFACE_INFO */
+ movw $PXENV_UNDI_GET_IFACE_INFO, %bx
+ call pxe_call
+ jnc 1f
+ call print_pxe_error
+ jmp 99f
+1: /* Print interface type */
+ movw $10f, %si
+ call print_message
+ leaw ( pxe_parameter_structure + 0x02 ), %si
+ call print_message
+ .section ".prefix.data", "aw", @progbits
+10: .asciz ", type "
+ .previous
+ /* Check for "Etherboot" interface type */
+ cmpl $EB_MAGIC_1, ( pxe_parameter_structure + 0x02 )
+ jne 99f
+ cmpl $EB_MAGIC_2, ( pxe_parameter_structure + 0x06 )
+ jne 99f
+ movw $10f, %si
+ call print_message
+ .section ".prefix.data", "aw", @progbits
+10: .asciz " (workaround enabled)"
+ .previous
+ /* Flag Etherboot workarounds as required */
+ orw $PXE_HACK_EB54, pxe_hacks
+
+99: movb $0x0a, %al
+ call print_character
+
+/*****************************************************************************
* Leave NIC in a safe state
*****************************************************************************
*/
@@ -339,6 +377,14 @@ shutdown_nic:
call print_pxe_error
1:
unload_base_code:
+ /* Etherboot treats PXENV_UNLOAD_STACK as PXENV_STOP_UNDI, so
+ * we must not issue this call if the underlying stack is
+ * Etherboot and we were not intending to issue a PXENV_STOP_UNDI.
+ */
+#ifdef PXELOADER_KEEP_UNDI
+ testw $PXE_HACK_EB54, pxe_hacks
+ jnz 99f
+#endif /* PXELOADER_KEEP_UNDI */
/* Issue PXENV_UNLOAD_STACK */
movw $PXENV_UNLOAD_STACK, %bx
call pxe_call
@@ -551,7 +597,9 @@ pxe_call:
testw %ax, %ax
jz 1f
stc
-1: /* Restore registers and return */
+1: /* Clear direction flag, for the sake of sanity */
+ cld
+ /* Restore registers and return */
popw %es
popw %di
ret
@@ -595,7 +643,7 @@ print_pxe_error:
pxe_esp: .long 0
pxe_ss: .word 0
-pxe_parameter_structure: .fill 20
+pxe_parameter_structure: .fill 64
undi_code_segoff:
undi_code_size: .word 0
@@ -605,6 +653,8 @@ undi_data_segoff:
undi_data_size: .word 0
undi_data_segment: .word 0
+pxe_hacks: .word 0
+
/* The following fields are part of a struct undi_device */
undi_device:
@@ -668,6 +718,13 @@ run_gpxe:
lret
.section ".text16", "ax", @progbits
1:
+ /* Update the exit hook */
+ movw %cs,pxe_exit_hook+2
+ push %ax
+ mov $2f,%ax
+ mov %ax,pxe_exit_hook
+ pop %ax
+
/* Run main program */
pushl $main
pushw %cs
@@ -681,7 +738,10 @@ run_gpxe:
movw %di, %ss
movl %ebp, %esp
- /* Check PXE stack magic */
+ /* Jump to hook if applicable */
+ ljmpw *pxe_exit_hook
+
+2: /* Check PXE stack magic */
popl %eax
cmpl $STACK_MAGIC, %eax
jne 1f
diff --git a/gpxe/src/arch/i386/prefix/romprefix.S b/gpxe/src/arch/i386/prefix/romprefix.S
index 7d532375..02e54976 100644
--- a/gpxe/src/arch/i386/prefix/romprefix.S
+++ b/gpxe/src/arch/i386/prefix/romprefix.S
@@ -6,6 +6,8 @@
* table so using a noticeable amount of stack space is a no-no.
*/
+FILE_LICENCE ( GPL2_OR_LATER )
+
#include <config/general.h>
#define PNP_SIGNATURE ( '$' + ( 'P' << 8 ) + ( 'n' << 16 ) + ( 'P' << 24 ) )
@@ -23,6 +25,19 @@
*/
#define ROM_BANNER_TIMEOUT ( 2 * ( 18 * BANNER_TIMEOUT ) / 10 )
+/* We can load a ROM in two ways: have the BIOS load all of it (.rom prefix)
+ * or have the BIOS load a stub that loads the rest using PCI (.xrom prefix).
+ * The latter is not as widely supported, but allows the use of large ROMs
+ * on some systems with crowded option ROM space.
+ */
+
+#ifdef LOAD_ROM_FROM_PCI
+#define ROM_SIZE_VALUE _prefix_filesz_sect /* Amount to load in BIOS */
+#else
+#define ROM_SIZE_VALUE 0 /* Load amount (before compr. fixup) */
+#endif
+
+
.text
.code16
.arch i386
@@ -31,10 +46,12 @@
.org 0x00
romheader:
.word 0xAA55 /* BIOS extension signature */
-romheader_size: .byte _filesz_sect /* Size in 512-byte blocks */
+romheader_size: .byte ROM_SIZE_VALUE /* Size in 512-byte blocks */
jmp init /* Initialisation vector */
checksum:
- .byte 0
+ .byte 0, 0
+real_size:
+ .word 0
.org 0x16
.word undiheader
.org 0x18
@@ -42,12 +59,18 @@ checksum:
.org 0x1a
.word pnpheader
.size romheader, . - romheader
-
+
.section ".zinfo.fixup", "a", @progbits /* Compressor fixups */
- .ascii "SUBB"
+#ifndef LOAD_ROM_FROM_PCI
+ .ascii "ADDB"
.long romheader_size
.long 512
.long 0
+#endif
+ .ascii "ADDB"
+ .long real_size
+ .long 512
+ .long 0
.previous
pciheader:
@@ -59,27 +82,29 @@ pciheader:
.byte 0x03 /* PCI data structure revision */
.byte 0x02, 0x00, 0x00 /* Class code */
pciheader_image_length:
- .word _filesz_sect /* Image length */
+ .word ROM_SIZE_VALUE /* Image length */
.word 0x0001 /* Revision level */
.byte 0x00 /* Code type */
.byte 0x80 /* Last image indicator */
pciheader_runtime_length:
- .word _filesz_sect /* Maximum run-time image length */
+ .word ROM_SIZE_VALUE /* Maximum run-time image length */
.word 0x0000 /* Configuration utility code header */
.word 0x0000 /* DMTF CLP entry point */
.equ pciheader_len, . - pciheader
.size pciheader, . - pciheader
-
+
+#ifndef LOAD_ROM_FROM_PCI
.section ".zinfo.fixup", "a", @progbits /* Compressor fixups */
- .ascii "SUBW"
+ .ascii "ADDW"
.long pciheader_image_length
.long 512
.long 0
- .ascii "SUBW"
+ .ascii "ADDW"
.long pciheader_runtime_length
.long 512
.long 0
.previous
+#endif
pnpheader:
.ascii "$PnP" /* Signature */
@@ -124,6 +149,7 @@ prodstr_pci_id:
.size prodstr, . - prodstr
.globl undiheader
+ .weak undiloader
undiheader:
.ascii "UNDI" /* Signature */
.byte undiheader_len /* Length of structure */
@@ -172,6 +198,11 @@ init:
call print_message
call print_pci_busdevfn
+#ifdef LOAD_ROM_FROM_PCI
+ /* Save PCI bus:dev.fn for later use */
+ movw %ax, pci_busdevfn
+#endif
+
/* Fill in product name string, if possible */
movw $prodstr_pci_id, %di
call print_pci_busdevfn
@@ -196,6 +227,9 @@ init:
jne no_pci3
testb %ah, %ah
jnz no_pci3
+#ifdef LOAD_ROM_FROM_PCI
+ incb pcibios_present
+#endif
movw $init_message_pci, %si
xorw %di, %di
call print_message
@@ -236,24 +270,37 @@ no_pci3:
popl %edx
popl %ebx
- /* Check for PnP BIOS */
- testw $0x0f, %bx /* PnP signature must be aligned - bochs */
- jnz no_bbs /* uses unalignment to indicate 'fake' PnP. */
- cmpl $PNP_SIGNATURE, %es:0(%bx)
- jne no_bbs
+ /* Check for PnP BIOS. Although %es:di should point to the
+ * PnP BIOS signature on entry, some BIOSes fail to do this.
+ */
+ movw $( 0xf000 - 1 ), %bx
+pnp_scan:
+ incw %bx
+ jz no_pnp
+ movw %bx, %es
+ cmpl $PNP_SIGNATURE, %es:0
+ jne pnp_scan
+ xorw %dx, %dx
+ xorw %si, %si
+ movzbw %es:5, %cx
+1: es lodsb
+ addb %al, %dl
+ loop 1b
+ jnz pnp_scan
/* Is PnP: print PnP message */
movw $init_message_pnp, %si
xorw %di, %di
call print_message
/* Check for BBS */
- pushw %es:0x1b(%bx) /* Real-mode data segment */
+ pushw %es:0x1b /* Real-mode data segment */
pushw %ds /* &(bbs_version) */
pushw $bbs_version
pushw $PNP_GET_BBS_VERSION
- lcall *%es:0xd(%bx)
+ lcall *%es:0xd
addw $8, %sp
testw %ax, %ax
je got_bbs
+no_pnp: /* Not PnP-compliant - therefore cannot be BBS-compliant */
no_bbs: /* Not BBS-compliant - must hook INT 19 */
movw $init_message_int19, %si
xorw %di, %di
@@ -294,7 +341,7 @@ pmm_scan:
/* We have PMM and so a 1kB stack: preserve upper register halves */
pushal
/* Calculate required allocation size in %esi */
- movzbl romheader_size, %eax
+ movzwl real_size, %eax
shll $9, %eax
addl $_textdata_memsz, %eax
orw $0xffff, %ax /* Ensure allocation size is at least 64kB