├── COPYING ├── COPYRIGHTS ├── LOG ├── README ├── contrib ├── README ├── errdb │ ├── .gitignore │ └── errdb.pl └── rom-o-matic │ ├── README │ ├── bottom.php │ ├── build.php │ ├── customize-flags.php │ ├── directions.php │ ├── doc │ ├── AUTOBOOT_CMD.html │ ├── BANNER_TIMEOUT.html │ ├── COMCONSOLE.html │ ├── COMDATA.html │ ├── COMPARITY.html │ ├── COMPRESERVE.html │ ├── COMSPEED.html │ ├── COMSTOP.html │ ├── CONFIG_CMD.html │ ├── CONSOLE_PC_BIOS.html │ ├── CONSOLE_SERIAL.html │ ├── CRYPTO_80211_WEP.html │ ├── CRYPTO_80211_WPA.html │ ├── CRYPTO_80211_WPA2.html │ ├── DHCP_CMD.html │ ├── DNS_RESOLVER.html │ ├── DOWNLOAD_PROTO_FTP.html │ ├── DOWNLOAD_PROTO_HTTP.html │ ├── DOWNLOAD_PROTO_TFTP.html │ ├── IFMGMT_CMD.html │ ├── IMAGE_BZIMAGE.html │ ├── IMAGE_CMD.html │ ├── IMAGE_ELF.html │ ├── IMAGE_MULTIBOOT.html │ ├── IMAGE_NBI.html │ ├── IMAGE_PXE.html │ ├── IMAGE_SCRIPT.html │ ├── IWMGMT_CMD.html │ ├── NMB_RESOLVER.html │ ├── NVO_CMD.html │ ├── ROUTE_CMD.html │ └── SANBOOT_CMD.html │ ├── flag-table.php │ ├── globals.php │ ├── index.php │ ├── top.php │ └── utils.php └── src ├── .gitignore ├── Makefile ├── Makefile.housekeeping ├── arch ├── i386 │ ├── Makefile │ ├── Makefile.efi │ ├── Makefile.pcbios │ ├── README.i386 │ ├── core │ │ ├── aout_loader.c │ │ ├── basemem_packet.c │ │ ├── cpu.c │ │ ├── dumpregs.c │ │ ├── freebsd_loader.c │ │ ├── gdbidt.S │ │ ├── gdbmach.c │ │ ├── nulltrap.c │ │ ├── patch_cf.S │ │ ├── pic8259.c │ │ ├── rdtsc_timer.c │ │ ├── relocate.c │ │ ├── setjmp.S │ │ ├── stack.S │ │ ├── stack16.S │ │ ├── timer2.c │ │ ├── video_subr.c │ │ ├── virtaddr.S │ │ ├── wince_loader.c │ │ └── x86_io.c │ ├── drivers │ │ └── net │ │ │ ├── undi.c │ │ │ ├── undiisr.S │ │ │ ├── undiload.c │ │ │ ├── undinet.c │ │ │ ├── undionly.c │ │ │ ├── undipreload.c │ │ │ └── undirom.c │ ├── firmware │ │ └── pcbios │ │ │ ├── basemem.c │ │ │ ├── bios_console.c │ │ │ ├── e820mangler.S │ │ │ ├── fakee820.c │ │ │ ├── hidemem.c │ │ │ ├── memmap.c │ │ │ └── pnpbios.c │ ├── hci │ │ └── commands │ │ │ └── pxe_cmd.c │ ├── image │ │ ├── bootsector.c │ │ ├── bzimage.c │ │ ├── com32.c │ │ ├── comboot.c │ │ ├── elfboot.c │ │ ├── eltorito.c │ │ ├── multiboot.c │ │ ├── nbi.c │ │ └── pxe_image.c │ ├── include │ │ ├── basemem.h │ │ ├── basemem_packet.h │ │ ├── bios.h │ │ ├── bios_disks.h │ │ ├── biosint.h │ │ ├── bits │ │ │ ├── byteswap.h │ │ │ ├── compiler.h │ │ │ ├── cpu.h │ │ │ ├── eltorito.h │ │ │ ├── endian.h │ │ │ ├── errfile.h │ │ │ ├── io.h │ │ │ ├── nap.h │ │ │ ├── smbios.h │ │ │ ├── stdint.h │ │ │ ├── timer.h │ │ │ ├── uaccess.h │ │ │ └── umalloc.h │ │ ├── bochs.h │ │ ├── bootsector.h │ │ ├── bzimage.h │ │ ├── comboot.h │ │ ├── efi │ │ │ └── gpxe │ │ │ │ └── dhcp_arch.h │ │ ├── fakee820.h │ │ ├── gdbmach.h │ │ ├── gpxe │ │ │ ├── abft.h │ │ │ ├── bios_nap.h │ │ │ ├── bios_smbios.h │ │ │ ├── bios_timer.h │ │ │ ├── ibft.h │ │ │ ├── memtop_umalloc.h │ │ │ ├── rdtsc_timer.h │ │ │ ├── sbft.h │ │ │ ├── timer2.h │ │ │ └── x86_io.h │ │ ├── int13.h │ │ ├── kir.h │ │ ├── libkir.h │ │ ├── librm.h │ │ ├── limits.h │ │ ├── memsizes.h │ │ ├── multiboot.h │ │ ├── pcbios │ │ │ └── gpxe │ │ │ │ └── dhcp_arch.h │ │ ├── pic8259.h │ │ ├── pnpbios.h │ │ ├── pxe.h │ │ ├── pxe_api.h │ │ ├── pxe_call.h │ │ ├── pxe_types.h │ │ ├── pxeparent.h │ │ ├── realmode.h │ │ ├── registers.h │ │ ├── setjmp.h │ │ ├── undi.h │ │ ├── undiload.h │ │ ├── undinet.h │ │ ├── undipreload.h │ │ ├── undirom.h │ │ └── vga.h │ ├── interface │ │ ├── pcbios │ │ │ ├── abft.c │ │ │ ├── aoeboot.c │ │ │ ├── bios_nap.c │ │ │ ├── bios_smbios.c │ │ │ ├── bios_timer.c │ │ │ ├── biosint.c │ │ │ ├── ib_srpboot.c │ │ │ ├── ibft.c │ │ │ ├── int13.c │ │ │ ├── iscsiboot.c │ │ │ ├── keepsan.c │ │ │ ├── memtop_umalloc.c │ │ │ ├── pcibios.c │ │ │ └── sbft.c │ │ ├── pxe │ │ │ ├── pxe_call.c │ │ │ ├── pxe_entry.S │ │ │ ├── pxe_file.c │ │ │ ├── pxe_loader.c │ │ │ ├── pxe_preboot.c │ │ │ ├── pxe_tftp.c │ │ │ ├── pxe_udp.c │ │ │ └── pxe_undi.c │ │ ├── pxeparent │ │ │ ├── pxeparent.c │ │ │ └── pxeparent_dhcp.c │ │ └── syslinux │ │ │ ├── com32_call.c │ │ │ ├── com32_wrapper.S │ │ │ ├── comboot_call.c │ │ │ └── comboot_resolv.c │ ├── kir-Makefile │ ├── prefix │ │ ├── bootpart.S │ │ ├── dskprefix.S │ │ ├── hdprefix.S │ │ ├── kkpxeprefix.S │ │ ├── kpxeprefix.S │ │ ├── libprefix.S │ │ ├── lkrnprefix.S │ │ ├── mbr.S │ │ ├── mromprefix.S │ │ ├── nbiprefix.S │ │ ├── nullprefix.S │ │ ├── pxeprefix.S │ │ ├── romprefix.S │ │ ├── undiloader.S │ │ ├── unnrv2b.S │ │ ├── unnrv2b16.S │ │ └── usbdisk.S │ ├── scripts │ │ ├── i386-kir.lds │ │ └── i386.lds │ └── transitions │ │ ├── libflat.S │ │ ├── libkir.S │ │ ├── libpm.S │ │ ├── librm.S │ │ └── librm_mgmt.c ├── x86 │ ├── Makefile │ ├── Makefile.efi │ ├── core │ │ ├── pcidirect.c │ │ └── x86_string.c │ ├── include │ │ ├── bits │ │ │ ├── pci_io.h │ │ │ └── string.h │ │ └── gpxe │ │ │ ├── efi │ │ │ └── efix86_nap.h │ │ │ ├── pcibios.h │ │ │ └── pcidirect.h │ ├── interface │ │ └── efi │ │ │ └── efix86_nap.c │ ├── prefix │ │ ├── efidrvprefix.c │ │ └── efiprefix.c │ └── scripts │ │ └── efi.lds └── x86_64 │ ├── Makefile │ ├── Makefile.efi │ └── include │ ├── bits │ ├── byteswap.h │ ├── compiler.h │ ├── endian.h │ ├── errfile.h │ ├── io.h │ ├── nap.h │ ├── smbios.h │ ├── stdint.h │ ├── timer.h │ ├── uaccess.h │ └── umalloc.h │ ├── efi │ └── gpxe │ │ └── dhcp_arch.h │ ├── gdbmach.h │ └── limits.h ├── bin └── .gitignore ├── config ├── .gitignore ├── config.c ├── config_net80211.c ├── config_romprefix.c ├── console.h ├── defaults.h ├── defaults │ ├── efi.h │ └── pcbios.h ├── general.h ├── ioapi.h ├── isa.h ├── local │ └── .gitignore ├── nap.h ├── serial.h ├── timer.h └── umalloc.h ├── core ├── acpi.c ├── ansiesc.c ├── asprintf.c ├── base16.c ├── base64.c ├── basename.c ├── bitmap.c ├── bitops.c ├── btext.c ├── console.c ├── cpio.c ├── ctype.c ├── cwuri.c ├── debug.c ├── device.c ├── downloader.c ├── errno.c ├── exec.c ├── filter.c ├── fnrec.c ├── gdbserial.c ├── gdbstub.c ├── gdbudp.c ├── getkey.c ├── getopt.c ├── hw.c ├── i82365.c ├── image.c ├── init.c ├── interface.c ├── iobuf.c ├── job.c ├── linebuf.c ├── main.c ├── malloc.c ├── misc.c ├── monojob.c ├── null_nap.c ├── nvo.c ├── open.c ├── pc_kbd.c ├── pcmcia.c ├── posix_io.c ├── process.c ├── random.c ├── refcnt.c ├── resolv.c ├── serial.c ├── serial_console.c ├── settings.c ├── string.c ├── stringextra.c ├── timer.c ├── uri.c ├── uuid.c ├── vsprintf.c └── xfer.c ├── crypto ├── aes_wrap.c ├── arc4.c ├── asn1.c ├── axtls │ ├── aes.c │ ├── bigint.c │ ├── bigint.h │ ├── bigint_impl.h │ ├── crypto.h │ ├── os_port.h │ ├── rsa.c │ └── sha1.c ├── axtls_aes.c ├── axtls_sha1.c ├── cbc.c ├── chap.c ├── crandom.c ├── crc32.c ├── crypto_null.c ├── hmac.c ├── md5.c ├── sha1extra.c └── x509.c ├── doc ├── build_sys.dox └── pxe_extensions ├── doxygen.cfg ├── drivers ├── bitbash │ ├── bitbash.c │ ├── i2c_bit.c │ └── spi_bit.c ├── block │ ├── ata.c │ ├── ramdisk.c │ ├── scsi.c │ └── srp.c ├── bus │ ├── eisa.c │ ├── isa.c │ ├── isa_ids.c │ ├── isapnp.c │ ├── mca.c │ ├── pci.c │ ├── pcibackup.c │ ├── pciextra.c │ ├── virtio-pci.c │ └── virtio-ring.c ├── infiniband │ ├── MT25218_PRM.h │ ├── MT25408_PRM.h │ ├── arbel.c │ ├── arbel.h │ ├── hermon.c │ ├── hermon.h │ ├── linda.c │ ├── linda.h │ ├── linda_fw.c │ ├── mlx_bitops.h │ ├── qib7322.c │ ├── qib7322.h │ ├── qib_7220_regs.h │ ├── qib_7322_regs.h │ └── qib_genbits.pl ├── net │ ├── 3c503.c │ ├── 3c509-eisa.c │ ├── 3c509.c │ ├── 3c509.h │ ├── 3c515.c │ ├── 3c515.txt │ ├── 3c529.c │ ├── 3c595.c │ ├── 3c595.h │ ├── 3c5x9.c │ ├── 3c90x.c │ ├── 3c90x.h │ ├── amd8111e.c │ ├── amd8111e.h │ ├── ath5k │ │ ├── ath5k.c │ │ ├── ath5k.h │ │ ├── ath5k_attach.c │ │ ├── ath5k_caps.c │ │ ├── ath5k_desc.c │ │ ├── ath5k_dma.c │ │ ├── ath5k_eeprom.c │ │ ├── ath5k_gpio.c │ │ ├── ath5k_initvals.c │ │ ├── ath5k_pcu.c │ │ ├── ath5k_phy.c │ │ ├── ath5k_qcu.c │ │ ├── ath5k_reset.c │ │ ├── ath5k_rfkill.c │ │ ├── base.h │ │ ├── desc.h │ │ ├── eeprom.h │ │ ├── reg.h │ │ ├── rfbuffer.h │ │ └── rfgain.h │ ├── atl1e.c │ ├── atl1e.h │ ├── b44.c │ ├── b44.h │ ├── bnx2.c │ ├── bnx2.h │ ├── bnx2_fw.h │ ├── cs89x0.c │ ├── cs89x0.h │ ├── cs89x0.txt │ ├── davicom.c │ ├── depca.c │ ├── dmfe.c │ ├── e1000 │ │ ├── e1000.c │ │ ├── e1000.h │ │ ├── e1000_82540.c │ │ ├── e1000_82541.c │ │ ├── e1000_82541.h │ │ ├── e1000_82542.c │ │ ├── e1000_82543.c │ │ ├── e1000_82543.h │ │ ├── e1000_api.c │ │ ├── e1000_api.h │ │ ├── e1000_defines.h │ │ ├── e1000_hw.h │ │ ├── e1000_mac.c │ │ ├── e1000_mac.h │ │ ├── e1000_main.c │ │ ├── e1000_manage.c │ │ ├── e1000_manage.h │ │ ├── e1000_nvm.c │ │ ├── e1000_nvm.h │ │ ├── e1000_osdep.h │ │ ├── e1000_phy.c │ │ ├── e1000_phy.h │ │ └── e1000_regs.h │ ├── e1000e │ │ ├── e1000e.c │ │ ├── e1000e.h │ │ ├── e1000e_80003es2lan.c │ │ ├── e1000e_80003es2lan.h │ │ ├── e1000e_82571.c │ │ ├── e1000e_82571.h │ │ ├── e1000e_defines.h │ │ ├── e1000e_hw.h │ │ ├── e1000e_ich8lan.c │ │ ├── e1000e_ich8lan.h │ │ ├── e1000e_mac.c │ │ ├── e1000e_mac.h │ │ ├── e1000e_main.c │ │ ├── e1000e_manage.c │ │ ├── e1000e_manage.h │ │ ├── e1000e_nvm.c │ │ ├── e1000e_nvm.h │ │ ├── e1000e_phy.c │ │ ├── e1000e_phy.h │ │ └── e1000e_regs.h │ ├── eepro.c │ ├── eepro100.c │ ├── eepro100.h │ ├── efi │ │ ├── snp.h │ │ ├── snpnet.c │ │ ├── snpnet.h │ │ └── snponly.c │ ├── epic100.c │ ├── epic100.h │ ├── etherfabric.c │ ├── etherfabric.h │ ├── etherfabric_nic.h │ ├── forcedeth.c │ ├── forcedeth.h │ ├── hfa384x.h │ ├── igb │ │ ├── igb.c │ │ ├── igb.h │ │ ├── igb_82575.c │ │ ├── igb_82575.h │ │ ├── igb_api.c │ │ ├── igb_api.h │ │ ├── igb_defines.h │ │ ├── igb_hw.h │ │ ├── igb_mac.c │ │ ├── igb_mac.h │ │ ├── igb_main.c │ │ ├── igb_manage.c │ │ ├── igb_manage.h │ │ ├── igb_nvm.c │ │ ├── igb_nvm.h │ │ ├── igb_osdep.h │ │ ├── igb_phy.c │ │ ├── igb_phy.h │ │ └── igb_regs.h │ ├── ipoib.c │ ├── jme.c │ ├── jme.h │ ├── legacy.c │ ├── mtd80x.c │ ├── mtnic.c │ ├── mtnic.h │ ├── myri10ge.c │ ├── myri10ge_mcp.h │ ├── natsemi.c │ ├── natsemi.h │ ├── ne.c │ ├── ne2k_isa.c │ ├── ns83820.c │ ├── ns8390.c │ ├── ns8390.h │ ├── p80211hdr.h │ ├── pcnet32.c │ ├── pcnet32.h │ ├── phantom │ │ ├── nx_bitops.h │ │ ├── nxhal_nic_interface.h │ │ ├── phantom.c │ │ ├── phantom.h │ │ └── phantom_hw.h │ ├── pnic.c │ ├── pnic_api.h │ ├── prism2.c │ ├── prism2_pci.c │ ├── prism2_plx.c │ ├── r8169.c │ ├── r8169.h │ ├── rtl8139.c │ ├── rtl818x │ │ ├── rtl8180.c │ │ ├── rtl8180_grf5101.c │ │ ├── rtl8180_max2820.c │ │ ├── rtl8180_sa2400.c │ │ ├── rtl8185.c │ │ ├── rtl8185_rtl8225.c │ │ ├── rtl818x.c │ │ └── rtl818x.h │ ├── sis190.c │ ├── sis190.h │ ├── sis900.c │ ├── sis900.h │ ├── skge.c │ ├── skge.h │ ├── sky2.c │ ├── sky2.h │ ├── smc9000.c │ ├── smc9000.h │ ├── sundance.c │ ├── tg3.c │ ├── tg3.h │ ├── tlan.c │ ├── tlan.h │ ├── tulip.c │ ├── tulip.txt │ ├── via-rhine.c │ ├── via-velocity.c │ ├── via-velocity.h │ ├── virtio-net.c │ ├── virtio-net.h │ ├── vxge │ │ ├── vxge.c │ │ ├── vxge_config.c │ │ ├── vxge_config.h │ │ ├── vxge_main.c │ │ ├── vxge_main.h │ │ ├── vxge_reg.h │ │ ├── vxge_traffic.c │ │ ├── vxge_traffic.h │ │ └── vxge_version.h │ ├── w89c840.c │ ├── wd.c │ └── wlan_compat.h └── nvs │ ├── nvs.c │ ├── spi.c │ └── threewire.c ├── hci ├── commands │ ├── autoboot_cmd.c │ ├── config_cmd.c │ ├── dhcp_cmd.c │ ├── digest_cmd.c │ ├── gdbstub_cmd.c │ ├── ifmgmt_cmd.c │ ├── image_cmd.c │ ├── ipv6_cmd.c │ ├── iwmgmt_cmd.c │ ├── login_cmd.c │ ├── nvo_cmd.c │ ├── route_cmd.c │ ├── sanboot_cmd.c │ └── time_cmd.c ├── editstring.c ├── mucurses │ ├── alert.c │ ├── ansi_screen.c │ ├── clear.c │ ├── colour.c │ ├── cursor.h │ ├── edging.c │ ├── kb.c │ ├── mucurses.c │ ├── mucurses.h │ ├── print.c │ ├── print_nadv.c │ ├── slk.c │ ├── widgets │ │ └── editbox.c │ ├── winattrs.c │ ├── windows.c │ └── wininit.c ├── readline.c ├── shell.c ├── shell_banner.c ├── strerror.c ├── tui │ ├── login_ui.c │ └── settings_ui.c └── wireless_errors.c ├── image ├── efi_image.c ├── elf.c ├── embedded.c ├── script.c └── segment.c ├── include ├── .gitignore ├── alloca.h ├── assert.h ├── big_bswap.h ├── bootp.h ├── btext.h ├── byteswap.h ├── cmdline.h ├── cmdlinelib.h ├── cmdlist.h ├── coff.h ├── compiler.h ├── console.h ├── cpu.h ├── ctype.h ├── curses.h ├── elf.h ├── endian.h ├── errno.h ├── etherboot.h ├── fs.h ├── getopt.h ├── gpxe │ ├── acpi.h │ ├── aes.h │ ├── ansiesc.h │ ├── aoe.h │ ├── api.h │ ├── arc4.h │ ├── arp.h │ ├── asn1.h │ ├── ata.h │ ├── base16.h │ ├── base64.h │ ├── bitbash.h │ ├── bitmap.h │ ├── bitops.h │ ├── blockdev.h │ ├── cbc.h │ ├── chap.h │ ├── command.h │ ├── cpio.h │ ├── crc32.h │ ├── crypto.h │ ├── device.h │ ├── dhcp.h │ ├── dhcp6.h │ ├── dhcpopts.h │ ├── dhcppkt.h │ ├── dns.h │ ├── downloader.h │ ├── eapol.h │ ├── editbox.h │ ├── editstring.h │ ├── efi │ │ ├── Base.h │ │ ├── Guid │ │ │ ├── HiiFormMapMethodGuid.h │ │ │ ├── PcAnsi.h │ │ │ ├── SmBios.h │ │ │ └── WinCertificate.h │ │ ├── Ia32 │ │ │ └── ProcessorBind.h │ │ ├── IndustryStandard │ │ │ ├── Pci22.h │ │ │ └── PeImage.h │ │ ├── LICENCE │ │ ├── Pi │ │ │ ├── PiBootMode.h │ │ │ ├── PiDependency.h │ │ │ ├── PiDxeCis.h │ │ │ ├── PiFirmwareFile.h │ │ │ ├── PiFirmwareVolume.h │ │ │ ├── PiHob.h │ │ │ ├── PiMultiPhase.h │ │ │ ├── PiS3BootScript.h │ │ │ └── PiStatusCode.h │ │ ├── PiDxe.h │ │ ├── ProcessorBind.h │ │ ├── Protocol │ │ │ ├── ComponentName2.h │ │ │ ├── Cpu.h │ │ │ ├── CpuIo.h │ │ │ ├── CpuIo2.h │ │ │ ├── DebugSupport.h │ │ │ ├── DevicePath.h │ │ │ ├── DriverBinding.h │ │ │ ├── LoadedImage.h │ │ │ ├── NetworkInterfaceIdentifier.h │ │ │ ├── PciIo.h │ │ │ ├── PciRootBridgeIo.h │ │ │ ├── SimpleNetwork.h │ │ │ ├── SimpleTextIn.h │ │ │ └── SimpleTextOut.h │ │ ├── Uefi.h │ │ ├── Uefi │ │ │ ├── UefiBaseType.h │ │ │ ├── UefiGpt.h │ │ │ ├── UefiInternalFormRepresentation.h │ │ │ ├── UefiMultiPhase.h │ │ │ ├── UefiPxe.h │ │ │ └── UefiSpec.h │ │ ├── X64 │ │ │ └── ProcessorBind.h │ │ ├── efi.h │ │ ├── efi_io.h │ │ ├── efi_pci.h │ │ ├── efi_smbios.h │ │ ├── efi_timer.h │ │ ├── efi_uaccess.h │ │ ├── efi_umalloc.h │ │ └── import.pl │ ├── eisa.h │ ├── elf.h │ ├── errfile.h │ ├── errortab.h │ ├── eth_slow.h │ ├── ethernet.h │ ├── fakedhcp.h │ ├── features.h │ ├── filter.h │ ├── ftp.h │ ├── gdbserial.h │ ├── gdbstub.h │ ├── gdbudp.h │ ├── hidemem.h │ ├── hmac.h │ ├── http.h │ ├── i2c.h │ ├── ib_cm.h │ ├── ib_cmrc.h │ ├── ib_mad.h │ ├── ib_mcast.h │ ├── ib_mi.h │ ├── ib_packet.h │ ├── ib_pathrec.h │ ├── ib_sma.h │ ├── ib_smc.h │ ├── ib_srp.h │ ├── icmp.h │ ├── icmp6.h │ ├── ieee80211.h │ ├── if_arp.h │ ├── if_ether.h │ ├── image.h │ ├── in.h │ ├── infiniband.h │ ├── init.h │ ├── interface.h │ ├── io.h │ ├── iobuf.h │ ├── ip.h │ ├── ip6.h │ ├── ipoib.h │ ├── isa.h │ ├── isa_ids.h │ ├── isapnp.h │ ├── iscsi.h │ ├── job.h │ ├── keys.h │ ├── linebuf.h │ ├── linux_compat.h │ ├── list.h │ ├── login_ui.h │ ├── malloc.h │ ├── mca.h │ ├── md5.h │ ├── memmap.h │ ├── monojob.h │ ├── nap.h │ ├── ndp.h │ ├── net80211.h │ ├── net80211_err.h │ ├── netdevice.h │ ├── null_nap.h │ ├── nvo.h │ ├── nvs.h │ ├── open.h │ ├── pci.h │ ├── pci_ids.h │ ├── pci_io.h │ ├── pcibackup.h │ ├── posix_io.h │ ├── process.h │ ├── profile.h │ ├── ramdisk.h │ ├── rarp.h │ ├── rc80211.h │ ├── refcnt.h │ ├── resolv.h │ ├── retry.h │ ├── rotate.h │ ├── rsa.h │ ├── sanboot.h │ ├── scsi.h │ ├── sec80211.h │ ├── segment.h │ ├── serial.h │ ├── settings.h │ ├── settings_ui.h │ ├── sha1.h │ ├── shell.h │ ├── shell_banner.h │ ├── smbios.h │ ├── socket.h │ ├── spi.h │ ├── spi_bit.h │ ├── srp.h │ ├── tables.h │ ├── tcp.h │ ├── tcpip.h │ ├── tftp.h │ ├── threewire.h │ ├── timer.h │ ├── tls.h │ ├── uaccess.h │ ├── udp.h │ ├── umalloc.h │ ├── uri.h │ ├── uuid.h │ ├── virtio-pci.h │ ├── virtio-ring.h │ ├── vsprintf.h │ ├── wpa.h │ ├── x509.h │ └── xfer.h ├── hci │ └── ifmgmt_cmd.h ├── i82365.h ├── libgen.h ├── little_bswap.h ├── mii.h ├── nic.h ├── old_tcp.h ├── pc_kbd.h ├── pcmcia-opts.h ├── pcmcia.h ├── readline │ └── readline.h ├── stdarg.h ├── stddef.h ├── stdint.h ├── stdio.h ├── stdlib.h ├── string.h ├── strings.h ├── sys │ └── time.h ├── sys_info.h ├── time.h ├── unistd.h └── usr │ ├── autoboot.h │ ├── dhcpmgmt.h │ ├── ifmgmt.h │ ├── imgmgmt.h │ ├── ip6mgmt.h │ ├── iwmgmt.h │ └── route.h ├── interface ├── efi │ ├── efi_console.c │ ├── efi_init.c │ ├── efi_io.c │ ├── efi_pci.c │ ├── efi_smbios.c │ ├── efi_snp.c │ ├── efi_strerror.c │ ├── efi_timer.c │ ├── efi_uaccess.c │ └── efi_umalloc.c └── smbios │ ├── smbios.c │ └── smbios_settings.c ├── libgcc ├── __divdi3.c ├── __moddi3.c ├── __udivdi3.c ├── __udivmoddi4.c ├── __umoddi3.c ├── icc.c ├── libgcc.h └── memcpy.c ├── net ├── 80211 │ ├── net80211.c │ ├── rc80211.c │ ├── sec80211.c │ ├── wep.c │ ├── wpa.c │ ├── wpa_ccmp.c │ ├── wpa_psk.c │ └── wpa_tkip.c ├── aoe.c ├── arp.c ├── cachedhcp.c ├── dhcpopts.c ├── dhcppkt.c ├── eapol.c ├── eth_slow.c ├── ethernet.c ├── fakedhcp.c ├── icmp.c ├── icmpv6.c ├── infiniband.c ├── infiniband │ ├── ib_cm.c │ ├── ib_cmrc.c │ ├── ib_mcast.c │ ├── ib_mi.c │ ├── ib_packet.c │ ├── ib_pathrec.c │ ├── ib_sma.c │ ├── ib_smc.c │ └── ib_srp.c ├── iobpad.c ├── ipv4.c ├── ipv6.c ├── mii.c ├── ndp.c ├── netdev_settings.c ├── netdevice.c ├── nullnet.c ├── rarp.c ├── retry.c ├── tcp.c ├── tcp │ ├── ftp.c │ ├── http.c │ ├── https.c │ └── iscsi.c ├── tcpip.c ├── tls.c ├── udp.c └── udp │ ├── dhcp.c │ ├── dhcp6.c │ ├── dns.c │ ├── slam.c │ └── tftp.c ├── tests ├── comboot │ ├── shuffle-simple.asm │ └── version.asm ├── gdbstub_test.S ├── gdbstub_test.gdb ├── linebuf_test.c ├── memcpy_test.c ├── umalloc_test.c └── uri_test.c ├── usr ├── autoboot.c ├── dhcpmgmt.c ├── ifmgmt.c ├── imgmgmt.c ├── ip6mgmt.c ├── iwmgmt.c ├── pxemenu.c └── route.c └── util ├── .gitignore ├── Makefile ├── Option └── ROM.pm ├── catrom.pl ├── diffsize.pl ├── disrom.pl ├── efirom.c ├── einfo.c ├── elf2efi.c ├── fixrom.pl ├── fnrec.sh ├── geniso ├── genliso ├── gensdsk ├── get-pci-ids ├── hijack.c ├── iccfix.c ├── licence.pl ├── mergerom.pl ├── modrom.pl ├── mucurses_test.c ├── nrv2b.c ├── padimg.pl ├── parserom.pl ├── sortobjdump.pl ├── swapdevids.pl ├── symcheck.pl └── zbin.c /COPYRIGHTS: -------------------------------------------------------------------------------- 1 | 2 | In general gPXE files are licensed under the GPL. GPLed files are in 3 | general either from Linux or have been explicitly put under GPL by the 4 | authors. The license for a file is usually documented at the top of 5 | the file. 6 | 7 | A few files are inherited from FreeBSD netboot and therefore can be 8 | used under BSD or GPL. Documented in this file are some of the 9 | non-GPL'ed files. If the internal documentation for a file disagrees 10 | with what is documented in this file, the internal documentation for 11 | the file shall be override this file. 12 | 13 | File Copyright status 14 | 15 | src/core/misc.c BSD 16 | src/drivers/net/3c509.c BSD 17 | src/drivers/net/3c509.h BSD 18 | src/drivers/net/3c595.c BSD 19 | src/drivers/net/3c595.h BSD 20 | src/drivers/net/3c90x.c Open Source 21 | src/drivers/net/epic100.c None 22 | src/drivers/net/epic100.h None 23 | src/drivers/net/ns8390.c BSD 24 | src/drivers/net/ns8390.h BSD 25 | src/arch/i386/include/bits/string.h None 26 | 27 | -------------------------------------------------------------------------------- /LOG: -------------------------------------------------------------------------------- 1 | gPXE LOG file 2 | 3 | + Development for gPXE was moved from SourceForge CVS to a git 4 | repository on git.etherboot.org in the first half of the year 2007. 5 | 6 | + The gitweb interface for gPXE is available at: 7 | 8 | http://git.etherboot.org/?p=gpxe.git 9 | 10 | + The gitweb interface largely obsoletes the LOG file that used to be 11 | distributed with Etherboot. 12 | 13 | -------------------------------------------------------------------------------- /contrib/README: -------------------------------------------------------------------------------- 1 | Most of the content that was previously in this directory has been 2 | moved to a separate git repository: 3 | 4 | http://git.etherboot.org/?p=contrib.git;a=summary 5 | 6 | or the Etherboot Project wiki: 7 | 8 | http://etherboot.org/ 9 | 10 | -------------------------------------------------------------------------------- /contrib/errdb/.gitignore: -------------------------------------------------------------------------------- 1 | errors.db 2 | -------------------------------------------------------------------------------- /contrib/rom-o-matic/doc/AUTOBOOT_CMD.html: -------------------------------------------------------------------------------- 1 | Automatic booting 2 | -------------------------------------------------------------------------------- /contrib/rom-o-matic/doc/BANNER_TIMEOUT.html: -------------------------------------------------------------------------------- 1 | Tenths of a second for which the shell banner should appear 2 | -------------------------------------------------------------------------------- /contrib/rom-o-matic/doc/COMCONSOLE.html: -------------------------------------------------------------------------------- 1 | Serial Console I/O port address. Common addresses are:
2 | COM1 => 0x3f8, COM2 => 0x2f8, COM3 => 0x3e8, COM4 => 0x2e8 3 | 4 | -------------------------------------------------------------------------------- /contrib/rom-o-matic/doc/COMDATA.html: -------------------------------------------------------------------------------- 1 | Serial Console Data bits 2 | -------------------------------------------------------------------------------- /contrib/rom-o-matic/doc/COMPARITY.html: -------------------------------------------------------------------------------- 1 | Serial Console Parity: 0=None, 1=Odd, 2=Even 2 | -------------------------------------------------------------------------------- /contrib/rom-o-matic/doc/COMPRESERVE.html: -------------------------------------------------------------------------------- 1 | Keep settings from a previous user of the serial port -------------------------------------------------------------------------------- /contrib/rom-o-matic/doc/COMSPEED.html: -------------------------------------------------------------------------------- 1 | Serial Console Baud rate 2 | -------------------------------------------------------------------------------- /contrib/rom-o-matic/doc/COMSTOP.html: -------------------------------------------------------------------------------- 1 | Serial Console Stop bits 2 | -------------------------------------------------------------------------------- /contrib/rom-o-matic/doc/CONFIG_CMD.html: -------------------------------------------------------------------------------- 1 | Option configuration console 2 | -------------------------------------------------------------------------------- /contrib/rom-o-matic/doc/CONSOLE_PC_BIOS.html: -------------------------------------------------------------------------------- 1 | Enable Default BIOS console 2 | -------------------------------------------------------------------------------- /contrib/rom-o-matic/doc/CONSOLE_SERIAL.html: -------------------------------------------------------------------------------- 1 | Enable Serial port console 2 | -------------------------------------------------------------------------------- /contrib/rom-o-matic/doc/CRYPTO_80211_WEP.html: -------------------------------------------------------------------------------- 1 | Wireless WEP encryption support 2 | -------------------------------------------------------------------------------- /contrib/rom-o-matic/doc/CRYPTO_80211_WPA.html: -------------------------------------------------------------------------------- 1 | Wireless WPA encryption support 2 | -------------------------------------------------------------------------------- /contrib/rom-o-matic/doc/CRYPTO_80211_WPA2.html: -------------------------------------------------------------------------------- 1 | Wireless WPA2 encryption support 2 | -------------------------------------------------------------------------------- /contrib/rom-o-matic/doc/DHCP_CMD.html: -------------------------------------------------------------------------------- 1 | DHCP management commands 2 | -------------------------------------------------------------------------------- /contrib/rom-o-matic/doc/DNS_RESOLVER.html: -------------------------------------------------------------------------------- 1 | DNS resolver 2 | -------------------------------------------------------------------------------- /contrib/rom-o-matic/doc/DOWNLOAD_PROTO_FTP.html: -------------------------------------------------------------------------------- 1 | File Transfer Protocol 2 | -------------------------------------------------------------------------------- /contrib/rom-o-matic/doc/DOWNLOAD_PROTO_HTTP.html: -------------------------------------------------------------------------------- 1 | Hypertext Transfer Protocol 2 | -------------------------------------------------------------------------------- /contrib/rom-o-matic/doc/DOWNLOAD_PROTO_TFTP.html: -------------------------------------------------------------------------------- 1 | Trivial File Transfer Protocol 2 | -------------------------------------------------------------------------------- /contrib/rom-o-matic/doc/IFMGMT_CMD.html: -------------------------------------------------------------------------------- 1 | Interface management commands 2 | -------------------------------------------------------------------------------- /contrib/rom-o-matic/doc/IMAGE_BZIMAGE.html: -------------------------------------------------------------------------------- 1 | Linux bzImage image support 2 | -------------------------------------------------------------------------------- /contrib/rom-o-matic/doc/IMAGE_CMD.html: -------------------------------------------------------------------------------- 1 | Image management commands 2 | -------------------------------------------------------------------------------- /contrib/rom-o-matic/doc/IMAGE_ELF.html: -------------------------------------------------------------------------------- 1 | ELF image support 2 | -------------------------------------------------------------------------------- /contrib/rom-o-matic/doc/IMAGE_MULTIBOOT.html: -------------------------------------------------------------------------------- 1 | MultiBoot image support 2 | -------------------------------------------------------------------------------- /contrib/rom-o-matic/doc/IMAGE_NBI.html: -------------------------------------------------------------------------------- 1 | NBI image support 2 | -------------------------------------------------------------------------------- /contrib/rom-o-matic/doc/IMAGE_PXE.html: -------------------------------------------------------------------------------- 1 | PXE image support 2 | -------------------------------------------------------------------------------- /contrib/rom-o-matic/doc/IMAGE_SCRIPT.html: -------------------------------------------------------------------------------- 1 | gPXE script image support 2 | -------------------------------------------------------------------------------- /contrib/rom-o-matic/doc/IWMGMT_CMD.html: -------------------------------------------------------------------------------- 1 | Wireless interface management commands 2 | -------------------------------------------------------------------------------- /contrib/rom-o-matic/doc/NMB_RESOLVER.html: -------------------------------------------------------------------------------- 1 | NMB resolver 2 | -------------------------------------------------------------------------------- /contrib/rom-o-matic/doc/NVO_CMD.html: -------------------------------------------------------------------------------- 1 | Non-volatile option storage commands 2 | -------------------------------------------------------------------------------- /contrib/rom-o-matic/doc/ROUTE_CMD.html: -------------------------------------------------------------------------------- 1 | Routing table management commands 2 | -------------------------------------------------------------------------------- /contrib/rom-o-matic/doc/SANBOOT_CMD.html: -------------------------------------------------------------------------------- 1 | SAN boot commands 2 | -------------------------------------------------------------------------------- /contrib/rom-o-matic/top.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | . 7 | * Copyright (C) 2009 Entity Cyber, Inc. 8 | * 9 | * This program is free software; you can redistribute it and/or 10 | * modify it under the terms of the GNU General Public License as 11 | * published by the Free Software Foundation; either version 2 of the 12 | * License, or any later version. 13 | * 14 | * This program is distributed in the hope that it will be useful, but 15 | * WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 17 | * General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU General Public License 20 | * along with this program; if not, write to the Free Software 21 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 22 | */ 23 | 24 | ?> 25 | 26 | 27 | 28 | "> 29 | 30 | <? echo $header_title ?> 31 | 32 | 33 |

34 |   35 |

36 |
37 |

38 | 39 |

40 | 41 |
42 | -------------------------------------------------------------------------------- /src/.gitignore: -------------------------------------------------------------------------------- 1 | .toolcheck 2 | .echocheck 3 | TAGS* 4 | bin* 5 | -------------------------------------------------------------------------------- /src/arch/i386/Makefile.efi: -------------------------------------------------------------------------------- 1 | # -*- makefile -*- : Force emacs to use Makefile mode 2 | 3 | # Specify EFI image builder 4 | # 5 | ELF2EFI = $(ELF2EFI32) 6 | 7 | # Include generic EFI Makefile 8 | # 9 | MAKEDEPS += arch/x86/Makefile.efi 10 | include arch/x86/Makefile.efi 11 | -------------------------------------------------------------------------------- /src/arch/i386/core/basemem_packet.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2007 Michael Brown . 3 | * 4 | * This program is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU General Public License as 6 | * published by the Free Software Foundation; either version 2 of the 7 | * License, or any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, but 10 | * WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | */ 18 | 19 | FILE_LICENCE ( GPL2_OR_LATER ); 20 | 21 | /** 22 | * @file 23 | * 24 | * Packet buffer in base memory. Used by various components which 25 | * need to pass packets to and from external real-mode code. 26 | * 27 | */ 28 | 29 | #include 30 | 31 | #undef basemem_packet 32 | char __bss16_array ( basemem_packet, [BASEMEM_PACKET_LEN] ); 33 | -------------------------------------------------------------------------------- /src/arch/i386/core/dumpregs.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | void __asmcall _dump_regs ( struct i386_all_regs *ix86 ) { 5 | 6 | __asm__ __volatile__ ( 7 | TEXT16_CODE ( ".globl dump_regs\n\t" 8 | "\ndump_regs:\n\t" 9 | "pushl $_dump_regs\n\t" 10 | "pushw %%cs\n\t" 11 | "call prot_call\n\t" 12 | "addr32 leal 4(%%esp), %%esp\n\t" 13 | "ret\n\t" ) : : ); 14 | 15 | printf ( "EAX=%08x EBX=%08x ECX=%08x EDX=%08x\n" 16 | "ESI=%08x EDI=%08x EBP=%08x ESP=%08x\n" 17 | "CS=%04x SS=%04x DS=%04x ES=%04x FS=%04x GS=%04x\n", 18 | ix86->regs.eax, ix86->regs.ebx, ix86->regs.ecx, 19 | ix86->regs.edx, ix86->regs.esi, ix86->regs.edi, 20 | ix86->regs.ebp, ix86->regs.esp, 21 | ix86->segs.cs, ix86->segs.ss, ix86->segs.ds, 22 | ix86->segs.es, ix86->segs.fs, ix86->segs.gs ); 23 | } 24 | -------------------------------------------------------------------------------- /src/arch/i386/core/patch_cf.S: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009 H. Peter Anvin 3 | * 4 | * This program is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU General Public License 6 | * as published by the Free Software Foundation; either version 2 7 | * of the License, or (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 17 | */ 18 | 19 | FILE_LICENCE ( GPL2_OR_LATER ) 20 | 21 | .text 22 | .arch i386 23 | .code16 24 | 25 | /**************************************************************************** 26 | * Set/clear CF on the stack as appropriate, assumes stack is as it should 27 | * be immediately before IRET 28 | **************************************************************************** 29 | */ 30 | .section ".text16", "ax", @progbits 31 | .globl patch_cf 32 | patch_cf: 33 | pushw %bp 34 | movw %sp, %bp 35 | setc 8(%bp) /* Set/reset CF; clears PF, AF, ZF, SF */ 36 | popw %bp 37 | ret 38 | .size patch_cf, . - patch_cf 39 | -------------------------------------------------------------------------------- /src/arch/i386/core/setjmp.S: -------------------------------------------------------------------------------- 1 | /* setjmp and longjmp. Use of these functions is deprecated. */ 2 | 3 | FILE_LICENCE ( GPL2_OR_LATER ) 4 | 5 | .text 6 | .arch i386 7 | .code32 8 | 9 | /************************************************************************** 10 | SETJMP - Save stack context for non-local goto 11 | **************************************************************************/ 12 | .globl setjmp 13 | setjmp: 14 | movl 4(%esp),%ecx /* jmpbuf */ 15 | movl 0(%esp),%edx /* return address */ 16 | movl %edx,0(%ecx) 17 | movl %ebx,4(%ecx) 18 | movl %esp,8(%ecx) 19 | movl %ebp,12(%ecx) 20 | movl %esi,16(%ecx) 21 | movl %edi,20(%ecx) 22 | movl $0,%eax 23 | ret 24 | 25 | /************************************************************************** 26 | LONGJMP - Non-local jump to a saved stack context 27 | **************************************************************************/ 28 | .globl longjmp 29 | longjmp: 30 | movl 4(%esp),%edx /* jumpbuf */ 31 | movl 8(%esp),%eax /* result */ 32 | movl 0(%edx),%ecx 33 | movl 4(%edx),%ebx 34 | movl 8(%edx),%esp 35 | movl 12(%edx),%ebp 36 | movl 16(%edx),%esi 37 | movl 20(%edx),%edi 38 | cmpl $0,%eax 39 | jne 1f 40 | movl $1,%eax 41 | 1: movl %ecx,0(%esp) 42 | ret 43 | -------------------------------------------------------------------------------- /src/arch/i386/core/stack.S: -------------------------------------------------------------------------------- 1 | FILE_LICENCE ( GPL2_OR_LATER ) 2 | 3 | .arch i386 4 | 5 | /**************************************************************************** 6 | * Internal stack 7 | **************************************************************************** 8 | */ 9 | .section ".stack", "aw", @nobits 10 | .align 8 11 | .globl _stack 12 | _stack: 13 | .space 4096 14 | .globl _estack 15 | _estack: 16 | -------------------------------------------------------------------------------- /src/arch/i386/core/stack16.S: -------------------------------------------------------------------------------- 1 | FILE_LICENCE ( GPL2_OR_LATER ) 2 | 3 | .arch i386 4 | 5 | /**************************************************************************** 6 | * Internal stack 7 | **************************************************************************** 8 | */ 9 | .section ".stack16", "aw", @nobits 10 | .align 8 11 | .globl _stack16 12 | _stack16: 13 | .space 4096 14 | .globl _estack16 15 | _estack16: 16 | -------------------------------------------------------------------------------- /src/arch/i386/drivers/net/undipreload.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2007 Michael Brown . 3 | * 4 | * This program is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU General Public License as 6 | * published by the Free Software Foundation; either version 2 of the 7 | * License, or any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, but 10 | * WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | */ 18 | 19 | FILE_LICENCE ( GPL2_OR_LATER ); 20 | 21 | #include 22 | #include 23 | 24 | /** @file 25 | * 26 | * Preloaded UNDI stack 27 | * 28 | */ 29 | 30 | /** 31 | * Preloaded UNDI device 32 | * 33 | * This is the UNDI device that was present when Etherboot started 34 | * execution (i.e. when loading a .kpxe image). The first driver to 35 | * claim this device must zero out this data structure. 36 | */ 37 | struct undi_device __data16 ( preloaded_undi ); 38 | -------------------------------------------------------------------------------- /src/arch/i386/firmware/pcbios/basemem.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2007 Michael Brown . 3 | * 4 | * This program is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU General Public License as 6 | * published by the Free Software Foundation; either version 2 of the 7 | * License, or any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, but 10 | * WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | */ 18 | 19 | FILE_LICENCE ( GPL2_OR_LATER ); 20 | 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | 27 | /** @file 28 | * 29 | * Base memory allocation 30 | * 31 | */ 32 | 33 | /** 34 | * Set the BIOS free base memory counter 35 | * 36 | * @v new_fbms New free base memory counter (in kB) 37 | */ 38 | void set_fbms ( unsigned int new_fbms ) { 39 | uint16_t fbms = new_fbms; 40 | 41 | /* Update the BIOS memory counter */ 42 | put_real ( fbms, BDA_SEG, BDA_FBMS ); 43 | 44 | /* Update our hidden memory region map */ 45 | hide_basemem(); 46 | } 47 | -------------------------------------------------------------------------------- /src/arch/i386/hci/commands/pxe_cmd.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | FILE_LICENCE ( GPL2_OR_LATER ); 7 | 8 | static int startpxe_payload ( struct net_device *netdev ) { 9 | if ( netdev_is_open ( netdev ) ) 10 | pxe_activate ( netdev ); 11 | return 0; 12 | } 13 | 14 | static int startpxe_exec ( int argc, char **argv ) { 15 | return ifcommon_exec ( argc, argv, startpxe_payload, 16 | "Activate PXE on" ); 17 | } 18 | 19 | static int stoppxe_exec ( int argc __unused, char **argv __unused ) { 20 | pxe_deactivate(); 21 | return 0; 22 | } 23 | 24 | struct command pxe_commands[] __command = { 25 | { 26 | .name = "startpxe", 27 | .exec = startpxe_exec, 28 | }, 29 | { 30 | .name = "stoppxe", 31 | .exec = stoppxe_exec, 32 | }, 33 | }; 34 | -------------------------------------------------------------------------------- /src/arch/i386/include/basemem.h: -------------------------------------------------------------------------------- 1 | #ifndef _BASEMEM_H 2 | #define _BASEMEM_H 3 | 4 | /** @file 5 | * 6 | * Base memory allocation 7 | * 8 | */ 9 | 10 | FILE_LICENCE ( GPL2_OR_LATER ); 11 | 12 | #include 13 | #include 14 | #include 15 | 16 | /** 17 | * Read the BIOS free base memory counter 18 | * 19 | * @ret fbms Free base memory counter (in kB) 20 | */ 21 | static inline unsigned int get_fbms ( void ) { 22 | uint16_t fbms; 23 | 24 | get_real ( fbms, BDA_SEG, BDA_FBMS ); 25 | return fbms; 26 | } 27 | 28 | extern void set_fbms ( unsigned int new_fbms ); 29 | 30 | /* Actually in hidemem.c, but putting it here avoids polluting the 31 | * architecture-independent include/hidemem.h. 32 | */ 33 | extern void hide_basemem ( void ); 34 | 35 | #endif /* _BASEMEM_H */ 36 | -------------------------------------------------------------------------------- /src/arch/i386/include/basemem_packet.h: -------------------------------------------------------------------------------- 1 | #ifndef BASEMEM_PACKET_H 2 | #define BASEMEM_PACKET_H 3 | 4 | FILE_LICENCE ( GPL2_OR_LATER ); 5 | 6 | #include 7 | 8 | /** Maximum length of base memory packet buffer */ 9 | #define BASEMEM_PACKET_LEN 1514 10 | 11 | /** Base memory packet buffer */ 12 | extern char __bss16_array ( basemem_packet, [BASEMEM_PACKET_LEN] ); 13 | #define basemem_packet __use_data16 ( basemem_packet ) 14 | 15 | #endif /* BASEMEM_PACKET_H */ 16 | -------------------------------------------------------------------------------- /src/arch/i386/include/bios.h: -------------------------------------------------------------------------------- 1 | #ifndef BIOS_H 2 | #define BIOS_H 3 | 4 | FILE_LICENCE ( GPL2_OR_LATER ); 5 | 6 | #define BDA_SEG 0x0040 7 | #define BDA_FBMS 0x0013 8 | #define BDA_NUM_DRIVES 0x0075 9 | 10 | #endif /* BIOS_H */ 11 | -------------------------------------------------------------------------------- /src/arch/i386/include/bios_disks.h: -------------------------------------------------------------------------------- 1 | #ifndef BIOS_DISKS_H 2 | #define BIOS_DISKS_H 3 | 4 | #include "dev.h" 5 | 6 | /* 7 | * Constants 8 | * 9 | */ 10 | 11 | #define BIOS_DISK_MAX_NAME_LEN 6 12 | 13 | struct bios_disk_sector { 14 | char data[512]; 15 | }; 16 | 17 | /* 18 | * The location of a BIOS disk 19 | * 20 | */ 21 | struct bios_disk_loc { 22 | uint8_t drive; 23 | }; 24 | 25 | /* 26 | * A physical BIOS disk device 27 | * 28 | */ 29 | struct bios_disk_device { 30 | char name[BIOS_DISK_MAX_NAME_LEN]; 31 | uint8_t drive; 32 | uint8_t type; 33 | }; 34 | 35 | /* 36 | * A BIOS disk driver, with a valid device ID range and naming 37 | * function. 38 | * 39 | */ 40 | struct bios_disk_driver { 41 | void ( *fill_drive_name ) ( char *buf, uint8_t drive ); 42 | uint8_t min_drive; 43 | uint8_t max_drive; 44 | }; 45 | 46 | /* 47 | * Define a BIOS disk driver 48 | * 49 | */ 50 | #define BIOS_DISK_DRIVER( _name, _fill_drive_name, _min_drive, _max_drive ) \ 51 | static struct bios_disk_driver _name = { \ 52 | .fill_drive_name = _fill_drive_name, \ 53 | .min_drive = _min_drive, \ 54 | .max_drive = _max_drive, \ 55 | } 56 | 57 | /* 58 | * Functions in bios_disks.c 59 | * 60 | */ 61 | 62 | 63 | /* 64 | * bios_disk bus global definition 65 | * 66 | */ 67 | extern struct bus_driver bios_disk_driver; 68 | 69 | #endif /* BIOS_DISKS_H */ 70 | -------------------------------------------------------------------------------- /src/arch/i386/include/biosint.h: -------------------------------------------------------------------------------- 1 | #ifndef BIOSINT_H 2 | #define BIOSINT_H 3 | 4 | /** 5 | * @file BIOS interrupts 6 | * 7 | */ 8 | 9 | FILE_LICENCE ( GPL2_OR_LATER ); 10 | 11 | #include 12 | 13 | struct segoff; 14 | 15 | /** 16 | * Hooked interrupt count 17 | * 18 | * At exit, after unhooking all possible interrupts, this counter 19 | * should be examined. If it is non-zero, it means that we failed to 20 | * unhook at least one interrupt vector, and so must not free up the 21 | * memory we are using. (Note that this also implies that we should 22 | * re-hook INT 15 in order to hide ourselves from the memory map). 23 | */ 24 | extern uint16_t __text16 ( hooked_bios_interrupts ); 25 | #define hooked_bios_interrupts __use_text16 ( hooked_bios_interrupts ) 26 | 27 | extern void hook_bios_interrupt ( unsigned int interrupt, unsigned int handler, 28 | struct segoff *chain_vector ); 29 | extern int unhook_bios_interrupt ( unsigned int interrupt, 30 | unsigned int handler, 31 | struct segoff *chain_vector ); 32 | 33 | #endif /* BIOSINT_H */ 34 | -------------------------------------------------------------------------------- /src/arch/i386/include/bits/byteswap.h: -------------------------------------------------------------------------------- 1 | #ifndef ETHERBOOT_BITS_BYTESWAP_H 2 | #define ETHERBOOT_BITS_BYTESWAP_H 3 | 4 | FILE_LICENCE ( GPL2_OR_LATER ); 5 | 6 | static inline __attribute__ ((always_inline, const)) uint16_t 7 | __bswap_variable_16(uint16_t x) 8 | { 9 | __asm__("xchgb %b0,%h0\n\t" 10 | : "=q" (x) 11 | : "0" (x)); 12 | return x; 13 | } 14 | 15 | static inline __attribute__ ((always_inline, const)) uint32_t 16 | __bswap_variable_32(uint32_t x) 17 | { 18 | __asm__("xchgb %b0,%h0\n\t" 19 | "rorl $16,%0\n\t" 20 | "xchgb %b0,%h0" 21 | : "=q" (x) 22 | : "0" (x)); 23 | return x; 24 | } 25 | 26 | static inline __attribute__ ((always_inline, const)) uint64_t 27 | __bswap_variable_64(uint64_t x) 28 | { 29 | union { 30 | uint64_t qword; 31 | uint32_t dword[2]; 32 | } u; 33 | 34 | u.qword = x; 35 | u.dword[0] = __bswap_variable_32(u.dword[0]); 36 | u.dword[1] = __bswap_variable_32(u.dword[1]); 37 | __asm__("xchgl %0,%1" 38 | : "=r" ( u.dword[0] ), "=r" ( u.dword[1] ) 39 | : "0" ( u.dword[0] ), "1" ( u.dword[1] ) ); 40 | return u.qword; 41 | } 42 | 43 | #endif /* ETHERBOOT_BITS_BYTESWAP_H */ 44 | -------------------------------------------------------------------------------- /src/arch/i386/include/bits/compiler.h: -------------------------------------------------------------------------------- 1 | #ifndef _BITS_COMPILER_H 2 | #define _BITS_COMPILER_H 3 | 4 | FILE_LICENCE ( GPL2_OR_LATER ); 5 | 6 | #ifndef ASSEMBLY 7 | 8 | /** Declare a function with standard calling conventions */ 9 | #define __asmcall __attribute__ (( cdecl, regparm(0) )) 10 | 11 | /** 12 | * Declare a function with libgcc implicit linkage 13 | * 14 | * It seems as though gcc expects its implicit arithmetic functions to 15 | * be cdecl, even if -mrtd is specified. This is somewhat 16 | * inconsistent; for example, if -mregparm=3 is used then the implicit 17 | * functions do become regparm(3). 18 | * 19 | * The implicit calls to memcpy() and memset() which gcc can generate 20 | * do not seem to have this inconsistency; -mregparm and -mrtd affect 21 | * them in the same way as any other function. 22 | */ 23 | #define __libgcc __attribute__ (( cdecl )) 24 | 25 | #endif /* ASSEMBLY */ 26 | 27 | #endif /* _BITS_COMPILER_H */ 28 | -------------------------------------------------------------------------------- /src/arch/i386/include/bits/eltorito.h: -------------------------------------------------------------------------------- 1 | #ifndef ELTORITO_PLATFORM 2 | #define ELTORITO_PLATFORM ELTORITO_PLATFORM_X86 3 | #endif /* ELTORITO_PLATFORM */ 4 | -------------------------------------------------------------------------------- /src/arch/i386/include/bits/endian.h: -------------------------------------------------------------------------------- 1 | #ifndef ETHERBOOT_BITS_ENDIAN_H 2 | #define ETHERBOOT_BITS_ENDIAN_H 3 | 4 | FILE_LICENCE ( GPL2_OR_LATER ); 5 | 6 | #define __BYTE_ORDER __LITTLE_ENDIAN 7 | 8 | #endif /* ETHERBOOT_BITS_ENDIAN_H */ 9 | -------------------------------------------------------------------------------- /src/arch/i386/include/bits/io.h: -------------------------------------------------------------------------------- 1 | #ifndef _BITS_IO_H 2 | #define _BITS_IO_H 3 | 4 | /** @file 5 | * 6 | * i386-specific I/O API implementations 7 | * 8 | */ 9 | 10 | FILE_LICENCE ( GPL2_OR_LATER ); 11 | 12 | #include 13 | 14 | #endif /* _BITS_IO_H */ 15 | -------------------------------------------------------------------------------- /src/arch/i386/include/bits/nap.h: -------------------------------------------------------------------------------- 1 | #ifndef _BITS_NAP_H 2 | #define _BITS_NAP_H 3 | 4 | /** @file 5 | * 6 | * i386-specific CPU sleeping API implementations 7 | * 8 | */ 9 | 10 | FILE_LICENCE ( GPL2_OR_LATER ); 11 | 12 | #include 13 | #include 14 | 15 | #endif /* _BITS_MAP_H */ 16 | -------------------------------------------------------------------------------- /src/arch/i386/include/bits/smbios.h: -------------------------------------------------------------------------------- 1 | #ifndef _BITS_SMBIOS_H 2 | #define _BITS_SMBIOS_H 3 | 4 | /** @file 5 | * 6 | * i386-specific SMBIOS API implementations 7 | * 8 | */ 9 | 10 | FILE_LICENCE ( GPL2_OR_LATER ); 11 | 12 | #include 13 | 14 | #endif /* _BITS_SMBIOS_H */ 15 | -------------------------------------------------------------------------------- /src/arch/i386/include/bits/stdint.h: -------------------------------------------------------------------------------- 1 | #ifndef _BITS_STDINT_H 2 | #define _BITS_STDINT_H 3 | 4 | FILE_LICENCE ( GPL2_OR_LATER ); 5 | 6 | typedef __SIZE_TYPE__ size_t; 7 | typedef signed long ssize_t; 8 | typedef signed long off_t; 9 | 10 | typedef unsigned char uint8_t; 11 | typedef unsigned short uint16_t; 12 | typedef unsigned int uint32_t; 13 | typedef unsigned long long uint64_t; 14 | 15 | typedef signed char int8_t; 16 | typedef signed short int16_t; 17 | typedef signed int int32_t; 18 | typedef signed long long int64_t; 19 | 20 | typedef unsigned long physaddr_t; 21 | typedef unsigned long intptr_t; 22 | 23 | #endif /* _BITS_STDINT_H */ 24 | -------------------------------------------------------------------------------- /src/arch/i386/include/bits/timer.h: -------------------------------------------------------------------------------- 1 | #ifndef _BITS_TIMER_H 2 | #define _BITS_TIMER_H 3 | 4 | /** @file 5 | * 6 | * i386-specific timer API implementations 7 | * 8 | */ 9 | 10 | FILE_LICENCE ( GPL2_OR_LATER ); 11 | 12 | #include 13 | #include 14 | 15 | #endif /* _BITS_TIMER_H */ 16 | -------------------------------------------------------------------------------- /src/arch/i386/include/bits/uaccess.h: -------------------------------------------------------------------------------- 1 | #ifndef _BITS_UACCESS_H 2 | #define _BITS_UACCESS_H 3 | 4 | /** @file 5 | * 6 | * i386-specific user access API implementations 7 | * 8 | */ 9 | 10 | FILE_LICENCE ( GPL2_OR_LATER ); 11 | 12 | #include 13 | 14 | #endif /* _BITS_UACCESS_H */ 15 | -------------------------------------------------------------------------------- /src/arch/i386/include/bits/umalloc.h: -------------------------------------------------------------------------------- 1 | #ifndef _BITS_UMALLOC_H 2 | #define _BITS_UMALLOC_H 3 | 4 | /** @file 5 | * 6 | * i386-specific user memory allocation API implementations 7 | * 8 | */ 9 | 10 | FILE_LICENCE ( GPL2_OR_LATER ); 11 | 12 | #include 13 | 14 | #endif /* _BITS_UMALLOC_H */ 15 | -------------------------------------------------------------------------------- /src/arch/i386/include/bochs.h: -------------------------------------------------------------------------------- 1 | #ifndef BOCHS_H 2 | #define BOCHS_H 3 | 4 | /** @file 5 | * 6 | * bochs breakpoints 7 | * 8 | * This file defines @c bochsbp, the magic breakpoint instruction that 9 | * is incredibly useful when debugging under bochs. This file should 10 | * never be included in production code. 11 | * 12 | * Use the pseudo-instruction @c bochsbp in assembly code, or the 13 | * bochsbp() function in C code. 14 | * 15 | */ 16 | 17 | #ifdef ASSEMBLY 18 | 19 | /* Breakpoint for when debugging under bochs */ 20 | #define bochsbp xchgw %bx, %bx 21 | #define BOCHSBP bochsbp 22 | 23 | #else /* ASSEMBLY */ 24 | 25 | /** Breakpoint for when debugging under bochs */ 26 | static inline void bochsbp ( void ) { 27 | __asm__ __volatile__ ( "xchgw %bx, %bx" ); 28 | } 29 | 30 | #endif /* ASSEMBLY */ 31 | 32 | #warning "bochs.h should not be included into production code" 33 | 34 | #endif /* BOCHS_H */ 35 | -------------------------------------------------------------------------------- /src/arch/i386/include/bootsector.h: -------------------------------------------------------------------------------- 1 | #ifndef _BOOTSECTOR_H 2 | #define _BOOTSECTOR_H 3 | 4 | /** @file 5 | * 6 | * x86 bootsector image format 7 | */ 8 | 9 | FILE_LICENCE ( GPL2_OR_LATER ); 10 | 11 | extern int call_bootsector ( unsigned int segment, unsigned int offset, 12 | unsigned int drive ); 13 | 14 | #endif /* _BOOTSECTOR_H */ 15 | -------------------------------------------------------------------------------- /src/arch/i386/include/efi/gpxe/dhcp_arch.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010 VMware, Inc. All Rights Reserved. 3 | * 4 | * This program is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU General Public License as 6 | * published by the Free Software Foundation; either version 2 of the 7 | * License, or any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, but 10 | * WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 17 | */ 18 | 19 | #ifndef _DHCP_ARCH_H 20 | #define _DHCP_ARCH_H 21 | 22 | /** @file 23 | * 24 | * Architecture-specific DHCP options 25 | */ 26 | 27 | FILE_LICENCE ( GPL2_OR_LATER ); 28 | 29 | #include 30 | 31 | #define DHCP_ARCH_VENDOR_CLASS_ID \ 32 | DHCP_STRING ( 'P', 'X', 'E', 'C', 'l', 'i', 'e', 'n', 't', ':', \ 33 | 'A', 'r', 'c', 'h', ':', '0', '0', '0', '0', '6', ':', \ 34 | 'U', 'N', 'D', 'I', ':', '0', '0', '3', '0', '1', '0' ) 35 | 36 | #define DHCP_ARCH_CLIENT_ARCHITECTURE DHCP_WORD ( 6 ) 37 | 38 | #define DHCP_ARCH_CLIENT_NDI DHCP_OPTION ( 1 /* UNDI */ , 3, 10 /* v3.10 */ ) 39 | 40 | #endif 41 | -------------------------------------------------------------------------------- /src/arch/i386/include/fakee820.h: -------------------------------------------------------------------------------- 1 | #ifndef _FAKEE820_H 2 | #define _FAKEE820_H 3 | 4 | FILE_LICENCE ( GPL2_OR_LATER ); 5 | 6 | extern void fake_e820 ( void ); 7 | extern void unfake_e820 ( void ); 8 | 9 | #endif /* _FAKEE820_H */ 10 | -------------------------------------------------------------------------------- /src/arch/i386/include/gdbmach.h: -------------------------------------------------------------------------------- 1 | #ifndef GDBMACH_H 2 | #define GDBMACH_H 3 | 4 | /** @file 5 | * 6 | * GDB architecture specifics 7 | * 8 | * This file declares functions for manipulating the machine state and 9 | * debugging context. 10 | * 11 | */ 12 | 13 | #include 14 | 15 | typedef unsigned long gdbreg_t; 16 | 17 | /* The register snapshot, this must be in sync with interrupt handler and the 18 | * GDB protocol. */ 19 | enum { 20 | GDBMACH_EAX, 21 | GDBMACH_ECX, 22 | GDBMACH_EDX, 23 | GDBMACH_EBX, 24 | GDBMACH_ESP, 25 | GDBMACH_EBP, 26 | GDBMACH_ESI, 27 | GDBMACH_EDI, 28 | GDBMACH_EIP, 29 | GDBMACH_EFLAGS, 30 | GDBMACH_CS, 31 | GDBMACH_SS, 32 | GDBMACH_DS, 33 | GDBMACH_ES, 34 | GDBMACH_FS, 35 | GDBMACH_GS, 36 | GDBMACH_NREGS, 37 | GDBMACH_SIZEOF_REGS = GDBMACH_NREGS * sizeof ( gdbreg_t ) 38 | }; 39 | 40 | /* Breakpoint types */ 41 | enum { 42 | GDBMACH_BPMEM, 43 | GDBMACH_BPHW, 44 | GDBMACH_WATCH, 45 | GDBMACH_RWATCH, 46 | GDBMACH_AWATCH, 47 | }; 48 | 49 | static inline void gdbmach_set_pc ( gdbreg_t *regs, gdbreg_t pc ) { 50 | regs [ GDBMACH_EIP ] = pc; 51 | } 52 | 53 | static inline void gdbmach_set_single_step ( gdbreg_t *regs, int step ) { 54 | regs [ GDBMACH_EFLAGS ] &= ~( 1 << 8 ); /* Trace Flag (TF) */ 55 | regs [ GDBMACH_EFLAGS ] |= ( step << 8 ); 56 | } 57 | 58 | static inline void gdbmach_breakpoint ( void ) { 59 | __asm__ __volatile__ ( "int $3\n" ); 60 | } 61 | 62 | extern int gdbmach_set_breakpoint ( int type, unsigned long addr, size_t len, int enable ); 63 | 64 | #endif /* GDBMACH_H */ 65 | -------------------------------------------------------------------------------- /src/arch/i386/include/gpxe/abft.h: -------------------------------------------------------------------------------- 1 | #ifndef _GPXE_ABFT_H 2 | #define _GPXE_ABFT_H 3 | 4 | /** @file 5 | * 6 | * AoE boot firmware table 7 | * 8 | */ 9 | 10 | FILE_LICENCE ( GPL2_OR_LATER ); 11 | 12 | #include 13 | #include 14 | #include 15 | 16 | /** AoE boot firmware table signature */ 17 | #define ABFT_SIG "aBFT" 18 | 19 | /** 20 | * AoE Boot Firmware Table (aBFT) 21 | */ 22 | struct abft_table { 23 | /** ACPI header */ 24 | struct acpi_description_header acpi; 25 | /** AoE shelf */ 26 | uint16_t shelf; 27 | /** AoE slot */ 28 | uint8_t slot; 29 | /** Reserved */ 30 | uint8_t reserved_a; 31 | /** MAC address */ 32 | uint8_t mac[ETH_ALEN]; 33 | } __attribute__ (( packed )); 34 | 35 | extern void abft_fill_data ( struct aoe_session *aoe ); 36 | 37 | #endif /* _GPXE_ABFT_H */ 38 | -------------------------------------------------------------------------------- /src/arch/i386/include/gpxe/bios_nap.h: -------------------------------------------------------------------------------- 1 | #ifndef _GPXE_BIOS_NAP_H 2 | #define _GPXE_BIOS_NAP_H 3 | 4 | /** @file 5 | * 6 | * BIOS CPU sleeping 7 | * 8 | */ 9 | 10 | FILE_LICENCE ( GPL2_OR_LATER ); 11 | 12 | #ifdef NAP_PCBIOS 13 | #define NAP_PREFIX_pcbios 14 | #else 15 | #define NAP_PREFIX_pcbios __pcbios_ 16 | #endif 17 | 18 | #endif /* _GPXE_BIOS_NAP_H */ 19 | -------------------------------------------------------------------------------- /src/arch/i386/include/gpxe/bios_smbios.h: -------------------------------------------------------------------------------- 1 | #ifndef _GPXE_BIOS_SMBIOS_H 2 | #define _GPXE_BIOS_SMBIOS_H 3 | 4 | /** @file 5 | * 6 | * Standard PC-BIOS SMBIOS interface 7 | * 8 | */ 9 | 10 | FILE_LICENCE ( GPL2_OR_LATER ); 11 | 12 | #ifdef SMBIOS_PCBIOS 13 | #define SMBIOS_PREFIX_pcbios 14 | #else 15 | #define SMBIOS_PREFIX_pcbios __pcbios_ 16 | #endif 17 | 18 | #endif /* _GPXE_BIOS_SMBIOS_H */ 19 | -------------------------------------------------------------------------------- /src/arch/i386/include/gpxe/bios_timer.h: -------------------------------------------------------------------------------- 1 | #ifndef _GPXE_BIOS_TIMER_H 2 | #define _GPXE_BIOS_TIMER_H 3 | 4 | /** @file 5 | * 6 | * BIOS timer 7 | * 8 | */ 9 | 10 | FILE_LICENCE ( GPL2_OR_LATER ); 11 | 12 | #ifdef TIMER_PCBIOS 13 | #define TIMER_PREFIX_pcbios 14 | #else 15 | #define TIMER_PREFIX_pcbios __pcbios_ 16 | #endif 17 | 18 | #include 19 | 20 | /** 21 | * Delay for a fixed number of microseconds 22 | * 23 | * @v usecs Number of microseconds for which to delay 24 | */ 25 | static inline __always_inline void 26 | TIMER_INLINE ( pcbios, udelay ) ( unsigned long usecs ) { 27 | /* BIOS timer is not high-resolution enough for udelay(), so 28 | * we use timer2 29 | */ 30 | timer2_udelay ( usecs ); 31 | } 32 | 33 | /** 34 | * Get number of ticks per second 35 | * 36 | * @ret ticks_per_sec Number of ticks per second 37 | */ 38 | static inline __always_inline unsigned long 39 | TIMER_INLINE ( pcbios, ticks_per_sec ) ( void ) { 40 | /* BIOS timer ticks over at 18.2 ticks per second */ 41 | return 18; 42 | } 43 | 44 | #endif /* _GPXE_BIOS_TIMER_H */ 45 | -------------------------------------------------------------------------------- /src/arch/i386/include/gpxe/memtop_umalloc.h: -------------------------------------------------------------------------------- 1 | #ifndef _GPXE_MEMTOP_UMALLOC_H 2 | #define _GPXE_MEMTOP_UMALLOC_H 3 | 4 | /** @file 5 | * 6 | * External memory allocation 7 | * 8 | */ 9 | 10 | FILE_LICENCE ( GPL2_OR_LATER ); 11 | 12 | #ifdef UMALLOC_MEMTOP 13 | #define UMALLOC_PREFIX_memtop 14 | #else 15 | #define UMALLOC_PREFIX_memtop __memtop_ 16 | #endif 17 | 18 | #endif /* _GPXE_MEMTOP_UMALLOC_H */ 19 | -------------------------------------------------------------------------------- /src/arch/i386/include/gpxe/rdtsc_timer.h: -------------------------------------------------------------------------------- 1 | #ifndef _GPXE_RDTSC_TIMER_H 2 | #define _GPXE_RDTSC_TIMER_H 3 | 4 | /** @file 5 | * 6 | * RDTSC timer 7 | * 8 | */ 9 | 10 | FILE_LICENCE ( GPL2_OR_LATER ); 11 | 12 | #ifdef TIMER_RDTSC 13 | #define TIMER_PREFIX_rdtsc 14 | #else 15 | #define TIMER_PREFIX_rdtsc __rdtsc_ 16 | #endif 17 | 18 | /** 19 | * RDTSC values can easily overflow an unsigned long. We discard the 20 | * low-order bits in order to obtain sensibly-scaled values. 21 | */ 22 | #define TSC_SHIFT 8 23 | 24 | /** 25 | * Get current system time in ticks 26 | * 27 | * @ret ticks Current time, in ticks 28 | */ 29 | static inline __always_inline unsigned long 30 | TIMER_INLINE ( rdtsc, currticks ) ( void ) { 31 | unsigned long ticks; 32 | 33 | __asm__ __volatile__ ( "rdtsc\n\t" 34 | "shrdl %1, %%edx, %%eax\n\t" 35 | : "=a" ( ticks ) : "i" ( TSC_SHIFT ) : "edx" ); 36 | return ticks; 37 | } 38 | 39 | #endif /* _GPXE_RDTSC_TIMER_H */ 40 | -------------------------------------------------------------------------------- /src/arch/i386/include/gpxe/timer2.h: -------------------------------------------------------------------------------- 1 | #ifndef _GPXE_TIMER2_H 2 | #define _GPXE_TIMER2_H 3 | 4 | /** @file 5 | * 6 | * Timer chip control 7 | * 8 | */ 9 | 10 | FILE_LICENCE ( GPL2_OR_LATER ); 11 | 12 | extern void timer2_udelay ( unsigned long usecs ); 13 | 14 | #endif /* _GPXE_TIMER2_H */ 15 | -------------------------------------------------------------------------------- /src/arch/i386/include/kir.h: -------------------------------------------------------------------------------- 1 | #ifndef KIR_H 2 | #define KIR_H 3 | 4 | #ifndef KEEP_IT_REAL 5 | #error "kir.h can be used only with -DKEEP_IT_REAL" 6 | #endif 7 | 8 | #ifdef ASSEMBLY 9 | 10 | #define code32 code16gcc 11 | 12 | #else /* ASSEMBLY */ 13 | 14 | __asm__ ( ".code16gcc" ); 15 | 16 | #endif /* ASSEMBLY */ 17 | 18 | #endif /* KIR_H */ 19 | -------------------------------------------------------------------------------- /src/arch/i386/include/memsizes.h: -------------------------------------------------------------------------------- 1 | #ifndef _MEMSIZES_H 2 | #define _MEMSIZES_H 3 | 4 | FILE_LICENCE ( GPL2_OR_LATER ); 5 | 6 | #include 7 | 8 | /** 9 | * Get size of base memory from BIOS free base memory counter 10 | * 11 | * @ret basemem Base memory size, in kB 12 | */ 13 | static inline unsigned int basememsize ( void ) { 14 | return get_fbms(); 15 | } 16 | 17 | extern unsigned int extmemsize ( void ); 18 | 19 | #endif /* _MEMSIZES_H */ 20 | -------------------------------------------------------------------------------- /src/arch/i386/include/pcbios/gpxe/dhcp_arch.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010 VMware, Inc. All Rights Reserved. 3 | * 4 | * This program is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU General Public License as 6 | * published by the Free Software Foundation; either version 2 of the 7 | * License, or any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, but 10 | * WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 17 | */ 18 | 19 | #ifndef _DHCP_ARCH_H 20 | #define _DHCP_ARCH_H 21 | 22 | /** @file 23 | * 24 | * Architecture-specific DHCP options 25 | */ 26 | 27 | FILE_LICENCE ( GPL2_OR_LATER ); 28 | 29 | #include 30 | 31 | #define DHCP_ARCH_VENDOR_CLASS_ID \ 32 | DHCP_STRING ( 'P', 'X', 'E', 'C', 'l', 'i', 'e', 'n', 't', ':', \ 33 | 'A', 'r', 'c', 'h', ':', '0', '0', '0', '0', '0', ':', \ 34 | 'U', 'N', 'D', 'I', ':', '0', '0', '2', '0', '0', '1' ) 35 | 36 | #define DHCP_ARCH_CLIENT_ARCHITECTURE DHCP_WORD ( 0 ) 37 | 38 | #define DHCP_ARCH_CLIENT_NDI DHCP_OPTION ( 1 /* UNDI */ , 2, 1 /* v2.1 */ ) 39 | 40 | #endif 41 | -------------------------------------------------------------------------------- /src/arch/i386/include/pnpbios.h: -------------------------------------------------------------------------------- 1 | #ifndef _PNPBIOS_H 2 | #define _PNPBIOS_H 3 | 4 | /** @file 5 | * 6 | * PnP BIOS 7 | * 8 | */ 9 | 10 | FILE_LICENCE ( GPL2_OR_LATER ); 11 | 12 | /* BIOS segment address */ 13 | #define BIOS_SEG 0xf000 14 | 15 | extern int find_pnp_bios ( void ); 16 | 17 | #endif /* _PNPBIOS_H */ 18 | -------------------------------------------------------------------------------- /src/arch/i386/include/pxe_call.h: -------------------------------------------------------------------------------- 1 | #ifndef _PXE_CALL_H 2 | #define _PXE_CALL_H 3 | 4 | /** @file 5 | * 6 | * PXE API entry point 7 | */ 8 | 9 | FILE_LICENCE ( GPL2_OR_LATER ); 10 | 11 | #include 12 | #include 13 | #include 14 | 15 | struct net_device; 16 | 17 | /** PXE load address segment */ 18 | #define PXE_LOAD_SEGMENT 0 19 | 20 | /** PXE load address offset */ 21 | #define PXE_LOAD_OFFSET 0x7c00 22 | 23 | /** PXE physical load address */ 24 | #define PXE_LOAD_PHYS ( ( PXE_LOAD_SEGMENT << 4 ) + PXE_LOAD_OFFSET ) 25 | 26 | /** !PXE structure */ 27 | extern struct s_PXE __text16 ( ppxe ); 28 | #define ppxe __use_text16 ( ppxe ) 29 | 30 | /** PXENV+ structure */ 31 | extern struct s_PXENV __text16 ( pxenv ); 32 | #define pxenv __use_text16 ( pxenv ) 33 | 34 | /** PXENV_RESTART_TFTP jump buffer */ 35 | extern rmjmp_buf pxe_restart_nbp; 36 | 37 | extern void pxe_activate ( struct net_device *netdev ); 38 | extern int pxe_deactivate ( void ); 39 | extern int pxe_start_nbp ( void ); 40 | extern __asmcall void pxe_api_call ( struct i386_all_regs *ix86 ); 41 | extern int pxe_api_call_weak ( struct i386_all_regs *ix86 ); 42 | 43 | #endif /* _PXE_CALL_H */ 44 | -------------------------------------------------------------------------------- /src/arch/i386/include/pxeparent.h: -------------------------------------------------------------------------------- 1 | #ifndef PXEPARENT_H 2 | #define PXEPARENT_H 3 | 4 | FILE_LICENCE ( GPL2_OR_LATER ); 5 | 6 | #include 7 | 8 | extern int pxeparent_call ( SEGOFF16_t entry, unsigned int function, 9 | void *params, size_t params_len ); 10 | 11 | #endif 12 | -------------------------------------------------------------------------------- /src/arch/i386/include/setjmp.h: -------------------------------------------------------------------------------- 1 | #ifndef ETHERBOOT_SETJMP_H 2 | #define ETHERBOOT_SETJMP_H 3 | 4 | FILE_LICENCE ( GPL2_OR_LATER ); 5 | 6 | #include 7 | #include 8 | 9 | /** A jump buffer */ 10 | typedef struct { 11 | uint32_t retaddr; 12 | uint32_t ebx; 13 | uint32_t esp; 14 | uint32_t ebp; 15 | uint32_t esi; 16 | uint32_t edi; 17 | } jmp_buf[1]; 18 | 19 | /** A real-mode-extended jump buffer */ 20 | typedef struct { 21 | jmp_buf env; 22 | uint16_t rm_ss; 23 | uint16_t rm_sp; 24 | } rmjmp_buf[1]; 25 | 26 | extern int __asmcall setjmp ( jmp_buf env ); 27 | extern void __asmcall longjmp ( jmp_buf env, int val ); 28 | 29 | #define rmsetjmp( _env ) ( { \ 30 | (_env)->rm_ss = rm_ss; \ 31 | (_env)->rm_sp = rm_sp; \ 32 | setjmp ( (_env)->env ); } ) \ 33 | 34 | #define rmlongjmp( _env, _val ) do { \ 35 | rm_ss = (_env)->rm_ss; \ 36 | rm_sp = (_env)->rm_sp; \ 37 | longjmp ( (_env)->env, (_val) ); \ 38 | } while ( 0 ) 39 | 40 | #endif /* ETHERBOOT_SETJMP_H */ 41 | -------------------------------------------------------------------------------- /src/arch/i386/include/undiload.h: -------------------------------------------------------------------------------- 1 | #ifndef _UNDILOAD_H 2 | #define _UNDILOAD_H 3 | 4 | /** @file 5 | * 6 | * UNDI load/unload 7 | * 8 | */ 9 | 10 | FILE_LICENCE ( GPL2_OR_LATER ); 11 | 12 | struct undi_device; 13 | struct undi_rom; 14 | 15 | extern int undi_load ( struct undi_device *undi, struct undi_rom *undirom ); 16 | extern int undi_unload ( struct undi_device *undi ); 17 | 18 | /** 19 | * Call UNDI loader to create a pixie 20 | * 21 | * @v undi UNDI device 22 | * @v undirom UNDI ROM 23 | * @v pci_busdevfn PCI bus:dev.fn 24 | * @ret rc Return status code 25 | */ 26 | static inline int undi_load_pci ( struct undi_device *undi, 27 | struct undi_rom *undirom, 28 | unsigned int pci_busdevfn ) { 29 | undi->pci_busdevfn = pci_busdevfn; 30 | undi->isapnp_csn = UNDI_NO_ISAPNP_CSN; 31 | undi->isapnp_read_port = UNDI_NO_ISAPNP_READ_PORT; 32 | return undi_load ( undi, undirom ); 33 | } 34 | 35 | #endif /* _UNDILOAD_H */ 36 | -------------------------------------------------------------------------------- /src/arch/i386/include/undinet.h: -------------------------------------------------------------------------------- 1 | #ifndef _UNDINET_H 2 | #define _UNDINET_H 3 | 4 | /** @file 5 | * 6 | * UNDI network device driver 7 | * 8 | */ 9 | 10 | FILE_LICENCE ( GPL2_OR_LATER ); 11 | 12 | struct undi_device; 13 | 14 | extern int undinet_probe ( struct undi_device *undi ); 15 | extern void undinet_remove ( struct undi_device *undi ); 16 | 17 | #endif /* _UNDINET_H */ 18 | -------------------------------------------------------------------------------- /src/arch/i386/include/undipreload.h: -------------------------------------------------------------------------------- 1 | #ifndef _UNDIPRELOAD_H 2 | #define _UNDIPRELOAD_H 3 | 4 | /** @file 5 | * 6 | * Preloaded UNDI stack 7 | * 8 | */ 9 | 10 | FILE_LICENCE ( GPL2_OR_LATER ); 11 | 12 | #include 13 | #include 14 | 15 | extern struct undi_device __data16 ( preloaded_undi ); 16 | #define preloaded_undi __use_data16 ( preloaded_undi ) 17 | 18 | #endif /* _UNDIPRELOAD_H */ 19 | -------------------------------------------------------------------------------- /src/arch/i386/include/undirom.h: -------------------------------------------------------------------------------- 1 | #ifndef _UNDIROM_H 2 | #define _UNDIROM_H 3 | 4 | /** @file 5 | * 6 | * UNDI expansion ROMs 7 | * 8 | */ 9 | 10 | FILE_LICENCE ( GPL2_OR_LATER ); 11 | 12 | #include 13 | 14 | /** An UNDI PCI device ID */ 15 | struct undi_pci_device_id { 16 | /** PCI vendor ID */ 17 | unsigned int vendor_id; 18 | /** PCI device ID */ 19 | unsigned int device_id; 20 | }; 21 | 22 | /** An UNDI device ID */ 23 | union undi_device_id { 24 | /** PCI device ID */ 25 | struct undi_pci_device_id pci; 26 | }; 27 | 28 | /** An UNDI ROM */ 29 | struct undi_rom { 30 | /** List of UNDI ROMs */ 31 | struct list_head list; 32 | /** ROM segment address */ 33 | unsigned int rom_segment; 34 | /** UNDI loader entry point */ 35 | SEGOFF16_t loader_entry; 36 | /** Code segment size */ 37 | size_t code_size; 38 | /** Data segment size */ 39 | size_t data_size; 40 | /** Bus type 41 | * 42 | * Values are as used by @c PXENV_UNDI_GET_NIC_TYPE 43 | */ 44 | unsigned int bus_type; 45 | /** Device ID */ 46 | union undi_device_id bus_id; 47 | }; 48 | 49 | extern struct undi_rom * undirom_find_pci ( unsigned int vendor_id, 50 | unsigned int device_id, 51 | unsigned int rombase ); 52 | 53 | #endif /* _UNDIROM_H */ 54 | -------------------------------------------------------------------------------- /src/arch/i386/interface/pcbios/bios_nap.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | FILE_LICENCE ( GPL2_OR_LATER ); 5 | 6 | /** 7 | * Save power by halting the CPU until the next interrupt 8 | * 9 | */ 10 | static void bios_cpu_nap ( void ) { 11 | __asm__ __volatile__ ( REAL_CODE ( "sti\n\t" 12 | "hlt\n\t" 13 | "cli\n\t" ) : : ); 14 | } 15 | 16 | PROVIDE_NAP ( pcbios, cpu_nap, bios_cpu_nap ); 17 | -------------------------------------------------------------------------------- /src/arch/i386/interface/pcbios/keepsan.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | struct setting keep_san_setting __setting = { 10 | .name = "keep-san", 11 | .description = "Preserve SAN connection", 12 | .tag = DHCP_EB_KEEP_SAN, 13 | .type = &setting_type_int8, 14 | }; 15 | 16 | int keep_san ( void ) { 17 | int keep_san; 18 | 19 | keep_san = fetch_intz_setting ( NULL, &keep_san_setting ); 20 | if ( ! keep_san ) 21 | return 0; 22 | 23 | printf ( "Preserving connection to SAN disk\n" ); 24 | shutdown_exit_flags |= SHUTDOWN_KEEP_DEVICES; 25 | return 1; 26 | } 27 | -------------------------------------------------------------------------------- /src/arch/i386/interface/syslinux/comboot_resolv.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | FILE_LICENCE ( GPL2_OR_LATER ); 9 | 10 | static int comboot_resolv_rc; 11 | static struct in_addr comboot_resolv_addr; 12 | 13 | static void comboot_resolv_done ( struct resolv_interface *resolv, 14 | struct sockaddr *sa, int rc ) { 15 | struct sockaddr_in *sin; 16 | 17 | resolv_unplug ( resolv ); 18 | 19 | if ( rc != 0 ) { 20 | comboot_resolv_rc = rc; 21 | return; 22 | } 23 | 24 | if ( sa->sa_family != AF_INET ) { 25 | comboot_resolv_rc = -EAFNOSUPPORT; 26 | return; 27 | } 28 | 29 | sin = ( ( struct sockaddr_in * ) sa ); 30 | comboot_resolv_addr = sin->sin_addr; 31 | 32 | comboot_resolv_rc = 0; 33 | } 34 | 35 | static struct resolv_interface_operations comboot_resolv_ops = { 36 | .done = comboot_resolv_done, 37 | }; 38 | 39 | static struct resolv_interface comboot_resolver = { 40 | .intf = { 41 | .dest = &null_resolv.intf, 42 | .refcnt = NULL, 43 | }, 44 | .op = &comboot_resolv_ops, 45 | }; 46 | 47 | int comboot_resolv ( const char *name, struct in_addr *address ) { 48 | int rc; 49 | 50 | comboot_resolv_rc = -EINPROGRESS; 51 | 52 | if ( ( rc = resolv ( &comboot_resolver, name, NULL ) ) != 0 ) 53 | return rc; 54 | 55 | while ( comboot_resolv_rc == -EINPROGRESS ) 56 | step(); 57 | 58 | *address = comboot_resolv_addr; 59 | return comboot_resolv_rc; 60 | } 61 | -------------------------------------------------------------------------------- /src/arch/i386/kir-Makefile: -------------------------------------------------------------------------------- 1 | # Makefile to build a KEEP_IT_REAL flavour 2 | # 3 | # KEEP_IT_REAL, by its nature, requires a different build of every 4 | # single object file, since the inclusion of ".code16gcc" will 5 | # generate different machine code from the assembly. Unlike the other 6 | # config options, there is no way that this global dependency can ever 7 | # be reduced, so it makes sense to be able to build both the normal 8 | # and the KIR versions without having to force a full rebuild each 9 | # time. 10 | 11 | # Add this Makefile to MAKEDEPS 12 | # 13 | MAKEDEPS += arch/i386/kir-Makefile 14 | 15 | # Place binaries in bin-kir 16 | # 17 | BIN = bin-kir 18 | 19 | # Compile with -DKEEP_IT_REAL, forcibly include kir.h at the start of 20 | # each file to drag in ".code16gcc" 21 | # 22 | CFLAGS += -DKEEP_IT_REAL -include kir.h 23 | 24 | include Makefile 25 | 26 | LDSCRIPT = arch/i386/scripts/i386-kir.lds 27 | -------------------------------------------------------------------------------- /src/arch/i386/prefix/kkpxeprefix.S: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * PXE prefix that keeps the whole PXE stack present 3 | ***************************************************************************** 4 | */ 5 | 6 | FILE_LICENCE ( GPL2_OR_LATER ) 7 | 8 | /* Since we have the whole stack, we can use cached DHCP information */ 9 | REQUEST_OBJECT ( pxeparent_dhcp ) 10 | 11 | #define PXELOADER_KEEP_UNDI 12 | #define PXELOADER_KEEP_PXE 13 | #include "pxeprefix.S" 14 | -------------------------------------------------------------------------------- /src/arch/i386/prefix/kpxeprefix.S: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * PXE prefix that keep the UNDI portion of the PXE stack present 3 | ***************************************************************************** 4 | */ 5 | 6 | FILE_LICENCE ( GPL2_OR_LATER ) 7 | 8 | #define PXELOADER_KEEP_UNDI 9 | #include "pxeprefix.S" 10 | -------------------------------------------------------------------------------- /src/arch/i386/prefix/mbr.S: -------------------------------------------------------------------------------- 1 | .text 2 | .arch i386 3 | .section ".prefix", "awx", @progbits 4 | .code16 5 | .org 0 6 | 7 | mbr: 8 | movw $exec_sector, %bp 9 | jmp find_active_partition 10 | exec_sector: 11 | ljmp $0x0000, $0x7c00 12 | 13 | #include "bootpart.S" 14 | -------------------------------------------------------------------------------- /src/arch/i386/prefix/nullprefix.S: -------------------------------------------------------------------------------- 1 | .org 0 2 | .text 3 | .arch i386 4 | 5 | .section ".prefix", "ax", @progbits 6 | .code16 7 | _prefix: 8 | 9 | .section ".text16", "ax", @progbits 10 | prefix_exit: 11 | 12 | prefix_exit_end: 13 | .previous 14 | -------------------------------------------------------------------------------- /src/arch/i386/prefix/undiloader.S: -------------------------------------------------------------------------------- 1 | .text 2 | .code16 3 | .arch i386 4 | .section ".prefix", "ax", @progbits 5 | 6 | /* UNDI loader 7 | * 8 | * Called by an external program to load our PXE stack. 9 | */ 10 | .globl undiloader 11 | undiloader: 12 | /* Save registers */ 13 | pushl %esi 14 | pushl %edi 15 | pushw %ds 16 | pushw %es 17 | pushw %bx 18 | /* ROM segment address to %ds */ 19 | pushw %cs 20 | popw %ds 21 | /* UNDI loader parameter structure address into %es:%di */ 22 | movw %sp, %bx 23 | movw %ss:18(%bx), %di 24 | movw %ss:20(%bx), %es 25 | /* Install to specified real-mode addresses */ 26 | pushw %di 27 | movw %es:12(%di), %bx 28 | movw %es:14(%di), %ax 29 | movl image_source, %esi 30 | movl decompress_to, %edi 31 | clc /* Allow relocation */ 32 | call install_prealloc 33 | popw %di 34 | /* Call UNDI loader C code */ 35 | pushl $pxe_loader_call 36 | pushw %cs 37 | pushw $1f 38 | pushw %ax 39 | pushw $prot_call 40 | lret 41 | 1: popw %bx /* discard */ 42 | popw %bx /* discard */ 43 | /* Restore registers and return */ 44 | popw %bx 45 | popw %es 46 | popw %ds 47 | popl %edi 48 | popl %esi 49 | lret 50 | .size undiloader, . - undiloader 51 | -------------------------------------------------------------------------------- /src/arch/i386/prefix/unnrv2b16.S: -------------------------------------------------------------------------------- 1 | /* 2 | * 16-bit version of the decompressor 3 | * 4 | */ 5 | 6 | FILE_LICENCE ( GPL2_OR_LATER ) 7 | 8 | #define CODE16 9 | #include "unnrv2b.S" 10 | -------------------------------------------------------------------------------- /src/arch/i386/prefix/usbdisk.S: -------------------------------------------------------------------------------- 1 | .text 2 | .arch i386 3 | .section ".prefix", "awx", @progbits 4 | .code16 5 | .org 0 6 | 7 | #include "mbr.S" 8 | 9 | /* Partition table: ZIP-compatible partition 4, 64 heads, 32 sectors/track */ 10 | .org 446 11 | .space 16 12 | .space 16 13 | .space 16 14 | .byte 0x80, 0x01, 0x01, 0x00 15 | .byte 0xeb, 0x3f, 0x20, 0x01 16 | .long 0x00000020 17 | .long 0x00000fe0 18 | 19 | .org 510 20 | .byte 0x55, 0xaa 21 | 22 | /* Skip to start of partition */ 23 | .org 32 * 512 24 | -------------------------------------------------------------------------------- /src/arch/i386/transitions/libpm.S: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/etherboot/gpxe/c23508d796325f8af724ad497c99ffb5a49abea0/src/arch/i386/transitions/libpm.S -------------------------------------------------------------------------------- /src/arch/x86/Makefile: -------------------------------------------------------------------------------- 1 | # Include common x86 headers 2 | # 3 | INCDIRS += arch/x86/include 4 | 5 | # x86-specific directories containing source files 6 | # 7 | SRCDIRS += arch/x86/core 8 | SRCDIRS += arch/x86/interface/efi 9 | SRCDIRS += arch/x86/prefix 10 | -------------------------------------------------------------------------------- /src/arch/x86/Makefile.efi: -------------------------------------------------------------------------------- 1 | # -*- makefile -*- : Force emacs to use Makefile mode 2 | 3 | # The EFI linker script 4 | # 5 | LDSCRIPT = arch/x86/scripts/efi.lds 6 | 7 | # Retain relocation information for elf2efi 8 | # 9 | LDFLAGS += -q -S 10 | 11 | # Media types. 12 | # 13 | NON_AUTO_MEDIA += efi 14 | NON_AUTO_MEDIA += efidrv 15 | 16 | # Extra LD FLAGS 17 | TGT_LD_FLAGS_PRE = --defsym _start=_$(TGT_PREFIX)_start 18 | 19 | # Rules for building EFI files 20 | # 21 | $(BIN)/%.efi : $(BIN)/%.efi.tmp $(ELF2EFI) 22 | $(QM)$(ECHO) " [FINISH] $@" 23 | $(Q)$(ELF2EFI) --subsystem=10 $< $@ 24 | 25 | $(BIN)/%.efidrv : $(BIN)/%.efidrv.tmp $(ELF2EFI) 26 | $(QM)$(ECHO) " [FINISH] $@" 27 | $(Q)$(ELF2EFI) --subsystem=11 $< $@ 28 | 29 | $(BIN)/%.efirom : $(BIN)/%.efidrv $(EFIROM) 30 | $(QM)$(ECHO) " [FINISH] $@" 31 | $(Q)$(EFIROM) -v $(TGT_PCI_VENDOR) -d $(TGT_PCI_DEVICE) $< $@ 32 | -------------------------------------------------------------------------------- /src/arch/x86/include/bits/pci_io.h: -------------------------------------------------------------------------------- 1 | #ifndef _BITS_PCI_IO_H 2 | #define _BITS_PCI_IO_H 3 | 4 | /** @file 5 | * 6 | * i386-specific PCI I/O API implementations 7 | * 8 | */ 9 | 10 | FILE_LICENCE ( GPL2_OR_LATER ); 11 | 12 | #include 13 | #include 14 | 15 | #endif /* _BITS_PCI_IO_H */ 16 | -------------------------------------------------------------------------------- /src/arch/x86/include/gpxe/efi/efix86_nap.h: -------------------------------------------------------------------------------- 1 | #ifndef _GPXE_EFIX86_NAP_H 2 | #define _GPXE_EFIX86_NAP_H 3 | 4 | /** @file 5 | * 6 | * EFI CPU sleeping 7 | * 8 | */ 9 | 10 | FILE_LICENCE ( GPL2_OR_LATER ); 11 | 12 | #ifdef NAP_EFIX86 13 | #define NAP_PREFIX_efix86 14 | #else 15 | #define NAP_PREFIX_efix86 __efix86_ 16 | #endif 17 | 18 | #endif /* _GPXE_EFIX86_NAP_H */ 19 | -------------------------------------------------------------------------------- /src/arch/x86/prefix/efidrvprefix.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009 Michael Brown . 3 | * 4 | * This program is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU General Public License as 6 | * published by the Free Software Foundation; either version 2 of the 7 | * License, or any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, but 10 | * WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | */ 18 | 19 | FILE_LICENCE ( GPL2_OR_LATER ); 20 | 21 | #include 22 | #include 23 | #include 24 | 25 | /** 26 | * EFI entry point 27 | * 28 | * @v image_handle Image handle 29 | * @v systab System table 30 | * @ret efirc EFI return status code 31 | */ 32 | EFI_STATUS EFIAPI _efidrv_start ( EFI_HANDLE image_handle, 33 | EFI_SYSTEM_TABLE *systab ) { 34 | EFI_STATUS efirc; 35 | 36 | /* Initialise EFI environment */ 37 | if ( ( efirc = efi_init ( image_handle, systab ) ) != 0 ) 38 | return efirc; 39 | 40 | /* Initialise gPXE environment */ 41 | initialise(); 42 | startup(); 43 | 44 | /* Install SNP driver and return */ 45 | return RC_TO_EFIRC ( efi_snp_install () ); 46 | } 47 | -------------------------------------------------------------------------------- /src/arch/x86/prefix/efiprefix.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009 Michael Brown . 3 | * 4 | * This program is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU General Public License as 6 | * published by the Free Software Foundation; either version 2 of the 7 | * License, or any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, but 10 | * WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | */ 18 | 19 | FILE_LICENCE ( GPL2_OR_LATER ); 20 | 21 | #include 22 | #include 23 | 24 | /** 25 | * EFI entry point 26 | * 27 | * @v image_handle Image handle 28 | * @v systab System table 29 | * @ret efirc EFI return status code 30 | */ 31 | EFI_STATUS EFIAPI _efi_start ( EFI_HANDLE image_handle, 32 | EFI_SYSTEM_TABLE *systab ) { 33 | EFI_STATUS efirc; 34 | 35 | /* Initialise EFI environment */ 36 | if ( ( efirc = efi_init ( image_handle, systab ) ) != 0 ) 37 | return efirc; 38 | 39 | /* Call to main() */ 40 | return RC_TO_EFIRC ( main () ); 41 | } 42 | -------------------------------------------------------------------------------- /src/arch/x86_64/Makefile: -------------------------------------------------------------------------------- 1 | # Code size reduction. 2 | # 3 | CFLAGS += -fstrength-reduce -fomit-frame-pointer 4 | 5 | # Code size reduction. gcc3 needs a different syntax to gcc2 if you 6 | # want to avoid spurious warnings. 7 | # 8 | CFLAGS += -falign-jumps=1 -falign-loops=1 -falign-functions=1 9 | 10 | # Use %rip-relative addressing wherever possible. 11 | # 12 | CFLAGS += -fpie 13 | 14 | # Force 64-bit code 15 | # 16 | CFLAGS += -m64 17 | ASFLAGS += --64 18 | LDFLAGS += -m elf_x86_64 19 | 20 | # EFI requires -fshort-wchar, and nothing else currently uses wchar_t 21 | # 22 | CFLAGS += -fshort-wchar 23 | 24 | # We need to undefine the default macro "i386" when compiling .S 25 | # files, otherwise ".arch i386" translates to ".arch 1"... 26 | # 27 | CFLAGS += -Ui386 28 | 29 | # x86_64-specific directories containing source files 30 | # 31 | SRCDIRS += arch/x86_64/prefix 32 | 33 | # Include common x86 Makefile 34 | # 35 | MAKEDEPS += arch/x86/Makefile 36 | include arch/x86/Makefile 37 | 38 | # Include platform-specific Makefile 39 | # 40 | MAKEDEPS += arch/x86_64/Makefile.$(PLATFORM) 41 | include arch/x86_64/Makefile.$(PLATFORM) 42 | -------------------------------------------------------------------------------- /src/arch/x86_64/Makefile.efi: -------------------------------------------------------------------------------- 1 | # -*- makefile -*- : Force emacs to use Makefile mode 2 | 3 | # EFI probably doesn't guarantee us a red zone, so let's not rely on it. 4 | # 5 | CFLAGS += -mno-red-zone 6 | 7 | # Specify EFI image builder 8 | # 9 | ELF2EFI = $(ELF2EFI64) 10 | 11 | # Include generic EFI Makefile 12 | # 13 | MAKEDEPS += arch/x86/Makefile.efi 14 | include arch/x86/Makefile.efi 15 | -------------------------------------------------------------------------------- /src/arch/x86_64/include/bits/byteswap.h: -------------------------------------------------------------------------------- 1 | #ifndef _BITS_BYTESWAP_H 2 | #define _BITS_BYTESWAP_H 3 | 4 | static inline __attribute__ (( always_inline, const )) uint16_t 5 | __bswap_variable_16 ( uint16_t x ) { 6 | __asm__ ( "xchgb %b0,%h0" : "=Q" ( x ) : "0" ( x ) ); 7 | return x; 8 | } 9 | 10 | static inline __attribute__ (( always_inline, const )) uint32_t 11 | __bswap_variable_32 ( uint32_t x ) { 12 | __asm__ ( "bswapl %k0" : "=r" ( x ) : "0" ( x ) ); 13 | return x; 14 | } 15 | 16 | static inline __attribute__ (( always_inline, const )) uint64_t 17 | __bswap_variable_64 ( uint64_t x ) { 18 | __asm__ ( "bswapq %q0" : "=r" ( x ) : "0" ( x ) ); 19 | return x; 20 | } 21 | 22 | #endif /* _BITS_BYTESWAP_H */ 23 | -------------------------------------------------------------------------------- /src/arch/x86_64/include/bits/compiler.h: -------------------------------------------------------------------------------- 1 | #ifndef _BITS_COMPILER_H 2 | #define _BITS_COMPILER_H 3 | 4 | #ifndef ASSEMBLY 5 | 6 | /** Declare a function with standard calling conventions */ 7 | #define __asmcall __attribute__ (( regparm(0) )) 8 | 9 | /** Declare a function with libgcc implicit linkage */ 10 | #define __libgcc 11 | 12 | #endif /* ASSEMBLY */ 13 | 14 | #endif /* _BITS_COMPILER_H */ 15 | -------------------------------------------------------------------------------- /src/arch/x86_64/include/bits/endian.h: -------------------------------------------------------------------------------- 1 | #ifndef ETHERBOOT_BITS_ENDIAN_H 2 | #define ETHERBOOT_BITS_ENDIAN_H 3 | 4 | #define __BYTE_ORDER __LITTLE_ENDIAN 5 | 6 | #endif /* ETHERBOOT_BITS_ENDIAN_H */ 7 | -------------------------------------------------------------------------------- /src/arch/x86_64/include/bits/errfile.h: -------------------------------------------------------------------------------- 1 | #ifndef _BITS_ERRFILE_H 2 | #define _BITS_ERRFILE_H 3 | 4 | /** 5 | * @addtogroup errfile Error file identifiers 6 | * @{ 7 | */ 8 | 9 | /** @} */ 10 | 11 | #endif /* _BITS_ERRFILE_H */ 12 | -------------------------------------------------------------------------------- /src/arch/x86_64/include/bits/io.h: -------------------------------------------------------------------------------- 1 | #ifndef _BITS_IO_H 2 | #define _BITS_IO_H 3 | 4 | /** @file 5 | * 6 | * x86_64-specific I/O API implementations 7 | * 8 | */ 9 | 10 | #endif /* _BITS_IO_H */ 11 | -------------------------------------------------------------------------------- /src/arch/x86_64/include/bits/nap.h: -------------------------------------------------------------------------------- 1 | #ifndef _BITS_NAP_H 2 | #define _BITS_NAP_H 3 | 4 | /** @file 5 | * 6 | * x86_64-specific CPU sleeping API implementations 7 | * 8 | */ 9 | 10 | #include 11 | 12 | #endif /* _BITS_MAP_H */ 13 | -------------------------------------------------------------------------------- /src/arch/x86_64/include/bits/smbios.h: -------------------------------------------------------------------------------- 1 | #ifndef _BITS_SMBIOS_H 2 | #define _BITS_SMBIOS_H 3 | 4 | /** @file 5 | * 6 | * i386-specific SMBIOS API implementations 7 | * 8 | */ 9 | 10 | #endif /* _BITS_SMBIOS_H */ 11 | -------------------------------------------------------------------------------- /src/arch/x86_64/include/bits/stdint.h: -------------------------------------------------------------------------------- 1 | #ifndef _BITS_STDINT_H 2 | #define _BITS_STDINT_H 3 | 4 | typedef __SIZE_TYPE__ size_t; 5 | typedef signed long ssize_t; 6 | typedef signed long off_t; 7 | 8 | typedef unsigned char uint8_t; 9 | typedef unsigned short uint16_t; 10 | typedef unsigned int uint32_t; 11 | typedef unsigned long long uint64_t; 12 | 13 | typedef signed char int8_t; 14 | typedef signed short int16_t; 15 | typedef signed int int32_t; 16 | typedef signed long long int64_t; 17 | 18 | typedef unsigned long physaddr_t; 19 | typedef unsigned long intptr_t; 20 | 21 | #endif /* _BITS_STDINT_H */ 22 | -------------------------------------------------------------------------------- /src/arch/x86_64/include/bits/timer.h: -------------------------------------------------------------------------------- 1 | #ifndef _BITS_TIMER_H 2 | #define _BITS_TIMER_H 3 | 4 | /** @file 5 | * 6 | * x86_64-specific timer API implementations 7 | * 8 | */ 9 | 10 | #endif /* _BITS_TIMER_H */ 11 | -------------------------------------------------------------------------------- /src/arch/x86_64/include/bits/uaccess.h: -------------------------------------------------------------------------------- 1 | #ifndef _BITS_UACCESS_H 2 | #define _BITS_UACCESS_H 3 | 4 | /** @file 5 | * 6 | * x86_64-specific user access API implementations 7 | * 8 | */ 9 | 10 | #endif /* _BITS_UACCESS_H */ 11 | -------------------------------------------------------------------------------- /src/arch/x86_64/include/bits/umalloc.h: -------------------------------------------------------------------------------- 1 | #ifndef _BITS_UMALLOC_H 2 | #define _BITS_UMALLOC_H 3 | 4 | /** @file 5 | * 6 | * x86_64-specific user memory allocation API implementations 7 | * 8 | */ 9 | 10 | #endif /* _BITS_UMALLOC_H */ 11 | -------------------------------------------------------------------------------- /src/arch/x86_64/include/efi/gpxe/dhcp_arch.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010 VMware, Inc. All Rights Reserved. 3 | * 4 | * This program is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU General Public License as 6 | * published by the Free Software Foundation; either version 2 of the 7 | * License, or any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, but 10 | * WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 17 | */ 18 | 19 | #ifndef _DHCP_ARCH_H 20 | #define _DHCP_ARCH_H 21 | 22 | /** @file 23 | * 24 | * Architecture-specific DHCP options 25 | */ 26 | 27 | FILE_LICENCE ( GPL2_OR_LATER ); 28 | 29 | #include 30 | 31 | #define DHCP_ARCH_VENDOR_CLASS_ID \ 32 | DHCP_STRING ( 'P', 'X', 'E', 'C', 'l', 'i', 'e', 'n', 't', ':', \ 33 | 'A', 'r', 'c', 'h', ':', '0', '0', '0', '0', '7', ':', \ 34 | 'U', 'N', 'D', 'I', ':', '0', '0', '3', '0', '1', '0' ) 35 | 36 | #define DHCP_ARCH_CLIENT_ARCHITECTURE DHCP_WORD ( 7 ) 37 | 38 | #define DHCP_ARCH_CLIENT_NDI DHCP_OPTION ( 1 /* UNDI */ , 3, 10 /* v3.10 */ ) 39 | 40 | #endif 41 | -------------------------------------------------------------------------------- /src/arch/x86_64/include/gdbmach.h: -------------------------------------------------------------------------------- 1 | #ifndef GDBMACH_H 2 | #define GDBMACH_H 3 | 4 | /** @file 5 | * 6 | * GDB architecture specifics 7 | * 8 | * This file declares functions for manipulating the machine state and 9 | * debugging context. 10 | * 11 | */ 12 | 13 | #include 14 | 15 | typedef unsigned long gdbreg_t; 16 | 17 | /* The register snapshot, this must be in sync with interrupt handler and the 18 | * GDB protocol. */ 19 | enum { 20 | // STUB: don't expect this to work! 21 | GDBMACH_EIP, 22 | GDBMACH_EFLAGS, 23 | GDBMACH_NREGS, 24 | GDBMACH_SIZEOF_REGS = GDBMACH_NREGS * sizeof ( gdbreg_t ) 25 | }; 26 | 27 | /* Breakpoint types */ 28 | enum { 29 | GDBMACH_BPMEM, 30 | GDBMACH_BPHW, 31 | GDBMACH_WATCH, 32 | GDBMACH_RWATCH, 33 | GDBMACH_AWATCH, 34 | }; 35 | 36 | static inline void gdbmach_set_pc ( gdbreg_t *regs, gdbreg_t pc ) { 37 | regs [ GDBMACH_EIP ] = pc; 38 | } 39 | 40 | static inline void gdbmach_set_single_step ( gdbreg_t *regs, int step ) { 41 | regs [ GDBMACH_EFLAGS ] &= ~( 1 << 8 ); /* Trace Flag (TF) */ 42 | regs [ GDBMACH_EFLAGS ] |= ( step << 8 ); 43 | } 44 | 45 | static inline void gdbmach_breakpoint ( void ) { 46 | __asm__ __volatile__ ( "int $3\n" ); 47 | } 48 | 49 | extern int gdbmach_set_breakpoint ( int type, unsigned long addr, size_t len, int enable ); 50 | 51 | #endif /* GDBMACH_H */ 52 | -------------------------------------------------------------------------------- /src/bin/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | -------------------------------------------------------------------------------- /src/config/.gitignore: -------------------------------------------------------------------------------- 1 | .buildserial.* 2 | -------------------------------------------------------------------------------- /src/config/config_net80211.c: -------------------------------------------------------------------------------- 1 | /* 2 | * This program is free software; you can redistribute it and/or 3 | * modify it under the terms of the GNU General Public License as 4 | * published by the Free Software Foundation; either version 2, or (at 5 | * your option) any later version. 6 | */ 7 | 8 | FILE_LICENCE ( GPL2_OR_LATER ); 9 | 10 | #include 11 | 12 | /** @file 13 | * 14 | * 802.11 configuration options 15 | * 16 | */ 17 | 18 | /* 19 | * Drag in 802.11-specific commands 20 | * 21 | */ 22 | #ifdef IWMGMT_CMD 23 | REQUIRE_OBJECT ( iwmgmt_cmd ); 24 | #endif 25 | 26 | /* 27 | * Drag in 802.11 error message tables 28 | * 29 | */ 30 | #ifdef ERRMSG_80211 31 | REQUIRE_OBJECT ( wireless_errors ); 32 | #endif 33 | 34 | /* 35 | * Drag in 802.11 cryptosystems and handshaking protocols 36 | * 37 | */ 38 | #ifdef CRYPTO_80211_WEP 39 | REQUIRE_OBJECT ( wep ); 40 | #endif 41 | 42 | #ifdef CRYPTO_80211_WPA2 43 | #define CRYPTO_80211_WPA 44 | REQUIRE_OBJECT ( wpa_ccmp ); 45 | #endif 46 | 47 | #ifdef CRYPTO_80211_WPA 48 | REQUIRE_OBJECT ( wpa_psk ); 49 | REQUIRE_OBJECT ( wpa_tkip ); 50 | #endif 51 | -------------------------------------------------------------------------------- /src/config/config_romprefix.c: -------------------------------------------------------------------------------- 1 | /* 2 | * This program is free software; you can redistribute it and/or 3 | * modify it under the terms of the GNU General Public License as 4 | * published by the Free Software Foundation; either version 2, or (at 5 | * your option) any later version. 6 | */ 7 | 8 | FILE_LICENCE ( GPL2_OR_LATER ); 9 | 10 | #include 11 | 12 | /** @file 13 | * 14 | * ROM prefix configuration options 15 | * 16 | */ 17 | 18 | /* 19 | * Provide UNDI loader if PXE stack is requested 20 | * 21 | */ 22 | #ifdef PXE_STACK 23 | REQUIRE_OBJECT ( undiloader ); 24 | #endif 25 | -------------------------------------------------------------------------------- /src/config/console.h: -------------------------------------------------------------------------------- 1 | #ifndef CONFIG_CONSOLE_H 2 | #define CONFIG_CONSOLE_H 3 | 4 | /** @file 5 | * 6 | * Console configuration 7 | * 8 | * These options specify the console types that Etherboot will use for 9 | * interaction with the user. 10 | * 11 | */ 12 | 13 | FILE_LICENCE ( GPL2_OR_LATER ); 14 | 15 | #include 16 | 17 | //#define CONSOLE_PCBIOS /* Default BIOS console */ 18 | //#define CONSOLE_SERIAL /* Serial port */ 19 | //#define CONSOLE_DIRECT_VGA /* Direct access to VGA card */ 20 | //#define CONSOLE_BTEXT /* Who knows what this does? */ 21 | //#define CONSOLE_PC_KBD /* Direct access to PC keyboard */ 22 | 23 | #include 24 | 25 | #endif /* CONFIG_CONSOLE_H */ 26 | -------------------------------------------------------------------------------- /src/config/defaults.h: -------------------------------------------------------------------------------- 1 | #ifndef CONFIG_DEFAULTS_H 2 | #define CONFIG_DEFAULTS_H 3 | 4 | FILE_LICENCE ( GPL2_OR_LATER ); 5 | 6 | #define CONFIG_DEFAULTS(_platform) 7 | 8 | #include CONFIG_DEFAULTS(PLATFORM) 9 | 10 | #endif /* CONFIG_DEFAULTS_H */ 11 | -------------------------------------------------------------------------------- /src/config/defaults/efi.h: -------------------------------------------------------------------------------- 1 | #ifndef CONFIG_DEFAULTS_EFI_H 2 | #define CONFIG_DEFAULTS_EFI_H 3 | 4 | /** @file 5 | * 6 | * Configuration defaults for EFI 7 | * 8 | */ 9 | 10 | #define UACCESS_EFI 11 | #define IOAPI_EFI 12 | #define PCIAPI_EFI 13 | #define CONSOLE_EFI 14 | #define TIMER_EFI 15 | #define NAP_EFIX86 16 | #define UMALLOC_EFI 17 | #define SMBIOS_EFI 18 | 19 | #define IMAGE_EFI /* EFI image support */ 20 | #define IMAGE_SCRIPT /* gPXE script image support */ 21 | 22 | #endif /* CONFIG_DEFAULTS_EFI_H */ 23 | -------------------------------------------------------------------------------- /src/config/defaults/pcbios.h: -------------------------------------------------------------------------------- 1 | #ifndef CONFIG_DEFAULTS_PCBIOS_H 2 | #define CONFIG_DEFAULTS_PCBIOS_H 3 | 4 | /** @file 5 | * 6 | * Configuration defaults for PCBIOS 7 | * 8 | */ 9 | 10 | FILE_LICENCE ( GPL2_OR_LATER ); 11 | 12 | #define UACCESS_LIBRM 13 | #define IOAPI_X86 14 | #define PCIAPI_PCBIOS 15 | #define TIMER_PCBIOS 16 | #define CONSOLE_PCBIOS 17 | #define NAP_PCBIOS 18 | #define UMALLOC_MEMTOP 19 | #define SMBIOS_PCBIOS 20 | 21 | #define IMAGE_ELF /* ELF image support */ 22 | #define IMAGE_MULTIBOOT /* MultiBoot image support */ 23 | #define IMAGE_PXE /* PXE image support */ 24 | #define IMAGE_SCRIPT /* gPXE script image support */ 25 | #define IMAGE_BZIMAGE /* Linux bzImage image support */ 26 | #define IMAGE_COMBOOT /* SYSLINUX COMBOOT image support */ 27 | 28 | #define PXE_STACK /* PXE stack in gPXE - required for PXELINUX */ 29 | #define PXE_MENU /* PXE menu booting */ 30 | #define PXE_CMD /* PXE commands */ 31 | 32 | #define SANBOOT_PROTO_ISCSI /* iSCSI protocol */ 33 | #define SANBOOT_PROTO_AOE /* AoE protocol */ 34 | 35 | #endif /* CONFIG_DEFAULTS_PCBIOS_H */ 36 | -------------------------------------------------------------------------------- /src/config/ioapi.h: -------------------------------------------------------------------------------- 1 | #ifndef CONFIG_IOAPI_H 2 | #define CONFIG_IOAPI_H 3 | 4 | /** @file 5 | * 6 | * I/O API configuration 7 | * 8 | */ 9 | 10 | FILE_LICENCE ( GPL2_OR_LATER ); 11 | 12 | #include 13 | 14 | //#undef PCIAPI_PCBIOS /* Access via PCI BIOS */ 15 | //#define PCIAPI_DIRECT /* Direct access via Type 1 accesses */ 16 | 17 | #include 18 | 19 | #endif /* CONFIG_IOAPI_H */ 20 | -------------------------------------------------------------------------------- /src/config/isa.h: -------------------------------------------------------------------------------- 1 | #ifndef CONFIG_ISA_H 2 | #define CONFIG_ISA_H 3 | 4 | /** @file 5 | * 6 | * ISA probe address configuration 7 | * 8 | * You can override the list of addresses that will be probed by any 9 | * ISA drivers. 10 | * 11 | */ 12 | #undef ISA_PROBE_ADDRS /* e.g. 0x200, 0x300 */ 13 | #undef ISA_PROBE_ONLY /* Do not probe any other addresses */ 14 | 15 | #include 16 | 17 | #endif /* CONFIG_ISA_H */ 18 | -------------------------------------------------------------------------------- /src/config/local/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | -------------------------------------------------------------------------------- /src/config/nap.h: -------------------------------------------------------------------------------- 1 | #ifndef CONFIG_NAP_H 2 | #define CONFIG_NAP_H 3 | 4 | /** @file 5 | * 6 | * CPU sleeping 7 | * 8 | */ 9 | 10 | FILE_LICENCE ( GPL2_OR_LATER ); 11 | 12 | #include 13 | 14 | //#undef NAP_PCBIOS 15 | //#define NAP_NULL 16 | 17 | #include 18 | 19 | #endif /* CONFIG_NAP_H */ 20 | -------------------------------------------------------------------------------- /src/config/serial.h: -------------------------------------------------------------------------------- 1 | #ifndef CONFIG_SERIAL_H 2 | #define CONFIG_SERIAL_H 3 | 4 | /** @file 5 | * 6 | * Serial port configuration 7 | * 8 | * These options affect the operation of the serial console. They 9 | * take effect only if the serial console is included using the 10 | * CONSOLE_SERIAL option. 11 | * 12 | */ 13 | 14 | FILE_LICENCE ( GPL2_OR_LATER ); 15 | 16 | #define COM1 0x3f8 17 | #define COM2 0x2f8 18 | #define COM3 0x3e8 19 | #define COM4 0x2e8 20 | 21 | #define COMCONSOLE COM1 /* I/O port address */ 22 | 23 | /* Keep settings from a previous user of the serial port (e.g. lilo or 24 | * LinuxBIOS), ignoring COMSPEED, COMDATA, COMPARITY and COMSTOP. 25 | */ 26 | #undef COMPRESERVE 27 | 28 | #ifndef COMPRESERVE 29 | #define COMSPEED 115200 /* Baud rate */ 30 | #define COMDATA 8 /* Data bits */ 31 | #define COMPARITY 0 /* Parity: 0=None, 1=Odd, 2=Even */ 32 | #define COMSTOP 1 /* Stop bits */ 33 | #endif 34 | 35 | #include 36 | 37 | #endif /* CONFIG_SERIAL_H */ 38 | -------------------------------------------------------------------------------- /src/config/timer.h: -------------------------------------------------------------------------------- 1 | #ifndef CONFIG_TIMER_H 2 | #define CONFIG_TIMER_H 3 | 4 | /** @file 5 | * 6 | * Timer configuration. 7 | * 8 | */ 9 | 10 | FILE_LICENCE ( GPL2_OR_LATER ); 11 | 12 | #include 13 | 14 | //#undef TIMER_PCBIOS 15 | //#define TIMER_RDTSC 16 | 17 | #include 18 | 19 | #endif /* CONFIG_TIMER_H */ 20 | -------------------------------------------------------------------------------- /src/config/umalloc.h: -------------------------------------------------------------------------------- 1 | #ifndef CONFIG_UMALLOC_H 2 | #define CONFIG_UMALLOC_H 3 | 4 | /** @file 5 | * 6 | * User memory allocation API configuration 7 | * 8 | */ 9 | 10 | FILE_LICENCE ( GPL2_OR_LATER ); 11 | 12 | #include 13 | 14 | #include 15 | 16 | #endif /* CONFIG_UMALLOC_H */ 17 | -------------------------------------------------------------------------------- /src/core/acpi.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2006 Michael Brown . 3 | * 4 | * This program is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU General Public License as 6 | * published by the Free Software Foundation; either version 2 of the 7 | * License, or any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, but 10 | * WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | */ 18 | 19 | FILE_LICENCE ( GPL2_OR_LATER ); 20 | 21 | #include 22 | 23 | /** @file 24 | * 25 | * ACPI support functions 26 | * 27 | */ 28 | 29 | /** 30 | * Fix up ACPI table checksum 31 | * 32 | * @v acpi ACPI table header 33 | */ 34 | void acpi_fix_checksum ( struct acpi_description_header *acpi ) { 35 | unsigned int i = 0; 36 | uint8_t sum = 0; 37 | 38 | for ( i = 0 ; i < acpi->length ; i++ ) { 39 | sum += *( ( ( uint8_t * ) acpi ) + i ); 40 | } 41 | acpi->checksum -= sum; 42 | } 43 | -------------------------------------------------------------------------------- /src/core/asprintf.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | FILE_LICENCE ( GPL2_OR_LATER ); 8 | 9 | /** 10 | * Write a formatted string to newly allocated memory. 11 | * 12 | * @v strp Pointer to hold allocated string 13 | * @v fmt Format string 14 | * @v args Arguments corresponding to the format string 15 | * @ret len Length of formatted string 16 | */ 17 | int vasprintf ( char **strp, const char *fmt, va_list args ) { 18 | size_t len; 19 | va_list args_tmp; 20 | 21 | /* Calculate length needed for string */ 22 | va_copy ( args_tmp, args ); 23 | len = ( vsnprintf ( NULL, 0, fmt, args_tmp ) + 1 ); 24 | va_end ( args_tmp ); 25 | 26 | /* Allocate and fill string */ 27 | *strp = malloc ( len ); 28 | if ( ! *strp ) 29 | return -ENOMEM; 30 | return vsnprintf ( *strp, len, fmt, args ); 31 | } 32 | 33 | /** 34 | * Write a formatted string to newly allocated memory. 35 | * 36 | * @v strp Pointer to hold allocated string 37 | * @v fmt Format string 38 | * @v ... Arguments corresponding to the format string 39 | * @ret len Length of formatted string 40 | */ 41 | int asprintf ( char **strp, const char *fmt, ... ) { 42 | va_list args; 43 | int len; 44 | 45 | va_start ( args, fmt ); 46 | len = vasprintf ( strp, fmt, args ); 47 | va_end ( args ); 48 | return len; 49 | } 50 | -------------------------------------------------------------------------------- /src/core/bitops.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | FILE_LICENCE ( GPL2_OR_LATER ); 4 | 5 | int __flsl ( long x ) { 6 | unsigned long value = x; 7 | int ls = 0; 8 | 9 | for ( ls = 0 ; value ; ls++ ) { 10 | value >>= 1; 11 | } 12 | return ls; 13 | } 14 | -------------------------------------------------------------------------------- /src/core/btext.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/etherboot/gpxe/c23508d796325f8af724ad497c99ffb5a49abea0/src/core/btext.c -------------------------------------------------------------------------------- /src/core/cpio.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2007 Michael Brown . 3 | * 4 | * This program is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU General Public License as 6 | * published by the Free Software Foundation; either version 2 of the 7 | * License, or any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, but 10 | * WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | */ 18 | 19 | FILE_LICENCE ( GPL2_OR_LATER ); 20 | 21 | /** @file 22 | * 23 | * CPIO archives 24 | * 25 | */ 26 | 27 | #include 28 | #include 29 | #include 30 | 31 | /** 32 | * Set field within a CPIO header 33 | * 34 | * @v field Field within CPIO header 35 | * @v value Value to set 36 | */ 37 | void cpio_set_field ( char *field, unsigned long value ) { 38 | char buf[9]; 39 | 40 | snprintf ( buf, sizeof ( buf ), "%08lx", value ); 41 | memcpy ( field, buf, 8 ); 42 | } 43 | -------------------------------------------------------------------------------- /src/core/ctype.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009 Michael Brown . 3 | * 4 | * This program is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU General Public License as 6 | * published by the Free Software Foundation; either version 2 of the 7 | * License, or any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, but 10 | * WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | */ 18 | 19 | FILE_LICENCE ( GPL2_OR_LATER ); 20 | 21 | /** 22 | * @file 23 | * 24 | * Character types 25 | * 26 | */ 27 | 28 | #include 29 | 30 | /** 31 | * Check to see if character is a space 32 | * 33 | * @v c Character 34 | * @ret isspace Character is a space 35 | */ 36 | int isspace ( int c ) { 37 | switch ( c ) { 38 | case ' ' : 39 | case '\f' : 40 | case '\n' : 41 | case '\r' : 42 | case '\t' : 43 | case '\v' : 44 | return 1; 45 | default: 46 | return 0; 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /src/core/cwuri.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2007 Michael Brown . 3 | * 4 | * This program is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU General Public License as 6 | * published by the Free Software Foundation; either version 2 of the 7 | * License, or any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, but 10 | * WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | */ 18 | 19 | FILE_LICENCE ( GPL2_OR_LATER ); 20 | 21 | #include 22 | #include 23 | 24 | /** @file 25 | * 26 | * Current working URI 27 | * 28 | * Somewhat analogous to the current working directory in a POSIX 29 | * system. 30 | */ 31 | 32 | /** Current working URI */ 33 | struct uri *cwuri = NULL; 34 | 35 | /** 36 | * Change working URI 37 | * 38 | * @v uri New working URI, or NULL 39 | */ 40 | void churi ( struct uri *uri ) { 41 | struct uri *new_uri = NULL; 42 | 43 | if ( uri ) 44 | new_uri = resolve_uri ( cwuri, uri ); 45 | 46 | uri_put ( cwuri ); 47 | cwuri = new_uri; 48 | } 49 | -------------------------------------------------------------------------------- /src/core/errno.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | /** @file 4 | * 5 | * Error codes 6 | * 7 | * This file provides the global variable #errno. 8 | * 9 | */ 10 | 11 | /** 12 | * Global "last error" number. 13 | * 14 | * This is valid only when a function has just returned indicating a 15 | * failure. 16 | * 17 | */ 18 | int errno; 19 | -------------------------------------------------------------------------------- /src/core/gdbserial.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2008 Stefan Hajnoczi . 3 | * 4 | * This program is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU General Public License as 6 | * published by the Free Software Foundation; either version 2 of the 7 | * License, or any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, but 10 | * WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | */ 18 | 19 | #include 20 | #include 21 | #include 22 | #include 23 | 24 | struct gdb_transport serial_gdb_transport __gdb_transport; 25 | 26 | static size_t gdbserial_recv ( char *buf, size_t len ) { 27 | assert ( len > 0 ); 28 | buf [ 0 ] = serial_getc(); 29 | return 1; 30 | } 31 | 32 | static void gdbserial_send ( const char *buf, size_t len ) { 33 | while ( len-- > 0 ) { 34 | serial_putc ( *buf++ ); 35 | } 36 | } 37 | 38 | struct gdb_transport serial_gdb_transport __gdb_transport = { 39 | .name = "serial", 40 | .recv = gdbserial_recv, 41 | .send = gdbserial_send, 42 | }; 43 | 44 | struct gdb_transport *gdbserial_configure ( void ) { 45 | return &serial_gdb_transport; 46 | } 47 | -------------------------------------------------------------------------------- /src/core/null_nap.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | PROVIDE_NAP_INLINE ( null, cpu_nap ); 4 | -------------------------------------------------------------------------------- /src/core/random.c: -------------------------------------------------------------------------------- 1 | /** @file 2 | * 3 | * Random number generation 4 | * 5 | */ 6 | 7 | FILE_LICENCE ( GPL2_OR_LATER ); 8 | 9 | #include 10 | #include 11 | 12 | static int32_t rnd_seed = 0; 13 | 14 | /** 15 | * Seed the pseudo-random number generator 16 | * 17 | * @v seed Seed value 18 | */ 19 | void srandom ( unsigned int seed ) { 20 | rnd_seed = seed; 21 | } 22 | 23 | /** 24 | * Generate a pseudo-random number between 0 and 2147483647L or 2147483562? 25 | * 26 | * @ret rand Pseudo-random number 27 | */ 28 | long int random ( void ) { 29 | int32_t q; 30 | 31 | if ( ! rnd_seed ) /* Initialize linear congruential generator */ 32 | srandom ( currticks() ); 33 | 34 | /* simplified version of the LCG given in Bruce Schneier's 35 | "Applied Cryptography" */ 36 | q = ( rnd_seed / 53668 ); 37 | rnd_seed = ( 40014 * ( rnd_seed - 53668 * q ) - 12211 * q ); 38 | if ( rnd_seed < 0 ) 39 | rnd_seed += 2147483563L; 40 | return rnd_seed; 41 | } 42 | -------------------------------------------------------------------------------- /src/core/serial_console.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "console.h" 4 | 5 | /** @file 6 | * 7 | * Serial console 8 | * 9 | */ 10 | 11 | struct console_driver serial_console __console_driver; 12 | 13 | static void serial_console_init ( void ) { 14 | /* Serial driver initialization should already be done, 15 | * time to enable the serial console. */ 16 | serial_console.disabled = 0; 17 | } 18 | 19 | struct console_driver serial_console __console_driver = { 20 | .putchar = serial_putc, 21 | .getchar = serial_getc, 22 | .iskey = serial_ischar, 23 | .disabled = 1, 24 | }; 25 | 26 | /** 27 | * Serial console initialisation function 28 | */ 29 | struct init_fn serial_console_init_fn __init_fn ( INIT_CONSOLE ) = { 30 | .initialise = serial_console_init, 31 | }; 32 | -------------------------------------------------------------------------------- /src/core/timer.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2008 Michael Brown . 3 | * 4 | * This program is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU General Public License as 6 | * published by the Free Software Foundation; either version 2 of the 7 | * License, or any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, but 10 | * WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | */ 18 | 19 | FILE_LICENCE ( GPL2_OR_LATER ); 20 | 21 | #include 22 | 23 | /** 24 | * Delay for a fixed number of milliseconds 25 | * 26 | * @v msecs Number of milliseconds for which to delay 27 | */ 28 | void mdelay ( unsigned long msecs ) { 29 | while ( msecs-- ) 30 | udelay ( 1000 ); 31 | } 32 | 33 | /** 34 | * Delay for a fixed number of seconds 35 | * 36 | * @v secs Number of seconds for which to delay 37 | */ 38 | unsigned int sleep ( unsigned int secs ) { 39 | while ( secs-- ) 40 | mdelay ( 1000 ); 41 | return 0; 42 | } 43 | -------------------------------------------------------------------------------- /src/crypto/axtls/os_port.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file os_port.h 3 | * 4 | * Trick the axtls code into building within our build environment. 5 | */ 6 | 7 | #ifndef HEADER_OS_PORT_H 8 | #define HEADER_OS_PORT_H 9 | 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | 17 | #define STDCALL 18 | #define EXP_FUNC 19 | #define TTY_FLUSH() 20 | 21 | /** We can't actually abort, since we are effectively a kernel... */ 22 | #define abort() assert ( 0 ) 23 | 24 | /** crypto_misc.c has a bad #ifdef */ 25 | static inline void close ( int fd __unused ) { 26 | /* Do nothing */ 27 | } 28 | 29 | typedef void FILE; 30 | 31 | static inline FILE * fopen ( const char *filename __unused, 32 | const char *mode __unused ) { 33 | return NULL; 34 | } 35 | 36 | static inline int fseek ( FILE *stream __unused, long offset __unused, 37 | int whence __unused ) { 38 | return -1; 39 | } 40 | 41 | static inline long ftell ( FILE *stream __unused ) { 42 | return -1; 43 | } 44 | 45 | static inline size_t fread ( void *ptr __unused, size_t size __unused, 46 | size_t nmemb __unused, FILE *stream __unused ) { 47 | return -1; 48 | } 49 | 50 | static inline int fclose ( FILE *stream __unused ) { 51 | return -1; 52 | } 53 | 54 | #define CONFIG_SSL_CERT_VERIFICATION 1 55 | #define CONFIG_SSL_MAX_CERTS 1 56 | #define CONFIG_X509_MAX_CA_CERTS 1 57 | #define CONFIG_SSL_EXPIRY_TIME 24 58 | #define CONFIG_SSL_ENABLE_CLIENT 1 59 | #define CONFIG_BIGINT_CLASSICAL 1 60 | 61 | #endif 62 | -------------------------------------------------------------------------------- /src/crypto/axtls_sha1.c: -------------------------------------------------------------------------------- 1 | #include "crypto/axtls/crypto.h" 2 | #include 3 | #include 4 | 5 | static void sha1_init ( void *ctx ) { 6 | SHA1Init ( ctx ); 7 | } 8 | 9 | static void sha1_update ( void *ctx, const void *data, size_t len ) { 10 | SHA1Update ( ctx, data, len ); 11 | } 12 | 13 | static void sha1_final ( void *ctx, void *out ) { 14 | SHA1Final ( ctx, out ); 15 | } 16 | 17 | struct digest_algorithm sha1_algorithm = { 18 | .name = "sha1", 19 | .ctxsize = SHA1_CTX_SIZE, 20 | .blocksize = 64, 21 | .digestsize = SHA1_DIGEST_SIZE, 22 | .init = sha1_init, 23 | .update = sha1_update, 24 | .final = sha1_final, 25 | }; 26 | -------------------------------------------------------------------------------- /src/drivers/bus/eisa.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/etherboot/gpxe/c23508d796325f8af724ad497c99ffb5a49abea0/src/drivers/bus/eisa.c -------------------------------------------------------------------------------- /src/drivers/bus/isa_ids.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | /* 7 | * EISA and ISAPnP IDs are actually mildly human readable, though in a 8 | * somewhat brain-damaged way. 9 | * 10 | */ 11 | char * isa_id_string ( unsigned int vendor, unsigned int product ) { 12 | static char buf[7]; 13 | int i; 14 | 15 | /* Vendor ID is a compressed ASCII string */ 16 | vendor = bswap_16 ( vendor ); 17 | for ( i = 2 ; i >= 0 ; i-- ) { 18 | buf[i] = ( 'A' - 1 + ( vendor & 0x1f ) ); 19 | vendor >>= 5; 20 | } 21 | 22 | /* Product ID is a 4-digit hex string */ 23 | sprintf ( &buf[3], "%04x", bswap_16 ( product ) ); 24 | 25 | return buf; 26 | } 27 | -------------------------------------------------------------------------------- /src/drivers/infiniband/MT25408_PRM.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/etherboot/gpxe/c23508d796325f8af724ad497c99ffb5a49abea0/src/drivers/infiniband/MT25408_PRM.h -------------------------------------------------------------------------------- /src/drivers/net/3c503.c: -------------------------------------------------------------------------------- 1 | /* 3Com 3c503, a memory-mapped NS8390-based card */ 2 | #if 0 /* Currently broken! */ 3 | #define INCLUDE_3C503 4 | #include "ns8390.c" 5 | #endif 6 | -------------------------------------------------------------------------------- /src/drivers/net/3c509-eisa.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Split out from 3c509.c, since EISA cards are relatively rare, and 3 | * ROM space in 3c509s is very limited. 4 | * 5 | */ 6 | 7 | #include 8 | #include 9 | #include "console.h" 10 | #include "3c509.h" 11 | 12 | /* 13 | * The EISA probe function 14 | * 15 | */ 16 | static int el3_eisa_probe ( struct nic *nic, struct eisa_device *eisa ) { 17 | 18 | 19 | nic->ioaddr = eisa->ioaddr; 20 | nic->irqno = 0; 21 | enable_eisa_device ( eisa ); 22 | 23 | /* Hand off to generic t5x9 probe routine */ 24 | return t5x9_probe ( nic, ISA_PROD_ID ( PROD_ID ), ISA_PROD_ID_MASK ); 25 | } 26 | 27 | static void el3_eisa_disable ( struct nic *nic, struct eisa_device *eisa ) { 28 | t5x9_disable ( nic ); 29 | disable_eisa_device ( eisa ); 30 | } 31 | 32 | static struct eisa_device_id el3_eisa_adapters[] = { 33 | { "3Com 3c509 EtherLink III (EISA)", MFG_ID, PROD_ID }, 34 | }; 35 | 36 | EISA_DRIVER ( el3_eisa_driver, el3_eisa_adapters ); 37 | 38 | DRIVER ( "3c509 (EISA)", nic_driver, eisa_driver, el3_eisa_driver, 39 | el3_eisa_probe, el3_eisa_disable ); 40 | 41 | ISA_ROM ( "3c509-eisa","3c509 (EISA)" ); 42 | 43 | /* 44 | * Local variables: 45 | * c-basic-offset: 8 46 | * c-indent-level: 8 47 | * tab-width: 8 48 | * End: 49 | */ 50 | -------------------------------------------------------------------------------- /src/drivers/net/e1000/e1000.c: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | 3 | Intel PRO/1000 Linux driver 4 | Copyright(c) 1999 - 2008 Intel Corporation. 5 | 6 | This program is free software; you can redistribute it and/or modify it 7 | under the terms and conditions of the GNU General Public License, 8 | version 2, as published by the Free Software Foundation. 9 | 10 | This program is distributed in the hope it will be useful, but WITHOUT 11 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 12 | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 13 | more details. 14 | 15 | You should have received a copy of the GNU General Public License along with 16 | this program; if not, write to the Free Software Foundation, Inc., 17 | 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. 18 | 19 | The full GNU General Public License is included in this distribution in 20 | the file called "COPYING". 21 | 22 | Contact Information: 23 | Linux NICS 24 | e1000-devel Mailing List 25 | Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 26 | 27 | *******************************************************************************/ 28 | 29 | FILE_LICENCE ( GPL2_ONLY ); 30 | 31 | REQUIRE_OBJECT(e1000_main); 32 | REQUIRE_OBJECT(e1000_82540); 33 | REQUIRE_OBJECT(e1000_82541); 34 | REQUIRE_OBJECT(e1000_82542); 35 | REQUIRE_OBJECT(e1000_82543); 36 | -------------------------------------------------------------------------------- /src/drivers/net/e1000e/e1000e.c: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | 3 | Intel PRO/1000 Linux driver 4 | Copyright(c) 1999 - 2008 Intel Corporation. 5 | 6 | This program is free software; you can redistribute it and/or modify it 7 | under the terms and conditions of the GNU General Public License, 8 | version 2, as published by the Free Software Foundation. 9 | 10 | This program is distributed in the hope it will be useful, but WITHOUT 11 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 12 | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 13 | more details. 14 | 15 | You should have received a copy of the GNU General Public License along with 16 | this program; if not, write to the Free Software Foundation, Inc., 17 | 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. 18 | 19 | The full GNU General Public License is included in this distribution in 20 | the file called "COPYING". 21 | 22 | Contact Information: 23 | Linux NICS 24 | e1000-devel Mailing List 25 | Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 26 | 27 | *******************************************************************************/ 28 | 29 | FILE_LICENCE ( GPL2_ONLY ); 30 | 31 | REQUIRE_OBJECT(e1000e_main); 32 | REQUIRE_OBJECT(e1000e_80003es2lan); 33 | REQUIRE_OBJECT(e1000e_82571); 34 | REQUIRE_OBJECT(e1000e_ich8lan); 35 | -------------------------------------------------------------------------------- /src/drivers/net/efi/snp.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010 VMware, Inc. All Rights Reserved. 3 | * 4 | * This program is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU General Public License as 6 | * published by the Free Software Foundation; either version 2 of the 7 | * License, or any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, but 10 | * WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 17 | */ 18 | 19 | #ifndef _SNP_H 20 | #define _SNP_H 21 | 22 | /** @file 23 | * 24 | * SNP driver 25 | * 26 | */ 27 | 28 | FILE_LICENCE ( GPL2_OR_LATER ); 29 | 30 | #include 31 | #include 32 | #include 33 | 34 | /** A network device that consumes the EFI Simple Network Protocol */ 35 | struct snp_device { 36 | /** Underlying simple network protocol instance */ 37 | EFI_SIMPLE_NETWORK_PROTOCOL *snp; 38 | 39 | /** Generic device */ 40 | struct device dev; 41 | 42 | /** Network device */ 43 | struct net_device *netdev; 44 | 45 | /** State to put the snp in when removing the device */ 46 | uint32 removal_state; 47 | }; 48 | 49 | #endif /* _SNP_H */ 50 | -------------------------------------------------------------------------------- /src/drivers/net/efi/snpnet.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010 VMware, Inc. All Rights Reserved. 3 | * 4 | * This program is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU General Public License as 6 | * published by the Free Software Foundation; either version 2 of the 7 | * License, or any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, but 10 | * WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 17 | */ 18 | 19 | #ifndef _SNPNET_H 20 | #define _SNPNET_H 21 | 22 | /** @file 23 | * 24 | * EFI Simple Network Protocol network device driver 25 | * 26 | */ 27 | 28 | FILE_LICENCE ( GPL2_OR_LATER ); 29 | 30 | struct snp_device; 31 | 32 | extern int snpnet_probe ( struct snp_device *snpdev ); 33 | extern void snpnet_remove ( struct snp_device *snpdev ); 34 | 35 | #endif /* _SNPNET_H */ 36 | -------------------------------------------------------------------------------- /src/drivers/net/igb/igb.c: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | 3 | Intel PRO/1000 Linux driver 4 | Copyright(c) 1999 - 2008 Intel Corporation. 5 | 6 | This program is free software; you can redistribute it and/or modify it 7 | under the terms and conditions of the GNU General Public License, 8 | version 2, as published by the Free Software Foundation. 9 | 10 | This program is distributed in the hope it will be useful, but WITHOUT 11 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 12 | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 13 | more details. 14 | 15 | You should have received a copy of the GNU General Public License along with 16 | this program; if not, write to the Free Software Foundation, Inc., 17 | 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. 18 | 19 | The full GNU General Public License is included in this distribution in 20 | the file called "COPYING". 21 | 22 | Contact Information: 23 | Linux NICS 24 | e1000-devel Mailing List 25 | Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 26 | 27 | *******************************************************************************/ 28 | 29 | FILE_LICENCE ( GPL2_ONLY ); 30 | 31 | REQUIRE_OBJECT(igb_main); 32 | REQUIRE_OBJECT(igb_82575); 33 | -------------------------------------------------------------------------------- /src/drivers/net/ne.c: -------------------------------------------------------------------------------- 1 | /* ISA I/O mapped NS8390-based cards, including NE2000 */ 2 | #if 0 /* Currently broken! */ 3 | #define INCLUDE_NE 1 4 | #define NE_SCAN 0x300,0x280,0x320,0x340,0x380 5 | #include "ns8390.c" 6 | #endif 7 | -------------------------------------------------------------------------------- /src/drivers/net/rtl818x/rtl8180.c: -------------------------------------------------------------------------------- 1 | /* Realtek 8180 card: rtl818x driver + rtl8180 RF modules */ 2 | 3 | FILE_LICENCE(GPL2_OR_LATER); 4 | 5 | #include 6 | 7 | REQUIRE_OBJECT(rtl818x); 8 | REQUIRE_OBJECT(rtl8180_grf5101); 9 | REQUIRE_OBJECT(rtl8180_max2820); 10 | REQUIRE_OBJECT(rtl8180_sa2400); 11 | 12 | static struct pci_device_id rtl8180_nics[] __unused = { 13 | PCI_ROM(0x10ec, 0x8180, "rtl8180", "Realtek 8180", 0), 14 | PCI_ROM(0x1799, 0x6001, "f5d6001", "Belkin F5D6001", 0), 15 | PCI_ROM(0x1799, 0x6020, "f5d6020", "Belkin F5D6020", 0), 16 | PCI_ROM(0x1186, 0x3300, "dwl510", "D-Link DWL-510", 0), 17 | }; 18 | -------------------------------------------------------------------------------- /src/drivers/net/rtl818x/rtl8185.c: -------------------------------------------------------------------------------- 1 | /* Realtek 8185 card: rtl818x driver + rtl8185_rtl8225 RF module */ 2 | 3 | FILE_LICENCE(GPL2_OR_LATER); 4 | 5 | #include 6 | 7 | REQUIRE_OBJECT(rtl818x); 8 | REQUIRE_OBJECT(rtl8185_rtl8225); 9 | 10 | static struct pci_device_id rtl8185_nics[] __unused = { 11 | PCI_ROM(0x10ec, 0x8185, "rtl8185", "Realtek 8185", 0), 12 | PCI_ROM(0x1799, 0x700f, "f5d7000", "Belkin F5D7000", 0), 13 | PCI_ROM(0x1799, 0x701f, "f5d7010", "Belkin F5D7010", 0), 14 | }; 15 | -------------------------------------------------------------------------------- /src/drivers/net/smc9000.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/etherboot/gpxe/c23508d796325f8af724ad497c99ffb5a49abea0/src/drivers/net/smc9000.c -------------------------------------------------------------------------------- /src/drivers/net/smc9000.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/etherboot/gpxe/c23508d796325f8af724ad497c99ffb5a49abea0/src/drivers/net/smc9000.h -------------------------------------------------------------------------------- /src/drivers/net/vxge/vxge.c: -------------------------------------------------------------------------------- 1 | /** @file Stub file for vxge driver 2 | * 3 | * This file drags in the rest of the driver for Neterion Inc's X3100 Series 4 | * 10GbE PCIe I/O Virtualized Server Adapter, allowing the driver to be built 5 | * as "vxge" even though the code is in vxge_* named files. 6 | */ 7 | 8 | FILE_LICENCE(GPL2_OR_LATER); 9 | 10 | #include 11 | 12 | REQUIRE_OBJECT(vxge_main); 13 | 14 | /** vxge PCI IDs for util/parserom.pl which are put into bin/NIC */ 15 | static struct pci_device_id vxge_nics[] __unused = { 16 | /* If you change this, also adjust vxge_main_nics[] in vxge_main.c */ 17 | PCI_ROM(0x17d5, 0x5833, "vxge-x3100", "Neterion X3100 Series", 0), 18 | }; 19 | -------------------------------------------------------------------------------- /src/drivers/net/vxge/vxge_version.h: -------------------------------------------------------------------------------- 1 | /* 2 | * vxge-version.h: gPXE driver for Neterion Inc's X3100 Series 10GbE 3 | * PCIe I/O Virtualized Server Adapter. 4 | * 5 | * Copyright(c) 2002-2010 Neterion Inc. 6 | * 7 | * This software may be used and distributed according to the terms of 8 | * the GNU General Public License (GPL), incorporated herein by 9 | * reference. Drivers based on or derived from this code fall under 10 | * the GPL and must retain the authorship, copyright and license 11 | * notice. 12 | * 13 | */ 14 | 15 | FILE_LICENCE(GPL2_ONLY); 16 | 17 | #ifndef VXGE_VERSION_H 18 | 19 | #define VXGE_VERSION_H 20 | 21 | /* gpxe vxge driver version fields. 22 | * Note: Each field must be a nibble size 23 | */ 24 | #define VXGE_VERSION_MAJOR 3 25 | #define VXGE_VERSION_MINOR 1 26 | #define VXGE_VERSION_FIX 0 27 | #define VXGE_VERSION_BUILD 0 28 | 29 | #define VXGE_FW_VER(major, minor, build) \ 30 | (((major) << 16) + ((minor) << 8) + (build)) 31 | 32 | /* Certified FW version. */ 33 | #define VXGE_CERT_FW_VER_MAJOR 1 34 | #define VXGE_CERT_FW_VER_MINOR 6 35 | #define VXGE_CERT_FW_VER_BUILD 0 36 | 37 | #define VXGE_CERT_FW_VER VXGE_FW_VER(VXGE_CERT_FW_VER_MAJOR, \ 38 | VXGE_CERT_FW_VER_MINOR, VXGE_CERT_FW_VER_BUILD) 39 | 40 | #endif 41 | -------------------------------------------------------------------------------- /src/drivers/net/wd.c: -------------------------------------------------------------------------------- 1 | /* ISA memory-mapped NS8390-based cards, including WD80x3 */ 2 | #if 0 /* Currently broken! */ 3 | #define INCLUDE_WD 4 | #define WD_DEFAULT_MEM 0xCC000 5 | #include "ns8390.c" 6 | #endif 7 | -------------------------------------------------------------------------------- /src/hci/commands/autoboot_cmd.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | FILE_LICENCE ( GPL2_OR_LATER ); 6 | 7 | static int autoboot_exec ( int argc, char **argv ) { 8 | 9 | if ( argc != 1 ) { 10 | printf ( "Usage:\n" 11 | " %s\n" 12 | "\n" 13 | "Attempts to boot the system\n", 14 | argv[0] ); 15 | return 1; 16 | } 17 | 18 | autoboot(); 19 | 20 | /* Can never return success by definition */ 21 | return 1; 22 | } 23 | 24 | struct command autoboot_command __command = { 25 | .name = "autoboot", 26 | .exec = autoboot_exec, 27 | }; 28 | -------------------------------------------------------------------------------- /src/hci/commands/config_cmd.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | FILE_LICENCE ( GPL2_OR_LATER ); 8 | 9 | static int config_exec ( int argc, char **argv ) { 10 | char *settings_name; 11 | struct settings *settings; 12 | int rc; 13 | 14 | if ( argc > 2 ) { 15 | printf ( "Usage: %s [scope]\n" 16 | "Opens the option configuration console\n", argv[0] ); 17 | return 1; 18 | } 19 | 20 | settings_name = ( ( argc == 2 ) ? argv[1] : "" ); 21 | settings = find_settings ( settings_name ); 22 | if ( ! settings ) { 23 | printf ( "No such scope \"%s\"\n", settings_name ); 24 | return 1; 25 | } 26 | 27 | if ( ( rc = settings_ui ( settings ) ) != 0 ) { 28 | printf ( "Could not save settings: %s\n", 29 | strerror ( rc ) ); 30 | return 1; 31 | } 32 | 33 | return 0; 34 | } 35 | 36 | struct command config_command __command = { 37 | .name = "config", 38 | .exec = config_exec, 39 | }; 40 | -------------------------------------------------------------------------------- /src/hci/commands/login_cmd.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | FILE_LICENCE ( GPL2_OR_LATER ); 7 | 8 | static int login_exec ( int argc, char **argv ) { 9 | int rc; 10 | 11 | if ( argc > 1 ) { 12 | printf ( "Usage: %s\n" 13 | "Prompt for login credentials\n", argv[0] ); 14 | return 1; 15 | } 16 | 17 | if ( ( rc = login_ui() ) != 0 ) { 18 | printf ( "Could not set credentials: %s\n", 19 | strerror ( rc ) ); 20 | return 1; 21 | } 22 | 23 | return 0; 24 | } 25 | 26 | struct command login_command __command = { 27 | .name = "login", 28 | .exec = login_exec, 29 | }; 30 | -------------------------------------------------------------------------------- /src/hci/mucurses/alert.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | /** @file 5 | * 6 | * MuCurses alert functions 7 | * 8 | */ 9 | 10 | /** 11 | * Audible signal 12 | * 13 | * @ret rc return status code 14 | */ 15 | int beep ( void ) { 16 | printf("\a"); 17 | return OK; 18 | } 19 | -------------------------------------------------------------------------------- /src/hci/mucurses/cursor.h: -------------------------------------------------------------------------------- 1 | #ifndef CURSOR_H 2 | #define CURSOR_H 3 | 4 | /** @file 5 | * 6 | * MuCurses cursor implementation specific header file 7 | * 8 | */ 9 | 10 | FILE_LICENCE ( GPL2_OR_LATER ); 11 | 12 | struct cursor_pos { 13 | unsigned int y, x; 14 | }; 15 | 16 | /** 17 | * Restore cursor position from encoded backup variable 18 | * 19 | * @v *win window on which to operate 20 | * @v *pos pointer to struct in which original cursor position is stored 21 | */ 22 | static inline void _restore_curs_pos ( WINDOW *win, struct cursor_pos *pos ) { 23 | wmove ( win, pos->y, pos->x ); 24 | } 25 | 26 | /** 27 | * Store cursor position for later restoration 28 | * 29 | * @v *win window on which to operate 30 | * @v *pos pointer to struct in which to store cursor position 31 | */ 32 | static inline void _store_curs_pos ( WINDOW *win, struct cursor_pos *pos ) { 33 | pos->y = win->curs_y; 34 | pos->x = win->curs_x; 35 | } 36 | 37 | #endif /* CURSOR_H */ 38 | -------------------------------------------------------------------------------- /src/hci/mucurses/mucurses.h: -------------------------------------------------------------------------------- 1 | #ifndef _MUCURSES_H 2 | #define _MUCURSES_H 3 | 4 | /** @file 5 | * 6 | * MuCurses core implementation specific header file 7 | * 8 | */ 9 | 10 | FILE_LICENCE ( GPL2_OR_LATER ); 11 | 12 | #define WRAP 0 13 | #define NOWRAP 1 14 | 15 | extern SCREEN _ansi_screen; 16 | 17 | extern void _wputch ( WINDOW *win, chtype ch, int wrap ) __nonnull; 18 | extern void _wputc ( WINDOW *win, char c, int wrap ) __nonnull; 19 | extern void _wputchstr ( WINDOW *win, const chtype *chstr, int wrap, int n ) __nonnull; 20 | extern void _wputstr ( WINDOW *win, const char *str, int wrap, int n ) __nonnull; 21 | extern void _wcursback ( WINDOW *win ) __nonnull; 22 | 23 | #endif /* _MUCURSES_H */ 24 | -------------------------------------------------------------------------------- /src/hci/mucurses/print_nadv.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "mucurses.h" 3 | #include "cursor.h" 4 | 5 | /** @file 6 | * 7 | * MuCurses printing functions (no cursor advance) 8 | * 9 | */ 10 | 11 | /** 12 | * Add string of single-byte characters and renditions to a window 13 | * 14 | * @v *win window to be rendered in 15 | * @v *chstr pointer to first chtype in "string" 16 | * @v n max number of chars from chstr to render 17 | * @ret rc return status code 18 | */ 19 | int waddchnstr ( WINDOW *win, const chtype *chstr, int n ) { 20 | struct cursor_pos pos; 21 | 22 | _store_curs_pos( win, &pos ); 23 | _wputchstr( win, chstr, NOWRAP, n ); 24 | _restore_curs_pos( win, &pos ); 25 | return OK; 26 | } 27 | -------------------------------------------------------------------------------- /src/hci/mucurses/wininit.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | /** @file 5 | * 6 | * MuCurses initialisation functions 7 | * 8 | */ 9 | 10 | FILE_LICENCE ( GPL2_OR_LATER ); 11 | 12 | /** 13 | * Initialise console environment 14 | * 15 | * @ret *win return pointer to stdscr 16 | */ 17 | WINDOW *initscr ( void ) { 18 | /* determine console size */ 19 | /* initialise screen */ 20 | stdscr->scr->init( stdscr->scr ); 21 | stdscr->height = LINES; 22 | stdscr->width = COLS; 23 | move ( 0, 0 ); 24 | return stdscr; 25 | } 26 | 27 | /** 28 | * Finalise console environment 29 | * 30 | */ 31 | int endwin ( void ) { 32 | attrset ( 0 ); 33 | color_set ( 0, NULL ); 34 | mvprintw ( ( LINES - 1 ), 0, "\n" ); 35 | stdscr->scr->exit( stdscr->scr ); 36 | return OK; 37 | } 38 | -------------------------------------------------------------------------------- /src/include/.gitignore: -------------------------------------------------------------------------------- 1 | .buildserial.h 2 | -------------------------------------------------------------------------------- /src/include/alloca.h: -------------------------------------------------------------------------------- 1 | #ifndef _ALLOCA_H 2 | #define _ALLOCA_H 3 | 4 | /** 5 | * @file 6 | * 7 | * Temporary memory allocation 8 | * 9 | */ 10 | 11 | #include 12 | 13 | /** 14 | * Allocate temporary memory from the stack 15 | * 16 | * @v size Size to allocate 17 | * @ret ptr Allocated memory 18 | * 19 | * This memory will be freed automatically when the containing 20 | * function returns. There are several caveats regarding use of 21 | * alloca(); use it only if you already know what they are. 22 | */ 23 | #define alloca(size) __builtin_alloca ( size ) 24 | 25 | #endif /* _ALLOCA_H */ 26 | -------------------------------------------------------------------------------- /src/include/big_bswap.h: -------------------------------------------------------------------------------- 1 | #ifndef ETHERBOOT_BIG_BSWAP_H 2 | #define ETHERBOOT_BIG_BSWAP_H 3 | 4 | #define ntohl(x) (x) 5 | #define htonl(x) (x) 6 | #define ntohs(x) (x) 7 | #define htons(x) (x) 8 | #define cpu_to_le64(x) __bswap_64(x) 9 | #define cpu_to_le32(x) __bswap_32(x) 10 | #define cpu_to_le16(x) __bswap_16(x) 11 | #define cpu_to_be64(x) (x) 12 | #define cpu_to_be32(x) (x) 13 | #define cpu_to_be16(x) (x) 14 | #define le64_to_cpu(x) __bswap_64(x) 15 | #define le32_to_cpu(x) __bswap_32(x) 16 | #define le16_to_cpu(x) __bswap_16(x) 17 | #define be64_to_cpu(x) (x) 18 | #define be32_to_cpu(x) (x) 19 | #define be16_to_cpu(x) (x) 20 | #define cpu_to_le64s(x) __bswap_64s(x) 21 | #define cpu_to_le32s(x) __bswap_32s(x) 22 | #define cpu_to_le16s(x) __bswap_16s(x) 23 | #define cpu_to_be64s(x) do {} while (0) 24 | #define cpu_to_be32s(x) do {} while (0) 25 | #define cpu_to_be16s(x) do {} while (0) 26 | #define le64_to_cpus(x) __bswap_64s(x) 27 | #define le32_to_cpus(x) __bswap_32s(x) 28 | #define le16_to_cpus(x) __bswap_16s(x) 29 | #define be64_to_cpus(x) do {} while (0) 30 | #define be32_to_cpus(x) do {} while (0) 31 | #define be16_to_cpus(x) do {} while (0) 32 | 33 | #endif /* ETHERBOOT_BIG_BSWAP_H */ 34 | -------------------------------------------------------------------------------- /src/include/cmdline.h: -------------------------------------------------------------------------------- 1 | #ifndef CMDLINE_H 2 | #define CMDLINE_H 3 | 4 | /* Command line external functions */ 5 | 6 | void cmdl_start(); 7 | 8 | #endif 9 | -------------------------------------------------------------------------------- /src/include/cmdlist.h: -------------------------------------------------------------------------------- 1 | #ifndef COMMANDLIST_H 2 | #define COMMANDLIST_H 3 | 4 | void test_req(); 5 | void test2_req(); 6 | void help_req(); 7 | void nvo_cmd_req(); 8 | 9 | void commandlist() 10 | { 11 | // test_req(); 12 | // test2_req(); 13 | help_req(); 14 | nvo_cmd_req(); 15 | } 16 | 17 | #endif 18 | 19 | -------------------------------------------------------------------------------- /src/include/cpu.h: -------------------------------------------------------------------------------- 1 | #ifndef CPU_H 2 | #define CPU_H 3 | 4 | #include "bits/cpu.h" 5 | 6 | #endif /* CPU_H */ 7 | -------------------------------------------------------------------------------- /src/include/ctype.h: -------------------------------------------------------------------------------- 1 | #ifndef _CTYPE_H 2 | #define _CTYPE_H 3 | 4 | /** @file 5 | * 6 | * Character types 7 | */ 8 | 9 | FILE_LICENCE ( GPL2_OR_LATER ); 10 | 11 | #define isdigit(c) ((c) >= '0' && (c) <= '9') 12 | #define islower(c) ((c) >= 'a' && (c) <= 'z') 13 | #define isupper(c) ((c) >= 'A' && (c) <= 'Z') 14 | 15 | static inline unsigned char tolower(unsigned char c) 16 | { 17 | if (isupper(c)) 18 | c -= 'A'-'a'; 19 | return c; 20 | } 21 | 22 | static inline unsigned char toupper(unsigned char c) 23 | { 24 | if (islower(c)) 25 | c -= 'a'-'A'; 26 | return c; 27 | } 28 | 29 | extern int isspace ( int c ); 30 | 31 | #endif /* _CTYPE_H */ 32 | -------------------------------------------------------------------------------- /src/include/endian.h: -------------------------------------------------------------------------------- 1 | #ifndef ETHERBOOT_ENDIAN_H 2 | #define ETHERBOOT_ENDIAN_H 3 | 4 | FILE_LICENCE ( GPL2_OR_LATER ); 5 | 6 | /* Definitions for byte order, according to significance of bytes, 7 | from low addresses to high addresses. The value is what you get by 8 | putting '4' in the most significant byte, '3' in the second most 9 | significant byte, '2' in the second least significant byte, and '1' 10 | in the least significant byte, and then writing down one digit for 11 | each byte, starting with the byte at the lowest address at the left, 12 | and proceeding to the byte with the highest address at the right. */ 13 | 14 | #define __LITTLE_ENDIAN 1234 15 | #define __BIG_ENDIAN 4321 16 | #define __PDP_ENDIAN 3412 17 | 18 | #include "bits/endian.h" 19 | 20 | 21 | #endif /* ETHERBOOT_ENDIAN_H */ 22 | -------------------------------------------------------------------------------- /src/include/etherboot.h: -------------------------------------------------------------------------------- 1 | #ifndef ETHERBOOT_H 2 | #define ETHERBOOT_H 3 | 4 | /* 5 | * Standard includes that we always want 6 | * 7 | */ 8 | 9 | FILE_LICENCE ( GPL2_OR_LATER ); 10 | 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | 22 | typedef unsigned long Address; 23 | 24 | /* 25 | * IMPORTANT!!!!!!!!!!!!!! 26 | * 27 | * Everything below this point is cruft left over from older versions 28 | * of Etherboot. Do not add *anything* below this point. Things are 29 | * gradually being moved to individual header files. 30 | * 31 | */ 32 | 33 | /* Link configuration time in tenths of a second */ 34 | #ifndef VALID_LINK_TIMEOUT 35 | #define VALID_LINK_TIMEOUT 100 /* 10.0 seconds */ 36 | #endif 37 | 38 | /* 39 | * Local variables: 40 | * c-basic-offset: 8 41 | * End: 42 | */ 43 | 44 | #endif /* ETHERBOOT_H */ 45 | -------------------------------------------------------------------------------- /src/include/fs.h: -------------------------------------------------------------------------------- 1 | #ifndef FS_H 2 | #define FS_H 3 | 4 | #include 5 | 6 | //typedef uint64_t sector_t; 7 | 8 | #ifdef IDE_DISK 9 | int ide_probe(int drive); 10 | int ide_read(int drive, sector_t sector, void *buffer); 11 | #endif 12 | 13 | #ifdef USB_DISK 14 | int usb_probe(int drive); 15 | int usb_read(int drive, sector_t sector, void *buffer); 16 | #endif 17 | 18 | #define DISK_IDE 1 19 | #define DISK_MEM 2 20 | #define DISK_USB 3 21 | 22 | int devopen(const char *name, int *reopen); 23 | int devread(unsigned long sector, unsigned long byte_offset, 24 | unsigned long byte_len, void *buf); 25 | 26 | int file_open(const char *filename); 27 | int file_read(void *buf, unsigned long len); 28 | int file_seek(unsigned long offset); 29 | unsigned long file_size(void); 30 | 31 | #define PARTITION_UNKNOWN 0xbad6a7 32 | 33 | #ifdef ELTORITO 34 | int open_eltorito_image(int part, unsigned long *start, unsigned long *length); 35 | #else 36 | # define open_eltorito_image(x,y,z) PARTITION_UNKNOWN 37 | #endif 38 | 39 | extern int using_devsize; 40 | 41 | #endif /* FS_H */ 42 | -------------------------------------------------------------------------------- /src/include/gpxe/acpi.h: -------------------------------------------------------------------------------- 1 | #ifndef _GPXE_ACPI_H 2 | #define _GPXE_ACPI_H 3 | 4 | /** @file 5 | * 6 | * ACPI data structures 7 | * 8 | */ 9 | 10 | FILE_LICENCE ( GPL2_OR_LATER ); 11 | 12 | #include 13 | 14 | /** 15 | * An ACPI description header 16 | * 17 | * This is the structure common to the start of all ACPI system 18 | * description tables. 19 | */ 20 | struct acpi_description_header { 21 | /** ACPI signature (4 ASCII characters) */ 22 | char signature[4]; 23 | /** Length of table, in bytes, including header */ 24 | uint32_t length; 25 | /** ACPI Specification minor version number */ 26 | uint8_t revision; 27 | /** To make sum of entire table == 0 */ 28 | uint8_t checksum; 29 | /** OEM identification */ 30 | char oem_id[6]; 31 | /** OEM table identification */ 32 | char oem_table_id[8]; 33 | /** OEM revision number */ 34 | uint32_t oem_revision; 35 | /** ASL compiler vendor ID */ 36 | char asl_compiler_id[4]; 37 | /** ASL compiler revision number */ 38 | uint32_t asl_compiler_revision; 39 | } __attribute__ (( packed )); 40 | 41 | extern void acpi_fix_checksum ( struct acpi_description_header *acpi ); 42 | 43 | #endif /* _GPXE_ACPI_H */ 44 | -------------------------------------------------------------------------------- /src/include/gpxe/aes.h: -------------------------------------------------------------------------------- 1 | #ifndef _GPXE_AES_H 2 | #define _GPXE_AES_H 3 | 4 | FILE_LICENCE ( GPL2_OR_LATER ); 5 | 6 | struct cipher_algorithm; 7 | 8 | /** Basic AES blocksize */ 9 | #define AES_BLOCKSIZE 16 10 | 11 | #include "crypto/axtls/crypto.h" 12 | 13 | /** AES context */ 14 | struct aes_context { 15 | /** AES context for AXTLS */ 16 | AES_CTX axtls_ctx; 17 | /** Cipher is being used for decrypting */ 18 | int decrypting; 19 | }; 20 | 21 | /** AES context size */ 22 | #define AES_CTX_SIZE sizeof ( struct aes_context ) 23 | 24 | extern struct cipher_algorithm aes_algorithm; 25 | extern struct cipher_algorithm aes_cbc_algorithm; 26 | 27 | int aes_wrap ( const void *kek, const void *src, void *dest, int nblk ); 28 | int aes_unwrap ( const void *kek, const void *src, void *dest, int nblk ); 29 | 30 | #endif /* _GPXE_AES_H */ 31 | -------------------------------------------------------------------------------- /src/include/gpxe/arc4.h: -------------------------------------------------------------------------------- 1 | #ifndef _GPXE_ARC4_H 2 | #define _GPXE_ARC4_H 3 | 4 | FILE_LICENCE ( GPL2_OR_LATER ); 5 | 6 | struct cipher_algorithm; 7 | 8 | #include 9 | 10 | struct arc4_ctx { 11 | int i, j; 12 | u8 state[256]; 13 | }; 14 | 15 | #define ARC4_CTX_SIZE sizeof ( struct arc4_ctx ) 16 | 17 | extern struct cipher_algorithm arc4_algorithm; 18 | 19 | void arc4_skip ( const void *key, size_t keylen, size_t skip, 20 | const void *src, void *dst, size_t msglen ); 21 | 22 | #endif /* _GPXE_ARC4_H */ 23 | -------------------------------------------------------------------------------- /src/include/gpxe/arp.h: -------------------------------------------------------------------------------- 1 | #ifndef _GPXE_ARP_H 2 | #define _GPXE_ARP_H 3 | 4 | /** @file 5 | * 6 | * Address Resolution Protocol 7 | * 8 | */ 9 | 10 | FILE_LICENCE ( GPL2_OR_LATER ); 11 | 12 | #include 13 | 14 | struct net_device; 15 | struct net_protocol; 16 | 17 | /** A network-layer protocol that relies upon ARP */ 18 | struct arp_net_protocol { 19 | /** Network-layer protocol */ 20 | struct net_protocol *net_protocol; 21 | /** Check existence of address 22 | * 23 | * @v netdev Network device 24 | * @v net_addr Network-layer address 25 | * @ret rc Return status code 26 | */ 27 | int ( * check ) ( struct net_device *netdev, 28 | const void *net_addr ); 29 | }; 30 | 31 | /** ARP protocol table */ 32 | #define ARP_NET_PROTOCOLS \ 33 | __table ( struct arp_net_protocol, "arp_net_protocols" ) 34 | 35 | /** Declare an ARP protocol */ 36 | #define __arp_net_protocol __table_entry ( ARP_NET_PROTOCOLS, 01 ) 37 | 38 | extern struct net_protocol arp_protocol; 39 | 40 | extern int arp_resolve ( struct net_device *netdev, 41 | struct net_protocol *net_protocol, 42 | const void *dest_net_addr, 43 | const void *source_net_addr, 44 | void *dest_ll_addr ); 45 | 46 | #endif /* _GPXE_ARP_H */ 47 | -------------------------------------------------------------------------------- /src/include/gpxe/asn1.h: -------------------------------------------------------------------------------- 1 | #ifndef _GPXE_ASN1_H 2 | #define _GPXE_ASN1_H 3 | 4 | /** @file 5 | * 6 | * ASN.1 encoding 7 | * 8 | */ 9 | 10 | FILE_LICENCE ( GPL2_OR_LATER ); 11 | 12 | #define ASN1_INTEGER 0x02 13 | #define ASN1_BIT_STRING 0x03 14 | #define ASN1_OCTET_STRING 0x04 15 | #define ASN1_NULL 0x05 16 | #define ASN1_OID 0x06 17 | #define ASN1_SEQUENCE 0x30 18 | #define ASN1_IP_ADDRESS 0x40 19 | #define ASN1_EXPLICIT_TAG 0xa0 20 | 21 | /** 22 | * A DER-encoded ASN.1 object cursor 23 | */ 24 | struct asn1_cursor { 25 | /** Start of data */ 26 | void *data; 27 | /** Length of data */ 28 | size_t len; 29 | }; 30 | 31 | extern int asn1_enter ( struct asn1_cursor *cursor, unsigned int type ); 32 | extern int asn1_skip ( struct asn1_cursor *cursor, unsigned int type ); 33 | 34 | #endif /* _GPXE_ASN1_H */ 35 | -------------------------------------------------------------------------------- /src/include/gpxe/base16.h: -------------------------------------------------------------------------------- 1 | #ifndef _IPXE_BASE16_H 2 | #define _IPXE_BASE16_H 3 | 4 | /** @file 5 | * 6 | * Base16 encoding 7 | * 8 | */ 9 | 10 | FILE_LICENCE ( GPL2_OR_LATER ); 11 | 12 | #include 13 | #include 14 | 15 | /** 16 | * Calculate length of base16-encoded data 17 | * 18 | * @v raw_len Raw data length 19 | * @ret encoded_len Encoded string length (excluding NUL) 20 | */ 21 | static inline size_t base16_encoded_len ( size_t raw_len ) { 22 | return ( 2 * raw_len ); 23 | } 24 | 25 | /** 26 | * Calculate maximum length of base16-decoded string 27 | * 28 | * @v encoded Encoded string 29 | * @v max_raw_len Maximum length of raw data 30 | */ 31 | static inline size_t base16_decoded_max_len ( const char *encoded ) { 32 | return ( ( strlen ( encoded ) + 1 ) / 2 ); 33 | } 34 | 35 | extern void base16_encode ( const uint8_t *raw, size_t len, char *encoded ); 36 | extern int base16_decode ( const char *encoded, uint8_t *raw ); 37 | 38 | #endif /* _IPXE_BASE16_H */ 39 | -------------------------------------------------------------------------------- /src/include/gpxe/base64.h: -------------------------------------------------------------------------------- 1 | #ifndef _GPXE_BASE64_H 2 | #define _GPXE_BASE64_H 3 | 4 | /** @file 5 | * 6 | * Base64 encoding 7 | * 8 | */ 9 | 10 | FILE_LICENCE ( GPL2_OR_LATER ); 11 | 12 | #include 13 | #include 14 | 15 | /** 16 | * Calculate length of base64-encoded data 17 | * 18 | * @v raw_len Raw data length 19 | * @ret encoded_len Encoded string length (excluding NUL) 20 | */ 21 | static inline size_t base64_encoded_len ( size_t raw_len ) { 22 | return ( ( ( raw_len + 3 - 1 ) / 3 ) * 4 ); 23 | } 24 | 25 | /** 26 | * Calculate maximum length of base64-decoded string 27 | * 28 | * @v encoded Encoded string 29 | * @v max_raw_len Maximum length of raw data 30 | * 31 | * Note that the exact length of the raw data cannot be known until 32 | * the string is decoded. 33 | */ 34 | static inline size_t base64_decoded_max_len ( const char *encoded ) { 35 | return ( ( ( strlen ( encoded ) + 4 - 1 ) / 4 ) * 3 ); 36 | } 37 | 38 | extern void base64_encode ( const uint8_t *raw, size_t len, char *encoded ); 39 | extern int base64_decode ( const char *encoded, uint8_t *raw ); 40 | 41 | #endif /* _GPXE_BASE64_H */ 42 | -------------------------------------------------------------------------------- /src/include/gpxe/bitbash.h: -------------------------------------------------------------------------------- 1 | #ifndef _GPXE_BITBASH_H 2 | #define _GPXE_BITBASH_H 3 | 4 | /** @file 5 | * 6 | * Bit-bashing interfaces 7 | * 8 | */ 9 | 10 | FILE_LICENCE ( GPL2_OR_LATER ); 11 | 12 | struct bit_basher; 13 | 14 | /** Bit-bashing operations */ 15 | struct bit_basher_operations { 16 | /** 17 | * Set/clear output bit 18 | * 19 | * @v basher Bit-bashing interface 20 | * @v bit_id Bit number 21 | * @v data Value to write 22 | * 23 | * @c data will be 0 if a logic 0 should be written (i.e. the 24 | * bit should be cleared), or -1UL if a logic 1 should be 25 | * written (i.e. the bit should be set). This is done so that 26 | * the method may simply binary-AND @c data with the 27 | * appropriate bit mask. 28 | */ 29 | void ( * write ) ( struct bit_basher *basher, unsigned int bit_id, 30 | unsigned long data ); 31 | /** 32 | * Read input bit 33 | * 34 | * @v basher Bit-bashing interface 35 | * @v bit_id Bit number 36 | * @ret zero Input is a logic 0 37 | * @ret non-zero Input is a logic 1 38 | */ 39 | int ( * read ) ( struct bit_basher *basher, unsigned int bit_id ); 40 | }; 41 | 42 | /** A bit-bashing interface */ 43 | struct bit_basher { 44 | /** Bit-bashing operations */ 45 | struct bit_basher_operations *op; 46 | }; 47 | 48 | extern void write_bit ( struct bit_basher *basher, unsigned int bit_id, 49 | unsigned long data ); 50 | extern int read_bit ( struct bit_basher *basher, unsigned int bit_id ); 51 | 52 | #endif /* _GPXE_BITBASH_H */ 53 | -------------------------------------------------------------------------------- /src/include/gpxe/blockdev.h: -------------------------------------------------------------------------------- 1 | #ifndef _GPXE_BLOCKDEV_H 2 | #define _GPXE_BLOCKDEV_H 3 | 4 | /** 5 | * @file 6 | * 7 | * Block devices 8 | * 9 | */ 10 | 11 | FILE_LICENCE ( GPL2_OR_LATER ); 12 | 13 | #include 14 | 15 | struct block_device; 16 | 17 | /** Block device operations */ 18 | struct block_device_operations { 19 | /** 20 | * Read block 21 | * 22 | * @v blockdev Block device 23 | * @v block Block number 24 | * @v count Block count 25 | * @v buffer Data buffer 26 | * @ret rc Return status code 27 | */ 28 | int ( * read ) ( struct block_device *blockdev, uint64_t block, 29 | unsigned long count, userptr_t buffer ); 30 | /** 31 | * Write block 32 | * 33 | * @v blockdev Block device 34 | * @v block Block number 35 | * @v count Block count 36 | * @v buffer Data buffer 37 | * @ret rc Return status code 38 | */ 39 | int ( * write ) ( struct block_device *blockdev, uint64_t block, 40 | unsigned long count, userptr_t buffer ); 41 | }; 42 | 43 | /** A block device */ 44 | struct block_device { 45 | /** Block device operations */ 46 | struct block_device_operations *op; 47 | /** Block size */ 48 | size_t blksize; 49 | /** Total number of blocks */ 50 | uint64_t blocks; 51 | }; 52 | 53 | #endif /* _GPXE_BLOCKDEV_H */ 54 | -------------------------------------------------------------------------------- /src/include/gpxe/chap.h: -------------------------------------------------------------------------------- 1 | #ifndef _GPXE_CHAP_H 2 | #define _GPXE_CHAP_H 3 | 4 | /** @file 5 | * 6 | * CHAP protocol 7 | * 8 | */ 9 | 10 | FILE_LICENCE ( GPL2_OR_LATER ); 11 | 12 | #include 13 | #include 14 | 15 | struct digest_algorithm; 16 | 17 | /** A CHAP response */ 18 | struct chap_response { 19 | /** Digest algorithm used for the response */ 20 | struct digest_algorithm *digest; 21 | /** Context used by the digest algorithm */ 22 | uint8_t *digest_context; 23 | /** CHAP response */ 24 | uint8_t *response; 25 | /** Length of CHAP response */ 26 | size_t response_len; 27 | }; 28 | 29 | extern int chap_init ( struct chap_response *chap, 30 | struct digest_algorithm *digest ); 31 | extern void chap_update ( struct chap_response *chap, const void *data, 32 | size_t len ); 33 | extern void chap_respond ( struct chap_response *chap ); 34 | extern void chap_finish ( struct chap_response *chap ); 35 | 36 | /** 37 | * Add identifier data to the CHAP challenge 38 | * 39 | * @v chap CHAP response 40 | * @v identifier CHAP identifier 41 | * 42 | * The CHAP identifier is the first byte of the CHAP challenge. This 43 | * function is a notational convenience for calling chap_update() for 44 | * the identifier byte. 45 | */ 46 | static inline void chap_set_identifier ( struct chap_response *chap, 47 | unsigned int identifier ) { 48 | uint8_t ident_byte = identifier; 49 | 50 | chap_update ( chap, &ident_byte, sizeof ( ident_byte ) ); 51 | } 52 | 53 | #endif /* _GPXE_CHAP_H */ 54 | -------------------------------------------------------------------------------- /src/include/gpxe/command.h: -------------------------------------------------------------------------------- 1 | #ifndef _GPXE_COMMAND_H 2 | #define _GPXE_COMMAND_H 3 | 4 | FILE_LICENCE ( GPL2_OR_LATER ); 5 | 6 | #include 7 | 8 | /** A command-line command */ 9 | struct command { 10 | /** Name of the command */ 11 | const char *name; 12 | /** 13 | * Function implementing the command 14 | * 15 | * @v argc Argument count 16 | * @v argv Argument list 17 | * @ret rc Return status code 18 | */ 19 | int ( * exec ) ( int argc, char **argv ); 20 | }; 21 | 22 | #define COMMANDS __table ( struct command, "commands" ) 23 | 24 | #define __command __table_entry ( COMMANDS, 01 ) 25 | 26 | #endif /* _GPXE_COMMAND_H */ 27 | -------------------------------------------------------------------------------- /src/include/gpxe/cpio.h: -------------------------------------------------------------------------------- 1 | #ifndef _GPXE_CPIO_H 2 | #define _GPXE_CPIO_H 3 | 4 | /** @file 5 | * 6 | * CPIO archives 7 | * 8 | */ 9 | 10 | FILE_LICENCE ( GPL2_OR_LATER ); 11 | 12 | /** A CPIO archive header 13 | * 14 | * All field are hexadecimal ASCII numbers padded with '0' on the 15 | * left to the full width of the field. 16 | */ 17 | struct cpio_header { 18 | /** The string "070701" or "070702" */ 19 | char c_magic[6]; 20 | /** File inode number */ 21 | char c_ino[8]; 22 | /** File mode and permissions */ 23 | char c_mode[8]; 24 | /** File uid */ 25 | char c_uid[8]; 26 | /** File gid */ 27 | char c_gid[8]; 28 | /** Number of links */ 29 | char c_nlink[8]; 30 | /** Modification time */ 31 | char c_mtime[8]; 32 | /** Size of data field */ 33 | char c_filesize[8]; 34 | /** Major part of file device number */ 35 | char c_maj[8]; 36 | /** Minor part of file device number */ 37 | char c_min[8]; 38 | /** Major part of device node reference */ 39 | char c_rmaj[8]; 40 | /** Minor part of device node reference */ 41 | char c_rmin[8]; 42 | /** Length of filename, including final NUL */ 43 | char c_namesize[8]; 44 | /** Checksum of data field if c_magic is 070702, othersize zero */ 45 | char c_chksum[8]; 46 | } __attribute__ (( packed )); 47 | 48 | /** CPIO magic */ 49 | #define CPIO_MAGIC "070701" 50 | 51 | extern void cpio_set_field ( char *field, unsigned long value ); 52 | 53 | #endif /* _GPXE_CPIO_H */ 54 | -------------------------------------------------------------------------------- /src/include/gpxe/crc32.h: -------------------------------------------------------------------------------- 1 | #ifndef _GPXE_CRC32_H 2 | #define _GPXE_CRC32_H 3 | 4 | FILE_LICENCE ( GPL2_OR_LATER ); 5 | 6 | #include 7 | 8 | u32 crc32_le ( u32 seed, const void *data, size_t len ); 9 | 10 | #endif 11 | -------------------------------------------------------------------------------- /src/include/gpxe/dhcpopts.h: -------------------------------------------------------------------------------- 1 | #ifndef _GPXE_DHCPOPTS_H 2 | #define _GPXE_DHCPOPTS_H 3 | 4 | /** @file 5 | * 6 | * DHCP options 7 | * 8 | */ 9 | 10 | FILE_LICENCE ( GPL2_OR_LATER ); 11 | 12 | #include 13 | 14 | /** A DHCP options block */ 15 | struct dhcp_options { 16 | /** Option block raw data */ 17 | void *data; 18 | /** Option block length */ 19 | size_t len; 20 | /** Option block maximum length */ 21 | size_t max_len; 22 | }; 23 | 24 | extern int dhcpopt_store ( struct dhcp_options *options, unsigned int tag, 25 | const void *data, size_t len ); 26 | extern int dhcpopt_extensible_store ( struct dhcp_options *options, 27 | unsigned int tag, 28 | const void *data, size_t len ); 29 | extern int dhcpopt_fetch ( struct dhcp_options *options, unsigned int tag, 30 | void *data, size_t len ); 31 | extern void dhcpopt_init ( struct dhcp_options *options, 32 | void *data, size_t max_len ); 33 | 34 | #endif /* _GPXE_DHCPOPTS_H */ 35 | -------------------------------------------------------------------------------- /src/include/gpxe/downloader.h: -------------------------------------------------------------------------------- 1 | #ifndef _GPXE_DOWNLOADER_H 2 | #define _GPXE_DOWNLOADER_H 3 | 4 | /** @file 5 | * 6 | * Image downloader 7 | * 8 | */ 9 | 10 | FILE_LICENCE ( GPL2_OR_LATER ); 11 | 12 | struct job_interface; 13 | struct image; 14 | 15 | extern int create_downloader ( struct job_interface *job, struct image *image, 16 | int ( * register_image ) ( struct image *image ), 17 | int type, ... ); 18 | 19 | #endif /* _GPXE_DOWNLOADER_H */ 20 | -------------------------------------------------------------------------------- /src/include/gpxe/editstring.h: -------------------------------------------------------------------------------- 1 | #ifndef _GPXE_EDITSTRING_H 2 | #define _GPXE_EDITSTRING_H 3 | 4 | /** @file 5 | * 6 | * Editable strings 7 | * 8 | */ 9 | 10 | FILE_LICENCE ( GPL2_OR_LATER ); 11 | 12 | /** An editable string */ 13 | struct edit_string { 14 | /** Buffer for string */ 15 | char *buf; 16 | /** Size of buffer (including terminating NUL) */ 17 | size_t len; 18 | /** Cursor position */ 19 | unsigned int cursor; 20 | 21 | /* The following items are the edit history */ 22 | 23 | /** Last cursor position */ 24 | unsigned int last_cursor; 25 | /** Start of modified portion of string */ 26 | unsigned int mod_start; 27 | /** End of modified portion of string */ 28 | unsigned int mod_end; 29 | }; 30 | 31 | extern int edit_string ( struct edit_string *string, int key ) __nonnull; 32 | 33 | #endif /* _GPXE_EDITSTRING_H */ 34 | -------------------------------------------------------------------------------- /src/include/gpxe/efi/Guid/HiiFormMapMethodGuid.h: -------------------------------------------------------------------------------- 1 | /** @file 2 | Guid used to identify HII FormMap configuration method. 3 | 4 | Copyright (c) 2009, Intel Corporation. All rights reserved.
5 | This program and the accompanying materials 6 | are licensed and made available under the terms and conditions of the BSD License 7 | which accompanies this distribution. The full text of the license may be found at 8 | http://opensource.org/licenses/bsd-license.php 9 | 10 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, 11 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. 12 | 13 | @par Revision Reference: 14 | GUID defined in UEFI 2.2 spec. 15 | **/ 16 | 17 | #ifndef __EFI_HII_FORMMAP_GUID_H__ 18 | #define __EFI_HII_FORMMAP_GUID_H__ 19 | 20 | FILE_LICENCE ( BSD3 ); 21 | 22 | #define EFI_HII_STANDARD_FORM_GUID \ 23 | { 0x3bd2f4ec, 0xe524, 0x46e4, { 0xa9, 0xd8, 0x51, 0x1, 0x17, 0x42, 0x55, 0x62 } } 24 | 25 | extern EFI_GUID gEfiHiiStandardFormGuid; 26 | 27 | #endif 28 | -------------------------------------------------------------------------------- /src/include/gpxe/efi/Guid/SmBios.h: -------------------------------------------------------------------------------- 1 | /** @file 2 | GUIDs used to locate the SMBIOS tables in the UEFI 2.0 system table. 3 | 4 | This GUID in the system table is the only legal way to search for and 5 | locate the SMBIOS tables. Do not search the 0xF0000 segment to find SMBIOS 6 | tables. 7 | 8 | Copyright (c) 2006 - 2009, Intel Corporation. All rights reserved.
9 | This program and the accompanying materials 10 | are licensed and made available under the terms and conditions of the BSD License 11 | which accompanies this distribution. The full text of the license may be found at 12 | http://opensource.org/licenses/bsd-license.php 13 | 14 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, 15 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. 16 | 17 | @par Revision Reference: 18 | GUIDs defined in UEFI 2.0 spec. 19 | 20 | **/ 21 | 22 | #ifndef __SMBIOS_GUID_H__ 23 | #define __SMBIOS_GUID_H__ 24 | 25 | FILE_LICENCE ( BSD3 ); 26 | 27 | #define SMBIOS_TABLE_GUID \ 28 | { \ 29 | 0xeb9d2d31, 0x2d88, 0x11d3, {0x9a, 0x16, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d } \ 30 | } 31 | 32 | extern EFI_GUID gEfiSmbiosTableGuid; 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /src/include/gpxe/efi/PiDxe.h: -------------------------------------------------------------------------------- 1 | /** @file 2 | 3 | Root include file for Mde Package DXE_CORE, DXE, RUNTIME, SMM, SAL type modules. 4 | 5 | Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.
6 | This program and the accompanying materials are licensed and made available under 7 | the terms and conditions of the BSD License that accompanies this distribution. 8 | The full text of the license may be found at 9 | http://opensource.org/licenses/bsd-license.php. 10 | 11 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. 13 | 14 | **/ 15 | 16 | #ifndef __PI_DXE_H__ 17 | #define __PI_DXE_H__ 18 | 19 | FILE_LICENCE ( BSD3 ); 20 | 21 | #include 22 | #include 23 | #include 24 | 25 | #endif 26 | 27 | -------------------------------------------------------------------------------- /src/include/gpxe/efi/ProcessorBind.h: -------------------------------------------------------------------------------- 1 | #ifndef _GPXE_EFI_PROCESSOR_BIND_H 2 | #define _GPXE_EFI_PROCESSOR_BIND_H 3 | 4 | /* 5 | * EFI header files rely on having the CPU architecture directory 6 | * present in the search path in order to pick up ProcessorBind.h. We 7 | * use this header file as a quick indirection layer. 8 | * - mcb30 9 | */ 10 | 11 | #if __i386__ 12 | #include 13 | #endif 14 | 15 | #if __x86_64__ 16 | #include 17 | #endif 18 | 19 | #endif /* _GPXE_EFI_PROCESSOR_BIND_H */ 20 | -------------------------------------------------------------------------------- /src/include/gpxe/efi/Uefi.h: -------------------------------------------------------------------------------- 1 | /** @file 2 | 3 | Root include file for Mde Package UEFI, UEFI_APPLICATION type modules. 4 | 5 | This is the include file for any module of type UEFI and UEFI_APPLICATION. Uefi modules only use 6 | types defined via this include file and can be ported easily to any 7 | environment. 8 | 9 | Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.
10 | This program and the accompanying materials are licensed and made available under 11 | the terms and conditions of the BSD License that accompanies this distribution. 12 | The full text of the license may be found at 13 | http://opensource.org/licenses/bsd-license.php. 14 | 15 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, 16 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. 17 | 18 | **/ 19 | 20 | #ifndef __PI_UEFI_H__ 21 | #define __PI_UEFI_H__ 22 | 23 | FILE_LICENCE ( BSD3 ); 24 | 25 | #include 26 | #include 27 | 28 | #endif 29 | 30 | -------------------------------------------------------------------------------- /src/include/gpxe/efi/efi_smbios.h: -------------------------------------------------------------------------------- 1 | #ifndef _GPXE_EFI_SMBIOS_H 2 | #define _GPXE_EFI_SMBIOS_H 3 | 4 | /** @file 5 | * 6 | * gPXE SMBIOS API for EFI 7 | * 8 | */ 9 | 10 | FILE_LICENCE ( GPL2_OR_LATER ); 11 | 12 | #ifdef SMBIOS_EFI 13 | #define SMBIOS_PREFIX_efi 14 | #else 15 | #define SMBIOS_PREFIX_efi __efi_ 16 | #endif 17 | 18 | #endif /* _GPXE_EFI_SMBIOS_H */ 19 | -------------------------------------------------------------------------------- /src/include/gpxe/efi/efi_timer.h: -------------------------------------------------------------------------------- 1 | #ifndef _GPXE_EFI_TIMER_H 2 | #define _GPXE_EFI_TIMER_H 3 | 4 | /** @file 5 | * 6 | * gPXE timer API for EFI 7 | * 8 | */ 9 | 10 | FILE_LICENCE ( GPL2_OR_LATER ); 11 | 12 | #ifdef TIMER_EFI 13 | #define TIMER_PREFIX_efi 14 | #else 15 | #define TIMER_PREFIX_efi __efi_ 16 | #endif 17 | 18 | #endif /* _GPXE_EFI_TIMER_H */ 19 | -------------------------------------------------------------------------------- /src/include/gpxe/efi/efi_umalloc.h: -------------------------------------------------------------------------------- 1 | #ifndef _GPXE_EFI_UMALLOC_H 2 | #define _GPXE_EFI_UMALLOC_H 3 | 4 | /** @file 5 | * 6 | * gPXE user memory allocation API for EFI 7 | * 8 | */ 9 | 10 | FILE_LICENCE ( GPL2_OR_LATER ); 11 | 12 | #ifdef UMALLOC_EFI 13 | #define UMALLOC_PREFIX_efi 14 | #else 15 | #define UMALLOC_PREFIX_efi __efi_ 16 | #endif 17 | 18 | #endif /* _GPXE_EFI_UMALLOC_H */ 19 | -------------------------------------------------------------------------------- /src/include/gpxe/elf.h: -------------------------------------------------------------------------------- 1 | #ifndef _GPXE_ELF_H 2 | #define _GPXE_ELF_H 3 | 4 | /** 5 | * @file 6 | * 7 | * ELF image format 8 | * 9 | */ 10 | 11 | FILE_LICENCE ( GPL2_OR_LATER ); 12 | 13 | #include 14 | 15 | extern int elf_load ( struct image *image ); 16 | 17 | #endif /* _GPXE_ELF_H */ 18 | -------------------------------------------------------------------------------- /src/include/gpxe/errortab.h: -------------------------------------------------------------------------------- 1 | #ifndef _GPXE_ERRORTAB_H 2 | #define _GPXE_ERRORTAB_H 3 | 4 | /** @file 5 | * 6 | * Error message tables 7 | * 8 | */ 9 | 10 | FILE_LICENCE ( GPL2_OR_LATER ); 11 | 12 | #include 13 | 14 | struct errortab { 15 | int errno; 16 | const char *text; 17 | }; 18 | 19 | #define ERRORTAB __table ( struct errortab, "errortab" ) 20 | 21 | #define __errortab __table_entry ( ERRORTAB, 01 ) 22 | 23 | #define __einfo_errortab( einfo ) { \ 24 | .errno = __einfo_errno ( einfo ), \ 25 | .text = __einfo_desc ( einfo ), \ 26 | } 27 | 28 | #endif /* _GPXE_ERRORTAB_H */ 29 | -------------------------------------------------------------------------------- /src/include/gpxe/fakedhcp.h: -------------------------------------------------------------------------------- 1 | #ifndef _GPXE_FAKEDHCP_H 2 | #define _GPXE_FAKEDHCP_H 3 | 4 | /** @file 5 | * 6 | * Fake DHCP packets 7 | * 8 | */ 9 | 10 | FILE_LICENCE ( GPL2_OR_LATER ); 11 | 12 | #include 13 | 14 | struct net_device; 15 | 16 | extern int create_fakedhcpdiscover ( struct net_device *netdev, 17 | void *data, size_t max_len ); 18 | extern int create_fakedhcpack ( struct net_device *netdev, 19 | void *data, size_t max_len ); 20 | extern int create_fakepxebsack ( struct net_device *netdev, 21 | void *data, size_t max_len ); 22 | 23 | #endif /* _GPXE_FAKEDHCP_H */ 24 | -------------------------------------------------------------------------------- /src/include/gpxe/ftp.h: -------------------------------------------------------------------------------- 1 | #ifndef _GPXE_FTP_H 2 | #define _GPXE_FTP_H 3 | 4 | /** @file 5 | * 6 | * File transfer protocol 7 | * 8 | */ 9 | 10 | FILE_LICENCE ( GPL2_OR_LATER ); 11 | 12 | /** FTP default port */ 13 | #define FTP_PORT 21 14 | 15 | #endif /* _GPXE_FTP_H */ 16 | -------------------------------------------------------------------------------- /src/include/gpxe/gdbserial.h: -------------------------------------------------------------------------------- 1 | #ifndef _GPXE_GDBSERIAL_H 2 | #define _GPXE_GDBSERIAL_H 3 | 4 | /** @file 5 | * 6 | * GDB remote debugging over serial 7 | * 8 | */ 9 | 10 | FILE_LICENCE ( GPL2_OR_LATER ); 11 | 12 | struct gdb_transport; 13 | 14 | /** 15 | * Set up the serial transport 16 | * 17 | * @ret transport suitable for starting the GDB stub or NULL on error 18 | */ 19 | struct gdb_transport *gdbserial_configure ( void ); 20 | 21 | #endif /* _GPXE_GDBSERIAL_H */ 22 | -------------------------------------------------------------------------------- /src/include/gpxe/gdbudp.h: -------------------------------------------------------------------------------- 1 | #ifndef _GPXE_GDBUDP_H 2 | #define _GPXE_GDBUDP_H 3 | 4 | /** @file 5 | * 6 | * GDB remote debugging over UDP 7 | * 8 | */ 9 | 10 | FILE_LICENCE ( GPL2_OR_LATER ); 11 | 12 | struct sockaddr_in; 13 | struct gdb_transport; 14 | 15 | /** 16 | * Set up the UDP transport with network address 17 | * 18 | * @name network device name 19 | * @addr IP address and UDP listen port, may be NULL and fields may be zero 20 | * @ret transport suitable for starting the GDB stub or NULL on error 21 | */ 22 | struct gdb_transport *gdbudp_configure ( const char *name, struct sockaddr_in *addr ); 23 | 24 | #endif /* _GPXE_GDBUDP_H */ 25 | -------------------------------------------------------------------------------- /src/include/gpxe/hidemem.h: -------------------------------------------------------------------------------- 1 | #ifndef _GPXE_HIDEMEM_H 2 | #define _GPXE_HIDEMEM_H 3 | 4 | /** 5 | * @file 6 | * 7 | * Hidden memory regions 8 | * 9 | */ 10 | 11 | FILE_LICENCE ( GPL2_OR_LATER ); 12 | 13 | #include 14 | 15 | extern void hide_umalloc ( physaddr_t start, physaddr_t end ); 16 | 17 | #endif /* _GPXE_HIDEMEM_H */ 18 | -------------------------------------------------------------------------------- /src/include/gpxe/hmac.h: -------------------------------------------------------------------------------- 1 | #ifndef _GPXE_HMAC_H 2 | #define _GPXE_HMAC_H 3 | 4 | /** @file 5 | * 6 | * Keyed-Hashing for Message Authentication 7 | */ 8 | 9 | FILE_LICENCE ( GPL2_OR_LATER ); 10 | 11 | #include 12 | 13 | /** 14 | * Update HMAC 15 | * 16 | * @v digest Digest algorithm to use 17 | * @v digest_ctx Digest context 18 | * @v data Data 19 | * @v len Length of data 20 | */ 21 | static inline void hmac_update ( struct digest_algorithm *digest, 22 | void *digest_ctx, const void *data, 23 | size_t len ) { 24 | digest_update ( digest, digest_ctx, data, len ); 25 | } 26 | 27 | extern void hmac_init ( struct digest_algorithm *digest, void *digest_ctx, 28 | void *key, size_t *key_len ); 29 | extern void hmac_final ( struct digest_algorithm *digest, void *digest_ctx, 30 | void *key, size_t *key_len, void *hmac ); 31 | 32 | #endif /* _GPXE_HMAC_H */ 33 | -------------------------------------------------------------------------------- /src/include/gpxe/http.h: -------------------------------------------------------------------------------- 1 | #ifndef _GPXE_HTTP_H 2 | #define _GPXE_HTTP_H 3 | 4 | /** @file 5 | * 6 | * Hyper Text Transport Protocol 7 | * 8 | */ 9 | 10 | FILE_LICENCE ( GPL2_OR_LATER ); 11 | 12 | /** HTTP default port */ 13 | #define HTTP_PORT 80 14 | 15 | /** HTTPS default port */ 16 | #define HTTPS_PORT 443 17 | 18 | extern int http_open_filter ( struct xfer_interface *xfer, struct uri *uri, 19 | unsigned int default_port, 20 | int ( * filter ) ( struct xfer_interface *, 21 | struct xfer_interface ** ) ); 22 | 23 | #endif /* _GPXE_HTTP_H */ 24 | -------------------------------------------------------------------------------- /src/include/gpxe/ib_cmrc.h: -------------------------------------------------------------------------------- 1 | #ifndef _GPXE_IB_CMRC_H 2 | #define _GPXE_IB_CMRC_H 3 | 4 | /** @file 5 | * 6 | * Infiniband Communication-managed Reliable Connections 7 | * 8 | */ 9 | 10 | FILE_LICENCE ( BSD2 ); 11 | 12 | #include 13 | #include 14 | 15 | extern int ib_cmrc_open ( struct xfer_interface *xfer, 16 | struct ib_device *ibdev, 17 | struct ib_gid *dgid, 18 | struct ib_gid_half *service_id ); 19 | 20 | #endif /* _GPXE_IB_CMRC_H */ 21 | -------------------------------------------------------------------------------- /src/include/gpxe/ib_mcast.h: -------------------------------------------------------------------------------- 1 | #ifndef _GPXE_IB_MCAST_H 2 | #define _GPXE_IB_MCAST_H 3 | 4 | /** @file 5 | * 6 | * Infiniband multicast groups 7 | * 8 | */ 9 | 10 | FILE_LICENCE ( GPL2_OR_LATER ); 11 | 12 | #include 13 | 14 | struct ib_mad_transaction; 15 | 16 | /** An Infiniband multicast group membership */ 17 | struct ib_mc_membership { 18 | /** Queue pair */ 19 | struct ib_queue_pair *qp; 20 | /** Multicast GID */ 21 | struct ib_gid gid; 22 | /** Multicast group join transaction */ 23 | struct ib_mad_transaction *madx; 24 | /** Handle join success/failure 25 | * 26 | * @v ibdev Infiniband device 27 | * @v qp Queue pair 28 | * @v membership Multicast group membership 29 | * @v rc Status code 30 | * @v mad Response MAD (or NULL on error) 31 | */ 32 | void ( * complete ) ( struct ib_device *ibdev, struct ib_queue_pair *qp, 33 | struct ib_mc_membership *membership, int rc, 34 | union ib_mad *mad ); 35 | }; 36 | 37 | extern int ib_mcast_join ( struct ib_device *ibdev, struct ib_queue_pair *qp, 38 | struct ib_mc_membership *membership, 39 | struct ib_gid *gid, 40 | void ( * joined ) ( struct ib_device *ibdev, 41 | struct ib_queue_pair *qp, 42 | struct ib_mc_membership *memb, 43 | int rc, union ib_mad *mad ) ); 44 | 45 | extern void ib_mcast_leave ( struct ib_device *ibdev, struct ib_queue_pair *qp, 46 | struct ib_mc_membership *membership ); 47 | 48 | #endif /* _GPXE_IB_MCAST_H */ 49 | -------------------------------------------------------------------------------- /src/include/gpxe/ib_sma.h: -------------------------------------------------------------------------------- 1 | #ifndef _GPXE_IB_SMA_H 2 | #define _GPXE_IB_SMA_H 3 | 4 | /** @file 5 | * 6 | * Infiniband subnet management agent 7 | * 8 | */ 9 | 10 | FILE_LICENCE ( GPL2_OR_LATER ); 11 | 12 | struct ib_device; 13 | struct ib_mad_interface; 14 | 15 | extern int ib_create_sma ( struct ib_device *ibdev, 16 | struct ib_mad_interface *mi ); 17 | extern void ib_destroy_sma ( struct ib_device *ibdev, 18 | struct ib_mad_interface *mi ); 19 | 20 | #endif /* _GPXE_IB_SMA_H */ 21 | -------------------------------------------------------------------------------- /src/include/gpxe/ib_smc.h: -------------------------------------------------------------------------------- 1 | #ifndef _GPXE_IB_SMC_H 2 | #define _GPXE_IB_SMC_H 3 | 4 | /** @file 5 | * 6 | * Infiniband Subnet Management Client 7 | * 8 | */ 9 | 10 | FILE_LICENCE ( GPL2_OR_LATER ); 11 | 12 | #include 13 | 14 | typedef int ( * ib_local_mad_t ) ( struct ib_device *ibdev, 15 | union ib_mad *mad ); 16 | 17 | extern int ib_smc_update ( struct ib_device *ibdev, 18 | ib_local_mad_t local_mad ); 19 | 20 | #endif /* _GPXE_IB_SMC_H */ 21 | -------------------------------------------------------------------------------- /src/include/gpxe/icmp.h: -------------------------------------------------------------------------------- 1 | #ifndef _GPXE_ICMP_H 2 | #define _GPXE_ICMP_H 3 | 4 | /** @file 5 | * 6 | * ICMP protocol 7 | * 8 | */ 9 | 10 | FILE_LICENCE ( GPL2_OR_LATER ); 11 | 12 | /** An ICMP header */ 13 | struct icmp_header { 14 | /** Type */ 15 | uint8_t type; 16 | /** Code */ 17 | uint8_t code; 18 | /** Checksum */ 19 | uint16_t chksum; 20 | } __attribute__ (( packed )); 21 | 22 | #define ICMP_ECHO_RESPONSE 0 23 | #define ICMP_ECHO_REQUEST 8 24 | 25 | #endif /* _GPXE_ICMP_H */ 26 | -------------------------------------------------------------------------------- /src/include/gpxe/if_ether.h: -------------------------------------------------------------------------------- 1 | #ifndef _GPXE_IF_ETHER_H 2 | #define _GPXE_IF_ETHER_H 3 | 4 | FILE_LICENCE ( GPL2_OR_LATER ); 5 | 6 | #include 7 | 8 | #define ETH_ALEN 6 /* Size of Ethernet address */ 9 | #define ETH_HLEN 14 /* Size of ethernet header */ 10 | #define ETH_ZLEN 60 /* Minimum packet */ 11 | #define ETH_FRAME_LEN 1514 /* Maximum packet */ 12 | #define ETH_DATA_ALIGN 2 /* Amount needed to align the data after an ethernet header */ 13 | #ifndef ETH_MAX_MTU 14 | #define ETH_MAX_MTU (ETH_FRAME_LEN-ETH_HLEN) 15 | #endif 16 | 17 | #define ETH_P_RAW 0x0000 /* Raw packet */ 18 | #define ETH_P_IP 0x0800 /* Internet Protocl Packet */ 19 | #define ETH_P_ARP 0x0806 /* Address Resolution Protocol */ 20 | #define ETH_P_RARP 0x8035 /* Reverse Address resolution Protocol */ 21 | #define ETH_P_IPV6 0x86DD /* IPv6 over blueblook */ 22 | #define ETH_P_SLOW 0x8809 /* Ethernet slow protocols */ 23 | #define ETH_P_EAPOL 0x888E /* 802.1X EAP over LANs */ 24 | #define ETH_P_AOE 0x88A2 /* ATA over Ethernet */ 25 | 26 | /** An Ethernet link-layer header */ 27 | struct ethhdr { 28 | /** Destination MAC address */ 29 | uint8_t h_dest[ETH_ALEN]; 30 | /** Source MAC address */ 31 | uint8_t h_source[ETH_ALEN]; 32 | /** Protocol ID */ 33 | uint16_t h_protocol; 34 | } __attribute__ ((packed)); 35 | 36 | #endif /* _GPXE_IF_ETHER_H */ 37 | -------------------------------------------------------------------------------- /src/include/gpxe/interface.h: -------------------------------------------------------------------------------- 1 | #ifndef _GPXE_INTERFACE_H 2 | #define _GPXE_INTERFACE_H 3 | 4 | /** @file 5 | * 6 | * Object communication interfaces 7 | * 8 | */ 9 | 10 | FILE_LICENCE ( GPL2_OR_LATER ); 11 | 12 | #include 13 | 14 | /** An object communication interface */ 15 | struct interface { 16 | /** Destination interface 17 | * 18 | * When messages are sent via this interface, they will be 19 | * delivered to the destination interface. 20 | * 21 | * This pointer may never be NULL. When the interface is 22 | * unplugged, it should point to a null interface. 23 | */ 24 | struct interface *dest; 25 | /** Reference counter 26 | * 27 | * If this interface is not part of a reference-counted 28 | * object, this field may be NULL. 29 | */ 30 | struct refcnt *refcnt; 31 | }; 32 | 33 | /** 34 | * Increment reference count on an interface 35 | * 36 | * @v intf Interface 37 | * @ret intf Interface 38 | */ 39 | static inline __attribute__ (( always_inline )) struct interface * 40 | intf_get ( struct interface *intf ) { 41 | ref_get ( intf->refcnt ); 42 | return intf; 43 | } 44 | 45 | /** 46 | * Decrement reference count on an interface 47 | * 48 | * @v intf Interface 49 | */ 50 | static inline __attribute__ (( always_inline )) void 51 | intf_put ( struct interface *intf ) { 52 | ref_put ( intf->refcnt ); 53 | } 54 | 55 | extern void plug ( struct interface *intf, struct interface *dest ); 56 | extern void plug_plug ( struct interface *a, struct interface *b ); 57 | 58 | #endif /* _GPXE_INTERFACE_H */ 59 | -------------------------------------------------------------------------------- /src/include/gpxe/linebuf.h: -------------------------------------------------------------------------------- 1 | #ifndef _GPXE_LINEBUF_H 2 | #define _GPXE_LINEBUF_H 3 | 4 | /** @file 5 | * 6 | * Line buffering 7 | * 8 | */ 9 | 10 | FILE_LICENCE ( GPL2_OR_LATER ); 11 | 12 | #include 13 | #include 14 | 15 | /** A line buffer */ 16 | struct line_buffer { 17 | /** Current string in the buffer */ 18 | char *data; 19 | /** Length of current string, excluding the terminating NUL */ 20 | size_t len; 21 | /** String is ready to read */ 22 | int ready; 23 | }; 24 | 25 | extern char * buffered_line ( struct line_buffer *linebuf ); 26 | extern ssize_t line_buffer ( struct line_buffer *linebuf, 27 | const char *data, size_t len ); 28 | extern void empty_line_buffer ( struct line_buffer *linebuf ); 29 | 30 | #endif /* _GPXE_LINEBUF_H */ 31 | -------------------------------------------------------------------------------- /src/include/gpxe/linux_compat.h: -------------------------------------------------------------------------------- 1 | #ifndef _GPXE_LINUX_COMPAT_H 2 | #define _GPXE_LINUX_COMPAT_H 3 | 4 | /** @file 5 | * 6 | * Linux code compatibility 7 | * 8 | * This file exists to ease the building of Linux source code within 9 | * gPXE. This is intended to facilitate quick testing; it is not 10 | * intended to be a substitute for proper porting. 11 | */ 12 | 13 | FILE_LICENCE ( GPL2_OR_LATER ); 14 | 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | 21 | #define __init 22 | #define __exit 23 | #define __initdata 24 | #define __exitdata 25 | #define printk printf 26 | 27 | #endif /* _GPXE_LINUX_COMPAT_H */ 28 | -------------------------------------------------------------------------------- /src/include/gpxe/login_ui.h: -------------------------------------------------------------------------------- 1 | #ifndef _GPXE_LOGIN_UI_H 2 | #define _GPXE_LOGIN_UI_H 3 | 4 | /** @file 5 | * 6 | * Login UI 7 | * 8 | */ 9 | 10 | FILE_LICENCE ( GPL2_OR_LATER ); 11 | 12 | extern int login_ui ( void ); 13 | 14 | #endif /* _GPXE_LOGIN_UI_H */ 15 | -------------------------------------------------------------------------------- /src/include/gpxe/md5.h: -------------------------------------------------------------------------------- 1 | #ifndef _GPXE_MD5_H 2 | #define _GPXE_MD5_H 3 | 4 | FILE_LICENCE ( GPL2_OR_LATER ); 5 | 6 | struct digest_algorithm; 7 | 8 | #include 9 | 10 | #define MD5_DIGEST_SIZE 16 11 | #define MD5_BLOCK_WORDS 16 12 | #define MD5_HASH_WORDS 4 13 | 14 | struct md5_ctx { 15 | u32 hash[MD5_HASH_WORDS]; 16 | u32 block[MD5_BLOCK_WORDS]; 17 | u64 byte_count; 18 | }; 19 | 20 | #define MD5_CTX_SIZE sizeof ( struct md5_ctx ) 21 | 22 | extern struct digest_algorithm md5_algorithm; 23 | 24 | #endif /* _GPXE_MD5_H */ 25 | -------------------------------------------------------------------------------- /src/include/gpxe/memmap.h: -------------------------------------------------------------------------------- 1 | #ifndef _GPXE_MEMMAP_H 2 | #define _GPXE_MEMMAP_H 3 | 4 | #include 5 | 6 | /** 7 | * @file 8 | * 9 | * Memory mapping 10 | * 11 | */ 12 | 13 | FILE_LICENCE ( GPL2_OR_LATER ); 14 | 15 | /** A usable memory region */ 16 | struct memory_region { 17 | /** Physical start address */ 18 | uint64_t start; 19 | /** Physical end address */ 20 | uint64_t end; 21 | }; 22 | 23 | /** Maximum number of memory regions we expect to encounter */ 24 | #define MAX_MEMORY_REGIONS 8 25 | 26 | /** A memory map */ 27 | struct memory_map { 28 | /** Memory regions */ 29 | struct memory_region regions[MAX_MEMORY_REGIONS]; 30 | /** Number of used regions */ 31 | unsigned int count; 32 | }; 33 | 34 | extern void get_memmap ( struct memory_map *memmap ); 35 | 36 | #endif /* _GPXE_MEMMAP_H */ 37 | -------------------------------------------------------------------------------- /src/include/gpxe/monojob.h: -------------------------------------------------------------------------------- 1 | #ifndef _GPXE_MONOJOB_H 2 | #define _GPXE_MONOJOB_H 3 | 4 | /** @file 5 | * 6 | * Single foreground job 7 | * 8 | */ 9 | 10 | FILE_LICENCE ( GPL2_OR_LATER ); 11 | 12 | struct job_interface; 13 | 14 | extern struct job_interface monojob; 15 | extern int monojob_wait ( const char *string ); 16 | 17 | #endif /* _GPXE_MONOJOB_H */ 18 | -------------------------------------------------------------------------------- /src/include/gpxe/nap.h: -------------------------------------------------------------------------------- 1 | #ifndef _GPXE_NAP_H 2 | #define _GPXE_NAP_H 3 | 4 | /** @file 5 | * 6 | * CPU sleeping 7 | * 8 | */ 9 | 10 | FILE_LICENCE ( GPL2_OR_LATER ); 11 | 12 | #include 13 | #include 14 | 15 | /** 16 | * Calculate static inline CPU sleeping API function name 17 | * 18 | * @v _prefix Subsystem prefix 19 | * @v _api_func API function 20 | * @ret _subsys_func Subsystem API function 21 | */ 22 | #define NAP_INLINE( _subsys, _api_func ) \ 23 | SINGLE_API_INLINE ( NAP_PREFIX_ ## _subsys, _api_func ) 24 | 25 | /** 26 | * Provide an CPU sleeping API implementation 27 | * 28 | * @v _prefix Subsystem prefix 29 | * @v _api_func API function 30 | * @v _func Implementing function 31 | */ 32 | #define PROVIDE_NAP( _subsys, _api_func, _func ) \ 33 | PROVIDE_SINGLE_API ( NAP_PREFIX_ ## _subsys, _api_func, _func ) 34 | 35 | /** 36 | * Provide a static inline CPU sleeping API implementation 37 | * 38 | * @v _prefix Subsystem prefix 39 | * @v _api_func API function 40 | */ 41 | #define PROVIDE_NAP_INLINE( _subsys, _api_func ) \ 42 | PROVIDE_SINGLE_API_INLINE ( NAP_PREFIX_ ## _subsys, _api_func ) 43 | 44 | /* Include all architecture-independent I/O API headers */ 45 | #include 46 | 47 | /* Include all architecture-dependent I/O API headers */ 48 | #include 49 | 50 | /** 51 | * Sleep until next CPU interrupt 52 | * 53 | */ 54 | void cpu_nap ( void ); 55 | 56 | #endif /* _GPXE_NAP_H */ 57 | -------------------------------------------------------------------------------- /src/include/gpxe/null_nap.h: -------------------------------------------------------------------------------- 1 | #ifndef _GPXE_NULL_NAP_H 2 | #define _GPXE_NULL_NAP_H 3 | 4 | /** @file 5 | * 6 | * Null CPU sleeping 7 | * 8 | */ 9 | 10 | FILE_LICENCE ( GPL2_OR_LATER ); 11 | 12 | #ifdef NAP_NULL 13 | #define NAP_PREFIX_null 14 | #else 15 | #define NAP_PREFIX_null __null_ 16 | #endif 17 | 18 | static inline __always_inline void 19 | NAP_INLINE ( null, cpu_nap ) ( void ) { 20 | /* Do nothing */ 21 | } 22 | 23 | #endif /* _GPXE_NULL_NAP_H */ 24 | -------------------------------------------------------------------------------- /src/include/gpxe/nvo.h: -------------------------------------------------------------------------------- 1 | #ifndef _GPXE_NVO_H 2 | #define _GPXE_NVO_H 3 | 4 | /** @file 5 | * 6 | * Non-volatile stored options 7 | * 8 | */ 9 | 10 | FILE_LICENCE ( GPL2_OR_LATER ); 11 | 12 | #include 13 | #include 14 | #include 15 | 16 | struct nvs_device; 17 | struct refcnt; 18 | 19 | /** 20 | * A fragment of a non-volatile storage device used for stored options 21 | */ 22 | struct nvo_fragment { 23 | /** Starting address of fragment within NVS device */ 24 | unsigned int address; 25 | /** Length of fragment */ 26 | size_t len; 27 | }; 28 | 29 | /** 30 | * A block of non-volatile stored options 31 | */ 32 | struct nvo_block { 33 | /** Settings block */ 34 | struct settings settings; 35 | /** Underlying non-volatile storage device */ 36 | struct nvs_device *nvs; 37 | /** List of option-containing fragments 38 | * 39 | * The list is terminated by a fragment with a length of zero. 40 | */ 41 | struct nvo_fragment *fragments; 42 | /** Total length of option-containing fragments */ 43 | size_t total_len; 44 | /** Option-containing data */ 45 | void *data; 46 | /** DHCP options block */ 47 | struct dhcp_options dhcpopts; 48 | }; 49 | 50 | extern void nvo_init ( struct nvo_block *nvo, struct nvs_device *nvs, 51 | struct nvo_fragment *fragments, struct refcnt *refcnt ); 52 | extern int register_nvo ( struct nvo_block *nvo, struct settings *parent ); 53 | extern void unregister_nvo ( struct nvo_block *nvo ); 54 | 55 | #endif /* _GPXE_NVO_H */ 56 | -------------------------------------------------------------------------------- /src/include/gpxe/pcibackup.h: -------------------------------------------------------------------------------- 1 | #ifndef _GPXE_PCIBACKUP_H 2 | #define _GPXE_PCIBACKUP_H 3 | 4 | /** @file 5 | * 6 | * PCI configuration space backup and restoration 7 | * 8 | */ 9 | 10 | FILE_LICENCE ( GPL2_OR_LATER ); 11 | 12 | #include 13 | 14 | /** A PCI configuration space backup */ 15 | struct pci_config_backup { 16 | uint32_t dwords[64]; 17 | }; 18 | 19 | /** PCI configuration space backup exclusion list end marker */ 20 | #define PCI_CONFIG_BACKUP_EXCLUDE_END 0xff 21 | 22 | /** Define a PCI configuration space backup exclusion list */ 23 | #define PCI_CONFIG_BACKUP_EXCLUDE(...) \ 24 | { __VA_ARGS__, PCI_CONFIG_BACKUP_EXCLUDE_END } 25 | 26 | extern void pci_backup ( struct pci_device *pci, 27 | struct pci_config_backup *backup, 28 | const uint8_t *exclude ); 29 | extern void pci_restore ( struct pci_device *pci, 30 | struct pci_config_backup *backup, 31 | const uint8_t *exclude ); 32 | 33 | #endif /* _GPXE_PCIBACKUP_H */ 34 | -------------------------------------------------------------------------------- /src/include/gpxe/ramdisk.h: -------------------------------------------------------------------------------- 1 | #ifndef _GPXE_RAMDISK_H 2 | #define _GPXE_RAMDISK_H 3 | 4 | /** 5 | * @file 6 | * 7 | * RAM disks 8 | * 9 | */ 10 | 11 | FILE_LICENCE ( GPL2_OR_LATER ); 12 | 13 | #include 14 | #include 15 | 16 | struct ramdisk { 17 | struct block_device blockdev; 18 | userptr_t data; 19 | }; 20 | 21 | extern int init_ramdisk ( struct ramdisk *ramdisk, userptr_t data, size_t len, 22 | unsigned int blksize ); 23 | 24 | #endif /* _GPXE_RAMDISK_H */ 25 | -------------------------------------------------------------------------------- /src/include/gpxe/rarp.h: -------------------------------------------------------------------------------- 1 | #ifndef _GPXE_RARP_H 2 | #define _GPXE_RARP_H 3 | 4 | /** @file 5 | * 6 | * Reverse Address Resolution Protocol 7 | * 8 | */ 9 | 10 | FILE_LICENCE ( GPL2_OR_LATER ); 11 | 12 | struct net_protocol; 13 | 14 | extern struct net_protocol rarp_protocol; 15 | 16 | #endif /* _GPXE_RARP_H */ 17 | -------------------------------------------------------------------------------- /src/include/gpxe/rc80211.h: -------------------------------------------------------------------------------- 1 | #ifndef _GPXE_RC80211_H 2 | #define _GPXE_RC80211_H 3 | 4 | /** @file 5 | * 6 | * Rate-control algorithm prototype for 802.11. 7 | */ 8 | 9 | FILE_LICENCE ( GPL2_OR_LATER ); 10 | 11 | struct net80211_device; 12 | struct rc80211_ctx; 13 | 14 | struct rc80211_ctx * rc80211_init ( struct net80211_device *dev ); 15 | void rc80211_update_tx ( struct net80211_device *dev, int retries, int rc ); 16 | void rc80211_update_rx ( struct net80211_device *dev, int retry, u16 rate ); 17 | void rc80211_free ( struct rc80211_ctx *ctx ); 18 | 19 | #endif /* _GPXE_RC80211_H */ 20 | -------------------------------------------------------------------------------- /src/include/gpxe/rotate.h: -------------------------------------------------------------------------------- 1 | #ifndef _GPXE_ROTATE_H 2 | #define _GPXE_ROTATE_H 3 | 4 | /** @file 5 | * 6 | * Bit operations 7 | */ 8 | 9 | FILE_LICENCE ( GPL2_OR_LATER ); 10 | 11 | #include 12 | 13 | static inline uint32_t rol32 ( uint32_t data, unsigned int rotation ) { 14 | return ( ( data << rotation ) | ( data >> ( 32 - rotation ) ) ); 15 | } 16 | 17 | static inline uint32_t ror32 ( uint32_t data, unsigned int rotation ) { 18 | return ( ( data >> rotation ) | ( data << ( 32 - rotation ) ) ); 19 | } 20 | 21 | static inline uint64_t rol64 ( uint64_t data, unsigned int rotation ) { 22 | return ( ( data << rotation ) | ( data >> ( 64 - rotation ) ) ); 23 | } 24 | 25 | static inline uint64_t ror64 ( uint64_t data, unsigned int rotation ) { 26 | return ( ( data >> rotation ) | ( data << ( 64 - rotation ) ) ); 27 | } 28 | 29 | #endif /* _GPXE_ROTATE_H */ 30 | -------------------------------------------------------------------------------- /src/include/gpxe/rsa.h: -------------------------------------------------------------------------------- 1 | #ifndef _GPXE_RSA_H 2 | #define _GPXE_RSA_H 3 | 4 | FILE_LICENCE ( GPL2_OR_LATER ); 5 | 6 | struct pubkey_algorithm; 7 | 8 | extern struct pubkey_algorithm rsa_algorithm; 9 | 10 | #include "crypto/axtls/crypto.h" 11 | 12 | #endif /* _GPXE_RSA_H */ 13 | -------------------------------------------------------------------------------- /src/include/gpxe/sanboot.h: -------------------------------------------------------------------------------- 1 | #ifndef _GPXE_SANBOOT_H 2 | #define _GPXE_SANBOOT_H 3 | 4 | FILE_LICENCE ( GPL2_OR_LATER ); 5 | 6 | #include 7 | 8 | struct sanboot_protocol { 9 | const char *prefix; 10 | int ( * boot ) ( const char *root_path ); 11 | }; 12 | 13 | #define SANBOOT_PROTOCOLS \ 14 | __table ( struct sanboot_protocol, "sanboot_protocols" ) 15 | 16 | #define __sanboot_protocol __table_entry ( SANBOOT_PROTOCOLS, 01 ) 17 | 18 | extern int keep_san ( void ); 19 | 20 | #endif /* _GPXE_SANBOOT_H */ 21 | -------------------------------------------------------------------------------- /src/include/gpxe/segment.h: -------------------------------------------------------------------------------- 1 | #ifndef _GPXE_SEGMENT_H 2 | #define _GPXE_SEGMENT_H 3 | 4 | /** 5 | * @file 6 | * 7 | * Executable image segments 8 | * 9 | */ 10 | 11 | FILE_LICENCE ( GPL2_OR_LATER ); 12 | 13 | #include 14 | 15 | extern int prep_segment ( userptr_t segment, size_t filesz, size_t memsz ); 16 | 17 | #endif /* _GPXE_SEGMENT_H */ 18 | -------------------------------------------------------------------------------- /src/include/gpxe/serial.h: -------------------------------------------------------------------------------- 1 | #ifndef _GPXE_SERIAL_H 2 | #define _GPXE_SERIAL_H 3 | 4 | /** @file 5 | * 6 | * Serial driver functions 7 | * 8 | */ 9 | 10 | FILE_LICENCE ( GPL2_OR_LATER ); 11 | 12 | extern void serial_putc ( int ch ); 13 | extern int serial_getc ( void ); 14 | extern int serial_ischar ( void ); 15 | 16 | #endif /* _GPXE_SERIAL_H */ 17 | -------------------------------------------------------------------------------- /src/include/gpxe/settings_ui.h: -------------------------------------------------------------------------------- 1 | #ifndef _GPXE_SETTINGS_UI_H 2 | #define _GPXE_SETTINGS_UI_H 3 | 4 | /** @file 5 | * 6 | * Option configuration console 7 | * 8 | */ 9 | 10 | FILE_LICENCE ( GPL2_OR_LATER ); 11 | 12 | struct settings; 13 | 14 | extern int settings_ui ( struct settings *settings ) __nonnull; 15 | 16 | #endif /* _GPXE_SETTINGS_UI_H */ 17 | -------------------------------------------------------------------------------- /src/include/gpxe/sha1.h: -------------------------------------------------------------------------------- 1 | #ifndef _GPXE_SHA1_H 2 | #define _GPXE_SHA1_H 3 | 4 | FILE_LICENCE ( GPL2_OR_LATER ); 5 | 6 | #include "crypto/axtls/crypto.h" 7 | 8 | struct digest_algorithm; 9 | 10 | #define SHA1_CTX_SIZE sizeof ( SHA1_CTX ) 11 | #define SHA1_DIGEST_SIZE SHA1_SIZE 12 | 13 | extern struct digest_algorithm sha1_algorithm; 14 | 15 | /* SHA1-wrapping functions defined in sha1extra.c: */ 16 | 17 | void prf_sha1 ( const void *key, size_t key_len, const char *label, 18 | const void *data, size_t data_len, void *prf, size_t prf_len ); 19 | 20 | void pbkdf2_sha1 ( const void *passphrase, size_t pass_len, 21 | const void *salt, size_t salt_len, 22 | int iterations, void *key, size_t key_len ); 23 | 24 | #endif /* _GPXE_SHA1_H */ 25 | -------------------------------------------------------------------------------- /src/include/gpxe/shell.h: -------------------------------------------------------------------------------- 1 | #ifndef _GPXE_SHELL_H 2 | #define _GPXE_SHELL_H 3 | 4 | /** @file 5 | * 6 | * Minimal command shell 7 | * 8 | */ 9 | 10 | FILE_LICENCE ( GPL2_OR_LATER ); 11 | 12 | extern void shell ( void ); 13 | 14 | #endif /* _GPXE_SHELL_H */ 15 | -------------------------------------------------------------------------------- /src/include/gpxe/shell_banner.h: -------------------------------------------------------------------------------- 1 | #ifndef _GPXE_SHELL_BANNER_H 2 | #define _GPXE_SHELL_BANNER_H 3 | 4 | /** @file 5 | * 6 | * Shell startup banner 7 | * 8 | */ 9 | 10 | FILE_LICENCE ( GPL2_OR_LATER ); 11 | 12 | extern int shell_banner ( void ); 13 | 14 | #endif /* _GPXE_SHELL_BANNER_H */ 15 | -------------------------------------------------------------------------------- /src/include/gpxe/udp.h: -------------------------------------------------------------------------------- 1 | #ifndef _GPXE_UDP_H 2 | #define _GPXE_UDP_H 3 | 4 | /** @file 5 | * 6 | * UDP protocol 7 | * 8 | * This file defines the gPXE UDP API. 9 | * 10 | */ 11 | 12 | FILE_LICENCE ( GPL2_OR_LATER ); 13 | 14 | #include 15 | #include 16 | #include 17 | #include 18 | 19 | struct xfer_interface; 20 | 21 | /** 22 | * UDP constants 23 | */ 24 | 25 | #define UDP_MAX_HLEN 72 26 | #define UDP_MAX_TXIOB ETH_MAX_MTU 27 | #define UDP_MIN_TXIOB ETH_ZLEN 28 | 29 | /** 30 | * A UDP header 31 | */ 32 | struct udp_header { 33 | /** Source port */ 34 | uint16_t src; 35 | /** Destination port */ 36 | uint16_t dest; 37 | /** Length */ 38 | uint16_t len; 39 | /** Checksum */ 40 | uint16_t chksum; 41 | }; 42 | 43 | extern int udp_open_promisc ( struct xfer_interface *xfer ); 44 | extern int udp_open ( struct xfer_interface *xfer, struct sockaddr *peer, 45 | struct sockaddr *local ); 46 | 47 | #endif /* _GPXE_UDP_H */ 48 | 49 | -------------------------------------------------------------------------------- /src/include/gpxe/uuid.h: -------------------------------------------------------------------------------- 1 | #ifndef _GPXE_UUID_H 2 | #define _GPXE_UUID_H 3 | 4 | /** @file 5 | * 6 | * Universally unique IDs 7 | */ 8 | 9 | FILE_LICENCE ( GPL2_OR_LATER ); 10 | 11 | #include 12 | 13 | /** A universally unique ID */ 14 | union uuid { 15 | /** Canonical form (00000000-0000-0000-0000-000000000000) */ 16 | struct { 17 | /** 8 hex digits, big-endian */ 18 | uint32_t a; 19 | /** 2 hex digits, big-endian */ 20 | uint16_t b; 21 | /** 2 hex digits, big-endian */ 22 | uint16_t c; 23 | /** 2 hex digits, big-endian */ 24 | uint16_t d; 25 | /** 12 hex digits, big-endian */ 26 | uint8_t e[6]; 27 | } canonical; 28 | uint8_t raw[16]; 29 | }; 30 | 31 | extern char * uuid_ntoa ( union uuid *uuid ); 32 | 33 | #endif /* _GPXE_UUID_H */ 34 | -------------------------------------------------------------------------------- /src/include/gpxe/x509.h: -------------------------------------------------------------------------------- 1 | #ifndef _GPXE_X509_H 2 | #define _GPXE_X509_H 3 | 4 | /** @file 5 | * 6 | * X.509 certificates 7 | * 8 | */ 9 | 10 | FILE_LICENCE ( GPL2_OR_LATER ); 11 | 12 | #include 13 | 14 | struct asn1_cursor; 15 | 16 | /** An X.509 RSA public key */ 17 | struct x509_rsa_public_key { 18 | /** Modulus */ 19 | uint8_t *modulus; 20 | /** Modulus length */ 21 | size_t modulus_len; 22 | /** Exponent */ 23 | uint8_t *exponent; 24 | /** Exponent length */ 25 | size_t exponent_len; 26 | }; 27 | 28 | /** 29 | * Free X.509 RSA public key 30 | * 31 | * @v rsa_pubkey RSA public key 32 | */ 33 | static inline void 34 | x509_free_rsa_public_key ( struct x509_rsa_public_key *rsa_pubkey ) { 35 | free ( rsa_pubkey->modulus ); 36 | } 37 | 38 | extern int x509_rsa_public_key ( const struct asn1_cursor *certificate, 39 | struct x509_rsa_public_key *rsa_pubkey ); 40 | 41 | #endif /* _GPXE_X509_H */ 42 | -------------------------------------------------------------------------------- /src/include/hci/ifmgmt_cmd.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2007 Michael Brown . 3 | * 4 | * This program is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU General Public License as 6 | * published by the Free Software Foundation; either version 2 of the 7 | * License, or any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, but 10 | * WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | */ 18 | 19 | #ifndef _IFMGMT_CMD_H 20 | #define _IFMGMT_CMD_H 21 | 22 | FILE_LICENCE ( GPL2_OR_LATER ); 23 | 24 | struct net_device; 25 | 26 | extern int ifcommon_exec ( int argc, char **argv, 27 | int ( * payload ) ( struct net_device * ), 28 | const char *verb ); 29 | 30 | #endif /* _IFMGMT_CMD_H */ 31 | -------------------------------------------------------------------------------- /src/include/libgen.h: -------------------------------------------------------------------------------- 1 | #ifndef _LIBGEN_H 2 | #define _LIBGEN_H 3 | 4 | FILE_LICENCE ( GPL2_OR_LATER ); 5 | 6 | extern char * basename ( char *path ); 7 | extern char * dirname ( char *path ); 8 | 9 | #endif /* _LIBGEN_H */ 10 | -------------------------------------------------------------------------------- /src/include/little_bswap.h: -------------------------------------------------------------------------------- 1 | #ifndef ETHERBOOT_LITTLE_BSWAP_H 2 | #define ETHERBOOT_LITTLE_BSWAP_H 3 | 4 | FILE_LICENCE ( GPL2_OR_LATER ); 5 | 6 | #define ntohl(x) __bswap_32(x) 7 | #define htonl(x) __bswap_32(x) 8 | #define ntohs(x) __bswap_16(x) 9 | #define htons(x) __bswap_16(x) 10 | #define cpu_to_le64(x) (x) 11 | #define cpu_to_le32(x) (x) 12 | #define cpu_to_le16(x) (x) 13 | #define cpu_to_be64(x) __bswap_64(x) 14 | #define cpu_to_be32(x) __bswap_32(x) 15 | #define cpu_to_be16(x) __bswap_16(x) 16 | #define le64_to_cpu(x) (x) 17 | #define le32_to_cpu(x) (x) 18 | #define le16_to_cpu(x) (x) 19 | #define be64_to_cpu(x) __bswap_64(x) 20 | #define be32_to_cpu(x) __bswap_32(x) 21 | #define be16_to_cpu(x) __bswap_16(x) 22 | #define cpu_to_le64s(x) do {} while (0) 23 | #define cpu_to_le32s(x) do {} while (0) 24 | #define cpu_to_le16s(x) do {} while (0) 25 | #define cpu_to_be64s(x) __bswap_64s(x) 26 | #define cpu_to_be32s(x) __bswap_32s(x) 27 | #define cpu_to_be16s(x) __bswap_16s(x) 28 | #define le64_to_cpus(x) do {} while (0) 29 | #define le32_to_cpus(x) do {} while (0) 30 | #define le16_to_cpus(x) do {} while (0) 31 | #define be64_to_cpus(x) __bswap_64s(x) 32 | #define be32_to_cpus(x) __bswap_32s(x) 33 | #define be16_to_cpus(x) __bswap_16s(x) 34 | 35 | #endif /* ETHERBOOT_LITTLE_BSWAP_H */ 36 | -------------------------------------------------------------------------------- /src/include/old_tcp.h: -------------------------------------------------------------------------------- 1 | #ifndef _TCP_H 2 | #define _TCP_H 3 | 4 | #define TCP_INITIAL_TIMEOUT (3*TICKS_PER_SEC) 5 | #define TCP_MAX_TIMEOUT (60*TICKS_PER_SEC) 6 | #define TCP_MIN_TIMEOUT (TICKS_PER_SEC) 7 | #define TCP_MAX_RETRY 10 8 | #define TCP_MAX_HEADER ((int)sizeof(struct iphdr)+64) 9 | #define TCP_MIN_WINDOW (1500-TCP_MAX_HEADER) 10 | #define TCP_MAX_WINDOW (65535-TCP_MAX_HEADER) 11 | 12 | #define FIN 1 13 | #define SYN 2 14 | #define RST 4 15 | #define PSH 8 16 | #define ACK 16 17 | #define URG 32 18 | 19 | 20 | struct tcphdr { 21 | uint16_t src; 22 | uint16_t dst; 23 | int32_t seq; 24 | int32_t ack; 25 | uint16_t ctrl; 26 | uint16_t window; 27 | uint16_t chksum; 28 | uint16_t urgent; 29 | }; 30 | 31 | extern int tcp_transaction ( unsigned long destip, unsigned int destsock, 32 | void *ptr, 33 | int (*send)(int len, void *buf, void *ptr), 34 | int (*recv)(int len, const void *buf, void *ptr)); 35 | 36 | 37 | #endif /* _TCP_H */ 38 | -------------------------------------------------------------------------------- /src/include/pc_kbd.h: -------------------------------------------------------------------------------- 1 | #ifndef _PC_KBD_H 2 | #define _PC_KBD_H 3 | 4 | int kbd_ischar(void); 5 | 6 | int kbd_getc(void); 7 | #endif 8 | -------------------------------------------------------------------------------- /src/include/pcmcia-opts.h: -------------------------------------------------------------------------------- 1 | // pcmcia-opts.h 2 | // special options file for development time. Later this could end in Config(?) 3 | #ifndef __pcmciaopts 4 | #define __pcmciaopts 5 | 6 | #define _yes_ 1 7 | #define _no_ 0 8 | 9 | #define SUPPORT_I82365 (_yes_) 10 | // #define SUPPORT_YENTA (_no_) 11 | // #define SUPPORT_SOME_DRIVER (_no_) 12 | 13 | #define PCMCIA_SHUTDOWN (_yes_) 14 | #define MAP_ATTRMEM_TO 0xd0000 15 | #define MAP_ATTRMEM_LEN 0x02000 16 | 17 | #define PDEBUG 3 18 | // The higher the more output you get, 0..3 19 | // Not fully implemented though, but for the future... 20 | 21 | #undef _yes_ 22 | #undef _no_ 23 | #endif 24 | -------------------------------------------------------------------------------- /src/include/readline/readline.h: -------------------------------------------------------------------------------- 1 | #ifndef _READLINE_H 2 | #define _READLINE_H 3 | 4 | /** @file 5 | * 6 | * Minmal readline 7 | * 8 | */ 9 | 10 | FILE_LICENCE ( GPL2_OR_LATER ); 11 | 12 | extern char * __malloc readline ( const char *prompt ); 13 | 14 | #endif /* _READLINE_H */ 15 | -------------------------------------------------------------------------------- /src/include/stdarg.h: -------------------------------------------------------------------------------- 1 | #ifndef _STDARG_H 2 | #define _STDARG_H 3 | 4 | FILE_LICENCE ( GPL2_OR_LATER ); 5 | 6 | typedef __builtin_va_list va_list; 7 | #define va_start( ap, last ) __builtin_va_start ( ap, last ) 8 | #define va_arg( ap, type ) __builtin_va_arg ( ap, type ) 9 | #define va_end( ap ) __builtin_va_end ( ap ) 10 | #define va_copy( dest, src ) __builtin_va_copy ( dest, src ) 11 | 12 | #endif /* _STDARG_H */ 13 | -------------------------------------------------------------------------------- /src/include/stddef.h: -------------------------------------------------------------------------------- 1 | #ifndef STDDEF_H 2 | #define STDDEF_H 3 | 4 | FILE_LICENCE ( GPL2_ONLY ); 5 | 6 | /* for size_t */ 7 | #include 8 | 9 | #undef NULL 10 | #define NULL ((void *)0) 11 | 12 | #undef offsetof 13 | #define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER) 14 | 15 | #undef container_of 16 | #define container_of(ptr, type, member) ({ \ 17 | const typeof( ((type *)0)->member ) *__mptr = (ptr); \ 18 | (type *)( (char *)__mptr - offsetof(type,member) );}) 19 | 20 | /* __WCHAR_TYPE__ is defined by gcc and will change if -fshort-wchar is used */ 21 | #ifndef __WCHAR_TYPE__ 22 | #define __WCHAR_TYPE__ long int 23 | #endif 24 | typedef __WCHAR_TYPE__ wchar_t; 25 | 26 | #endif /* STDDEF_H */ 27 | -------------------------------------------------------------------------------- /src/include/stdint.h: -------------------------------------------------------------------------------- 1 | #ifndef _STDINT_H 2 | #define _STDINT_H 3 | 4 | FILE_LICENCE ( GPL2_OR_LATER ); 5 | 6 | /* 7 | * This is a standard predefined macro on all gcc's I've seen. It's 8 | * important that we define size_t in the same way as the compiler, 9 | * because that's what it's expecting when it checks %zd/%zx printf 10 | * format specifiers. 11 | */ 12 | #ifndef __SIZE_TYPE__ 13 | #define __SIZE_TYPE__ unsigned long /* safe choice on most systems */ 14 | #endif 15 | 16 | #include 17 | 18 | typedef int8_t s8; 19 | typedef uint8_t u8; 20 | typedef int16_t s16; 21 | typedef uint16_t u16; 22 | typedef int32_t s32; 23 | typedef uint32_t u32; 24 | typedef int64_t s64; 25 | typedef uint64_t u64; 26 | 27 | typedef int8_t int8; 28 | typedef uint8_t uint8; 29 | typedef int16_t int16; 30 | typedef uint16_t uint16; 31 | typedef int32_t int32; 32 | typedef uint32_t uint32; 33 | typedef int64_t int64; 34 | typedef uint64_t uint64; 35 | 36 | #endif /* _STDINT_H */ 37 | -------------------------------------------------------------------------------- /src/include/stdio.h: -------------------------------------------------------------------------------- 1 | #ifndef _STDIO_H 2 | #define _STDIO_H 3 | 4 | FILE_LICENCE ( GPL2_OR_LATER ); 5 | 6 | #include 7 | #include 8 | 9 | extern int __attribute__ (( format ( printf, 1, 2 ) )) 10 | printf ( const char *fmt, ... ); 11 | 12 | extern int __attribute__ (( format ( printf, 3, 4 ) )) 13 | snprintf ( char *buf, size_t size, const char *fmt, ... ); 14 | 15 | extern int __attribute__ (( format ( printf, 2, 3 ) )) 16 | asprintf ( char **strp, const char *fmt, ... ); 17 | 18 | extern int vprintf ( const char *fmt, va_list args ); 19 | 20 | extern int vsnprintf ( char *buf, size_t size, const char *fmt, va_list args ); 21 | 22 | extern int vasprintf ( char **strp, const char *fmt, va_list args ); 23 | 24 | /** 25 | * Write a formatted string to a buffer 26 | * 27 | * @v buf Buffer into which to write the string 28 | * @v fmt Format string 29 | * @v ... Arguments corresponding to the format string 30 | * @ret len Length of formatted string 31 | */ 32 | #define sprintf( buf, fmt, ... ) \ 33 | snprintf ( (buf), ~( ( size_t ) 0 ), (fmt), ## __VA_ARGS__ ) 34 | 35 | /** 36 | * Write a formatted string to a buffer 37 | * 38 | * @v buf Buffer into which to write the string 39 | * @v fmt Format string 40 | * @v args Arguments corresponding to the format string 41 | * @ret len Length of formatted string 42 | */ 43 | static inline int vsprintf ( char *buf, const char *fmt, va_list args ) { 44 | return vsnprintf ( buf, ~( ( size_t ) 0 ), fmt, args ); 45 | } 46 | 47 | #endif /* _STDIO_H */ 48 | -------------------------------------------------------------------------------- /src/include/strings.h: -------------------------------------------------------------------------------- 1 | #ifndef _STRINGS_H 2 | #define _STRINGS_H 3 | 4 | FILE_LICENCE ( GPL2_OR_LATER ); 5 | 6 | #include 7 | #include 8 | 9 | static inline __attribute__ (( always_inline )) int 10 | __constant_flsl ( unsigned long x ) { 11 | int r = 0; 12 | 13 | #if ULONG_MAX > 0xffffffff 14 | if ( x & 0xffffffff00000000UL ) { 15 | x >>= 32; 16 | r += 32; 17 | } 18 | #endif 19 | if ( x & 0xffff0000UL ) { 20 | x >>= 16; 21 | r += 16; 22 | } 23 | if ( x & 0xff00 ) { 24 | x >>= 8; 25 | r += 8; 26 | } 27 | if ( x & 0xf0 ) { 28 | x >>= 4; 29 | r += 4; 30 | } 31 | if ( x & 0xc ) { 32 | x >>= 2; 33 | r += 2; 34 | } 35 | if ( x & 0x2 ) { 36 | x >>= 1; 37 | r += 1; 38 | } 39 | if ( x & 0x1 ) { 40 | r += 1; 41 | } 42 | return r; 43 | } 44 | 45 | /* We don't actually have these functions yet */ 46 | extern int __flsl ( long x ); 47 | 48 | #define flsl( x ) \ 49 | ( __builtin_constant_p ( x ) ? __constant_flsl ( x ) : __flsl ( x ) ) 50 | 51 | #define fls( x ) flsl ( x ) 52 | 53 | extern int strcasecmp ( const char *s1, const char *s2 ); 54 | 55 | static inline __attribute__ (( always_inline )) void 56 | bcopy ( const void *src, void *dest, size_t n ) { 57 | memmove ( dest, src, n ); 58 | } 59 | 60 | static inline __attribute__ (( always_inline )) void 61 | bzero ( void *s, size_t n ) { 62 | memset ( s, 0, n ); 63 | } 64 | 65 | #endif /* _STRINGS_H */ 66 | -------------------------------------------------------------------------------- /src/include/sys/time.h: -------------------------------------------------------------------------------- 1 | #ifndef _SYS_TIME_H 2 | #define _SYS_TIME_H 3 | 4 | #include 5 | 6 | typedef unsigned long suseconds_t; 7 | 8 | struct timeval { 9 | time_t tv_sec; /* seconds */ 10 | suseconds_t tv_usec; /* microseconds */ 11 | }; 12 | 13 | struct timezone { 14 | int tz_minuteswest; /* minutes W of Greenwich */ 15 | int tz_dsttime; /* type of dst correction */ 16 | }; 17 | 18 | extern int gettimeofday ( struct timeval *tv, struct timezone *tz ); 19 | 20 | #endif /* _SYS_TIME_H */ 21 | -------------------------------------------------------------------------------- /src/include/sys_info.h: -------------------------------------------------------------------------------- 1 | #ifndef SYS_INFO_H 2 | #define SYS_INFO_H 3 | 4 | /* Information collected from firmware/bootloader */ 5 | 6 | struct sys_info { 7 | /* Values passed by bootloader */ 8 | unsigned long boot_type; 9 | unsigned long boot_data; 10 | unsigned long boot_arg; 11 | 12 | char *firmware; /* "PCBIOS", "LinuxBIOS", etc. */ 13 | char *command_line; /* command line given to us */ 14 | #if 0 15 | //By LYH 16 | //Will use meminfo in Etherboot 17 | /* memory map */ 18 | int n_memranges; 19 | struct memrange { 20 | unsigned long long base; 21 | unsigned long long size; 22 | } *memrange; 23 | #endif 24 | }; 25 | 26 | void collect_sys_info(struct sys_info *info); 27 | void collect_elfboot_info(struct sys_info *info); 28 | void collect_linuxbios_info(struct sys_info *info); 29 | 30 | /* Our name and version. I want to see single instance of these in the image */ 31 | extern const char *program_name, *program_version; 32 | 33 | #endif /* SYS_INFO_H */ 34 | -------------------------------------------------------------------------------- /src/include/time.h: -------------------------------------------------------------------------------- 1 | #ifndef _TIME_H 2 | #define _TIME_H 3 | 4 | typedef unsigned long time_t; 5 | 6 | struct tm { 7 | int tm_sec; /* seconds */ 8 | int tm_min; /* minutes */ 9 | int tm_hour; /* hours */ 10 | int tm_mday; /* day of the month */ 11 | int tm_mon; /* month */ 12 | int tm_year; /* year */ 13 | int tm_wday; /* day of the week */ 14 | int tm_yday; /* day in the year */ 15 | int tm_isdst; /* daylight saving time */ 16 | }; 17 | 18 | extern time_t time ( time_t *t ); 19 | 20 | extern time_t mktime ( struct tm *tm ); 21 | 22 | #endif /* _TIME_H */ 23 | -------------------------------------------------------------------------------- /src/include/unistd.h: -------------------------------------------------------------------------------- 1 | #ifndef _UNISTD_H 2 | #define _UNISTD_H 3 | 4 | FILE_LICENCE ( GPL2_OR_LATER ); 5 | 6 | #include 7 | #include 8 | 9 | extern int execv ( const char *command, char * const argv[] ); 10 | 11 | /** 12 | * Execute command 13 | * 14 | * @v command Command name 15 | * @v arg ... Argument list (starting with argv[0]) 16 | * @ret rc Command exit status 17 | * 18 | * This is a front end to execv(). 19 | */ 20 | #define execl( command, arg, ... ) ( { \ 21 | char * const argv[] = { (arg), ## __VA_ARGS__ }; \ 22 | int rc = execv ( (command), argv ); \ 23 | rc; \ 24 | } ) 25 | 26 | /* Pick up udelay() */ 27 | #include 28 | 29 | /* 30 | * sleep() prototype is defined by POSIX.1. usleep() prototype is 31 | * defined by 4.3BSD. udelay() and mdelay() prototypes are chosen to 32 | * be reasonably sensible. 33 | * 34 | */ 35 | 36 | extern unsigned int sleep ( unsigned int seconds ); 37 | extern void mdelay ( unsigned long msecs ); 38 | 39 | static inline __always_inline void usleep ( unsigned long usecs ) { 40 | udelay ( usecs ); 41 | } 42 | 43 | #endif /* _UNISTD_H */ 44 | -------------------------------------------------------------------------------- /src/include/usr/autoboot.h: -------------------------------------------------------------------------------- 1 | #ifndef _USR_AUTOBOOT_H 2 | #define _USR_AUTOBOOT_H 3 | 4 | /** @file 5 | * 6 | * Automatic booting 7 | * 8 | */ 9 | 10 | FILE_LICENCE ( GPL2_OR_LATER ); 11 | 12 | #include 13 | struct net_device; 14 | 15 | extern int shutdown_exit_flags; 16 | 17 | extern void autoboot ( void ); 18 | extern int boot_next_server_and_filename ( struct in_addr next_server, 19 | const char *filename ); 20 | extern int boot_root_path ( const char *root_path ); 21 | 22 | extern int pxe_menu_boot ( struct net_device *netdev ); 23 | 24 | #endif /* _USR_AUTOBOOT_H */ 25 | -------------------------------------------------------------------------------- /src/include/usr/dhcpmgmt.h: -------------------------------------------------------------------------------- 1 | #ifndef _USR_DHCPMGMT_H 2 | #define _USR_DHCPMGMT_H 3 | 4 | /** @file 5 | * 6 | * DHCP management 7 | * 8 | */ 9 | 10 | FILE_LICENCE ( GPL2_OR_LATER ); 11 | 12 | struct net_device; 13 | 14 | extern int dhcp ( struct net_device *netdev ); 15 | extern int pxebs ( struct net_device *netdev, unsigned int pxe_type ); 16 | 17 | #endif /* _USR_DHCPMGMT_H */ 18 | -------------------------------------------------------------------------------- /src/include/usr/ifmgmt.h: -------------------------------------------------------------------------------- 1 | #ifndef _USR_IFMGMT_H 2 | #define _USR_IFMGMT_H 3 | 4 | /** @file 5 | * 6 | * Network interface management 7 | * 8 | */ 9 | 10 | FILE_LICENCE ( GPL2_OR_LATER ); 11 | 12 | struct net_device; 13 | 14 | extern int ifopen ( struct net_device *netdev ); 15 | extern void ifclose ( struct net_device *netdev ); 16 | extern void ifstat ( struct net_device *netdev ); 17 | extern int iflinkwait ( struct net_device *netdev, unsigned int max_wait_ms ); 18 | 19 | #endif /* _USR_IFMGMT_H */ 20 | -------------------------------------------------------------------------------- /src/include/usr/imgmgmt.h: -------------------------------------------------------------------------------- 1 | #ifndef _USR_IMGMGMT_H 2 | #define _USR_IMGMGMT_H 3 | 4 | /** @file 5 | * 6 | * Image management 7 | * 8 | */ 9 | 10 | FILE_LICENCE ( GPL2_OR_LATER ); 11 | 12 | struct image; 13 | 14 | extern int imgfetch ( struct image *image, const char *uri_string, 15 | int ( * image_register ) ( struct image *image ) ); 16 | extern int imgload ( struct image *image ); 17 | extern int imgexec ( struct image *image ); 18 | extern struct image * imgautoselect ( void ); 19 | extern void imgstat ( struct image *image ); 20 | extern void imgfree ( struct image *image ); 21 | 22 | #endif /* _USR_IMGMGMT_H */ 23 | -------------------------------------------------------------------------------- /src/include/usr/ip6mgmt.h: -------------------------------------------------------------------------------- 1 | #ifndef _USR_IPV6MGMT_H 2 | #define _USR_IPV6MGMT_H 3 | 4 | /** @file 5 | * 6 | * IPv6 management 7 | * 8 | */ 9 | 10 | FILE_LICENCE ( GPL2_OR_LATER ); 11 | 12 | struct net_device; 13 | 14 | extern int ip6_autoconf ( struct net_device *netdev ); 15 | 16 | #endif /* _USR_IPV6MGMT_H */ 17 | 18 | -------------------------------------------------------------------------------- /src/include/usr/iwmgmt.h: -------------------------------------------------------------------------------- 1 | #ifndef _USR_IWMGMT_H 2 | #define _USR_IWMGMT_H 3 | 4 | /** @file 5 | * 6 | * Wireless network interface management 7 | * 8 | */ 9 | 10 | FILE_LICENCE ( GPL2_OR_LATER ); 11 | 12 | struct net80211_device; 13 | 14 | extern void iwstat ( struct net80211_device *dev ); 15 | extern int iwlist ( struct net80211_device *dev ); 16 | 17 | #endif /* _USR_IWMGMT_H */ 18 | -------------------------------------------------------------------------------- /src/include/usr/route.h: -------------------------------------------------------------------------------- 1 | #ifndef _USR_ROUTE_H 2 | #define _USR_ROUTE_H 3 | 4 | /** @file 5 | * 6 | * Routing table management 7 | * 8 | */ 9 | 10 | FILE_LICENCE ( GPL2_OR_LATER ); 11 | 12 | extern void route ( void ); 13 | 14 | #endif /* _USR_ROUTE_H */ 15 | -------------------------------------------------------------------------------- /src/interface/efi/efi_strerror.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2008 Michael Brown . 3 | * 4 | * This program is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU General Public License as 6 | * published by the Free Software Foundation; either version 2 of the 7 | * License, or any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, but 10 | * WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | */ 18 | 19 | FILE_LICENCE ( GPL2_OR_LATER ); 20 | 21 | #include 22 | #include 23 | 24 | /** @file 25 | * 26 | * gPXE error message formatting for EFI 27 | * 28 | */ 29 | 30 | /** 31 | * Format EFI status code 32 | * 33 | * @v efirc EFI status code 34 | * @v efi_strerror EFI status code string 35 | */ 36 | const char * efi_strerror ( EFI_STATUS efirc ) { 37 | static char errbuf[32]; 38 | 39 | if ( ! efirc ) 40 | return "No error"; 41 | 42 | snprintf ( errbuf, sizeof ( errbuf ), "Error %lld", 43 | ( unsigned long long ) ( efirc ^ MAX_BIT ) ); 44 | return errbuf; 45 | } 46 | -------------------------------------------------------------------------------- /src/interface/efi/efi_uaccess.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2008 Michael Brown . 3 | * 4 | * This program is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU General Public License as 6 | * published by the Free Software Foundation; either version 2 of the 7 | * License, or any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, but 10 | * WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | */ 18 | 19 | FILE_LICENCE ( GPL2_OR_LATER ); 20 | 21 | #include 22 | #include 23 | 24 | /** @file 25 | * 26 | * gPXE user access API for EFI 27 | * 28 | */ 29 | 30 | PROVIDE_UACCESS_INLINE ( efi, phys_to_user ); 31 | PROVIDE_UACCESS_INLINE ( efi, user_to_phys ); 32 | PROVIDE_UACCESS_INLINE ( efi, virt_to_user ); 33 | PROVIDE_UACCESS_INLINE ( efi, user_to_virt ); 34 | PROVIDE_UACCESS_INLINE ( efi, userptr_add ); 35 | PROVIDE_UACCESS_INLINE ( efi, memcpy_user ); 36 | PROVIDE_UACCESS_INLINE ( efi, memmove_user ); 37 | PROVIDE_UACCESS_INLINE ( efi, memset_user ); 38 | PROVIDE_UACCESS_INLINE ( efi, strlen_user ); 39 | PROVIDE_UACCESS_INLINE ( efi, memchr_user ); 40 | -------------------------------------------------------------------------------- /src/libgcc/__divdi3.c: -------------------------------------------------------------------------------- 1 | /* 2 | * arch/i386/libgcc/__divdi3.c 3 | */ 4 | 5 | #include "libgcc.h" 6 | 7 | __libgcc int64_t __divdi3(int64_t num, int64_t den) 8 | { 9 | int minus = 0; 10 | int64_t v; 11 | 12 | if ( num < 0 ) { 13 | num = -num; 14 | minus = 1; 15 | } 16 | if ( den < 0 ) { 17 | den = -den; 18 | minus ^= 1; 19 | } 20 | 21 | v = __udivmoddi4(num, den, NULL); 22 | if ( minus ) 23 | v = -v; 24 | 25 | return v; 26 | } 27 | -------------------------------------------------------------------------------- /src/libgcc/__moddi3.c: -------------------------------------------------------------------------------- 1 | /* 2 | * arch/i386/libgcc/__moddi3.c 3 | */ 4 | 5 | #include "libgcc.h" 6 | 7 | __libgcc int64_t __moddi3(int64_t num, int64_t den) 8 | { 9 | int minus = 0; 10 | int64_t v; 11 | 12 | if ( num < 0 ) { 13 | num = -num; 14 | minus = 1; 15 | } 16 | if ( den < 0 ) { 17 | den = -den; 18 | minus ^= 1; 19 | } 20 | 21 | (void) __udivmoddi4(num, den, (uint64_t *)&v); 22 | if ( minus ) 23 | v = -v; 24 | 25 | return v; 26 | } 27 | -------------------------------------------------------------------------------- /src/libgcc/__udivdi3.c: -------------------------------------------------------------------------------- 1 | /* 2 | * arch/i386/libgcc/__divdi3.c 3 | */ 4 | 5 | #include "libgcc.h" 6 | 7 | __libgcc uint64_t __udivdi3(uint64_t num, uint64_t den) 8 | { 9 | return __udivmoddi4(num, den, NULL); 10 | } 11 | -------------------------------------------------------------------------------- /src/libgcc/__udivmoddi4.c: -------------------------------------------------------------------------------- 1 | #include "libgcc.h" 2 | 3 | __libgcc uint64_t __udivmoddi4(uint64_t num, uint64_t den, uint64_t *rem_p) 4 | { 5 | uint64_t quot = 0, qbit = 1; 6 | 7 | if ( den == 0 ) { 8 | return 1/((unsigned)den); /* Intentional divide by zero, without 9 | triggering a compiler warning which 10 | would abort the build */ 11 | } 12 | 13 | /* Left-justify denominator and count shift */ 14 | while ( (int64_t)den >= 0 ) { 15 | den <<= 1; 16 | qbit <<= 1; 17 | } 18 | 19 | while ( qbit ) { 20 | if ( den <= num ) { 21 | num -= den; 22 | quot += qbit; 23 | } 24 | den >>= 1; 25 | qbit >>= 1; 26 | } 27 | 28 | if ( rem_p ) 29 | *rem_p = num; 30 | 31 | return quot; 32 | } 33 | -------------------------------------------------------------------------------- /src/libgcc/__umoddi3.c: -------------------------------------------------------------------------------- 1 | /* 2 | * arch/i386/libgcc/__umoddi3.c 3 | */ 4 | 5 | #include "libgcc.h" 6 | 7 | __libgcc uint64_t __umoddi3(uint64_t num, uint64_t den) 8 | { 9 | uint64_t v; 10 | 11 | (void) __udivmoddi4(num, den, &v); 12 | return v; 13 | } 14 | -------------------------------------------------------------------------------- /src/libgcc/icc.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Intel's compiler creates an implicit call to this function at the 3 | * start of main(). 4 | * 5 | */ 6 | void __libgcc __intel_new_proc_init ( void ) { 7 | /* Do nothing */ 8 | } 9 | -------------------------------------------------------------------------------- /src/libgcc/libgcc.h: -------------------------------------------------------------------------------- 1 | #ifndef _LIBGCC_H 2 | #define _LIBGCC_H 3 | 4 | #include 5 | #include 6 | 7 | extern __libgcc uint64_t __udivmoddi4 ( uint64_t num, uint64_t den, 8 | uint64_t *rem ); 9 | extern __libgcc uint64_t __udivdi3 (uint64_t num, uint64_t den ); 10 | extern __libgcc uint64_t __umoddi3 ( uint64_t num, uint64_t den ); 11 | extern __libgcc int64_t __divdi3 ( int64_t num, int64_t den ); 12 | extern __libgcc int64_t __moddi3 ( int64_t num, int64_t den ); 13 | 14 | #endif /* _LIBGCC_H */ 15 | -------------------------------------------------------------------------------- /src/libgcc/memcpy.c: -------------------------------------------------------------------------------- 1 | /** @file 2 | * 3 | * gcc sometimes likes to insert implicit calls to memcpy(). 4 | * Unfortunately, there doesn't seem to be any way to prevent it from 5 | * doing this, or to force it to use the optimised memcpy() as seen by 6 | * C code; it insists on inserting a symbol reference to "memcpy". We 7 | * therefore include wrapper functions just to keep gcc happy. 8 | * 9 | */ 10 | 11 | #include 12 | 13 | void * gcc_implicit_memcpy ( void *dest, const void *src, 14 | size_t len ) asm ( "memcpy" ); 15 | 16 | void * gcc_implicit_memcpy ( void *dest, const void *src, size_t len ) { 17 | return memcpy ( dest, src, len ); 18 | } 19 | -------------------------------------------------------------------------------- /src/tests/comboot/shuffle-simple.asm: -------------------------------------------------------------------------------- 1 | bits 16 2 | org 100h 3 | 4 | jmp start 5 | 6 | shuffle_start: 7 | push 0xB800 8 | pop es 9 | mov cx, 80*24*2 10 | mov ax, 'AA' 11 | xor di, di 12 | rep stosw 13 | .lbl: jmp .lbl 14 | shuffle_end: 15 | nop 16 | shuffle_len equ (shuffle_end - shuffle_start + 1) 17 | 18 | start: 19 | ; calculate physical address of shuffled part 20 | xor eax, eax 21 | push ds 22 | pop ax 23 | shl eax, 4 24 | add ax, shuffle_start 25 | mov dword [source], eax 26 | 27 | mov ax, 0012h 28 | mov di, shuffle_descriptors 29 | mov cx, num_shuffle_descriptors 30 | mov ebp, 0x7c00 31 | int 22h 32 | int3 33 | 34 | shuffle_descriptors: 35 | dd 0x7C00 36 | source: dd 0 37 | dd shuffle_len 38 | 39 | num_shuffle_descriptors equ 1 40 | 41 | -------------------------------------------------------------------------------- /src/tests/gdbstub_test.S: -------------------------------------------------------------------------------- 1 | .arch i386 2 | 3 | .section ".data", "aw", @progbits 4 | watch_me: 5 | .long 0xfeedbeef 6 | 7 | .section ".text", "ax", @progbits 8 | .code32 9 | gdbstub_test: 10 | /* 1. Read registers test */ 11 | movl $0xea010203, %eax 12 | movl $0xeb040506, %ebx 13 | movl $0xec070809, %ecx 14 | movl $0xed0a0b0c, %edx 15 | movl $0x510d0e0f, %esi 16 | movl $0xd1102030, %edi 17 | int $3 18 | 19 | /* 2. Write registers test */ 20 | int $3 21 | 22 | /* 3. Read memory test */ 23 | subl $8, %esp 24 | movl $0x11223344, 4(%esp) 25 | movw $0x5566, 2(%esp) 26 | movb $0x77, (%esp) 27 | int $3 28 | 29 | /* 4. Write memory test */ 30 | int $3 31 | addl $8, %esp 32 | 33 | /* 5. Step test */ 34 | int $3 35 | nop 36 | 37 | /* 6. Access watch test */ 38 | movl $0x600d0000, %ecx 39 | movl watch_me, %eax 40 | movl $0xbad00000, %ecx 41 | int $3 42 | movl $0x600d0001, %ecx 43 | movl %eax, watch_me 44 | movl $0xbad00001, %ecx 45 | int $3 46 | 47 | /* 7. Write watch test */ 48 | movl $0x600d0002, %ecx 49 | movl %eax, watch_me 50 | movl $0xbad00002, %ecx 51 | int $3 52 | 53 | 1: 54 | jmp 1b 55 | -------------------------------------------------------------------------------- /src/tests/linebuf_test.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | static const char data1[] = 7 | "Hello world\r\n" 8 | "This is a reasonably nice set of lines\n" 9 | "with not many different terminators\r\n\r\n" 10 | "There should be exactly one blank line above\n" 11 | "and this line should never appear at all since it has no terminator"; 12 | 13 | void linebuf_test ( void ) { 14 | struct line_buffer linebuf; 15 | const char *data = data1; 16 | size_t len = ( sizeof ( data1 ) - 1 /* be mean; strip the NUL */ ); 17 | ssize_t frag_len; 18 | char *line; 19 | 20 | memset ( &linebuf, 0, sizeof ( linebuf ) ); 21 | while ( len ) { 22 | frag_len = line_buffer ( &linebuf, data, len ); 23 | if ( frag_len < 0 ) { 24 | printf ( "line_buffer() failed: %s\n", 25 | strerror ( frag_len ) ); 26 | return; 27 | } 28 | data += frag_len; 29 | len -= frag_len; 30 | if ( ( line = buffered_line ( &linebuf ) ) ) 31 | printf ( "\"%s\"\n", line ); 32 | } 33 | 34 | empty_line_buffer ( &linebuf ); 35 | } 36 | -------------------------------------------------------------------------------- /src/tests/umalloc_test.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | void umalloc_test ( void ) { 7 | struct memory_map memmap; 8 | userptr_t bob; 9 | userptr_t fred; 10 | 11 | printf ( "Before allocation:\n" ); 12 | get_memmap ( &memmap ); 13 | 14 | bob = umalloc ( 1234 ); 15 | bob = urealloc ( bob, 12345 ); 16 | fred = umalloc ( 999 ); 17 | 18 | printf ( "After allocation:\n" ); 19 | get_memmap ( &memmap ); 20 | 21 | ufree ( bob ); 22 | ufree ( fred ); 23 | 24 | printf ( "After freeing:\n" ); 25 | get_memmap ( &memmap ); 26 | } 27 | -------------------------------------------------------------------------------- /src/util/.gitignore: -------------------------------------------------------------------------------- 1 | nrv2b 2 | zbin 3 | hijack 4 | prototester 5 | elf2efi32 6 | elf2efi64 7 | efirom 8 | iccfix 9 | einfo 10 | -------------------------------------------------------------------------------- /src/util/Makefile: -------------------------------------------------------------------------------- 1 | BLIB = ../bin/blib.a 2 | CFLAGS = -Os 3 | 4 | all : hijack prototester mucurses_test 5 | 6 | hijack : hijack.c 7 | $(CC) $(CFLAGS) $(EXTRA_CFLAGS) -Wall -lpcap -o $@ $< 8 | 9 | prototester.o : prototester.c 10 | $(CC) $(CFLAGS) $(EXTRA_CFLAGS) -Wall -o $@ -c $< -idirafter ../include 11 | 12 | prototester : prototester.o $(BLIB) 13 | $(CC) -o $@ $< -lc $(BLIB) 14 | 15 | mucurses_test.o : mucurses_test.c 16 | $(CC) $(CFLAGS) $(EXTRA_CFLAGS) -Wall -o $@ -c $< 17 | 18 | mucurses_test : mucurses_test.o $(BLIB) 19 | $(CC) -o $@ $< -lc $(BLIB) 20 | 21 | clean : 22 | rm -f hijack prototester mucurses_test *.o 23 | -------------------------------------------------------------------------------- /src/util/fixrom.pl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl -w 2 | # 3 | # Copyright (C) 2010 Michael Brown . 4 | # 5 | # This program is free software; you can redistribute it and/or 6 | # modify it under the terms of the GNU General Public License as 7 | # published by the Free Software Foundation; either version 2 of the 8 | # License, or any later version. 9 | # 10 | # This program is distributed in the hope that it will be useful, but 11 | # WITHOUT ANY WARRANTY; without even the implied warranty of 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | # General Public License for more details. 14 | # 15 | # You should have received a copy of the GNU General Public License 16 | # along with this program; if not, write to the Free Software 17 | # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 18 | 19 | use strict; 20 | use warnings; 21 | 22 | use FindBin; 23 | use lib "$FindBin::Bin"; 24 | use Option::ROM qw ( :all ); 25 | 26 | my @romfiles = @ARGV; 27 | 28 | foreach my $romfile ( @romfiles ) { 29 | my $rom = new Option::ROM; 30 | $rom->load ( $romfile ); 31 | $rom->pnp_header->fix_checksum() if $rom->pnp_header; 32 | $rom->fix_checksum(); 33 | $rom->save ( $romfile ); 34 | } 35 | -------------------------------------------------------------------------------- /src/util/fnrec.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # Copyright (C) 2010 Stefan Hajnoczi . 4 | # 5 | # This program is free software; you can redistribute it and/or 6 | # modify it under the terms of the GNU General Public License as 7 | # published by the Free Software Foundation; either version 2 of the 8 | # License, or any later version. 9 | # 10 | # This program is distributed in the hope that it will be useful, but 11 | # WITHOUT ANY WARRANTY; without even the implied warranty of 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | # General Public License for more details. 14 | # 15 | # You should have received a copy of the GNU General Public License 16 | # along with this program; if not, write to the Free Software 17 | # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 18 | 19 | if [ $# != 2 ] 20 | then 21 | cat >&2 < 23 | Look up symbol names in for function addresses from 24 | . 25 | 26 | Example: 27 | $0 bin/gpxe.hd.tmp fnrec.dat 28 | EOF 29 | exit 1 30 | fi 31 | 32 | tr ' ' '\n' <"$2" | addr2line -fe "$1" | awk '(NR % 2) { print }' 33 | -------------------------------------------------------------------------------- /src/util/genliso: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # Generate a legacy floppy emulation ISO boot image 4 | # 5 | # genliso foo.liso foo.lkrn bar.lkrn ... 6 | # 7 | # The .liso image filename is the first argument followed by 8 | # a list of .lkrn images include in .liso image 9 | 10 | case $# in 11 | 0|1) 12 | echo Usage: $0 foo.liso foo.lkrn ... 13 | exit 1 14 | ;; 15 | esac 16 | 17 | case "`mtools -V`" in 18 | Mtools\ version\ 3.9.9*|Mtools\ version\ 3.9.1[0-9]*|[mM]tools\ *\ [4-9].*) 19 | ;; 20 | *) 21 | echo Mtools version 3.9.9 or later is required 22 | exit 1 23 | ;; 24 | esac 25 | 26 | out=$1 27 | shift 28 | 29 | dir=`mktemp -d bin/liso.dir.XXXXXX` 30 | 31 | img=$dir/boot.img 32 | mformat -f 1440 -C -i $img :: 33 | 34 | cfg=$dir/syslinux.cfg 35 | cat > $cfg <&2 47 | continue 48 | fi 49 | # shorten name for 8.3 filesystem 50 | b=$(basename $f) 51 | g=${b%.lkrn} 52 | g=${g//[^a-z0-9]} 53 | g=${g:0:8}.krn 54 | case "$first" in 55 | "") 56 | echo DEFAULT $g 57 | ;; 58 | esac 59 | first=$g 60 | echo LABEL $b 61 | echo "" KERNEL $g 62 | mcopy -m -i $img $f ::$g 63 | done >> $cfg 64 | 65 | mcopy -i $img $cfg ::syslinux.cfg 66 | 67 | if ! syslinux $img 68 | then 69 | exit 1 70 | fi 71 | 72 | mkisofs -q -o $out -c boot.cat -b boot.img $dir 73 | 74 | rm -fr $dir 75 | -------------------------------------------------------------------------------- /src/util/gensdsk: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # Generate a syslinux floppy that loads a gPXE image 4 | # 5 | # gensdsk foo.sdsk foo.lkrn 6 | # 7 | # the floppy image is the first argument 8 | # followed by list of .lkrn images 9 | # 10 | 11 | case $# in 12 | 0|1) 13 | echo Usage: $0 foo.sdsk foo.lkrn ... 14 | exit 1 15 | ;; 16 | esac 17 | case "`mtools -V`" in 18 | Mtools\ version\ 3.9.9*|Mtools\ version\ 3.9.1[0-9]*|[mM]tools\ *\ [4-9].*) 19 | ;; 20 | *) 21 | echo Mtools version 3.9.9 or later is required 22 | exit 1 23 | ;; 24 | esac 25 | img=$1 26 | shift 27 | dir=`mktemp -d bin/sdsk.dir.XXXXXX` 28 | 29 | mformat -f 1440 -C -i $img :: 30 | cfg=$dir/syslinux.cfg 31 | cat > $cfg <&2 42 | continue 43 | fi 44 | # shorten name for 8.3 filesystem 45 | b=$(basename $f) 46 | g=${b%.lkrn} 47 | g=${g//[^a-z0-9]} 48 | g=${g:0:8}.krn 49 | case "$first" in 50 | "") 51 | echo DEFAULT $g 52 | ;; 53 | esac 54 | first=$g 55 | echo LABEL $b 56 | echo "" KERNEL $g 57 | mcopy -m -i $img $f ::$g 58 | done >> $cfg 59 | mcopy -i $img $cfg ::syslinux.cfg 60 | if ! syslinux $img 61 | then 62 | exit 1 63 | fi 64 | 65 | rm -fr $dir 66 | -------------------------------------------------------------------------------- /src/util/padimg.pl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl -w 2 | 3 | use strict; 4 | use warnings; 5 | use Getopt::Long; 6 | use Fcntl; 7 | 8 | my $verbosity = 0; 9 | my $blksize = 512; 10 | my $byte = 0; 11 | 12 | my %opts = ( 13 | 'verbose|v+' => sub { $verbosity++; }, 14 | 'quiet|q+' => sub { $verbosity--; }, 15 | 'blksize|s=o' => sub { $blksize = $_[1]; }, 16 | 'byte|b=o' => sub { $byte = $_[1]; }, 17 | ); 18 | 19 | Getopt::Long::Configure ( 'bundling', 'auto_abbrev' ); 20 | GetOptions ( %opts ) or die "Could not parse command-line options\n"; 21 | 22 | while ( my $filename = shift ) { 23 | die "$filename is not a file\n" unless -f $filename; 24 | my $oldsize = -s $filename; 25 | my $padsize = ( ( -$oldsize ) % $blksize ); 26 | my $newsize = ( $oldsize + $padsize ); 27 | next unless $padsize; 28 | if ( $verbosity >= 1 ) { 29 | printf "Padding %s from %d to %d bytes with %d x 0x%02x\n", 30 | $filename, $oldsize, $newsize, $padsize, $byte; 31 | } 32 | if ( $byte ) { 33 | sysopen ( my $fh, $filename, ( O_WRONLY | O_APPEND ) ) 34 | or die "Could not open $filename for appending: $!\n"; 35 | syswrite $fh, ( chr ( $byte ) x $padsize ) 36 | or die "Could not append to $filename: $!\n"; 37 | close ( $fh ); 38 | } else { 39 | truncate $filename, $newsize 40 | or die "Could not resize $filename: $!\n"; 41 | } 42 | die "Failed to pad $filename\n" 43 | unless ( ( ( -s $filename ) % $blksize ) == 0 ); 44 | } 45 | --------------------------------------------------------------------------------