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

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