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"
25 #define FOUR_GIGABYTES (UINT64) 0x100000000ULL
27 #define SNP_DRIVER_SIGNATURE EFI_SIGNATURE_32 ('s', 'n', 'd', 's')
28 #define MAX_MAP_LENGTH 100
30 #define PCI_BAR_IO_MASK 0x00000003
31 #define PCI_BAR_IO_MODE 0x00000001
33 #define PCI_BAR_MEM_MASK 0x0000000F
34 #define PCI_BAR_MEM_MODE 0x00000000
35 #define PCI_BAR_MEM_64BIT 0x00000004
41 EFI_SIMPLE_NETWORK_PROTOCOL snp
;
42 EFI_SIMPLE_NETWORK_MODE mode
;
44 EFI_HANDLE device_handle
;
45 EFI_DEVICE_PATH_PROTOCOL
*device_path
;
48 // Local instance data needed by SNP driver
50 // Pointer to S/W UNDI API entry point
51 // This will be NULL for H/W UNDI
53 EFI_STATUS (*issue_undi32_command
) (UINT64 cdb
);
58 // undi interface number, if one undi manages more nics
63 // Allocated tx/rx buffer that was passed to UNDI Initialize.
68 // mappable buffers for receive and fill header for undi3.0
69 // these will be used if the user buffers are above 4GB limit (instead of
70 // mapping the user buffers)
73 VOID
*ReceiveBufUnmap
;
75 VOID
*FillHdrBufUnmap
;
77 EFI_PCI_IO_PROTOCOL
*IoFncs
;
80 BOOLEAN IsOldUndi
; // true for EFI1.0 UNDI (3.0) drivers
82 // Buffers for command descriptor block, command parameter block
91 // UNDI structure, we need to remember the init info for a long time!
93 PXE_DB_GET_INIT_INFO init_info
;
97 // when ever we map an address, we must remember it's address and the un-map
98 // cookie so that we can unmap later
101 EFI_PHYSICAL_ADDRESS virt
;
103 } map_list
[MAX_MAP_LENGTH
];
107 #define EFI_SIMPLE_NETWORK_DEV_FROM_THIS(a) CR (a, SNP_DRIVER, snp, SNP_DRIVER_SIGNATURE)
112 extern EFI_COMPONENT_NAME_PROTOCOL gSimpleNetworkComponentName
;
113 extern EFI_DRIVER_BINDING_PROTOCOL gSimpleNetworkDriverBinding
;
115 extern EFI_PCI_IO_PROTOCOL
*mPciIoFncs
;
118 // EFI Component Name Functions
122 SimpleNetworkComponentNameGetDriverName (
123 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
125 OUT CHAR16
**DriverName
130 SimpleNetworkComponentNameGetControllerName (
131 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
132 IN EFI_HANDLE ControllerHandle
,
133 IN EFI_HANDLE ChildHandle OPTIONAL
,
135 OUT CHAR16
**ControllerName
139 // Virtual to physical mapping for all UNDI 3.0s.
141 extern struct s_v2p
{
145 EFI_PHYSICAL_ADDRESS paddr
;
153 EFI_PCI_IO_PROTOCOL_OPERATION type
,
174 snp_undi32_callback_block_30 (
181 snp_undi32_callback_delay_30 (
182 IN UINT64 MicroSeconds
188 snp_undi32_callback_memio_30 (
189 IN UINT8 ReadOrWrite
,
191 IN UINT64 MemOrPortAddress
,
192 IN OUT UINT64 BufferPtr
198 snp_undi32_callback_v2p_30 (
200 IN OUT UINT64 DeviceAddrPtr
206 snp_undi32_callback_block (
214 snp_undi32_callback_delay (
216 IN UINT64 MicroSeconds
222 snp_undi32_callback_memio (
224 IN UINT8 ReadOrWrite
,
226 IN UINT64 MemOrPortAddr
,
227 IN OUT UINT64 BufferPtr
233 snp_undi32_callback_map (
238 IN OUT UINT64 DeviceAddrPtr
244 snp_undi32_callback_unmap (
249 IN UINT64 DeviceAddr
// not a pointer to device address
255 snp_undi32_callback_sync (
260 IN UINT64 DeviceAddr
// not a pointer to device address
268 IN EFI_SIMPLE_NETWORK_PROTOCOL
*this
276 IN EFI_SIMPLE_NETWORK_PROTOCOL
*this
283 snp_undi32_initialize (
284 IN EFI_SIMPLE_NETWORK_PROTOCOL
*this,
285 IN UINTN extra_rx_buffer_size OPTIONAL
,
286 IN UINTN extra_tx_buffer_size OPTIONAL
294 IN EFI_SIMPLE_NETWORK_PROTOCOL
*this,
295 IN BOOLEAN ExtendedVerification
302 snp_undi32_shutdown (
303 IN EFI_SIMPLE_NETWORK_PROTOCOL
*this
310 snp_undi32_receive_filters (
311 IN EFI_SIMPLE_NETWORK_PROTOCOL
* this,
314 IN BOOLEAN reset_mcast_filter
,
315 IN UINTN mcast_filter_count OPTIONAL
,
316 IN EFI_MAC_ADDRESS
* mcast_filter OPTIONAL
323 snp_undi32_station_address (
324 IN EFI_SIMPLE_NETWORK_PROTOCOL
* this,
326 IN EFI_MAC_ADDRESS
*new OPTIONAL
333 snp_undi32_statistics (
334 IN EFI_SIMPLE_NETWORK_PROTOCOL
* this,
336 IN OUT UINTN
*statistics_size OPTIONAL
,
337 IN OUT EFI_NETWORK_STATISTICS
* statistics_table OPTIONAL
344 snp_undi32_mcast_ip_to_mac (
345 IN EFI_SIMPLE_NETWORK_PROTOCOL
*this,
347 IN EFI_IP_ADDRESS
*IP
,
348 OUT EFI_MAC_ADDRESS
*MAC
356 IN EFI_SIMPLE_NETWORK_PROTOCOL
*this,
357 IN BOOLEAN read_write
,
359 IN UINTN buffer_size
,
367 snp_undi32_get_status (
368 IN EFI_SIMPLE_NETWORK_PROTOCOL
* this,
369 OUT UINT32
*interrupt_status OPTIONAL
,
370 OUT VOID
**tx_buffer OPTIONAL
377 snp_undi32_transmit (
378 IN EFI_SIMPLE_NETWORK_PROTOCOL
* this,
379 IN UINTN header_size
,
380 IN UINTN buffer_size
,
382 IN EFI_MAC_ADDRESS
* src_addr OPTIONAL
,
383 IN EFI_MAC_ADDRESS
* dest_addr OPTIONAL
,
384 IN UINT16
*protocol OPTIONAL
392 IN EFI_SIMPLE_NETWORK_PROTOCOL
* this,
393 OUT UINTN
*header_size OPTIONAL
,
394 IN OUT UINTN
*buffer_size
,
396 OUT EFI_MAC_ADDRESS
* src_addr OPTIONAL
,
397 OUT EFI_MAC_ADDRESS
* dest_addr OPTIONAL
,
398 OUT UINT16
*protocol OPTIONAL
404 SnpWaitForPacketNotify (
437 (*issue_undi32_command
) (
447 #define SNP_MEM_PAGES(x) (((x) - 1) / 4096 + 1)