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.

undi.h 4.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  1. /**************************************************************************
  2. Etherboot - BOOTP/TFTP Bootstrap Program
  3. UNDI NIC driver for Etherboot - header file
  4. This file Copyright (C) 2003 Michael Brown <mbrown@fensystems.co.uk>
  5. of Fen Systems Ltd. (http://www.fensystems.co.uk/). All rights
  6. reserved.
  7. $Id$
  8. ***************************************************************************/
  9. /*
  10. * This program is free software; you can redistribute it and/or
  11. * modify it under the terms of the GNU General Public License as
  12. * published by the Free Software Foundation; either version 2, or (at
  13. * your option) any later version.
  14. */
  15. #include "pxe.h"
  16. #include "pic8259.h"
  17. /* A union that can function as the parameter block for any UNDI API call.
  18. */
  19. typedef t_PXENV_ANY pxenv_structure_t;
  20. /* BIOS PnP parameter block. We scan for this so that we can pass it
  21. * to the UNDI driver.
  22. */
  23. #define PNP_BIOS_SIGNATURE ( ('$'<<0) + ('P'<<8) + ('n'<<16) + ('P'<<24) )
  24. typedef struct pnp_bios {
  25. uint32_t signature;
  26. uint8_t version;
  27. uint8_t length;
  28. uint16_t control;
  29. uint8_t checksum;
  30. uint8_t dontcare[24];
  31. } PACKED pnp_bios_t;
  32. /* Structures within the PXE ROM.
  33. */
  34. #define ROM_SIGNATURE 0xaa55
  35. typedef struct rom {
  36. uint16_t signature;
  37. uint8_t unused[0x14];
  38. uint16_t undi_rom_id_off;
  39. uint16_t pcir_off;
  40. uint16_t pnp_off;
  41. } PACKED rom_t;
  42. #define PCIR_SIGNATURE ( ('P'<<0) + ('C'<<8) + ('I'<<16) + ('R'<<24) )
  43. typedef struct pcir_header {
  44. uint32_t signature;
  45. uint16_t vendor_id;
  46. uint16_t device_id;
  47. } PACKED pcir_header_t;
  48. #define PNP_SIGNATURE ( ('$'<<0) + ('P'<<8) + ('n'<<16) + ('P'<<24) )
  49. typedef struct pnp_header {
  50. uint32_t signature;
  51. uint8_t struct_revision;
  52. uint8_t length;
  53. uint16_t next;
  54. uint8_t reserved;
  55. uint8_t checksum;
  56. uint16_t id[2];
  57. uint16_t manuf_str_off;
  58. uint16_t product_str_off;
  59. uint8_t base_type;
  60. uint8_t sub_type;
  61. uint8_t interface_type;
  62. uint8_t indicator;
  63. uint16_t boot_connect_off;
  64. uint16_t disconnect_off;
  65. uint16_t initialise_off;
  66. uint16_t reserved2;
  67. uint16_t info;
  68. } PACKED pnp_header_t;
  69. #define UNDI_SIGNATURE ( ('U'<<0) + ('N'<<8) + ('D'<<16) + ('I'<<24) )
  70. typedef struct undi_rom_id {
  71. uint32_t signature;
  72. uint8_t struct_length;
  73. uint8_t struct_cksum;
  74. uint8_t struct_rev;
  75. uint8_t undi_rev[3];
  76. uint16_t undi_loader_off;
  77. uint16_t stack_size;
  78. uint16_t data_size;
  79. uint16_t code_size;
  80. } PACKED undi_rom_id_t;
  81. /* Nontrivial IRQ handler structure */
  82. typedef struct {
  83. segoff_t chain_to;
  84. uint8_t irq_chain, pad1, pad2, pad3;
  85. segoff_t entry;
  86. uint16_t count_all;
  87. uint16_t count_ours;
  88. t_PXENV_UNDI_ISR undi_isr;
  89. char code[0];
  90. } PACKED undi_irq_handler_t ;
  91. /* Storage buffers that we need in base memory. We collect these into
  92. * a single structure to make allocation simpler.
  93. */
  94. typedef struct undi_base_mem_xmit_data {
  95. MAC_ADDR destaddr;
  96. t_PXENV_UNDI_TBD tbd;
  97. } undi_base_mem_xmit_data_t;
  98. typedef struct undi_base_mem_data {
  99. pxenv_structure_t pxs;
  100. undi_base_mem_xmit_data_t xmit_data;
  101. char xmit_buffer[ETH_FRAME_LEN];
  102. /* Must be last in structure and paragraph-aligned */
  103. union {
  104. char e820mangler[0];
  105. char irq_handler[0];
  106. undi_irq_handler_t nontrivial_irq_handler;
  107. } __attribute__ ((aligned(16)));
  108. } undi_base_mem_data_t;
  109. /* Macros and data structures used when freeing bits of base memory
  110. * used by the UNDI driver.
  111. */
  112. #define FIRING_SQUAD_TARGET_SIZE 8
  113. #define FIRING_SQUAD_TARGET_INDEX(x) ( (x) / FIRING_SQUAD_TARGET_SIZE )
  114. #define FIRING_SQUAD_TARGET_BIT(x) ( (x) % FIRING_SQUAD_TARGET_SIZE )
  115. typedef struct firing_squad_lineup {
  116. uint8_t targets[ 640 / FIRING_SQUAD_TARGET_SIZE ];
  117. } firing_squad_lineup_t;
  118. typedef enum firing_squad_shoot {
  119. DONTSHOOT = 0,
  120. SHOOT = 1
  121. } firing_squad_shoot_t;
  122. /* Driver private data structure.
  123. */
  124. typedef struct undi {
  125. /* Pointers to various data structures */
  126. pnp_bios_t *pnp_bios;
  127. rom_t *rom;
  128. undi_rom_id_t *undi_rom_id;
  129. pxe_t *pxe;
  130. pxenv_structure_t *pxs;
  131. undi_base_mem_xmit_data_t *xmit_data;
  132. /* Pointers and sizes to keep track of allocated base memory */
  133. undi_base_mem_data_t *base_mem_data;
  134. void *driver_code;
  135. size_t driver_code_size;
  136. void *driver_data;
  137. size_t driver_data_size;
  138. char *xmit_buffer;
  139. /* Flags. We keep our own instead of trusting the UNDI driver
  140. * to have implemented PXENV_UNDI_GET_STATE correctly. Plus
  141. * there's the small issue of PXENV_UNDI_GET_STATE being the
  142. * same API call as PXENV_STOP_UNDI...
  143. */
  144. uint8_t prestarted; /* pxenv_start_undi() has been called */
  145. uint8_t started; /* pxenv_undi_startup() has been called */
  146. uint8_t initialized; /* pxenv_undi_initialize() has been called */
  147. uint8_t opened; /* pxenv_undi_open() has been called */
  148. /* Parameters that we need to store for future reference
  149. */
  150. struct pci_device pci;
  151. irq_t irq;
  152. } undi_t;
  153. /* Constants
  154. */
  155. #define HUNT_FOR_PIXIES 0
  156. #define HUNT_FOR_UNDI_ROMS 1