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