Changelog: v1->v2: Removing platform dependencies and improving EBC code performance by replacing the following functions with their Boot Service versions: CopyMem() -> gBS->CopyMem() AllocateZeroPool() -> gBS->AllocatePool() + gBS->SetMem() ZeroMem() -> gBS->SetMem() FreePool() -> gBS->FreePool()
v1: The patch removes dependencies on platform specific libraries and direct calls to functions with a platform specific implementation. Added MarvelYukonDxe.dsc for platform independent builds including EBC: build -a <target_architecture> \ -p OpenPlatformPkg/Drivers/Net/MarvellYukonDxe/MarvellYukonDxe.dsc \ -m OpenPlatformPkg/Drivers/Net/MarvellYukonDxe/MarvellYukonDxe.inf \ -b DEBUG -t <toolchain>
Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Daniil Egranov daniil.egranov@arm.com --- NOTE: This patch is based on "OpenPlatformPkg/MarvellYukonDxe: Marvell Yukon NIC driver" v4 patch. This patch includes same fix as Alan Ott's "[PATCH 1/7] Drivers/Net/MarvellYukon: Remove ARM-specific include" patch. Depending on the apply order, the patch for DeviceConfig.c should be ignored in one of the cases.
Drivers/Net/MarvellYukonDxe/DeviceConfig.c | 38 ++++---- Drivers/Net/MarvellYukonDxe/DriverBinding.c | 27 +++--- Drivers/Net/MarvellYukonDxe/MarvellYukonDxe.dsc | 88 ++++++++++++++++++ Drivers/Net/MarvellYukonDxe/MarvellYukonDxe.inf | 1 - Drivers/Net/MarvellYukonDxe/Snp.c | 30 +++--- Drivers/Net/MarvellYukonDxe/e1000phy.c | 14 ++- Drivers/Net/MarvellYukonDxe/if_msk.c | 116 ++++++++++++++---------- 7 files changed, 217 insertions(+), 97 deletions(-) create mode 100644 Drivers/Net/MarvellYukonDxe/MarvellYukonDxe.dsc
diff --git a/Drivers/Net/MarvellYukonDxe/DeviceConfig.c b/Drivers/Net/MarvellYukonDxe/DeviceConfig.c index c64f82a..0aec7be 100644 --- a/Drivers/Net/MarvellYukonDxe/DeviceConfig.c +++ b/Drivers/Net/MarvellYukonDxe/DeviceConfig.c @@ -12,7 +12,6 @@ * **/
-#include <ArmPlatform.h> #include <Protocol/PciIo.h> #include <IndustryStandard/Pci.h> #include <Library/IoLib.h> @@ -198,12 +197,16 @@ DeviceConfigSupported ( return EFI_UNSUPPORTED; }
- ConfigHandles = AllocateZeroPool (sizeof (EFI_HANDLE) * HandleCount); - if (ConfigHandles == NULL) { - FreePool(HandleBuffer); - return EFI_OUT_OF_RESOURCES; + Status = gBS->AllocatePool (EfiBootServicesData, + sizeof (EFI_HANDLE) * HandleCount, + (VOID**) &ConfigHandles); + if (EFI_ERROR (Status)) { + gBS->FreePool(HandleBuffer); + return Status; }
+ gBS->SetMem (ConfigHandles, sizeof (EFI_HANDLE) * HandleCount, 0); + // Loop through all device handles and probe for the Marvel Yukon for (HIndex = 0; HIndex < HandleCount; ++HIndex) {
@@ -228,11 +231,13 @@ DeviceConfigSupported ( Status = EFI_SUCCESS;
if (*RecordCount != 0) { - *Buffer = - AllocateZeroPool (sizeof (EFI_DEVICE_CONFIGURATION_RECORD) * (*RecordCount)); - if (*Buffer == NULL) { - Status = EFI_OUT_OF_RESOURCES; - } else { + Status = gBS->AllocatePool (EfiBootServicesData, + sizeof (EFI_DEVICE_CONFIGURATION_RECORD) * (*RecordCount), + (VOID**) &(*Buffer)); + if (!EFI_ERROR (Status)) { + gBS->SetMem (Buffer, + sizeof (EFI_DEVICE_CONFIGURATION_RECORD) * (*RecordCount), + 0); for (RIndex = 0; RIndex < *RecordCount; ++RIndex) { (*Buffer)[RIndex].Controller = ConfigHandles[RIndex]; (*Buffer)[RIndex].SupportedConfigs = 0; @@ -247,8 +252,8 @@ DeviceConfigSupported ( Status = EFI_UNSUPPORTED; }
- FreePool(HandleBuffer); - FreePool(ConfigHandles); + gBS->FreePool(HandleBuffer); + gBS->FreePool(ConfigHandles);
return Status; } @@ -281,10 +286,11 @@ DeviceConfigGet ( Status = EFI_UNSUPPORTED;
if (ConfigType == EfiConfigMacAddress) { - MacAddress = AllocateZeroPool (sizeof (EFI_MAC_ADDRESS)); - if (MacAddress == NULL) { - Status = EFI_OUT_OF_RESOURCES; - } else { + Status = gBS->AllocatePool (EfiBootServicesData, + sizeof (EFI_MAC_ADDRESS), + (VOID**) &MacAddress); + if (!EFI_ERROR (Status)) { + gBS->SetMem (MacAddress, sizeof (EFI_MAC_ADDRESS), 0); Status = ConfigMACAddress (Controller, TRUE, MacAddress); if (!EFI_ERROR (Status)) { *Buffer = MacAddress; diff --git a/Drivers/Net/MarvellYukonDxe/DriverBinding.c b/Drivers/Net/MarvellYukonDxe/DriverBinding.c index 98dd991..428ffee 100644 --- a/Drivers/Net/MarvellYukonDxe/DriverBinding.c +++ b/Drivers/Net/MarvellYukonDxe/DriverBinding.c @@ -107,25 +107,25 @@ MarvellYukonDriverStart ( {
EFI_STATUS Status; - UINTN LengthInBytes; EFI_DEVICE_PATH_PROTOCOL *ParentDevicePath; MAC_ADDR_DEVICE_PATH MacDeviceNode; VOID *ChildPciIo; YUKON_DRIVER *YukonDriver;
- LengthInBytes = sizeof (*YukonDriver); - YukonDriver = (YUKON_DRIVER *)AllocateZeroPool (sizeof (YUKON_DRIVER)); - if (YukonDriver == NULL) { - DEBUG ((EFI_D_ERROR, "Marvell Yukon: AllocateZeroPool() failed with Status = %r\n", EFI_OUT_OF_RESOURCES)); - return EFI_OUT_OF_RESOURCES; + Status = gBS->AllocatePool (EfiBootServicesData, + sizeof (YUKON_DRIVER), + (VOID**) &YukonDriver); + if (EFI_ERROR (Status)) { + DEBUG ((EFI_D_ERROR, "Marvell Yukon: AllocatePool() failed with Status = %r\n", EFI_OUT_OF_RESOURCES)); + return Status; }
+ gBS->SetMem (YukonDriver, sizeof (YUKON_DRIVER), 0); EfiInitializeLock (&YukonDriver->Lock, TPL_NOTIFY);
// // Set the structure signature // - ZeroMem (YukonDriver, LengthInBytes); YukonDriver->Signature = YUKON_DRIVER_SIGNATURE;
Status = gBS->OpenProtocol ( @@ -184,7 +184,7 @@ MarvellYukonDriverStart ( return Status; }
- ZeroMem (&MacDeviceNode, sizeof (MAC_ADDR_DEVICE_PATH)); + gBS->SetMem (&MacDeviceNode, sizeof (MAC_ADDR_DEVICE_PATH), 0); MacDeviceNode.Header.Type = MESSAGING_DEVICE_PATH; MacDeviceNode.Header.SubType = MSG_MAC_ADDR_DP;
@@ -205,8 +205,8 @@ MarvellYukonDriverStart ( // // Assign fields for device path // - CopyMem (&YukonDriver->SnpMode.CurrentAddress, &YukonDriver->SnpMode.PermanentAddress, sizeof (EFI_MAC_ADDRESS)); - CopyMem (&MacDeviceNode.MacAddress, &YukonDriver->SnpMode.CurrentAddress, sizeof (EFI_MAC_ADDRESS)); + gBS->CopyMem (&YukonDriver->SnpMode.CurrentAddress, &YukonDriver->SnpMode.PermanentAddress, sizeof (EFI_MAC_ADDRESS)); + gBS->CopyMem (&MacDeviceNode.MacAddress, &YukonDriver->SnpMode.CurrentAddress, sizeof (EFI_MAC_ADDRESS));
MacDeviceNode.IfType = YukonDriver->SnpMode.IfType; YukonDriver->DevicePath = AppendDevicePathNode (ParentDevicePath, &MacDeviceNode.Header); @@ -490,8 +490,11 @@ InitializeMarvellYukonDriver (
if (!EFI_ERROR (Status)) { ControllerHandle = NULL; - if((CfgProtocol = AllocateZeroPool (sizeof (EFI_EMBEDDED_DEVICE_CONFIG_PROTOCOL))) != NULL) { - + Status = gBS->AllocatePool (EfiBootServicesData, + sizeof (EFI_EMBEDDED_DEVICE_CONFIG_PROTOCOL), + (VOID**) &CfgProtocol); + if(!EFI_ERROR (Status)) { + gBS->SetMem (CfgProtocol, sizeof (EFI_EMBEDDED_DEVICE_CONFIG_PROTOCOL), 0); InitializeDeviceConfigProtocol(CfgProtocol); Status = gBS->InstallProtocolInterface ( &ControllerHandle, diff --git a/Drivers/Net/MarvellYukonDxe/MarvellYukonDxe.dsc b/Drivers/Net/MarvellYukonDxe/MarvellYukonDxe.dsc new file mode 100644 index 0000000..718d48c --- /dev/null +++ b/Drivers/Net/MarvellYukonDxe/MarvellYukonDxe.dsc @@ -0,0 +1,88 @@ +# +# Copyright (c) 2013-2016, ARM Limited. All rights reserved. +# +# This program and the accompanying materials +# are licensed and made available under the terms and conditions of the BSD License +# which accompanies this distribution. The full text of the license may be found at +# http://opensource.org/licenses/bsd-license.php +# +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +# + +################################################################################ +# +# Defines Section - statements that will be processed to create a Makefile. +# +################################################################################ +[Defines] + PLATFORM_NAME = MarvellYukonDxe + PLATFORM_GUID = 8391d2d4-63fc-11e6-82d5-7b6c1a2ff410 + PLATFORM_VERSION = 0.96 + DSC_SPECIFICATION = 0x00010005 + OUTPUT_DIRECTORY = Build/OpenPlatformPkg + SUPPORTED_ARCHITECTURES = IA32|IPF|X64|EBC|ARM|AARCH64 + BUILD_TARGETS = DEBUG|RELEASE|NOOPT + SKUID_IDENTIFIER = DEFAULT + +[LibraryClasses] + # + # Entry point + # + UefiDriverEntryPoint|MdePkg/Library/UefiDriverEntryPoint/UefiDriverEntryPoint.inf + # + # Basic + # + BaseLib|MdePkg/Library/BaseLib/BaseLib.inf + BaseMemoryLib|MdePkg/Library/BaseMemoryLib/BaseMemoryLib.inf + IoLib|MdePkg/Library/BaseIoLibIntrinsic/BaseIoLibIntrinsic.inf + PrintLib|MdePkg/Library/BasePrintLib/BasePrintLib.inf + # + # UEFI & PI + # + UefiLib|MdePkg/Library/UefiLib/UefiLib.inf + UefiBootServicesTableLib|MdePkg/Library/UefiBootServicesTableLib/UefiBootServicesTableLib.inf + DevicePathLib|MdePkg/Library/UefiDevicePathLib/UefiDevicePathLib.inf + UefiRuntimeServicesTableLib|MdePkg/Library/UefiRuntimeServicesTableLib/UefiRuntimeServicesTableLib.inf + # + # Generic Modules + # + TimerLib|MdePkg/Library/BaseTimerLibNullTemplate/BaseTimerLibNullTemplate.inf + NetLib|MdeModulePkg/Library/DxeNetLib/DxeNetLib.inf + PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf + # + # Misc + # + DebugPrintErrorLevelLib|MdePkg/Library/BaseDebugPrintErrorLevelLib/BaseDebugPrintErrorLevelLib.inf + + +[LibraryClasses.common.UEFI_DRIVER] + HobLib|MdePkg/Library/DxeHobLib/DxeHobLib.inf + MemoryAllocationLib|MdePkg/Library/UefiMemoryAllocationLib/UefiMemoryAllocationLib.inf + DebugLib|MdePkg/Library/UefiDebugLibConOut/UefiDebugLibConOut.inf + +[LibraryClasses.ARM, LibraryClasses.AARCH64] + # + # It is not possible to prevent ARM compiler calls to generic intrinsic functions. + # This library provides the instrinsic functions generated by a given compiler. + # [LibraryClasses.ARM] and NULL mean link this library into all ARM images. + # + NULL|ArmPkg/Library/CompilerIntrinsicsLib/CompilerIntrinsicsLib.inf + +[LibraryClasses.EBC] + LockBoxLib|MdeModulePkg/Library/LockBoxNullLib/LockBoxNullLib.inf + +[PcdsFeatureFlag] + +[PcdsFixedAtBuild] + +[PcdsFixedAtBuild.IPF] + +################################################################################################### +# +# Components Section - list of all EDK II Modules included in the build +# +################################################################################################### + +[Components] + OpenPlatformPkg/Drivers/Net/MarvellYukonDxe/MarvellYukonDxe.inf diff --git a/Drivers/Net/MarvellYukonDxe/MarvellYukonDxe.inf b/Drivers/Net/MarvellYukonDxe/MarvellYukonDxe.inf index de1059d..cf3e870 100644 --- a/Drivers/Net/MarvellYukonDxe/MarvellYukonDxe.inf +++ b/Drivers/Net/MarvellYukonDxe/MarvellYukonDxe.inf @@ -56,7 +56,6 @@ DebugLib TimerLib NetLib - ArmLib DevicePathLib
[Pcd] diff --git a/Drivers/Net/MarvellYukonDxe/Snp.c b/Drivers/Net/MarvellYukonDxe/Snp.c index fcc4e31..8166528 100644 --- a/Drivers/Net/MarvellYukonDxe/Snp.c +++ b/Drivers/Net/MarvellYukonDxe/Snp.c @@ -56,12 +56,12 @@ InitializeSNPProtocol ( YukonDriver->SnpMode.IfType = NET_IFTYPE_ETHERNET; YukonDriver->SnpMode.MaxMCastFilterCount = MAX_MCAST_FILTER_CNT; YukonDriver->SnpMode.MCastFilterCount = 0; - ZeroMem (&YukonDriver->SnpMode.MCastFilter, MAX_MCAST_FILTER_CNT * sizeof(EFI_MAC_ADDRESS)); + gBS->SetMem (&YukonDriver->SnpMode.MCastFilter, MAX_MCAST_FILTER_CNT * sizeof(EFI_MAC_ADDRESS), 0);
// // Set broadcast address // - SetMem (&YukonDriver->SnpMode.BroadcastAddress, sizeof (EFI_MAC_ADDRESS), 0xFF); + gBS->SetMem (&YukonDriver->SnpMode.BroadcastAddress, sizeof (EFI_MAC_ADDRESS), 0xFF);
YukonDriver->SnpMode.MediaPresentSupported = FALSE; YukonDriver->SnpMode.MacAddressChangeable = FALSE; @@ -227,8 +227,8 @@ SnpInitialize (
YukonDriver->SnpMode.MCastFilterCount = 0; YukonDriver->SnpMode.ReceiveFilterSetting = 0; - ZeroMem (YukonDriver->SnpMode.MCastFilter, sizeof YukonDriver->SnpMode.MCastFilter); - CopyMem (&YukonDriver->SnpMode.CurrentAddress, &YukonDriver->SnpMode.PermanentAddress, sizeof (EFI_MAC_ADDRESS)); + gBS->SetMem (YukonDriver->SnpMode.MCastFilter, sizeof YukonDriver->SnpMode.MCastFilter, 0); + gBS->CopyMem (&YukonDriver->SnpMode.CurrentAddress, &YukonDriver->SnpMode.PermanentAddress, sizeof (EFI_MAC_ADDRESS));
Status = mskc_init ();
@@ -550,13 +550,13 @@ SnpReceive ( }
if (SrcAddr != NULL) { - ZeroMem (SrcAddr, NET_ETHER_ADDR_LEN); - CopyMem (SrcAddr, ((UINT8 *) Buffer) + NET_ETHER_ADDR_LEN, NET_ETHER_ADDR_LEN); + gBS->SetMem (SrcAddr, NET_ETHER_ADDR_LEN, 0); + gBS->CopyMem (SrcAddr, ((UINT8 *) Buffer) + NET_ETHER_ADDR_LEN, NET_ETHER_ADDR_LEN); }
if (DestAddr != NULL) { - ZeroMem (DestAddr, NET_ETHER_ADDR_LEN); - CopyMem (DestAddr, ((UINT8 *) Buffer), NET_ETHER_ADDR_LEN); + gBS->SetMem (DestAddr, NET_ETHER_ADDR_LEN, 0); + gBS->CopyMem (DestAddr, ((UINT8 *) Buffer), NET_ETHER_ADDR_LEN); }
if (Protocol != NULL) { @@ -899,8 +899,8 @@ SnpShutdown (
YukonDriver->SnpMode.MCastFilterCount = 0; YukonDriver->SnpMode.ReceiveFilterSetting = 0; - ZeroMem (YukonDriver->SnpMode.MCastFilter, sizeof YukonDriver->SnpMode.MCastFilter); - CopyMem ( + gBS->SetMem (YukonDriver->SnpMode.MCastFilter, sizeof YukonDriver->SnpMode.MCastFilter, 0); + gBS->CopyMem ( &YukonDriver->SnpMode.CurrentAddress, &YukonDriver->SnpMode.PermanentAddress, sizeof (EFI_MAC_ADDRESS) @@ -973,7 +973,7 @@ SnpStart ( }
YukonDriver->SnpMode.State = EfiSimpleNetworkStarted; - CopyMem (&YukonDriver->SnpMode.CurrentAddress, &YukonDriver->SnpMode.PermanentAddress, sizeof (EFI_MAC_ADDRESS)); + gBS->CopyMem (&YukonDriver->SnpMode.CurrentAddress, &YukonDriver->SnpMode.PermanentAddress, sizeof (EFI_MAC_ADDRESS)); YukonDriver->SnpMode.MCastFilterCount = 0; goto ON_EXIT;
@@ -1271,7 +1271,7 @@ SnpStop (
mskc_detach (); YukonDriver->SnpMode.State = EfiSimpleNetworkStopped; - ZeroMem (&YukonDriver->SnpMode.CurrentAddress, sizeof (EFI_MAC_ADDRESS)); + gBS->SetMem (&YukonDriver->SnpMode.CurrentAddress, sizeof (EFI_MAC_ADDRESS), 0); Status = EFI_SUCCESS; goto ON_EXIT;
@@ -1402,9 +1402,9 @@ SnpTransmit ( Frame = (ETHER_HEAD*)Buffer; ProtocolNet = NTOHS (*Protocol);
- CopyMem (Frame->SrcMac, SrcAddr, NET_ETHER_ADDR_LEN); - CopyMem (Frame->DstMac, DestAddr, NET_ETHER_ADDR_LEN); - CopyMem (&Frame->EtherType, &ProtocolNet, sizeof (UINT16)); + gBS->CopyMem (Frame->SrcMac, SrcAddr, NET_ETHER_ADDR_LEN); + gBS->CopyMem (Frame->DstMac, DestAddr, NET_ETHER_ADDR_LEN); + gBS->CopyMem (&Frame->EtherType, &ProtocolNet, sizeof (UINT16)); }
Status = mskc_transmit (BufferSize, Buffer); diff --git a/Drivers/Net/MarvellYukonDxe/e1000phy.c b/Drivers/Net/MarvellYukonDxe/e1000phy.c index d544e88..417aea0 100644 --- a/Drivers/Net/MarvellYukonDxe/e1000phy.c +++ b/Drivers/Net/MarvellYukonDxe/e1000phy.c @@ -56,6 +56,7 @@
#include <Library/MemoryAllocationLib.h> #include <Library/DebugLib.h> +#include <Library/UefiBootServicesTableLib.h>
#include "if_media.h"
@@ -119,10 +120,13 @@ e1000_probe_and_attach ( INTN bmsr; EFI_STATUS Status;
- mPhySoftc = AllocateZeroPool (sizeof (struct e1000phy_softc)); - if (mPhySoftc == NULL) { - return EFI_OUT_OF_RESOURCES; + Status = gBS->AllocatePool (EfiBootServicesData, + sizeof (struct e1000phy_softc), + (VOID**) &mPhySoftc); + if (EFI_ERROR (Status)) { + return Status; } + gBS->SetMem (mPhySoftc, sizeof (struct e1000phy_softc), 0); mPhySoftc->mmd = mmd;
@@ -134,7 +138,7 @@ e1000_probe_and_attach ( bmsr = PHY_READ (mPhySoftc, E1000_SR); if (bmsr == 0 || bmsr == 0xffff || (bmsr & (E1000_SR_EXTENDED_STATUS|E1000_SR_MEDIAMASK)) == 0) { /* Assume no PHY at this address. */ - FreePool (mPhySoftc); + gBS->FreePool (mPhySoftc); return EFI_DEVICE_ERROR; }
@@ -148,7 +152,7 @@ e1000_probe_and_attach (
Status = e1000phy_probe (&ma); if (EFI_ERROR (Status)) { - FreePool (mPhySoftc); + gBS->FreePool (mPhySoftc); return Status; }
diff --git a/Drivers/Net/MarvellYukonDxe/if_msk.c b/Drivers/Net/MarvellYukonDxe/if_msk.c index 5e7da93..3dc16b3 100644 --- a/Drivers/Net/MarvellYukonDxe/if_msk.c +++ b/Drivers/Net/MarvellYukonDxe/if_msk.c @@ -247,7 +247,7 @@ msk_phy_readreg ( GMAC_WRITE_2 (mSoftc, port, GM_SMI_CTRL, GM_SMI_CT_PHY_AD(PHY_ADDR_MARV) | GM_SMI_CT_REG_AD(reg) | GM_SMI_CT_OP_RD);
for (i = 0; i < MSK_TIMEOUT; i++) { - MicroSecondDelay (1); + gBS->Stall (1); val = GMAC_READ_2 (mSoftc, port, GM_SMI_CTRL); if ((val & GM_SMI_CT_RD_VAL) != 0) { val = GMAC_READ_2 (mSoftc, port, GM_SMI_DATA); @@ -275,7 +275,7 @@ msk_phy_writereg ( GMAC_WRITE_2 (mSoftc, port, GM_SMI_DATA, val); GMAC_WRITE_2 (mSoftc, port, GM_SMI_CTRL, GM_SMI_CT_PHY_AD(PHY_ADDR_MARV) | GM_SMI_CT_REG_AD(reg)); for (i = 0; i < MSK_TIMEOUT; i++) { - MicroSecondDelay (1); + gBS->Stall (1); if ((GMAC_READ_2 (mSoftc, port, GM_SMI_CTRL) & GM_SMI_CT_BUSY) == 0) { break; } @@ -437,7 +437,7 @@ msk_rxfilter ( UINT16 mode; INTN port = sc_if->msk_md.port;
- ZeroMem (mchash, sizeof (mchash)); + gBS->SetMem (mchash, sizeof (mchash), 0); mode = GMAC_READ_2 (mSoftc, port, GM_RX_CTRL); // if ((ifp->if_flags & IFF_PROMISC) != 0) if ((FilterFlags & EFI_SIMPLE_NETWORK_RECEIVE_PROMISCUOUS) != 0) { @@ -503,11 +503,11 @@ msk_init_rx_ring ( sc_if->msk_cdata.msk_rx_putwm = MSK_PUT_WM;
rd = &sc_if->msk_rdata; - ZeroMem (rd->msk_rx_ring, MSK_RX_RING_SZ); + gBS->SetMem (rd->msk_rx_ring, MSK_RX_RING_SZ, 0); prod = sc_if->msk_cdata.msk_rx_prod; for (i = 0; i < MSK_RX_RING_CNT; i++) { rxd = &sc_if->msk_cdata.msk_rxdesc[prod]; - ZeroMem (&rxd->rx_m, sizeof (MSK_DMA_BUF)); + gBS->SetMem (&rxd->rx_m, sizeof (MSK_DMA_BUF), 0); rxd->rx_le = &rd->msk_rx_ring[prod]; Status = msk_newbuf (sc_if, prod); if (EFI_ERROR (Status)) { @@ -538,10 +538,10 @@ msk_init_tx_ring ( sc_if->msk_cdata.msk_tx_cnt = 0;
rd = &sc_if->msk_rdata; - ZeroMem (rd->msk_tx_ring, sizeof (struct msk_tx_desc) * MSK_TX_RING_CNT); + gBS->SetMem (rd->msk_tx_ring, sizeof (struct msk_tx_desc) * MSK_TX_RING_CNT, 0); for (i = 0; i < MSK_TX_RING_CNT; i++) { txd = &sc_if->msk_cdata.msk_txdesc[i]; - ZeroMem (&(txd->tx_m), sizeof (MSK_DMA_BUF)); + gBS->SetMem (&(txd->tx_m), sizeof (MSK_DMA_BUF), 0); txd->tx_le = &rd->msk_tx_ring[i]; } } @@ -604,7 +604,7 @@ msk_newbuf ( return Status; }
- ZeroMem (&(rxd->rx_m), sizeof (MSK_DMA_BUF)); + gBS->SetMem (&(rxd->rx_m), sizeof (MSK_DMA_BUF), 0); rxd->rx_m.DmaMapping = Mapping; rxd->rx_m.Buf = Buffer; rxd->rx_m.Length = Length; @@ -1024,7 +1024,7 @@ mskc_reset ( } */ // Clear status list - ZeroMem (mSoftc->msk_stat_ring, sizeof (struct msk_stat_desc) * MSK_STAT_RING_CNT); + gBS->SetMem (mSoftc->msk_stat_ring, sizeof (struct msk_stat_desc) * MSK_STAT_RING_CNT, 0); mSoftc->msk_stat_cons = 0; CSR_WRITE_4 (mSoftc, STAT_CTRL, SC_STAT_RST_SET); CSR_WRITE_4 (mSoftc, STAT_CTRL, SC_STAT_RST_CLR); @@ -1140,14 +1140,17 @@ mskc_attach ( struct msk_if_softc *ScIf;
mPciIo = PciIo; - mSoftc = AllocateZeroPool (sizeof (struct msk_softc)); - if (mSoftc == NULL) { - return EFI_OUT_OF_RESOURCES; + Status = gBS->AllocatePool (EfiBootServicesData, + sizeof (struct msk_softc), + (VOID**) &mSoftc); + if (EFI_ERROR (Status)) { + return Status; }
// // Save original PCI attributes // + gBS->SetMem (mSoftc, sizeof (struct msk_softc), 0); Status = mPciIo->Attributes ( mPciIo, EfiPciIoAttributeOperationGet, @@ -1155,7 +1158,7 @@ mskc_attach ( &mSoftc->OriginalPciAttributes ); if (EFI_ERROR (Status)) { - FreePool (mSoftc); + gBS->FreePool (mSoftc); return Status; }
@@ -1341,11 +1344,13 @@ mskc_attach (
mskc_setup_rambuffer ();
- ScIf = AllocateZeroPool (sizeof (struct msk_if_softc)); - if (ScIf == NULL) { - Status = EFI_OUT_OF_RESOURCES; + Status = gBS->AllocatePool (EfiBootServicesData, + sizeof (struct msk_if_softc), + (VOID**) &ScIf); + if (EFI_ERROR (Status)) { goto fail; } + gBS->SetMem (ScIf, sizeof (struct msk_if_softc), 0); mSoftc->msk_if[MSK_PORT_A] = ScIf; Status = msk_attach (MSK_PORT_A); if (EFI_ERROR (Status)) { @@ -1353,7 +1358,7 @@ mskc_attach ( }
if (Mac != NULL) { - CopyMem (Mac, &ScIf->MacAddress, sizeof (EFI_MAC_ADDRESS)); + gBS->CopyMem (Mac, &ScIf->MacAddress, sizeof (EFI_MAC_ADDRESS)); }
mmd = &ScIf->msk_md; @@ -1364,11 +1369,13 @@ mskc_attach ( }
if (mSoftc->msk_num_port > 1) { - ScIf = AllocateZeroPool (sizeof (struct msk_if_softc)); - if (ScIf == NULL) { - Status = EFI_OUT_OF_RESOURCES; + Status = gBS->AllocatePool (EfiBootServicesData, + sizeof (struct msk_if_softc), + (VOID**) &ScIf); + if (EFI_ERROR (Status)) { goto fail; } + gBS->SetMem (ScIf, sizeof (struct msk_if_softc), 0); mSoftc->msk_if[MSK_PORT_B] = ScIf; Status = msk_attach (MSK_PORT_B); if (EFI_ERROR (Status)) { @@ -1416,7 +1423,7 @@ RESTORE_PCI_ATTRIBS: mSoftc->OriginalPciAttributes, NULL ); - FreePool (mSoftc); + gBS->FreePool (mSoftc); return Status; }
@@ -1453,12 +1460,12 @@ mskc_detach (
if (mSoftc->msk_if[MSK_PORT_A] != NULL) { msk_detach (MSK_PORT_A); - FreePool (mSoftc->msk_if[MSK_PORT_A]); + gBS->FreePool (mSoftc->msk_if[MSK_PORT_A]); mSoftc->msk_if[MSK_PORT_A] = NULL; } if (mSoftc->msk_if[MSK_PORT_B] != NULL) { msk_detach (MSK_PORT_B); - FreePool (mSoftc->msk_if[MSK_PORT_B]); + gBS->FreePool (mSoftc->msk_if[MSK_PORT_B]); mSoftc->msk_if[MSK_PORT_B] = NULL; }
@@ -1491,7 +1498,7 @@ mskc_detach ( mSoftc->OriginalPciAttributes, NULL ); - FreePool (mSoftc); + gBS->FreePool (mSoftc); mSoftc = NULL; mPciIo = NULL;
@@ -1598,12 +1605,12 @@ msk_txrx_dma_alloc ( // Create DMA maps for Tx buffers. for (i = 0; i < MSK_TX_RING_CNT; i++) { txd = &sc_if->msk_cdata.msk_txdesc[i]; - ZeroMem (&(txd->tx_m), sizeof (MSK_DMA_BUF)); + gBS->SetMem (&(txd->tx_m), sizeof (MSK_DMA_BUF), 0); } // Create DMA maps for Rx buffers. for (i = 0; i < MSK_RX_RING_CNT; i++) { rxd = &sc_if->msk_cdata.msk_rxdesc[i]; - ZeroMem (&(rxd->rx_m), sizeof (MSK_DMA_BUF)); + gBS->SetMem (&(rxd->rx_m), sizeof (MSK_DMA_BUF), 0); }
fail: @@ -1645,7 +1652,7 @@ msk_txrx_dma_free ( txd = &sc_if->msk_cdata.msk_txdesc[i]; if (txd->tx_m.DmaMapping) { mPciIo->Unmap (mPciIo, txd->tx_m.DmaMapping); - ZeroMem (&(txd->tx_m), sizeof (MSK_DMA_BUF)); + gBS->SetMem (&(txd->tx_m), sizeof (MSK_DMA_BUF), 0); // We don't own the transmit buffers so don't free them } } @@ -1659,7 +1666,7 @@ msk_txrx_dma_free ( mPciIo->FreeBuffer (mPciIo, EFI_SIZE_TO_PAGES (rxd->rx_m.Length), rxd->rx_m.Buf); rxd->rx_m.Buf = NULL; } - ZeroMem (&(rxd->rx_m), sizeof (MSK_DMA_BUF)); + gBS->SetMem (&(rxd->rx_m), sizeof (MSK_DMA_BUF), 0); } } } @@ -1733,11 +1740,15 @@ mskc_transmit ( ) { MSK_LINKED_SYSTEM_BUF *LinkedSystemBuf; + EFI_STATUS Status;
- LinkedSystemBuf = AllocateZeroPool (sizeof (MSK_LINKED_SYSTEM_BUF)); - if (LinkedSystemBuf == NULL) { - return EFI_OUT_OF_RESOURCES; + Status = gBS->AllocatePool (EfiBootServicesData, + sizeof (MSK_LINKED_SYSTEM_BUF), + (VOID**) &LinkedSystemBuf); + if (EFI_ERROR (Status)) { + return Status; } + gBS->SetMem (LinkedSystemBuf, sizeof (MSK_LINKED_SYSTEM_BUF), 0); LinkedSystemBuf->Signature = TX_MBUF_SIGNATURE; // // Add the passed Buffer to the transmit queue. Don't copy. @@ -1773,7 +1784,7 @@ mskc_getstatus ( if(m_head != NULL) { *TxBuf = m_head->SystemBuf.Buf; RemoveEntryList (&m_head->Link); - FreePool (m_head); + gBS->FreePool (m_head); } } } @@ -1959,9 +1970,9 @@ mskc_receive ( } *BufferSize = mBuf->DmaBuf.Length; RemoveEntryList (&mBuf->Link); - CopyMem (Buffer, mBuf->DmaBuf.Buf, *BufferSize); - FreePool(mBuf->DmaBuf.Buf); - FreePool (mBuf); + gBS->CopyMem (Buffer, mBuf->DmaBuf.Buf, *BufferSize); + gBS->FreePool(mBuf->DmaBuf.Buf); + gBS->FreePool (mBuf); return EFI_SUCCESS; }
@@ -2006,17 +2017,26 @@ msk_rxeof ( // Reuse old buffer msk_discard_rxbuf (sc_if, cons); } - m_link = AllocateZeroPool (sizeof (MSK_LINKED_DMA_BUF)); - if (m_link != NULL) { + Status = gBS->AllocatePool (EfiBootServicesData, + sizeof (MSK_LINKED_DMA_BUF), + (VOID**) &m_link); + if (!EFI_ERROR (Status)) { + gBS->SetMem (m_link, sizeof (MSK_LINKED_DMA_BUF), 0); rxd = &sc_if->msk_cdata.msk_rxdesc[cons];
m_link->Signature = RX_MBUF_SIGNATURE; - m_link->DmaBuf.Buf = AllocateZeroPool (len); - CopyMem (m_link->DmaBuf.Buf, rxd->rx_m.Buf, len); - m_link->DmaBuf.Length = len; - m_link->DmaBuf.DmaMapping = rxd->rx_m.DmaMapping; - - InsertTailList (&mSoftc->ReceiveQueueHead, &m_link->Link); + Status = gBS->AllocatePool (EfiBootServicesData, + len, + (VOID**) &m_link->DmaBuf.Buf); + if(!EFI_ERROR (Status)) { + gBS->CopyMem (m_link->DmaBuf.Buf, rxd->rx_m.Buf, len); + m_link->DmaBuf.Length = len; + m_link->DmaBuf.DmaMapping = rxd->rx_m.DmaMapping; + + InsertTailList (&mSoftc->ReceiveQueueHead, &m_link->Link); + } else { + DEBUG ((EFI_D_NET, "Marvell Yukon: failed to allocate DMA buffer. Dropping Frame\n")); + } } else { DEBUG ((EFI_D_NET, "Marvell Yukon: failed to allocate receive buffer link. Dropping Frame\n")); } @@ -2059,7 +2079,7 @@ msk_txeof ( } txd = &sc_if->msk_cdata.msk_txdesc[cons]; mPciIo->Unmap (mPciIo, txd->tx_m.DmaMapping); - ZeroMem (&(txd->tx_m), sizeof (MSK_DMA_BUF)); + gBS->SetMem (&(txd->tx_m), sizeof (MSK_DMA_BUF), 0); // We don't own the transmit buffers so don't free them }
@@ -2810,7 +2830,7 @@ msk_stop ( } else { break; } - MicroSecondDelay (1); + gBS->Stall (1); } if (i == MSK_TIMEOUT) { DEBUG ((EFI_D_NET, "Marvell Yukon: Tx BMU stop failed\n")); @@ -2856,7 +2876,7 @@ msk_stop ( if (CSR_READ_1 (mSoftc, RB_ADDR (sc_if->msk_rxq, Q_RSL)) == CSR_READ_1 (mSoftc, RB_ADDR (sc_if->msk_rxq, Q_RL))) { break; } - MicroSecondDelay (1); + gBS->Stall (1); } if (i == MSK_TIMEOUT) { DEBUG ((EFI_D_NET, "Marvell Yukon: Rx BMU stop failed\n")); @@ -2878,7 +2898,7 @@ msk_stop ( mPciIo->FreeBuffer (mPciIo, EFI_SIZE_TO_PAGES (rxd->rx_m.Length), rxd->rx_m.Buf); rxd->rx_m.Buf = NULL; } - ZeroMem (&(rxd->rx_m), sizeof (MSK_DMA_BUF)); + gBS->SetMem (&(rxd->rx_m), sizeof (MSK_DMA_BUF), 0); } }
@@ -2886,7 +2906,7 @@ msk_stop ( txd = &sc_if->msk_cdata.msk_txdesc[i]; if (txd->tx_m.Buf != NULL) { mPciIo->Unmap (mPciIo, txd->tx_m.DmaMapping); - ZeroMem (&(txd->tx_m), sizeof (MSK_DMA_BUF)); + gBS->SetMem (&(txd->tx_m), sizeof (MSK_DMA_BUF), 0); // We don't own the transmit buffers so don't free them } }