]>
Commit | Line | Data |
---|---|---|
2883b67e | 1 | /** @file\r |
2 | \r | |
3 | Copyright (c) 2004 - 2007, Intel Corporation\r | |
4 | All rights reserved. This program and the accompanying materials\r | |
5 | are licensed and made available under the terms and conditions of the BSD License\r | |
6 | which accompanies this distribution. The full text of the license may be found at\r | |
7 | http://opensource.org/licenses/bsd-license.php\r | |
8 | \r | |
9 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r | |
10 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
11 | \r | |
12 | Module name:\r | |
13 | snp.h\r | |
14 | \r | |
15 | Abstract:\r | |
16 | \r | |
17 | Revision history:\r | |
18 | \r | |
19 | \r | |
20 | **/\r | |
21 | #ifndef _SNP_H\r | |
22 | #define _SNP_H\r | |
23 | \r | |
24 | \r | |
25 | #include <PiDxe.h>\r | |
26 | \r | |
27 | #include <Protocol/SimpleNetwork.h>\r | |
28 | #include <Protocol/PciIo.h>\r | |
29 | #include <Protocol/NetworkInterfaceIdentifier.h>\r | |
30 | #include <Protocol/DevicePath.h>\r | |
31 | \r | |
32 | #include <Library/DebugLib.h>\r | |
33 | #include <Library/BaseMemoryLib.h>\r | |
34 | #include <Library/UefiDriverEntryPoint.h>\r | |
35 | #include <Library/UefiBootServicesTableLib.h>\r | |
36 | #include <Library/BaseLib.h>\r | |
37 | #include <Library/UefiLib.h>\r | |
38 | #include <Library/MemoryAllocationLib.h>\r | |
39 | \r | |
40 | #include <IndustryStandard/Pci22.h>\r | |
41 | \r | |
42 | #define FOUR_GIGABYTES (UINT64) 0x100000000ULL\r | |
43 | \r | |
44 | \r | |
45 | #define SNP_DRIVER_SIGNATURE EFI_SIGNATURE_32 ('s', 'n', 'd', 's')\r | |
46 | #define MAX_MAP_LENGTH 100\r | |
47 | \r | |
48 | #define PCI_BAR_IO_MASK 0x00000003\r | |
49 | #define PCI_BAR_IO_MODE 0x00000001\r | |
50 | \r | |
51 | #define PCI_BAR_MEM_MASK 0x0000000F\r | |
52 | #define PCI_BAR_MEM_MODE 0x00000000\r | |
53 | #define PCI_BAR_MEM_64BIT 0x00000004\r | |
54 | \r | |
55 | typedef struct {\r | |
56 | UINT32 Signature;\r | |
57 | EFI_LOCK lock;\r | |
58 | \r | |
59 | EFI_SIMPLE_NETWORK_PROTOCOL snp;\r | |
60 | EFI_SIMPLE_NETWORK_MODE mode;\r | |
61 | \r | |
62 | EFI_HANDLE device_handle;\r | |
63 | EFI_DEVICE_PATH_PROTOCOL *device_path;\r | |
64 | \r | |
65 | //\r | |
66 | // Local instance data needed by SNP driver\r | |
67 | //\r | |
68 | // Pointer to S/W UNDI API entry point\r | |
69 | // This will be NULL for H/W UNDI\r | |
70 | //\r | |
71 | EFI_STATUS (*issue_undi32_command) (UINT64 cdb);\r | |
72 | \r | |
73 | BOOLEAN is_swundi;\r | |
74 | \r | |
75 | //\r | |
76 | // undi interface number, if one undi manages more nics\r | |
77 | //\r | |
78 | PXE_IFNUM if_num;\r | |
79 | \r | |
80 | //\r | |
81 | // Allocated tx/rx buffer that was passed to UNDI Initialize.\r | |
82 | //\r | |
83 | UINT32 tx_rx_bufsize;\r | |
84 | VOID *tx_rx_buffer;\r | |
85 | //\r | |
86 | // mappable buffers for receive and fill header for undi3.0\r | |
87 | // these will be used if the user buffers are above 4GB limit (instead of\r | |
88 | // mapping the user buffers)\r | |
89 | //\r | |
90 | UINT8 *receive_buf;\r | |
91 | VOID *ReceiveBufUnmap;\r | |
92 | UINT8 *fill_hdr_buf;\r | |
93 | VOID *FillHdrBufUnmap;\r | |
94 | \r | |
95 | EFI_PCI_IO_PROTOCOL *IoFncs;\r | |
96 | UINT8 IoBarIndex;\r | |
97 | UINT8 MemoryBarIndex;\r | |
98 | \r | |
99 | //\r | |
100 | // Buffers for command descriptor block, command parameter block\r | |
101 | // and data block.\r | |
102 | //\r | |
103 | PXE_CDB cdb;\r | |
104 | VOID *cpb;\r | |
105 | VOID *CpbUnmap;\r | |
106 | VOID *db;\r | |
107 | \r | |
108 | //\r | |
109 | // UNDI structure, we need to remember the init info for a long time!\r | |
110 | //\r | |
111 | PXE_DB_GET_INIT_INFO init_info;\r | |
112 | \r | |
113 | VOID *SnpDriverUnmap;\r | |
114 | //\r | |
115 | // when ever we map an address, we must remember it's address and the un-map\r | |
116 | // cookie so that we can unmap later\r | |
117 | //\r | |
118 | struct s_map_list {\r | |
119 | EFI_PHYSICAL_ADDRESS virt;\r | |
120 | VOID *map_cookie;\r | |
121 | } map_list[MAX_MAP_LENGTH];\r | |
122 | }\r | |
123 | SNP_DRIVER;\r | |
124 | \r | |
125 | #define EFI_SIMPLE_NETWORK_DEV_FROM_THIS(a) CR (a, SNP_DRIVER, snp, SNP_DRIVER_SIGNATURE)\r | |
126 | \r | |
127 | //\r | |
128 | // Global Variables\r | |
129 | //\r | |
130 | extern EFI_COMPONENT_NAME_PROTOCOL gSimpleNetworkComponentName;\r | |
131 | extern EFI_COMPONENT_NAME2_PROTOCOL gSimpleNetworkComponentName2;\r | |
132 | \r | |
133 | //\r | |
134 | // Virtual to physical mapping for all UNDI 3.0s.\r | |
135 | //\r | |
136 | extern struct s_v2p {\r | |
137 | struct s_v2p *next;\r | |
138 | VOID *vaddr;\r | |
139 | UINTN bsize;\r | |
140 | EFI_PHYSICAL_ADDRESS paddr;\r | |
141 | VOID *unmap;\r | |
142 | }\r | |
143 | *_v2p;\r | |
144 | \r | |
145 | EFI_STATUS\r | |
146 | add_v2p (\r | |
147 | struct s_v2p **v2p,\r | |
148 | EFI_PCI_IO_PROTOCOL_OPERATION type,\r | |
149 | VOID *vaddr,\r | |
150 | UINTN bsize\r | |
ed66e1bc | 151 | );\r |
2883b67e | 152 | \r |
153 | EFI_STATUS\r | |
154 | find_v2p (\r | |
155 | struct s_v2p **v2p,\r | |
156 | VOID *vaddr\r | |
ed66e1bc | 157 | );\r |
2883b67e | 158 | \r |
159 | EFI_STATUS\r | |
160 | del_v2p (\r | |
161 | VOID *vaddr\r | |
ed66e1bc | 162 | );\r |
2883b67e | 163 | \r |
164 | extern\r | |
165 | VOID \r | |
166 | snp_undi32_callback_block_30 (\r | |
167 | IN UINT32 Enable\r | |
ed66e1bc | 168 | );\r |
2883b67e | 169 | \r |
170 | extern\r | |
171 | VOID \r | |
172 | snp_undi32_callback_delay_30 (\r | |
173 | IN UINT64 MicroSeconds\r | |
ed66e1bc | 174 | );\r |
2883b67e | 175 | \r |
176 | extern\r | |
177 | VOID \r | |
178 | snp_undi32_callback_memio_30 (\r | |
179 | IN UINT8 ReadOrWrite,\r | |
180 | IN UINT8 NumBytes,\r | |
181 | IN UINT64 MemOrPortAddress,\r | |
182 | IN OUT UINT64 BufferPtr\r | |
ed66e1bc | 183 | );\r |
2883b67e | 184 | \r |
185 | extern\r | |
186 | VOID \r | |
187 | snp_undi32_callback_v2p_30 (\r | |
188 | IN UINT64 CpuAddr,\r | |
189 | IN OUT UINT64 DeviceAddrPtr\r | |
ed66e1bc | 190 | );\r |
2883b67e | 191 | \r |
192 | extern\r | |
193 | VOID \r | |
194 | snp_undi32_callback_block (\r | |
195 | IN UINT64 UniqueId,\r | |
196 | IN UINT32 Enable\r | |
ed66e1bc | 197 | );\r |
2883b67e | 198 | \r |
199 | extern\r | |
200 | VOID \r | |
201 | snp_undi32_callback_delay (\r | |
202 | IN UINT64 UniqueId,\r | |
203 | IN UINT64 MicroSeconds\r | |
ed66e1bc | 204 | );\r |
2883b67e | 205 | \r |
206 | extern\r | |
207 | VOID \r | |
208 | snp_undi32_callback_memio (\r | |
209 | IN UINT64 UniqueId,\r | |
210 | IN UINT8 ReadOrWrite,\r | |
211 | IN UINT8 NumBytes,\r | |
212 | IN UINT64 MemOrPortAddr,\r | |
213 | IN OUT UINT64 BufferPtr\r | |
ed66e1bc | 214 | );\r |
2883b67e | 215 | \r |
216 | extern\r | |
217 | VOID \r | |
218 | snp_undi32_callback_map (\r | |
219 | IN UINT64 UniqueId,\r | |
220 | IN UINT64 CpuAddr,\r | |
221 | IN UINT32 NumBytes,\r | |
222 | IN UINT32 Direction,\r | |
223 | IN OUT UINT64 DeviceAddrPtr\r | |
ed66e1bc | 224 | );\r |
2883b67e | 225 | \r |
226 | extern\r | |
227 | VOID \r | |
228 | snp_undi32_callback_unmap (\r | |
229 | IN UINT64 UniqueId,\r | |
230 | IN UINT64 CpuAddr,\r | |
231 | IN UINT32 NumBytes,\r | |
232 | IN UINT32 Direction,\r | |
233 | IN UINT64 DeviceAddr // not a pointer to device address\r | |
ed66e1bc | 234 | );\r |
2883b67e | 235 | \r |
236 | extern\r | |
237 | VOID \r | |
238 | snp_undi32_callback_sync (\r | |
239 | IN UINT64 UniqueId,\r | |
240 | IN UINT64 CpuAddr,\r | |
241 | IN UINT32 NumBytes,\r | |
242 | IN UINT32 Direction,\r | |
243 | IN UINT64 DeviceAddr // not a pointer to device address\r | |
ed66e1bc | 244 | );\r |
2883b67e | 245 | \r |
246 | extern\r | |
247 | EFI_STATUS \r | |
248 | EFIAPI\r | |
249 | snp_undi32_start (\r | |
250 | IN EFI_SIMPLE_NETWORK_PROTOCOL *this\r | |
ed66e1bc | 251 | );\r |
2883b67e | 252 | \r |
253 | extern\r | |
254 | EFI_STATUS \r | |
255 | EFIAPI\r | |
256 | snp_undi32_stop (\r | |
257 | IN EFI_SIMPLE_NETWORK_PROTOCOL *this\r | |
ed66e1bc | 258 | );\r |
2883b67e | 259 | \r |
260 | extern\r | |
261 | EFI_STATUS \r | |
262 | EFIAPI\r | |
263 | snp_undi32_initialize (\r | |
264 | IN EFI_SIMPLE_NETWORK_PROTOCOL *this,\r | |
265 | IN UINTN extra_rx_buffer_size OPTIONAL,\r | |
266 | IN UINTN extra_tx_buffer_size OPTIONAL\r | |
ed66e1bc | 267 | );\r |
2883b67e | 268 | \r |
269 | extern\r | |
270 | EFI_STATUS \r | |
271 | EFIAPI\r | |
272 | snp_undi32_reset (\r | |
273 | IN EFI_SIMPLE_NETWORK_PROTOCOL *this,\r | |
274 | IN BOOLEAN ExtendedVerification\r | |
ed66e1bc | 275 | );\r |
2883b67e | 276 | \r |
277 | extern\r | |
278 | EFI_STATUS \r | |
279 | EFIAPI\r | |
280 | snp_undi32_shutdown (\r | |
281 | IN EFI_SIMPLE_NETWORK_PROTOCOL *this\r | |
ed66e1bc | 282 | );\r |
2883b67e | 283 | \r |
284 | extern\r | |
285 | EFI_STATUS \r | |
286 | EFIAPI\r | |
287 | snp_undi32_receive_filters (\r | |
288 | IN EFI_SIMPLE_NETWORK_PROTOCOL * this,\r | |
289 | IN UINT32 enable,\r | |
290 | IN UINT32 disable,\r | |
291 | IN BOOLEAN reset_mcast_filter,\r | |
292 | IN UINTN mcast_filter_count OPTIONAL,\r | |
293 | IN EFI_MAC_ADDRESS * mcast_filter OPTIONAL\r | |
ed66e1bc | 294 | );\r |
2883b67e | 295 | \r |
296 | extern\r | |
297 | EFI_STATUS \r | |
298 | EFIAPI\r | |
299 | snp_undi32_station_address (\r | |
300 | IN EFI_SIMPLE_NETWORK_PROTOCOL * this,\r | |
301 | IN BOOLEAN reset,\r | |
302 | IN EFI_MAC_ADDRESS *new OPTIONAL\r | |
ed66e1bc | 303 | );\r |
2883b67e | 304 | \r |
305 | extern\r | |
306 | EFI_STATUS \r | |
307 | EFIAPI\r | |
308 | snp_undi32_statistics (\r | |
309 | IN EFI_SIMPLE_NETWORK_PROTOCOL * this,\r | |
310 | IN BOOLEAN reset,\r | |
311 | IN OUT UINTN *statistics_size OPTIONAL,\r | |
312 | IN OUT EFI_NETWORK_STATISTICS * statistics_table OPTIONAL\r | |
ed66e1bc | 313 | );\r |
2883b67e | 314 | \r |
315 | extern\r | |
316 | EFI_STATUS \r | |
317 | EFIAPI\r | |
318 | snp_undi32_mcast_ip_to_mac (\r | |
319 | IN EFI_SIMPLE_NETWORK_PROTOCOL *this,\r | |
320 | IN BOOLEAN IPv6,\r | |
321 | IN EFI_IP_ADDRESS *IP,\r | |
322 | OUT EFI_MAC_ADDRESS *MAC\r | |
ed66e1bc | 323 | );\r |
2883b67e | 324 | \r |
325 | extern\r | |
326 | EFI_STATUS \r | |
327 | EFIAPI\r | |
328 | snp_undi32_nvdata (\r | |
329 | IN EFI_SIMPLE_NETWORK_PROTOCOL *this,\r | |
330 | IN BOOLEAN read_write,\r | |
331 | IN UINTN offset,\r | |
332 | IN UINTN buffer_size,\r | |
333 | IN OUT VOID *buffer\r | |
ed66e1bc | 334 | );\r |
2883b67e | 335 | \r |
336 | extern\r | |
337 | EFI_STATUS \r | |
338 | EFIAPI\r | |
339 | snp_undi32_get_status (\r | |
340 | IN EFI_SIMPLE_NETWORK_PROTOCOL * this,\r | |
341 | OUT UINT32 *interrupt_status OPTIONAL,\r | |
342 | OUT VOID **tx_buffer OPTIONAL\r | |
ed66e1bc | 343 | );\r |
2883b67e | 344 | \r |
345 | extern\r | |
346 | EFI_STATUS \r | |
347 | EFIAPI\r | |
348 | snp_undi32_transmit (\r | |
349 | IN EFI_SIMPLE_NETWORK_PROTOCOL * this,\r | |
350 | IN UINTN header_size,\r | |
351 | IN UINTN buffer_size,\r | |
352 | IN VOID *buffer,\r | |
353 | IN EFI_MAC_ADDRESS * src_addr OPTIONAL,\r | |
354 | IN EFI_MAC_ADDRESS * dest_addr OPTIONAL,\r | |
355 | IN UINT16 *protocol OPTIONAL\r | |
ed66e1bc | 356 | );\r |
2883b67e | 357 | \r |
358 | extern\r | |
359 | EFI_STATUS \r | |
360 | EFIAPI\r | |
361 | snp_undi32_receive (\r | |
362 | IN EFI_SIMPLE_NETWORK_PROTOCOL * this,\r | |
363 | OUT UINTN *header_size OPTIONAL,\r | |
364 | IN OUT UINTN *buffer_size,\r | |
365 | OUT VOID *buffer,\r | |
366 | OUT EFI_MAC_ADDRESS * src_addr OPTIONAL,\r | |
367 | OUT EFI_MAC_ADDRESS * dest_addr OPTIONAL,\r | |
368 | OUT UINT16 *protocol OPTIONAL\r | |
ed66e1bc | 369 | );\r |
2883b67e | 370 | \r |
371 | typedef\r | |
372 | EFI_STATUS\r | |
373 | (*issue_undi32_command) (\r | |
374 | UINT64 cdb\r | |
375 | );\r | |
376 | typedef\r | |
377 | VOID\r | |
378 | (*ptr) (\r | |
379 | VOID\r | |
380 | );\r | |
381 | \r | |
382 | \r | |
383 | /**\r | |
384 | Install all the driver protocol\r | |
385 | \r | |
386 | @param ImageHandle Driver image handle\r | |
387 | @param SystemTable System services table\r | |
388 | \r | |
389 | @retval EFI_SUCEESS Initialization routine has found UNDI hardware, loaded it's\r | |
390 | ROM, and installed a notify event for the Network\r | |
391 | Indentifier Interface Protocol successfully.\r | |
392 | @retval Other Return value from HandleProtocol for DeviceIoProtocol or\r | |
393 | LoadedImageProtocol\r | |
394 | \r | |
395 | **/\r | |
396 | EFI_STATUS\r | |
397 | EFIAPI\r | |
398 | InitializeSnpNiiDriver (\r | |
399 | IN EFI_HANDLE ImageHandle,\r | |
400 | IN EFI_SYSTEM_TABLE *SystemTable\r | |
ed66e1bc | 401 | );\r |
2883b67e | 402 | \r |
403 | #define SNP_MEM_PAGES(x) (((x) - 1) / 4096 + 1)\r | |
404 | \r | |
405 | \r | |
406 | #endif /* _SNP_H */\r |