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