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