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