You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

pxe.h 5.9KB

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