1 /* 2 * Copyright 2006, Marcus Overhagen <marcus@overhagen.de. All rights reserved. 3 * Distributed under the terms of the MIT License. 4 */ 5 6 #ifndef _PXE_UNDI_H 7 #define _PXE_UNDI_H 8 9 extern "C" uint16 call_pxe_bios(void *pxe, uint16 opcode, void *param); 10 11 #define UNDI_OPEN 0x0006 12 #define UNDI_TRANSMIT 0x0008 13 #define UNDI_GET_INFORMATION 0x000C 14 #define UNDI_ISR 0x0014 15 #define UNDI_GET_STATE 0x0015 16 17 #define TFTP_OPEN 0x0020 18 #define TFTP_CLOSE 0x0021 19 #define TFTP_READ 0x0022 20 #define TFTP_GET_FILE_SIZE 0x0025 21 22 #define GET_CACHED_INFO 0x0071 23 24 #define SEG(ptr) ((uint16)(((uint32)(ptr)) >> 4)) 25 #define OFS(ptr) ((uint16)(((uint32)(ptr)) & 15)) 26 27 #define MAC_ADDR_LEN 16 28 typedef uint8 MAC_ADDR[MAC_ADDR_LEN]; 29 30 struct SEGSEL 31 { 32 uint16 a; 33 }; 34 35 struct SEGOFF16 36 { 37 uint16 ofs; 38 uint16 seg; 39 }; 40 41 struct SEGDESC 42 { 43 uint64 a; 44 }; 45 46 struct PXE_STRUCT 47 { 48 uint32 Signature; 49 uint8 StructLength; 50 uint8 StructCksum; 51 uint8 StructRev; 52 uint8 reserved_1; 53 SEGOFF16 UNDIROMID; 54 SEGOFF16 BaseROMID; 55 SEGOFF16 EntryPointSP; 56 SEGOFF16 EntryPointESP; 57 SEGOFF16 StatusCallout; 58 uint8 reserved_2; 59 uint8 SegDescCnt; 60 SEGSEL FirstSelector; 61 SEGDESC Stack; 62 SEGDESC UNDIData; 63 SEGDESC UNDICode; 64 SEGDESC UNDICodeWrite; 65 SEGDESC BC_Data; 66 SEGDESC BC_Code; 67 SEGDESC BC_CodeWrite; 68 }; 69 70 struct PXENV_GET_CACHED_INFO 71 { 72 uint16 Status; 73 uint16 PacketType; 74 #define PXENV_PACKET_TYPE_DHCP_DISCOVER 1 75 #define PXENV_PACKET_TYPE_DHCP_ACK 2 76 #define PXENV_PACKET_TYPE_CACHED_REPLY 3 77 uint16 BufferSize; 78 SEGOFF16 Buffer; 79 uint16 BufferLimit; 80 }; 81 82 struct PXENV_UNDI_MCAST_ADDRESS 83 { 84 #define MAXNUM_MCADDR 8 85 uint16 MCastAddrCount; 86 MAC_ADDR McastAddr[MAXNUM_MCADDR]; 87 }; 88 89 struct PXENV_UNDI_OPEN 90 { 91 uint16 Status; 92 uint16 OpenFlag; 93 uint16 PktFilter; 94 #define FLTR_DIRECTED 0x0001 95 #define FLTR_BRDCST 0x0002 96 #define FLTR_PRMSCS 0x0004 97 #define FLTR_SRC_RTG 0x0008 98 PXENV_UNDI_MCAST_ADDRESS R_Mcast_Buf; 99 }; 100 101 struct PXENV_UNDI_GET_STATE 102 { 103 #define PXE_UNDI_GET_STATE_STARTED 1 104 #define PXE_UNDI_GET_STATE_INITIALIZED 2 105 #define PXE_UNDI_GET_STATE_OPENED 3 106 uint16 Status; 107 uint8 UNDIstate; 108 }; 109 110 struct PXENV_UNDI_GET_INFORMATION 111 { 112 uint16 Status; 113 uint16 BaseIo; 114 uint16 IntNumber; 115 uint16 MaxTranUnit; 116 uint16 HwType; 117 #define ETHER_TYPE 1 118 #define EXP_ETHER_TYPE 2 119 #define IEEE_TYPE 6 120 #define ARCNET_TYPE 7 121 uint16 HwAddrLen; 122 MAC_ADDR CurrentNodeAddress; 123 MAC_ADDR PermNodeAddress; 124 SEGSEL ROMAddress; 125 uint16 RxBufCt; 126 uint16 TxBufCt; 127 }; 128 129 struct PXENV_UNDI_TRANSMIT 130 { 131 uint16 Status; 132 uint8 Protocol; 133 #define P_UNKNOWN 0 134 #define P_IP 1 135 #define P_ARP 2 136 #define P_RARP 3 137 uint8 XmitFlag; 138 #define XMT_DESTADDR 0x0000 139 #define XMT_BROADCAST 0x0001 140 SEGOFF16 DestAddr; 141 SEGOFF16 TBD; 142 uint32 Reserved[2]; 143 }; 144 145 #define MAX_DATA_BLKS 8 146 struct PXENV_UNDI_TBD 147 { 148 uint16 ImmedLength; 149 SEGOFF16 Xmit; 150 uint16 DataBlkCount; 151 struct DataBlk 152 { 153 uint8 TDPtrType; 154 uint8 TDRsvdByte; 155 uint16 TDDataLen; 156 SEGOFF16 TDDataPtr; 157 } DataBlock[MAX_DATA_BLKS]; 158 }; 159 160 struct PXENV_UNDI_ISR 161 { 162 uint16 Status; 163 uint16 FuncFlag; 164 uint16 BufferLength; 165 uint16 FrameLength; 166 uint16 FrameHeaderLength; 167 SEGOFF16 Frame; 168 uint8 ProtType; 169 uint8 PktType; 170 }; 171 172 #define PXENV_UNDI_ISR_IN_START 1 173 #define PXENV_UNDI_ISR_IN_PROCESS 2 174 #define PXENV_UNDI_ISR_IN_GET_NEXT 3 175 176 /* One of these will be returned for 177 PXENV_UNDI_ISR_IN_START 178 */ 179 #define PXENV_UNDI_ISR_OUT_OURS 0 180 #define PXENV_UNDI_USR_OUT_NOT_OURS 1 181 182 /* One of these will be returned for 183 PXENV_UNDI_ISR_IN_PROCESS and 184 PXENV_UNDI_ISR_IN_GET_NEXT 185 */ 186 #define PXENV_UNDI_ISR_OUT_DONE 0 187 #define PXENV_UNDI_ISR_OUT_TRANSMIT 2 188 #define PXENV_UNDI_ISR_OUT_RECEIVE 3 189 #define PXENV_UNDI_ISR_OUT_BUSY 4 190 191 192 typedef union { 193 uint32 num; 194 uint8 array[4]; 195 } pxenv_ip4; 196 197 struct pxenv_tftp_open { 198 uint16 status; 199 pxenv_ip4 server_ip; 200 pxenv_ip4 gateway_ip; 201 char file_name[128]; 202 uint16 port; 203 uint16 packet_size; 204 } __attribute__((packed)); 205 206 struct pxenv_tftp_close { 207 uint16 status; 208 } __attribute__((packed)); 209 210 struct pxenv_tftp_read { 211 uint16 status; 212 uint16 packet_number; 213 uint16 buffer_size; 214 SEGOFF16 buffer; 215 } __attribute__((packed)); 216 217 struct pxenv_tftp_get_fsize { 218 uint16 status; 219 pxenv_ip4 server_ip; 220 pxenv_ip4 gateway_ip; 221 char file_name[128]; 222 uint32 file_size; 223 } __attribute__((packed)); 224 225 226 PXE_STRUCT * pxe_undi_find_data(); 227 228 #endif 229