1#ifndef PXE_H 2#define PXE_H 3 4FILE_LICENCE ( GPL2_OR_LATER ); 5 6#include "pxe_types.h" 7#include "pxe_api.h" 8#include <gpxe/device.h> 9 10/* Parameter block for pxenv_unknown() */ 11struct s_PXENV_UNKNOWN { 12 PXENV_STATUS_t Status; /**< PXE status code */ 13} PACKED; 14 15typedef struct s_PXENV_UNKNOWN PXENV_UNKNOWN_t; 16 17/* Union used for PXE API calls; we don't know the type of the 18 * structure until we interpret the opcode. Also, Status is available 19 * in the same location for any opcode, and it's convenient to have 20 * non-specific access to it. 21 */ 22union u_PXENV_ANY { 23 /* Make it easy to read status for any operation */ 24 PXENV_STATUS_t Status; 25 struct s_PXENV_UNKNOWN unknown; 26 struct s_PXENV_UNLOAD_STACK unload_stack; 27 struct s_PXENV_GET_CACHED_INFO get_cached_info; 28 struct s_PXENV_TFTP_READ_FILE restart_tftp; 29 struct s_PXENV_START_UNDI start_undi; 30 struct s_PXENV_STOP_UNDI stop_undi; 31 struct s_PXENV_START_BASE start_base; 32 struct s_PXENV_STOP_BASE stop_base; 33 struct s_PXENV_TFTP_OPEN tftp_open; 34 struct s_PXENV_TFTP_CLOSE tftp_close; 35 struct s_PXENV_TFTP_READ tftp_read; 36 struct s_PXENV_TFTP_READ_FILE tftp_read_file; 37 struct s_PXENV_TFTP_GET_FSIZE tftp_get_fsize; 38 struct s_PXENV_UDP_OPEN udp_open; 39 struct s_PXENV_UDP_CLOSE udp_close; 40 struct s_PXENV_UDP_WRITE udp_write; 41 struct s_PXENV_UDP_READ udp_read; 42 struct s_PXENV_UNDI_STARTUP undi_startup; 43 struct s_PXENV_UNDI_CLEANUP undi_cleanup; 44 struct s_PXENV_UNDI_INITIALIZE undi_initialize; 45 struct s_PXENV_UNDI_RESET undi_reset_adapter; 46 struct s_PXENV_UNDI_SHUTDOWN undi_shutdown; 47 struct s_PXENV_UNDI_OPEN undi_open; 48 struct s_PXENV_UNDI_CLOSE undi_close; 49 struct s_PXENV_UNDI_TRANSMIT undi_transmit; 50 struct s_PXENV_UNDI_SET_MCAST_ADDRESS undi_set_mcast_address; 51 struct s_PXENV_UNDI_SET_STATION_ADDRESS undi_set_station_address; 52 struct s_PXENV_UNDI_SET_PACKET_FILTER undi_set_packet_filter; 53 struct s_PXENV_UNDI_GET_INFORMATION undi_get_information; 54 struct s_PXENV_UNDI_GET_STATISTICS undi_get_statistics; 55 struct s_PXENV_UNDI_CLEAR_STATISTICS undi_clear_statistics; 56 struct s_PXENV_UNDI_INITIATE_DIAGS undi_initiate_diags; 57 struct s_PXENV_UNDI_FORCE_INTERRUPT undi_force_interrupt; 58 struct s_PXENV_UNDI_GET_MCAST_ADDRESS undi_get_mcast_address; 59 struct s_PXENV_UNDI_GET_NIC_TYPE undi_get_nic_type; 60 struct s_PXENV_UNDI_GET_IFACE_INFO undi_get_iface_info; 61 struct s_PXENV_UNDI_GET_STATE undi_get_state; 62 struct s_PXENV_UNDI_ISR undi_isr; 63 struct s_PXENV_FILE_OPEN file_open; 64 struct s_PXENV_FILE_CLOSE file_close; 65 struct s_PXENV_FILE_SELECT file_select; 66 struct s_PXENV_FILE_READ file_read; 67 struct s_PXENV_GET_FILE_SIZE get_file_size; 68 struct s_PXENV_FILE_EXEC file_exec; 69 struct s_PXENV_FILE_API_CHECK file_api_check; 70 struct s_PXENV_FILE_EXIT_HOOK file_exit_hook; 71}; 72 73typedef union u_PXENV_ANY PXENV_ANY_t; 74 75/** An UNDI expansion ROM header */ 76struct undi_rom_header { 77 /** Signature 78 * 79 * Must be equal to @c ROM_SIGNATURE 80 */ 81 UINT16_t Signature; 82 /** ROM length in 512-byte blocks */ 83 UINT8_t ROMLength; 84 /** Unused */ 85 UINT8_t unused[0x13]; 86 /** Offset of the PXE ROM ID structure */ 87 UINT16_t PXEROMID; 88 /** Offset of the PCI ROM structure */ 89 UINT16_t PCIRHeader; 90} PACKED; 91 92/** Signature for an expansion ROM */ 93#define ROM_SIGNATURE 0xaa55 94 95/** An UNDI ROM ID structure */ 96struct undi_rom_id { 97 /** Signature 98 * 99 * Must be equal to @c UNDI_ROM_ID_SIGNATURE 100 */ 101 UINT32_t Signature; 102 /** Length of structure */ 103 UINT8_t StructLength; 104 /** Checksum */ 105 UINT8_t StructCksum; 106 /** Structure revision 107 * 108 * Must be zero. 109 */ 110 UINT8_t StructRev; 111 /** UNDI revision 112 * 113 * Version 2.1.0 is encoded as the byte sequence 0x00, 0x01, 0x02. 114 */ 115 UINT8_t UNDIRev[3]; 116 /** Offset to UNDI loader */ 117 UINT16_t UNDILoader; 118 /** Minimum required stack segment size */ 119 UINT16_t StackSize; 120 /** Minimum required data segment size */ 121 UINT16_t DataSize; 122 /** Minimum required code segment size */ 123 UINT16_t CodeSize; 124} PACKED; 125 126/** Signature for an UNDI ROM ID structure */ 127#define UNDI_ROM_ID_SIGNATURE \ 128 ( ( 'U' << 0 ) + ( 'N' << 8 ) + ( 'D' << 16 ) + ( 'I' << 24 ) ) 129 130/** A PCI expansion header */ 131struct pcir_header { 132 /** Signature 133 * 134 * Must be equal to @c PCIR_SIGNATURE 135 */ 136 uint32_t signature; 137 /** PCI vendor ID */ 138 uint16_t vendor_id; 139 /** PCI device ID */ 140 uint16_t device_id; 141} PACKED; 142 143/** Signature for an UNDI ROM ID structure */ 144#define PCIR_SIGNATURE \ 145 ( ( 'P' << 0 ) + ( 'C' << 8 ) + ( 'I' << 16 ) + ( 'R' << 24 ) ) 146 147 148extern struct net_device *pxe_netdev; 149 150extern void pxe_set_netdev ( struct net_device *netdev ); 151 152extern void pxe_set_cached_filename ( const unsigned char *filename ); 153 154#endif /* PXE_H */ 155