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