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