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
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.
17 2000-Feb-03 M(f)J Genesis.
23 #include "IndustryStandard/pci22.h"
26 #define FOUR_GIGABYTES (UINT64) 0x100000000ULL
31 #define SNP_PRINT(DebugInfo) Print (DebugInfo)
33 #define SNP_PRINT(DebugInfo)
36 #define SNP_DRIVER_SIGNATURE EFI_SIGNATURE_32 ('s', 'n', 'd', 's')
37 #define MAX_MAP_LENGTH 100
39 #define PCI_BAR_IO_MASK 0x00000003
40 #define PCI_BAR_IO_MODE 0x00000001
42 #define PCI_BAR_MEM_MASK 0x0000000F
43 #define PCI_BAR_MEM_MODE 0x00000000
44 #define PCI_BAR_MEM_64BIT 0x00000004
50 EFI_SIMPLE_NETWORK_PROTOCOL snp
;
51 EFI_SIMPLE_NETWORK_MODE mode
;
53 EFI_HANDLE device_handle
;
54 EFI_DEVICE_PATH_PROTOCOL
*device_path
;
57 // Local instance data needed by SNP driver
59 // Pointer to S/W UNDI API entry point
60 // This will be NULL for H/W UNDI
62 EFI_STATUS (*issue_undi32_command
) (UINT64 cdb
);
67 // undi interface number, if one undi manages more nics
72 // Allocated tx/rx buffer that was passed to UNDI Initialize.
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)
82 VOID
*ReceiveBufUnmap
;
84 VOID
*FillHdrBufUnmap
;
86 EFI_PCI_IO_PROTOCOL
*IoFncs
;
89 BOOLEAN IsOldUndi
; // true for EFI1.0 UNDI (3.0) drivers
91 // Buffers for command descriptor block, command parameter block
100 // UNDI structure, we need to remember the init info for a long time!
102 PXE_DB_GET_INIT_INFO init_info
;
104 VOID
*SnpDriverUnmap
;
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
110 EFI_PHYSICAL_ADDRESS virt
;
112 } map_list
[MAX_MAP_LENGTH
];
116 #define EFI_SIMPLE_NETWORK_DEV_FROM_THIS(a) CR (a, SNP_DRIVER, snp, SNP_DRIVER_SIGNATURE)
121 extern EFI_COMPONENT_NAME_PROTOCOL gSimpleNetworkComponentName
;
122 extern EFI_DRIVER_BINDING_PROTOCOL gSimpleNetworkDriverBinding
;
125 // Virtual to physical mapping for all UNDI 3.0s.
127 extern struct s_v2p
{
131 EFI_PHYSICAL_ADDRESS paddr
;
139 EFI_PCI_IO_PROTOCOL_OPERATION type
,
160 snp_undi32_callback_block_30 (
167 snp_undi32_callback_delay_30 (
168 IN UINT64 MicroSeconds
174 snp_undi32_callback_memio_30 (
175 IN UINT8 ReadOrWrite
,
177 IN UINT64 MemOrPortAddress
,
178 IN OUT UINT64 BufferPtr
184 snp_undi32_callback_v2p_30 (
186 IN OUT UINT64 DeviceAddrPtr
192 snp_undi32_callback_block (
200 snp_undi32_callback_delay (
202 IN UINT64 MicroSeconds
208 snp_undi32_callback_memio (
210 IN UINT8 ReadOrWrite
,
212 IN UINT64 MemOrPortAddr
,
213 IN OUT UINT64 BufferPtr
219 snp_undi32_callback_map (
224 IN OUT UINT64 DeviceAddrPtr
230 snp_undi32_callback_unmap (
235 IN UINT64 DeviceAddr
// not a pointer to device address
241 snp_undi32_callback_sync (
246 IN UINT64 DeviceAddr
// not a pointer to device address
254 IN EFI_SIMPLE_NETWORK_PROTOCOL
*this
262 IN EFI_SIMPLE_NETWORK_PROTOCOL
*this
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
280 IN EFI_SIMPLE_NETWORK_PROTOCOL
*this,
281 IN BOOLEAN ExtendedVerification
288 snp_undi32_shutdown (
289 IN EFI_SIMPLE_NETWORK_PROTOCOL
*this
296 snp_undi32_receive_filters (
297 IN EFI_SIMPLE_NETWORK_PROTOCOL
* this,
300 IN BOOLEAN reset_mcast_filter
,
301 IN UINTN mcast_filter_count OPTIONAL
,
302 IN EFI_MAC_ADDRESS
* mcast_filter OPTIONAL
309 snp_undi32_station_address (
310 IN EFI_SIMPLE_NETWORK_PROTOCOL
* this,
312 IN EFI_MAC_ADDRESS
*new OPTIONAL
319 snp_undi32_statistics (
320 IN EFI_SIMPLE_NETWORK_PROTOCOL
* this,
322 IN OUT UINTN
*statistics_size OPTIONAL
,
323 IN OUT EFI_NETWORK_STATISTICS
* statistics_table OPTIONAL
330 snp_undi32_mcast_ip_to_mac (
331 IN EFI_SIMPLE_NETWORK_PROTOCOL
*this,
333 IN EFI_IP_ADDRESS
*IP
,
334 OUT EFI_MAC_ADDRESS
*MAC
342 IN EFI_SIMPLE_NETWORK_PROTOCOL
*this,
343 IN BOOLEAN read_write
,
345 IN UINTN buffer_size
,
353 snp_undi32_get_status (
354 IN EFI_SIMPLE_NETWORK_PROTOCOL
* this,
355 OUT UINT32
*interrupt_status OPTIONAL
,
356 OUT VOID
**tx_buffer OPTIONAL
363 snp_undi32_transmit (
364 IN EFI_SIMPLE_NETWORK_PROTOCOL
* this,
365 IN UINTN header_size
,
366 IN UINTN buffer_size
,
368 IN EFI_MAC_ADDRESS
* src_addr OPTIONAL
,
369 IN EFI_MAC_ADDRESS
* dest_addr OPTIONAL
,
370 IN UINT16
*protocol OPTIONAL
378 IN EFI_SIMPLE_NETWORK_PROTOCOL
* this,
379 OUT UINTN
*header_size OPTIONAL
,
380 IN OUT UINTN
*buffer_size
,
382 OUT EFI_MAC_ADDRESS
* src_addr OPTIONAL
,
383 OUT EFI_MAC_ADDRESS
* dest_addr OPTIONAL
,
384 OUT UINT16
*protocol OPTIONAL
390 (*issue_undi32_command
) (
399 #define SNP_MEM_PAGES(x) (((x) - 1) / 4096 + 1)