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 3.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. #ifndef PXE_H
  2. #define PXE_H
  3. #include "pxe_types.h"
  4. #include "pxe_api.h"
  5. #include "etherboot.h"
  6. #include "tftp.h"
  7. /* Union used for PXE API calls; we don't know the type of the
  8. * structure until we interpret the opcode. Also, Status is available
  9. * in the same location for any opcode, and it's convenient to have
  10. * non-specific access to it.
  11. */
  12. union u_PXENV_ANY {
  13. /* Make it easy to read status for any operation */
  14. PXENV_STATUS_t Status;
  15. struct s_PXENV_UNLOAD_STACK unload_stack;
  16. struct s_PXENV_GET_CACHED_INFO get_cached_info;
  17. struct s_PXENV_TFTP_READ_FILE restart_tftp;
  18. struct s_PXENV_START_UNDI start_undi;
  19. struct s_PXENV_STOP_UNDI stop_undi;
  20. struct s_PXENV_START_BASE start_base;
  21. struct s_PXENV_STOP_BASE stop_base;
  22. struct s_PXENV_TFTP_OPEN tftp_open;
  23. struct s_PXENV_TFTP_CLOSE tftp_close;
  24. struct s_PXENV_TFTP_READ tftp_read;
  25. struct s_PXENV_TFTP_READ_FILE tftp_read_file;
  26. struct s_PXENV_TFTP_GET_FSIZE tftp_get_fsize;
  27. struct s_PXENV_UDP_OPEN udp_open;
  28. struct s_PXENV_UDP_CLOSE udp_close;
  29. struct s_PXENV_UDP_WRITE udp_write;
  30. struct s_PXENV_UDP_READ udp_read;
  31. struct s_PXENV_UNDI_STARTUP undi_startup;
  32. struct s_PXENV_UNDI_CLEANUP undi_cleanup;
  33. struct s_PXENV_UNDI_INITIALIZE undi_initialize;
  34. struct s_PXENV_UNDI_RESET undi_reset_adapter;
  35. struct s_PXENV_UNDI_SHUTDOWN undi_shutdown;
  36. struct s_PXENV_UNDI_OPEN undi_open;
  37. struct s_PXENV_UNDI_CLOSE undi_close;
  38. struct s_PXENV_UNDI_TRANSMIT undi_transmit;
  39. struct s_PXENV_UNDI_SET_MCAST_ADDRESS undi_set_mcast_address;
  40. struct s_PXENV_UNDI_SET_STATION_ADDRESS undi_set_station_address;
  41. struct s_PXENV_UNDI_SET_PACKET_FILTER undi_set_packet_filter;
  42. struct s_PXENV_UNDI_GET_INFORMATION undi_get_information;
  43. struct s_PXENV_UNDI_GET_STATISTICS undi_get_statistics;
  44. struct s_PXENV_UNDI_CLEAR_STATISTICS undi_clear_statistics;
  45. struct s_PXENV_UNDI_INITIATE_DIAGS undi_initiate_diags;
  46. struct s_PXENV_UNDI_FORCE_INTERRUPT undi_force_interrupt;
  47. struct s_PXENV_UNDI_GET_MCAST_ADDRESS undi_get_mcast_address;
  48. struct s_PXENV_UNDI_GET_NIC_TYPE undi_get_nic_type;
  49. struct s_PXENV_UNDI_GET_IFACE_INFO undi_get_iface_info;
  50. struct s_PXENV_UNDI_GET_STATE undi_get_state;
  51. struct s_PXENV_UNDI_ISR undi_isr;
  52. };
  53. typedef union u_PXENV_ANY PXENV_ANY_t;
  54. /* PXE stack status indicator. See pxe_export.c for further
  55. * explanation.
  56. */
  57. typedef enum {
  58. CAN_UNLOAD = 0,
  59. MIDWAY,
  60. READY
  61. } pxe_stack_state_t;
  62. #define ENSURE_CAN_UNLOAD(structure) if ( ! ensure_pxe_state(CAN_UNLOAD) ) { \
  63. structure->Status = PXENV_STATUS_UNDI_INVALID_STATE; \
  64. return PXENV_EXIT_FAILURE; }
  65. #define ENSURE_MIDWAY(structure) if ( ! ensure_pxe_state(MIDWAY) ) { \
  66. structure->Status = PXENV_STATUS_UNDI_INVALID_STATE; \
  67. return PXENV_EXIT_FAILURE; }
  68. #define ENSURE_READY(structure) if ( ! ensure_pxe_state(READY) ) { \
  69. structure->Status = PXENV_STATUS_UNDI_INVALID_STATE; \
  70. return PXENV_EXIT_FAILURE; }
  71. /* Data structures installed as part of a PXE stack. Architectures
  72. * will have extra information to append to the end of this.
  73. */
  74. #define PXE_TFTP_MAGIC_COOKIE ( ( 'P'<<24 ) | ( 'x'<<16 ) | ( 'T'<<8 ) | 'f' )
  75. typedef struct pxe_stack {
  76. struct s_PXE pxe __attribute__ ((aligned(16)));
  77. struct s_PXENV pxenv __attribute__ ((aligned(16)));
  78. pxe_stack_state_t state;
  79. union {
  80. BOOTPLAYER_t cached_info;
  81. char packet[ETH_FRAME_LEN];
  82. struct {
  83. uint32_t magic_cookie;
  84. unsigned int len;
  85. int eof;
  86. char data[TFTP_MAX_BLKSIZE];
  87. } tftpdata;
  88. struct {
  89. char *buffer;
  90. uint32_t offset;
  91. uint32_t bufferlen;
  92. } readfile;
  93. };
  94. struct {} arch_data __attribute__ ((aligned(16)));
  95. } pxe_stack_t;
  96. extern int ensure_pxe_state ( pxe_stack_state_t wanted );
  97. extern pxe_stack_t *pxe_stack;
  98. extern PXENV_EXIT_t pxe_api_call ( int opcode, union u_PXENV_ANY *any );
  99. #endif /* PXE_H */