]> git.proxmox.com Git - mirror_edk2.git/blob - MdeModulePkg/Universal/Network/SnpDxe/Snp.h
clean up the un-suitable ';' location when declaring the functions.
[mirror_edk2.git] / MdeModulePkg / Universal / Network / SnpDxe / Snp.h
1 /** @file
2
3 Copyright (c) 2004 - 2007, Intel Corporation
4 All rights reserved. This program and the accompanying materials
5 are licensed and made available under the terms and conditions of the BSD License
6 which accompanies this distribution. The full text of the license may be found at
7 http://opensource.org/licenses/bsd-license.php
8
9 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
10 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
11
12 Module name:
13 snp.h
14
15 Abstract:
16
17 Revision history:
18
19
20 **/
21 #ifndef _SNP_H
22 #define _SNP_H
23
24
25 #include <PiDxe.h>
26
27 #include <Protocol/SimpleNetwork.h>
28 #include <Protocol/PciIo.h>
29 #include <Protocol/NetworkInterfaceIdentifier.h>
30 #include <Protocol/DevicePath.h>
31
32 #include <Library/DebugLib.h>
33 #include <Library/BaseMemoryLib.h>
34 #include <Library/UefiDriverEntryPoint.h>
35 #include <Library/UefiBootServicesTableLib.h>
36 #include <Library/BaseLib.h>
37 #include <Library/UefiLib.h>
38 #include <Library/MemoryAllocationLib.h>
39
40 #include <IndustryStandard/Pci22.h>
41
42 #define FOUR_GIGABYTES (UINT64) 0x100000000ULL
43
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
55 typedef 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
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 }
123 SNP_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 //
130 extern EFI_COMPONENT_NAME_PROTOCOL gSimpleNetworkComponentName;
131 extern EFI_COMPONENT_NAME2_PROTOCOL gSimpleNetworkComponentName2;
132
133 //
134 // Virtual to physical mapping for all UNDI 3.0s.
135 //
136 extern struct s_v2p {
137 struct s_v2p *next;
138 VOID *vaddr;
139 UINTN bsize;
140 EFI_PHYSICAL_ADDRESS paddr;
141 VOID *unmap;
142 }
143 *_v2p;
144
145 EFI_STATUS
146 add_v2p (
147 struct s_v2p **v2p,
148 EFI_PCI_IO_PROTOCOL_OPERATION type,
149 VOID *vaddr,
150 UINTN bsize
151 );
152
153 EFI_STATUS
154 find_v2p (
155 struct s_v2p **v2p,
156 VOID *vaddr
157 );
158
159 EFI_STATUS
160 del_v2p (
161 VOID *vaddr
162 );
163
164 extern
165 VOID
166 snp_undi32_callback_block_30 (
167 IN UINT32 Enable
168 );
169
170 extern
171 VOID
172 snp_undi32_callback_delay_30 (
173 IN UINT64 MicroSeconds
174 );
175
176 extern
177 VOID
178 snp_undi32_callback_memio_30 (
179 IN UINT8 ReadOrWrite,
180 IN UINT8 NumBytes,
181 IN UINT64 MemOrPortAddress,
182 IN OUT UINT64 BufferPtr
183 );
184
185 extern
186 VOID
187 snp_undi32_callback_v2p_30 (
188 IN UINT64 CpuAddr,
189 IN OUT UINT64 DeviceAddrPtr
190 );
191
192 extern
193 VOID
194 snp_undi32_callback_block (
195 IN UINT64 UniqueId,
196 IN UINT32 Enable
197 );
198
199 extern
200 VOID
201 snp_undi32_callback_delay (
202 IN UINT64 UniqueId,
203 IN UINT64 MicroSeconds
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 extern
217 VOID
218 snp_undi32_callback_map (
219 IN UINT64 UniqueId,
220 IN UINT64 CpuAddr,
221 IN UINT32 NumBytes,
222 IN UINT32 Direction,
223 IN OUT UINT64 DeviceAddrPtr
224 );
225
226 extern
227 VOID
228 snp_undi32_callback_unmap (
229 IN UINT64 UniqueId,
230 IN UINT64 CpuAddr,
231 IN UINT32 NumBytes,
232 IN UINT32 Direction,
233 IN UINT64 DeviceAddr // not a pointer to device address
234 );
235
236 extern
237 VOID
238 snp_undi32_callback_sync (
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 extern
247 EFI_STATUS
248 EFIAPI
249 snp_undi32_start (
250 IN EFI_SIMPLE_NETWORK_PROTOCOL *this
251 );
252
253 extern
254 EFI_STATUS
255 EFIAPI
256 snp_undi32_stop (
257 IN EFI_SIMPLE_NETWORK_PROTOCOL *this
258 );
259
260 extern
261 EFI_STATUS
262 EFIAPI
263 snp_undi32_initialize (
264 IN EFI_SIMPLE_NETWORK_PROTOCOL *this,
265 IN UINTN extra_rx_buffer_size OPTIONAL,
266 IN UINTN extra_tx_buffer_size OPTIONAL
267 );
268
269 extern
270 EFI_STATUS
271 EFIAPI
272 snp_undi32_reset (
273 IN EFI_SIMPLE_NETWORK_PROTOCOL *this,
274 IN BOOLEAN ExtendedVerification
275 );
276
277 extern
278 EFI_STATUS
279 EFIAPI
280 snp_undi32_shutdown (
281 IN EFI_SIMPLE_NETWORK_PROTOCOL *this
282 );
283
284 extern
285 EFI_STATUS
286 EFIAPI
287 snp_undi32_receive_filters (
288 IN EFI_SIMPLE_NETWORK_PROTOCOL * this,
289 IN UINT32 enable,
290 IN UINT32 disable,
291 IN BOOLEAN reset_mcast_filter,
292 IN UINTN mcast_filter_count OPTIONAL,
293 IN EFI_MAC_ADDRESS * mcast_filter OPTIONAL
294 );
295
296 extern
297 EFI_STATUS
298 EFIAPI
299 snp_undi32_station_address (
300 IN EFI_SIMPLE_NETWORK_PROTOCOL * this,
301 IN BOOLEAN reset,
302 IN EFI_MAC_ADDRESS *new OPTIONAL
303 );
304
305 extern
306 EFI_STATUS
307 EFIAPI
308 snp_undi32_statistics (
309 IN EFI_SIMPLE_NETWORK_PROTOCOL * this,
310 IN BOOLEAN reset,
311 IN OUT UINTN *statistics_size OPTIONAL,
312 IN OUT EFI_NETWORK_STATISTICS * statistics_table OPTIONAL
313 );
314
315 extern
316 EFI_STATUS
317 EFIAPI
318 snp_undi32_mcast_ip_to_mac (
319 IN EFI_SIMPLE_NETWORK_PROTOCOL *this,
320 IN BOOLEAN IPv6,
321 IN EFI_IP_ADDRESS *IP,
322 OUT EFI_MAC_ADDRESS *MAC
323 );
324
325 extern
326 EFI_STATUS
327 EFIAPI
328 snp_undi32_nvdata (
329 IN EFI_SIMPLE_NETWORK_PROTOCOL *this,
330 IN BOOLEAN read_write,
331 IN UINTN offset,
332 IN UINTN buffer_size,
333 IN OUT VOID *buffer
334 );
335
336 extern
337 EFI_STATUS
338 EFIAPI
339 snp_undi32_get_status (
340 IN EFI_SIMPLE_NETWORK_PROTOCOL * this,
341 OUT UINT32 *interrupt_status OPTIONAL,
342 OUT VOID **tx_buffer OPTIONAL
343 );
344
345 extern
346 EFI_STATUS
347 EFIAPI
348 snp_undi32_transmit (
349 IN EFI_SIMPLE_NETWORK_PROTOCOL * this,
350 IN UINTN header_size,
351 IN UINTN buffer_size,
352 IN VOID *buffer,
353 IN EFI_MAC_ADDRESS * src_addr OPTIONAL,
354 IN EFI_MAC_ADDRESS * dest_addr OPTIONAL,
355 IN UINT16 *protocol OPTIONAL
356 );
357
358 extern
359 EFI_STATUS
360 EFIAPI
361 snp_undi32_receive (
362 IN EFI_SIMPLE_NETWORK_PROTOCOL * this,
363 OUT UINTN *header_size OPTIONAL,
364 IN OUT UINTN *buffer_size,
365 OUT VOID *buffer,
366 OUT EFI_MAC_ADDRESS * src_addr OPTIONAL,
367 OUT EFI_MAC_ADDRESS * dest_addr OPTIONAL,
368 OUT UINT16 *protocol OPTIONAL
369 );
370
371 typedef
372 EFI_STATUS
373 (*issue_undi32_command) (
374 UINT64 cdb
375 );
376 typedef
377 VOID
378 (*ptr) (
379 VOID
380 );
381
382
383 /**
384 Install all the driver protocol
385
386 @param ImageHandle Driver image handle
387 @param SystemTable System services table
388
389 @retval EFI_SUCEESS Initialization routine has found UNDI hardware, loaded it's
390 ROM, and installed a notify event for the Network
391 Indentifier Interface Protocol successfully.
392 @retval Other Return value from HandleProtocol for DeviceIoProtocol or
393 LoadedImageProtocol
394
395 **/
396 EFI_STATUS
397 EFIAPI
398 InitializeSnpNiiDriver (
399 IN EFI_HANDLE ImageHandle,
400 IN EFI_SYSTEM_TABLE *SystemTable
401 );
402
403 #define SNP_MEM_PAGES(x) (((x) - 1) / 4096 + 1)
404
405
406 #endif /* _SNP_H */