/** @file\r
Declaration of strctures and functions for SnpDxe driver.\r
\r
-Copyright (c) 2004 - 2010, Intel Corporation. All rights reserved.<BR>\r
-This program and the accompanying materials are licensed\r
-and made available under the terms and conditions of the BSD License which\r
-accompanies this distribution. The full text of the license may be found at\r
-http://opensource.org/licenses/bsd-license.php\r
-\r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+Copyright (c) 2004 - 2016, Intel Corporation. All rights reserved.<BR>\r
+SPDX-License-Identifier: BSD-2-Clause-Patent\r
\r
**/\r
#ifndef _SNP_H_\r
#include <Library/BaseLib.h>\r
#include <Library/UefiLib.h>\r
#include <Library/MemoryAllocationLib.h>\r
+#include <Library/PrintLib.h>\r
\r
#include <IndustryStandard/Pci.h>\r
+#include <IndustryStandard/Acpi.h>\r
\r
#define FOUR_GIGABYTES (UINT64) 0x100000000ULL\r
\r
#define PCI_BAR_MEM_MODE 0x00000000\r
#define PCI_BAR_MEM_64BIT 0x00000004\r
\r
+#define SNP_TX_BUFFER_INCREASEMENT MAX_XMIT_BUFFERS\r
+#define SNP_MAX_TX_BUFFER_NUM 65536\r
+\r
typedef\r
EFI_STATUS\r
-(*ISSUE_UNDI32_COMMAND) (\r
+(EFIAPI *ISSUE_UNDI32_COMMAND) (\r
UINT64 Cdb\r
);\r
\r
\r
//\r
// Whether UNDI support reporting media status from GET_STATUS command,\r
- // i.e. PXE_STATFLAGS_GET_STATUS_NO_MEDIA_SUPPORTED\r
+ // i.e. PXE_STATFLAGS_GET_STATUS_NO_MEDIA_SUPPORTED or\r
+ // PXE_STATFLAGS_GET_STATUS_NO_MEDIA_NOT_SUPPORTED\r
//\r
BOOLEAN MediaStatusSupported;\r
+\r
+ //\r
+ // Whether UNDI support cable detect for INITIALIZE command,\r
+ // i.e. PXE_STATFLAGS_CABLE_DETECT_SUPPORTED or\r
+ // PXE_STATFLAGS_CABLE_DETECT_NOT_SUPPORTED\r
+ //\r
+ BOOLEAN CableDetectSupported;\r
+\r
+ //\r
+ // Array of the recycled transmit buffer address from UNDI.\r
+ //\r
+ UINT64 *RecycledTxBuf;\r
+ //\r
+ // The maximum number of recycled buffer pointers in RecycledTxBuf.\r
+ //\r
+ UINT32 MaxRecycledTxBuf;\r
+ //\r
+ // Current number of recycled buffer pointers in RecycledTxBuf.\r
+ //\r
+ UINT32 RecycledTxBufCount;\r
} SNP_DRIVER;\r
\r
#define EFI_SIMPLE_NETWORK_DEV_FROM_THIS(a) CR (a, SNP_DRIVER, Snp, SNP_DRIVER_SIGNATURE)\r
//\r
// Global Variables\r
//\r
+extern EFI_DRIVER_BINDING_PROTOCOL gSimpleNetworkDriverBinding;\r
extern EFI_COMPONENT_NAME_PROTOCOL gSimpleNetworkComponentName;\r
extern EFI_COMPONENT_NAME2_PROTOCOL gSimpleNetworkComponentName2;\r
\r
-//\r
-// Virtual to physical mapping for all UNDI 3.0s.\r
-//\r
-typedef struct _V2P V2P;\r
-\r
-struct _V2P {\r
- V2P *Next;\r
- VOID *VirtualAddress;\r
- UINTN BufferSize;\r
- EFI_PHYSICAL_ADDRESS PhysicalAddress;\r
- VOID *Unmap;\r
-};\r
-\r
-/**\r
- This routine maps the given CPU address to a Device address. It creates a\r
- an entry in the map list with the virtual and physical addresses and the\r
- un map cookie.\r
-\r
- @param V2p pointer to return a map list node pointer.\r
- @param Type the direction in which the data flows from the given\r
- virtual address device->cpu or cpu->device or both\r
- ways.\r
- @param VirtualAddress virtual address (or CPU address) to be mapped.\r
- @param BufferSize size of the buffer to be mapped.\r
-\r
- @retval EFI_SUCEESS routine has completed the mapping.\r
- @retval other error as indicated.\r
-\r
-**/\r
-EFI_STATUS\r
-AddV2p (\r
- V2P **V2p,\r
- EFI_PCI_IO_PROTOCOL_OPERATION Type,\r
- VOID *VirtualAddress,\r
- UINTN BufferSize\r
- );\r
-\r
-/**\r
- This routine searches the linked list of mapped address nodes (for undi3.0\r
- interface) to find the node that corresponds to the given virtual address and\r
- returns a pointer to that node.\r
-\r
- @param V2p pointer to return a map list node pointer.\r
- @param VirtualAddress virtual address (or CPU address) to be searched in\r
- the map list\r
-\r
- @retval EFI_SUCEESS if a match found!\r
- @retval Other match not found\r
-\r
-**/\r
-EFI_STATUS\r
-FindV2p (\r
- V2P **V2p,\r
- VOID *VirtualAddress\r
- );\r
-\r
/**\r
this routine calls undi to start the interface and changes the snp state.\r
\r
);\r
\r
/**\r
- This routine unmaps the given virtual address and frees the memory allocated\r
- for the map list node corresponding to that address.\r
+ Call undi to get the status of the interrupts, get the list of recycled transmit\r
+ buffers that completed transmitting. The recycled transmit buffer address will\r
+ be saved into Snp->RecycledTxBuf. This function will also update the MediaPresent\r
+ field of EFI_SIMPLE_NETWORK_MODE if UNDI support it.\r
\r
- @param VirtualAddress virtual address (or CPU address) to be unmapped\r
+ @param[in] Snp Pointer to snp driver structure.\r
+ @param[out] InterruptStatusPtr A non null pointer to contain the interrupt\r
+ status.\r
+ @param[in] GetTransmittedBuf Set to TRUE to retrieve the recycled transmit\r
+ buffer address.\r
\r
- @retval EFI_SUCEESS if successfully unmapped\r
- @retval Other as indicated by the error\r
+ @retval EFI_SUCCESS The status of the network interface was retrieved.\r
+ @retval EFI_DEVICE_ERROR The command could not be sent to the network\r
+ interface.\r
\r
**/\r
EFI_STATUS\r
-DelV2p (\r
- VOID *VirtualAddress\r
- );\r
-\r
-/**\r
- This is a callback routine supplied to UNDI at undi_start time.\r
- UNDI call this routine when it wants to have exclusive access to a critical\r
- section of the code/data.\r
-\r
- @param Enable non-zero indicates acquire\r
- zero indicates release\r
-\r
-**/\r
-VOID\r
-SnpUndi32CallbackBlock30 (\r
- IN UINT32 Enable\r
- );\r
-\r
-/**\r
- This is a callback routine supplied to UNDI at undi_start time.\r
- UNDI call this routine with the number of micro seconds when it wants to\r
- pause.\r
-\r
- @param MicroSeconds number of micro seconds to pause, ususlly multiple of 10.\r
-\r
-**/\r
-VOID\r
-SnpUndi32CallbackDelay30 (\r
- IN UINT64 MicroSeconds\r
- );\r
-\r
-/**\r
- This is a callback routine supplied to UNDI at undi_start time.\r
- This is the IO routine for UNDI. This is not currently being used by UNDI3.0\r
- because Undi3.0 uses io/mem offsets relative to the beginning of the device\r
- io/mem address and so it needs to use the PCI_IO_FUNCTION that abstracts the\r
- start of the device's io/mem addresses. Since SNP cannot retrive the context\r
- of the undi3.0 interface it cannot use the PCI_IO_FUNCTION that specific for\r
- that NIC and uses one global IO functions structure, this does not work.\r
- This however works fine for EFI1.0 Undis because they use absolute addresses\r
- for io/mem access.\r
-\r
- @param ReadOrWrite indicates read or write, IO or Memory\r
- @param NumBytes number of bytes to read or write\r
- @param Address IO or memory address to read from or write to\r
- @param BufferAddr memory location to read into or that contains the bytes to\r
- write\r
-\r
-**/\r
-VOID\r
-SnpUndi32CallbackMemio30 (\r
- IN UINT8 ReadOrWrite,\r
- IN UINT8 NumBytes,\r
- IN UINT64 Address,\r
- IN OUT UINT64 BufferAddr\r
- );\r
-\r
-/**\r
- This is a callback routine supplied to UNDI at undi_start time.\r
- UNDI call this routine with a virtual or CPU address that SNP provided to\r
- convert it to a physical or device address. Since EFI uses the identical\r
- mapping, this routine returns the physical address same as the virtual address\r
- for most of the addresses. an address above 4GB cannot generally be used as a\r
- device address, it needs to be mapped to a lower physical address. This\r
- routine does not call the map routine itself, but it assumes that the mapping\r
- was done at the time of providing the address to UNDI. This routine just\r
- looks up the address in a map table (which is the v2p structure chain).\r
-\r
- @param CpuAddr virtual address of a buffer.\r
- @param DeviceAddrPtr pointer to the physical address.\r
- The DeviceAddrPtr will contain 0 in case of any error.\r
-\r
-**/\r
-VOID\r
-SnpUndi32CallbackV2p30 (\r
- IN UINT64 CpuAddr,\r
- IN OUT UINT64 DeviceAddrPtr\r
+PxeGetStatus (\r
+ IN SNP_DRIVER *Snp,\r
+ OUT UINT32 *InterruptStatusPtr,\r
+ IN BOOLEAN GetTransmittedBuf\r
);\r
\r
/**\r
the MemMap call to map the required address by itself!\r
\r
@param UniqueId This was supplied to UNDI at Undi_Start, SNP uses this to\r
- store Undi interface context (Undi does not read or write\r
- this variable)\r
+ store Undi interface context (Undi does not read or write\r
+ this variable)\r
@param Enable non-zero indicates acquire\r
zero indicates release\r
**/\r
VOID\r
+EFIAPI\r
SnpUndi32CallbackBlock (\r
IN UINT64 UniqueId,\r
IN UINT32 Enable\r
pause.\r
\r
@param UniqueId This was supplied to UNDI at Undi_Start, SNP uses this to\r
- store Undi interface context (Undi does not read or write\r
- this variable)\r
+ store Undi interface context (Undi does not read or write\r
+ this variable)\r
@param MicroSeconds number of micro seconds to pause, ususlly multiple of 10.\r
**/\r
VOID\r
+EFIAPI\r
SnpUndi32CallbackDelay (\r
IN UINT64 UniqueId,\r
IN UINT64 MicroSeconds\r
This is the IO routine for UNDI3.1 to start CPB.\r
\r
@param UniqueId This was supplied to UNDI at Undi_Start, SNP uses this\r
- to store Undi interface context (Undi does not read or\r
- write this variable)\r
+ to store Undi interface context (Undi does not read or\r
+ write this variable)\r
@param ReadOrWrite indicates read or write, IO or Memory.\r
@param NumBytes number of bytes to read or write.\r
@param MemOrPortAddr IO or memory address to read from or write to.\r
to write.\r
**/\r
VOID\r
+EFIAPI\r
SnpUndi32CallbackMemio (\r
IN UINT64 UniqueId,\r
IN UINT8 ReadOrWrite,\r
\r
**/\r
VOID\r
+EFIAPI\r
SnpUndi32CallbackMap (\r
IN UINT64 UniqueId,\r
IN UINT64 CpuAddr,\r
\r
**/\r
VOID\r
+EFIAPI\r
SnpUndi32CallbackUnmap (\r
IN UINT64 UniqueId,\r
IN UINT64 CpuAddr,\r
\r
**/\r
VOID\r
+EFIAPI\r
SnpUndi32CallbackSync (\r
IN UINT64 UniqueId,\r
IN UINT64 CpuAddr,\r