]> git.proxmox.com Git - mirror_edk2.git/blob - EdkModulePkg/Universal/Network/Snp32_64/Dxe/Snp.h
Fix capitalization.
[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 //
125 // Virtual to physical mapping for all UNDI 3.0s.
126 //
127 extern struct s_v2p {
128 struct s_v2p *next;
129 VOID *vaddr;
130 UINTN bsize;
131 EFI_PHYSICAL_ADDRESS paddr;
132 VOID *unmap;
133 }
134 *_v2p;
135
136 EFI_STATUS
137 add_v2p (
138 struct s_v2p **v2p,
139 EFI_PCI_IO_PROTOCOL_OPERATION type,
140 VOID *vaddr,
141 UINTN bsize
142 )
143 ;
144
145 EFI_STATUS
146 find_v2p (
147 struct s_v2p **v2p,
148 VOID *vaddr
149 )
150 ;
151
152 EFI_STATUS
153 del_v2p (
154 VOID *vaddr
155 )
156 ;
157
158 extern
159 VOID
160 snp_undi32_callback_block_30 (
161 IN UINT32 Enable
162 )
163 ;
164
165 extern
166 VOID
167 snp_undi32_callback_delay_30 (
168 IN UINT64 MicroSeconds
169 )
170 ;
171
172 extern
173 VOID
174 snp_undi32_callback_memio_30 (
175 IN UINT8 ReadOrWrite,
176 IN UINT8 NumBytes,
177 IN UINT64 MemOrPortAddress,
178 IN OUT UINT64 BufferPtr
179 )
180 ;
181
182 extern
183 VOID
184 snp_undi32_callback_v2p_30 (
185 IN UINT64 CpuAddr,
186 IN OUT UINT64 DeviceAddrPtr
187 )
188 ;
189
190 extern
191 VOID
192 snp_undi32_callback_block (
193 IN UINT64 UniqueId,
194 IN UINT32 Enable
195 )
196 ;
197
198 extern
199 VOID
200 snp_undi32_callback_delay (
201 IN UINT64 UniqueId,
202 IN UINT64 MicroSeconds
203 )
204 ;
205
206 extern
207 VOID
208 snp_undi32_callback_memio (
209 IN UINT64 UniqueId,
210 IN UINT8 ReadOrWrite,
211 IN UINT8 NumBytes,
212 IN UINT64 MemOrPortAddr,
213 IN OUT UINT64 BufferPtr
214 )
215 ;
216
217 extern
218 VOID
219 snp_undi32_callback_map (
220 IN UINT64 UniqueId,
221 IN UINT64 CpuAddr,
222 IN UINT32 NumBytes,
223 IN UINT32 Direction,
224 IN OUT UINT64 DeviceAddrPtr
225 )
226 ;
227
228 extern
229 VOID
230 snp_undi32_callback_unmap (
231 IN UINT64 UniqueId,
232 IN UINT64 CpuAddr,
233 IN UINT32 NumBytes,
234 IN UINT32 Direction,
235 IN UINT64 DeviceAddr // not a pointer to device address
236 )
237 ;
238
239 extern
240 VOID
241 snp_undi32_callback_sync (
242 IN UINT64 UniqueId,
243 IN UINT64 CpuAddr,
244 IN UINT32 NumBytes,
245 IN UINT32 Direction,
246 IN UINT64 DeviceAddr // not a pointer to device address
247 )
248 ;
249
250 extern
251 EFI_STATUS
252 EFIAPI
253 snp_undi32_start (
254 IN EFI_SIMPLE_NETWORK_PROTOCOL *this
255 )
256 ;
257
258 extern
259 EFI_STATUS
260 EFIAPI
261 snp_undi32_stop (
262 IN EFI_SIMPLE_NETWORK_PROTOCOL *this
263 )
264 ;
265
266 extern
267 EFI_STATUS
268 EFIAPI
269 snp_undi32_initialize (
270 IN EFI_SIMPLE_NETWORK_PROTOCOL *this,
271 IN UINTN extra_rx_buffer_size OPTIONAL,
272 IN UINTN extra_tx_buffer_size OPTIONAL
273 )
274 ;
275
276 extern
277 EFI_STATUS
278 EFIAPI
279 snp_undi32_reset (
280 IN EFI_SIMPLE_NETWORK_PROTOCOL *this,
281 IN BOOLEAN ExtendedVerification
282 )
283 ;
284
285 extern
286 EFI_STATUS
287 EFIAPI
288 snp_undi32_shutdown (
289 IN EFI_SIMPLE_NETWORK_PROTOCOL *this
290 )
291 ;
292
293 extern
294 EFI_STATUS
295 EFIAPI
296 snp_undi32_receive_filters (
297 IN EFI_SIMPLE_NETWORK_PROTOCOL * this,
298 IN UINT32 enable,
299 IN UINT32 disable,
300 IN BOOLEAN reset_mcast_filter,
301 IN UINTN mcast_filter_count OPTIONAL,
302 IN EFI_MAC_ADDRESS * mcast_filter OPTIONAL
303 )
304 ;
305
306 extern
307 EFI_STATUS
308 EFIAPI
309 snp_undi32_station_address (
310 IN EFI_SIMPLE_NETWORK_PROTOCOL * this,
311 IN BOOLEAN reset,
312 IN EFI_MAC_ADDRESS *new OPTIONAL
313 )
314 ;
315
316 extern
317 EFI_STATUS
318 EFIAPI
319 snp_undi32_statistics (
320 IN EFI_SIMPLE_NETWORK_PROTOCOL * this,
321 IN BOOLEAN reset,
322 IN OUT UINTN *statistics_size OPTIONAL,
323 IN OUT EFI_NETWORK_STATISTICS * statistics_table OPTIONAL
324 )
325 ;
326
327 extern
328 EFI_STATUS
329 EFIAPI
330 snp_undi32_mcast_ip_to_mac (
331 IN EFI_SIMPLE_NETWORK_PROTOCOL *this,
332 IN BOOLEAN IPv6,
333 IN EFI_IP_ADDRESS *IP,
334 OUT EFI_MAC_ADDRESS *MAC
335 )
336 ;
337
338 extern
339 EFI_STATUS
340 EFIAPI
341 snp_undi32_nvdata (
342 IN EFI_SIMPLE_NETWORK_PROTOCOL *this,
343 IN BOOLEAN read_write,
344 IN UINTN offset,
345 IN UINTN buffer_size,
346 IN OUT VOID *buffer
347 )
348 ;
349
350 extern
351 EFI_STATUS
352 EFIAPI
353 snp_undi32_get_status (
354 IN EFI_SIMPLE_NETWORK_PROTOCOL * this,
355 OUT UINT32 *interrupt_status OPTIONAL,
356 OUT VOID **tx_buffer OPTIONAL
357 )
358 ;
359
360 extern
361 EFI_STATUS
362 EFIAPI
363 snp_undi32_transmit (
364 IN EFI_SIMPLE_NETWORK_PROTOCOL * this,
365 IN UINTN header_size,
366 IN UINTN buffer_size,
367 IN VOID *buffer,
368 IN EFI_MAC_ADDRESS * src_addr OPTIONAL,
369 IN EFI_MAC_ADDRESS * dest_addr OPTIONAL,
370 IN UINT16 *protocol OPTIONAL
371 )
372 ;
373
374 extern
375 EFI_STATUS
376 EFIAPI
377 snp_undi32_receive (
378 IN EFI_SIMPLE_NETWORK_PROTOCOL * this,
379 OUT UINTN *header_size OPTIONAL,
380 IN OUT UINTN *buffer_size,
381 OUT VOID *buffer,
382 OUT EFI_MAC_ADDRESS * src_addr OPTIONAL,
383 OUT EFI_MAC_ADDRESS * dest_addr OPTIONAL,
384 OUT UINT16 *protocol OPTIONAL
385 )
386 ;
387
388 typedef
389 EFI_STATUS
390 (*issue_undi32_command) (
391 UINT64 cdb
392 );
393 typedef
394 VOID
395 (*ptr) (
396 VOID
397 );
398
399 #define SNP_MEM_PAGES(x) (((x) - 1) / 4096 + 1)
400
401 #if SNP_DEBUG
402 extern
403 VOID
404 snp_wait_for_key (
405 VOID
406 )
407 ;
408 #endif
409
410 #endif /* _SNP_H */