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
;
124 extern EFI_PCI_IO_PROTOCOL
*mPciIoFncs
;
127 // EFI Component Name Functions
131 SimpleNetworkComponentNameGetDriverName (
132 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
134 OUT CHAR16
**DriverName
139 SimpleNetworkComponentNameGetControllerName (
140 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
141 IN EFI_HANDLE ControllerHandle
,
142 IN EFI_HANDLE ChildHandle OPTIONAL
,
144 OUT CHAR16
**ControllerName
148 // Virtual to physical mapping for all UNDI 3.0s.
150 extern struct s_v2p
{
154 EFI_PHYSICAL_ADDRESS paddr
;
162 EFI_PCI_IO_PROTOCOL_OPERATION type
,
183 snp_undi32_callback_block_30 (
190 snp_undi32_callback_delay_30 (
191 IN UINT64 MicroSeconds
197 snp_undi32_callback_memio_30 (
198 IN UINT8 ReadOrWrite
,
200 IN UINT64 MemOrPortAddress
,
201 IN OUT UINT64 BufferPtr
207 snp_undi32_callback_v2p_30 (
209 IN OUT UINT64 DeviceAddrPtr
215 snp_undi32_callback_block (
223 snp_undi32_callback_delay (
225 IN UINT64 MicroSeconds
231 snp_undi32_callback_memio (
233 IN UINT8 ReadOrWrite
,
235 IN UINT64 MemOrPortAddr
,
236 IN OUT UINT64 BufferPtr
242 snp_undi32_callback_map (
247 IN OUT UINT64 DeviceAddrPtr
253 snp_undi32_callback_unmap (
258 IN UINT64 DeviceAddr
// not a pointer to device address
264 snp_undi32_callback_sync (
269 IN UINT64 DeviceAddr
// not a pointer to device address
277 IN EFI_SIMPLE_NETWORK_PROTOCOL
*this
285 IN EFI_SIMPLE_NETWORK_PROTOCOL
*this
292 snp_undi32_initialize (
293 IN EFI_SIMPLE_NETWORK_PROTOCOL
*this,
294 IN UINTN extra_rx_buffer_size OPTIONAL
,
295 IN UINTN extra_tx_buffer_size OPTIONAL
303 IN EFI_SIMPLE_NETWORK_PROTOCOL
*this,
304 IN BOOLEAN ExtendedVerification
311 snp_undi32_shutdown (
312 IN EFI_SIMPLE_NETWORK_PROTOCOL
*this
319 snp_undi32_receive_filters (
320 IN EFI_SIMPLE_NETWORK_PROTOCOL
* this,
323 IN BOOLEAN reset_mcast_filter
,
324 IN UINTN mcast_filter_count OPTIONAL
,
325 IN EFI_MAC_ADDRESS
* mcast_filter OPTIONAL
332 snp_undi32_station_address (
333 IN EFI_SIMPLE_NETWORK_PROTOCOL
* this,
335 IN EFI_MAC_ADDRESS
*new OPTIONAL
342 snp_undi32_statistics (
343 IN EFI_SIMPLE_NETWORK_PROTOCOL
* this,
345 IN OUT UINTN
*statistics_size OPTIONAL
,
346 IN OUT EFI_NETWORK_STATISTICS
* statistics_table OPTIONAL
353 snp_undi32_mcast_ip_to_mac (
354 IN EFI_SIMPLE_NETWORK_PROTOCOL
*this,
356 IN EFI_IP_ADDRESS
*IP
,
357 OUT EFI_MAC_ADDRESS
*MAC
365 IN EFI_SIMPLE_NETWORK_PROTOCOL
*this,
366 IN BOOLEAN read_write
,
368 IN UINTN buffer_size
,
376 snp_undi32_get_status (
377 IN EFI_SIMPLE_NETWORK_PROTOCOL
* this,
378 OUT UINT32
*interrupt_status OPTIONAL
,
379 OUT VOID
**tx_buffer OPTIONAL
386 snp_undi32_transmit (
387 IN EFI_SIMPLE_NETWORK_PROTOCOL
* this,
388 IN UINTN header_size
,
389 IN UINTN buffer_size
,
391 IN EFI_MAC_ADDRESS
* src_addr OPTIONAL
,
392 IN EFI_MAC_ADDRESS
* dest_addr OPTIONAL
,
393 IN UINT16
*protocol OPTIONAL
401 IN EFI_SIMPLE_NETWORK_PROTOCOL
* this,
402 OUT UINTN
*header_size OPTIONAL
,
403 IN OUT UINTN
*buffer_size
,
405 OUT EFI_MAC_ADDRESS
* src_addr OPTIONAL
,
406 OUT EFI_MAC_ADDRESS
* dest_addr OPTIONAL
,
407 OUT UINT16
*protocol OPTIONAL
413 SnpWaitForPacketNotify (
446 (*issue_undi32_command
) (
456 #define SNP_MEM_PAGES(x) (((x) - 1) / 4096 + 1)