1 /**************************************************************************
2 Etherboot - BOOTP/TFTP Bootstrap Program
3 UNDI NIC driver for Etherboot - header file
5 This file Copyright (C) 2003 Michael Brown <mbrown@fensystems.co.uk>
6 of Fen Systems Ltd. (http://www.fensystems.co.uk/). All rights
10 ***************************************************************************/
13 * This program is free software; you can redistribute it and/or
14 * modify it under the terms of the GNU General Public License as
15 * published by the Free Software Foundation; either version 2, or (at
16 * your option) any later version.
22 /* A union that can function as the parameter block for any UNDI API call.
24 typedef t_PXENV_ANY pxenv_structure_t;
26 /* BIOS PnP parameter block. We scan for this so that we can pass it
30 #define PNP_BIOS_SIGNATURE ( ('$'<<0) + ('P'<<8) + ('n'<<16) + ('P'<<24) )
31 typedef struct pnp_bios {
40 /* Structures within the PXE ROM.
43 #define ROM_SIGNATURE 0xaa55
47 uint16_t undi_rom_id_off;
52 #define PCIR_SIGNATURE ( ('P'<<0) + ('C'<<8) + ('I'<<16) + ('R'<<24) )
53 typedef struct pcir_header {
57 } PACKED pcir_header_t;
59 #define PNP_SIGNATURE ( ('$'<<0) + ('P'<<8) + ('n'<<16) + ('P'<<24) )
60 typedef struct pnp_header {
62 uint8_t struct_revision;
68 uint16_t manuf_str_off;
69 uint16_t product_str_off;
72 uint8_t interface_type;
74 uint16_t boot_connect_off;
75 uint16_t disconnect_off;
76 uint16_t initialise_off;
79 } PACKED pnp_header_t;
81 #define UNDI_SIGNATURE ( ('U'<<0) + ('N'<<8) + ('D'<<16) + ('I'<<24) )
82 typedef struct undi_rom_id {
84 uint8_t struct_length;
88 uint16_t undi_loader_off;
92 } PACKED undi_rom_id_t;
94 /* Nontrivial IRQ handler structure */
97 uint8_t irq_chain, pad1, pad2, pad3;
101 t_PXENV_UNDI_ISR undi_isr;
103 } PACKED undi_irq_handler_t ;
105 /* Storage buffers that we need in base memory. We collect these into
106 * a single structure to make allocation simpler.
109 typedef struct undi_base_mem_xmit_data {
111 t_PXENV_UNDI_TBD tbd;
112 } undi_base_mem_xmit_data_t;
114 typedef struct undi_base_mem_data {
115 pxenv_structure_t pxs;
116 undi_base_mem_xmit_data_t xmit_data;
117 char xmit_buffer[ETH_FRAME_LEN];
118 /* Must be last in structure and paragraph-aligned */
122 undi_irq_handler_t nontrivial_irq_handler;
123 } __attribute__ ((aligned(16)));
124 } undi_base_mem_data_t;
126 /* Macros and data structures used when freeing bits of base memory
127 * used by the UNDI driver.
130 #define FIRING_SQUAD_TARGET_SIZE 8
131 #define FIRING_SQUAD_TARGET_INDEX(x) ( (x) / FIRING_SQUAD_TARGET_SIZE )
132 #define FIRING_SQUAD_TARGET_BIT(x) ( (x) % FIRING_SQUAD_TARGET_SIZE )
133 typedef struct firing_squad_lineup {
134 uint8_t targets[ 640 / FIRING_SQUAD_TARGET_SIZE ];
135 } firing_squad_lineup_t;
136 typedef enum firing_squad_shoot {
139 } firing_squad_shoot_t;
141 /* Driver private data structure.
144 typedef struct undi {
145 /* Pointers to various data structures */
146 pnp_bios_t *pnp_bios;
148 undi_rom_id_t *undi_rom_id;
150 pxenv_structure_t *pxs;
151 undi_base_mem_xmit_data_t *xmit_data;
152 /* Pointers and sizes to keep track of allocated base memory */
153 undi_base_mem_data_t *base_mem_data;
155 size_t driver_code_size;
157 size_t driver_data_size;
159 /* Flags. We keep our own instead of trusting the UNDI driver
160 * to have implemented PXENV_UNDI_GET_STATE correctly. Plus
161 * there's the small issue of PXENV_UNDI_GET_STATE being the
162 * same API call as PXENV_STOP_UNDI...
164 uint8_t prestarted; /* pxenv_start_undi() has been called */
165 uint8_t started; /* pxenv_undi_startup() has been called */
166 uint8_t initialized; /* pxenv_undi_initialize() has been called */
167 uint8_t opened; /* pxenv_undi_open() has been called */
168 /* Parameters that we need to store for future reference
170 struct pci_device *pci;
177 #define HUNT_FOR_PIXIES 0
178 #define HUNT_FOR_UNDI_ROMS 1