From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wr1-f66.google.com (mail-wr1-f66.google.com [209.85.221.66]) by mx.groups.io with SMTP id smtpd.web10.5061.1592392028829813563 for ; Wed, 17 Jun 2020 04:07:09 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@nuviainc-com.20150623.gappssmtp.com header.s=20150623 header.b=PFTyswAu; spf=pass (domain: nuviainc.com, ip: 209.85.221.66, mailfrom: leif@nuviainc.com) Received: by mail-wr1-f66.google.com with SMTP id q11so1888987wrp.3 for ; Wed, 17 Jun 2020 04:07:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nuviainc-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:content-transfer-encoding:in-reply-to :user-agent; bh=eh6zumvoie/Ik8iwoyu87szO1zPG+xVUQnAlsHv1ulA=; b=PFTyswAuRsubhCqzCZn/HiNqHQrYdOKHAmdW4Qy3wvvhGGBxy5/6e4vRCftBiZlvoM XHMvxifGyz4d1IoNiGOad9/NbQp1cI/uxN2pPRcph1GOtluwqo2vcxceD1kxLEpmZ52k eNPBD6qCAhAdDF/j3tBHM2z06ganbJftiGhHSNRse52QHvgMUJFGqy3lcCNR9z0oOAFY BWqD+8zUb38YF4dcos7jNiEt/R5VnjNfRQ2QpTjF4mYjfq5/1ZXWp5nBUsKyBpxughub /FvRInzsoV1reE3IX99CxAR+zSijXlm1el87AqhUAJEFpcBS4P6/03re3kXJFw1ef5Zm jHkA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to:user-agent; bh=eh6zumvoie/Ik8iwoyu87szO1zPG+xVUQnAlsHv1ulA=; b=DMgvBHf7DFAenaJU1fhiW0jv4gZoRqny6a4OiZ9ReFaW7LHUhXmTWNinTwjdRuRkfI nUXK/QxVpDETIyND0lZnyC7cP2CzBPOFc9k/eKa686j2Yqidn37tiYqJdaw56wsAComt 5DkDRW+osaXyPmUmwKTu46IPI7xArK8LFcA30x8vKRHhCEds6AA3+pjmnBPGrLkg0erK MI2MO+8f6/oowO+mmZMbtRWRUkneTegUOIoMQKW1DRGSli1VOp6AW0JWyR7GhJonVC9d TmVnAiC3ceywZTp7x1rL3B6cPXRxw3rRrWwW49p3rF5W8J/twrMK59Oj8DQjnWZP7Bxm Ac2w== X-Gm-Message-State: AOAM530uzj4eNGxX/FgT8tZHJCrOvP5mWtnCg0pp9TjS+KygSiQIIYKx gZuVXbEKHV9G668ju2ZEzV2+rg== X-Google-Smtp-Source: ABdhPJyn7MGrrClRl3EGwNnAbxZoKuLUUI9qwmGRPdr58cwD75qqxzZeBA59D4paw4BVf2lmzcq+aA== X-Received: by 2002:a5d:4f0d:: with SMTP id c13mr8397802wru.357.1592392027186; Wed, 17 Jun 2020 04:07:07 -0700 (PDT) Return-Path: Received: from vanye ([2001:470:1f09:12f0:b26e:bfff:fea9:f1b8]) by smtp.gmail.com with ESMTPSA id g82sm7973940wmf.1.2020.06.17.04.07.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Jun 2020 04:07:06 -0700 (PDT) Date: Wed, 17 Jun 2020 12:07:03 +0100 From: "Leif Lindholm" To: Ming Huang Cc: devel@edk2.groups.io, ard.biesheuvel@linaro.org, lidongzhan@huawei.com, songdongkuang@huawei.com, wanghuiqiang@huawei.com, qiuliangen@huawei.com, shenlimei@huawei.com, xiewenyi2@huawei.com Subject: Re: [edk2-devel] [PATCH edk2-platforms v3 3/4] Silicon/Hisilicon/Acpi: Add update sas address feature Message-ID: <20200617110703.GI6739@vanye> References: <1591709245-44527-1-git-send-email-huangming23@huawei.com> <1591709245-44527-4-git-send-email-huangming23@huawei.com> <20200616142006.GE6739@vanye> <9564872f-ba0f-22c3-fb4f-d05db39802a3@huawei.com> MIME-Version: 1.0 In-Reply-To: <9564872f-ba0f-22c3-fb4f-d05db39802a3@huawei.com> User-Agent: Mutt/1.10.1 (2018-07-13) Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit On Wed, Jun 17, 2020 at 10:07:39 +0800, Ming Huang wrote: > > > 在 2020/6/16 22:20, Leif Lindholm 写道: > > One remaining question, then this set is ready to go in: > > > > On Tue, Jun 09, 2020 at 21:27:24 +0800, Ming Huang wrote: > >> The updating sas address feature is similar with apdating mac address. > >> Modify updating dsdt flow for add this feature. > >> > >> Signed-off-by: Ming Huang > >> --- > >> Silicon/Hisilicon/Drivers/AcpiPlatformDxe/AcpiPlatform.c | 2 +- > >> Silicon/Hisilicon/Drivers/AcpiPlatformDxe/AcpiPlatformDxe.inf | 1 + > >> Silicon/Hisilicon/Drivers/AcpiPlatformDxe/EthMac.c | 292 +++++++++++++++----- > >> Silicon/Hisilicon/Drivers/AcpiPlatformDxe/EthMac.h | 2 +- > >> 4 files changed, 227 insertions(+), 70 deletions(-) > >> > >> diff --git a/Silicon/Hisilicon/Drivers/AcpiPlatformDxe/AcpiPlatform.c b/Silicon/Hisilicon/Drivers/AcpiPlatformDxe/AcpiPlatform.c > >> index c45a0bb..9cdf710 100644 > >> --- a/Silicon/Hisilicon/Drivers/AcpiPlatformDxe/AcpiPlatform.c > >> +++ b/Silicon/Hisilicon/Drivers/AcpiPlatformDxe/AcpiPlatform.c > >> @@ -46,7 +46,7 @@ UpdateAcpiDsdt ( > >> return; > >> } > >> > >> - Status = EthMacInit (); > >> + Status = UpdateAcpiDsdtTable (); > >> if (EFI_ERROR (Status)) { > >> DEBUG ((DEBUG_ERROR, " UpdateAcpiDsdtTable Failed, Status = %r\n", Status)); > >> } > >> diff --git a/Silicon/Hisilicon/Drivers/AcpiPlatformDxe/AcpiPlatformDxe.inf b/Silicon/Hisilicon/Drivers/AcpiPlatformDxe/AcpiPlatformDxe.inf > >> index 866ff75..856309a 100644 > >> --- a/Silicon/Hisilicon/Drivers/AcpiPlatformDxe/AcpiPlatformDxe.inf > >> +++ b/Silicon/Hisilicon/Drivers/AcpiPlatformDxe/AcpiPlatformDxe.inf > >> @@ -46,6 +46,7 @@ > >> gEfiAcpiTableProtocolGuid # PROTOCOL ALWAYS_CONSUMED > >> gEfiAcpiSdtProtocolGuid # PROTOCOL ALWAYS_CONSUMED > >> gHisiBoardNicProtocolGuid # PROTOCOL ALWAYS_CONSUMED > >> + gHisiSasConfigProtocolGuid > >> > >> [FeaturePcd] > >> gEfiMdeModulePkgTokenSpaceGuid.PcdInstallAcpiSdtProtocol > >> diff --git a/Silicon/Hisilicon/Drivers/AcpiPlatformDxe/EthMac.c b/Silicon/Hisilicon/Drivers/AcpiPlatformDxe/EthMac.c > >> index cd98506..841c94e 100644 > >> --- a/Silicon/Hisilicon/Drivers/AcpiPlatformDxe/EthMac.c > >> +++ b/Silicon/Hisilicon/Drivers/AcpiPlatformDxe/EthMac.c > >> @@ -1,7 +1,7 @@ > >> /** @file > >> > >> Copyright (c) 2014, Applied Micro Curcuit Corporation. All rights reserved.
> >> - Copyright (c) 2015, Hisilicon Limited. All rights reserved.
> >> + Copyright (c) 2015 - 2020, Hisilicon Limited. All rights reserved.
> >> Copyright (c) 2015, Linaro Limited. All rights reserved.
> >> SPDX-License-Identifier: BSD-2-Clause-Patent > >> > >> @@ -23,6 +23,7 @@ > >> #include > >> #include > >> #include > >> +#include > >> #include > >> #include > >> #include > >> @@ -32,6 +33,7 @@ > >> #include > >> > >> #include > >> +#include > >> > >> // Turn on debug message by enabling below define > >> //#define ACPI_DEBUG > >> @@ -45,17 +47,27 @@ > >> #define EFI_ACPI_MAX_NUM_TABLES 20 > >> #define DSDT_SIGNATURE 0x54445344 > >> > >> -#define D03_ACPI_ETH_ID "HISI00C2" > >> - > >> #define ACPI_ETH_MAC_KEY "local-mac-address" > >> +#define ACPI_ETH_SAS_KEY "sas-addr" > >> > >> #define PREFIX_VARIABLE_NAME L"MAC" > >> #define PREFIX_VARIABLE_NAME_COMPAT L"RGMII_MAC" > >> -#define MAC_MAX_LEN 30 > >> +#define ADDRESS_MAX_LEN 30 > >> + > >> +CHAR8 *mHisiAcpiDevId[] = {"HISI00C1","HISI00C2","HISI0162"}; > >> + > >> +typedef enum { > >> + DsdtDeviceUnknown, > >> + DsdtDeviceLan, > >> + DsdtDeviceSas > >> +} DSDT_DEVICE_TYPE; > >> > >> -EFI_STATUS GetEnvMac( > >> - IN UINTN MacNextID, > >> - IN OUT UINT8 *MacBuffer) > >> +STATIC > >> +EFI_STATUS > >> +GetEnvMac( > >> + IN UINTN MacNextID, > >> + IN OUT UINT8 *MacBuffer > >> + ) > >> { > >> EFI_MAC_ADDRESS Mac; > >> EFI_STATUS Status; > >> @@ -89,12 +101,121 @@ EFI_STATUS GetEnvMac( > >> return EFI_SUCCESS; > >> } > >> > >> -EFI_STATUS _SearchReplacePackageMACAddress( > >> +STATIC > >> +EFI_STATUS > >> +GetSasAddress ( > >> + IN UINT8 Index, > >> + IN OUT UINT8 *SasAddrBuffer > >> + ) > >> +{ > >> + EFI_STATUS Status; > >> + HISI_SAS_CONFIG_PROTOCOL *HisiSasConf; > >> + > >> + if (SasAddrBuffer == NULL) { > >> + return EFI_INVALID_PARAMETER; > >> + } > >> + > >> + Status = gBS->LocateProtocol (&gHisiSasConfigProtocolGuid, NULL, (VOID **)&HisiSasConf); > >> + if (EFI_ERROR (Status)) { > >> + DEBUG ((DEBUG_ERROR, "Locate Sas Config Protocol failed %r\n", Status)); > >> + SasAddrBuffer[0] = 0x50; > >> + SasAddrBuffer[1] = 0x01; > >> + SasAddrBuffer[2] = 0x88; > >> + SasAddrBuffer[3] = 0x20; > >> + SasAddrBuffer[4] = 0x16; > >> + SasAddrBuffer[5] = 0x00; > >> + SasAddrBuffer[6] = 0x00; > >> + SasAddrBuffer[7] = Index; > > > > This is still a sompletely random-looking value being stuffed into the > > buffer. What is it? > > This is a random value. Maybe it is more appropriate to stuff zero into the > buffer here. I think so. Would you be happy for me to fold that in before pushing? Regards Leif > Thanks, > Ming > > > > > / > > Leif > > > >> + return Status; > >> + } > >> + > >> + return HisiSasConf->GetAddr (Index, SasAddrBuffer); > >> +} > >> + > >> +STATIC > >> +EFI_STATUS > >> +UpdateAddressInOption ( > >> + IN EFI_ACPI_SDT_PROTOCOL *AcpiTableProtocol, > >> + IN EFI_ACPI_HANDLE ChildHandle, > >> + IN UINTN DevNextID, > >> + IN DSDT_DEVICE_TYPE FoundDev > >> + ) > >> +{ > >> + EFI_STATUS Status; > >> + EFI_ACPI_DATA_TYPE DataType; > >> + CONST VOID *Buffer; > >> + UINTN DataSize; > >> + UINTN Count; > >> + EFI_ACPI_HANDLE CurrentHandle; > >> + UINT8 *AddressBuffer; > >> + UINT8 AddressByte; > >> + > >> + AddressByte = 0; > >> + AddressBuffer = AllocateZeroPool (ADDRESS_MAX_LEN); > >> + if (AddressBuffer == NULL) { > >> + DEBUG ((DEBUG_ERROR, "%a:%d AllocateZeroPool failed\n", __FILE__, __LINE__)); > >> + return EFI_OUT_OF_RESOURCES; > >> + } > >> + > >> + switch (FoundDev) { > >> + case DsdtDeviceLan: > >> + //Update the MAC > >> + Status = GetEnvMac (DevNextID, AddressBuffer); > >> + AddressByte = 6; > >> + break; > >> + case DsdtDeviceSas: > >> + //Update SAS Address. > >> + Status = GetSasAddress (DevNextID, AddressBuffer); > >> + AddressByte = 8; > >> + break; > >> + default: > >> + Status = EFI_INVALID_PARAMETER; > >> + } > >> + if (EFI_ERROR (Status)) { > >> + FreePool (AddressBuffer); > >> + return Status; > >> + } > >> + > >> + for (Count = 0; Count < AddressByte; Count++) { > >> + Status = AcpiTableProtocol->GetOption (CurrentHandle, 1, &DataType, &Buffer, &DataSize); > >> + if (EFI_ERROR (Status)) { > >> + break; > >> + } > >> + > >> + if (DataType != EFI_ACPI_DATA_TYPE_UINT) > >> + break; > >> + > >> + // only need one byte. > >> + // FIXME: Assume the CPU is little endian > >> + Status = AcpiTableProtocol->SetOption ( > >> + CurrentHandle, > >> + 1, > >> + AddressBuffer + Count, > >> + sizeof(UINT8)); > >> + if (EFI_ERROR (Status)) { > >> + break; > >> + } > >> + > >> + Status = AcpiTableProtocol->GetChild (ChildHandle, &CurrentHandle); > >> + if (EFI_ERROR (Status) || CurrentHandle == NULL) { > >> + break; > >> + } > >> + } > >> + > >> + FreePool (AddressBuffer); > >> + return Status; > >> +} > >> + > >> +STATIC > >> +EFI_STATUS > >> +UpdateAddressInPackage ( > >> IN EFI_ACPI_SDT_PROTOCOL *AcpiTableProtocol, > >> IN EFI_ACPI_HANDLE ChildHandle, > >> IN UINTN Level, > >> IN OUT BOOLEAN *Found, > >> - IN UINTN MacNextID) > >> + IN UINTN DevNextID, > >> + IN DSDT_DEVICE_TYPE FoundDev > >> + ) > >> { > >> // ASL template for ethernet driver: > >> /* > >> @@ -114,15 +235,18 @@ EFI_STATUS _SearchReplacePackageMACAddress( > >> CONST UINT8 *Data; > >> CONST VOID *Buffer; > >> UINTN DataSize; > >> - UINTN Count; > >> EFI_ACPI_HANDLE CurrentHandle; > >> EFI_ACPI_HANDLE NextHandle; > >> - UINT8 MACBuffer[MAC_MAX_LEN]; > >> + EFI_ACPI_HANDLE Level1Handle; > >> > >> DBG("In Level:%d\n", Level); > >> + Level1Handle = NULL; > >> Status = EFI_SUCCESS; > >> for (CurrentHandle = NULL; ;) { > >> Status = AcpiTableProtocol->GetChild(ChildHandle, &CurrentHandle); > >> + if (Level == 1) { > >> + Level1Handle = CurrentHandle; > >> + } > >> if (Level != 3 && (EFI_ERROR(Status) || CurrentHandle == NULL)) > >> break; > >> > >> @@ -143,11 +267,14 @@ EFI_STATUS _SearchReplacePackageMACAddress( > >> DataSize, Data[0], DataSize > 1 ? Data[1] : 0); > >> > >> Data = Buffer; > >> - if (DataType != EFI_ACPI_DATA_TYPE_STRING > >> - || AsciiStrCmp((CHAR8 *) Data, ACPI_ETH_MAC_KEY) != 0) > >> + if ((DataType != EFI_ACPI_DATA_TYPE_STRING) || > >> + ((AsciiStrCmp ((CHAR8 *) Data, ACPI_ETH_MAC_KEY) != 0) && > >> + (AsciiStrCmp ((CHAR8 *) Data, ACPI_ETH_SAS_KEY) != 0))) { > >> + ChildHandle = Level1Handle; > >> continue; > >> + } > >> > >> - DBG("_DSD Key Type %d. Found MAC address key\n", DataType); > >> + DBG("_DSD Key Type %d. Found address key\n", DataType); > >> > >> // > >> // We found the node. > >> @@ -157,33 +284,7 @@ EFI_STATUS _SearchReplacePackageMACAddress( > >> } > >> > >> if (Level == 3 && *Found) { > >> - > >> - //Update the MAC > >> - Status = GetEnvMac(MacNextID, MACBuffer); > >> - if (EFI_ERROR(Status)) > >> - break; > >> - > >> - for (Count = 0; Count < 6; Count++) { > >> - Status = AcpiTableProtocol->GetOption(CurrentHandle, 1, &DataType, &Buffer, &DataSize); > >> - if (EFI_ERROR(Status)) > >> - break; > >> - > >> - Data = Buffer; > >> - DBG(" _DSD Child Subnode Store Op Code 0x%02X 0x%02X %02X DataType 0x%X\n", > >> - DataSize, Data[0], DataSize > 1 ? Data[1] : 0, DataType); > >> - > >> - if (DataType != EFI_ACPI_DATA_TYPE_UINT) > >> - break; > >> - > >> - // only need one byte. > >> - // FIXME: Assume the CPU is little endian > >> - Status = AcpiTableProtocol->SetOption(CurrentHandle, 1, (VOID *)&MACBuffer[Count], sizeof(UINT8)); > >> - if (EFI_ERROR(Status)) > >> - break; > >> - Status = AcpiTableProtocol->GetChild(ChildHandle, &CurrentHandle); > >> - if (EFI_ERROR(Status) || CurrentHandle == NULL) > >> - break; > >> - } > >> + Status = UpdateAddressInOption (AcpiTableProtocol, ChildHandle, DevNextID, FoundDev); > >> break; > >> } > >> > >> @@ -192,7 +293,13 @@ EFI_STATUS _SearchReplacePackageMACAddress( > >> > >> //Search next package > >> AcpiTableProtocol->Open((VOID *) Buffer, &NextHandle); > >> - Status = _SearchReplacePackageMACAddress(AcpiTableProtocol, NextHandle, Level + 1, Found, MacNextID); > >> + Status = UpdateAddressInPackage ( > >> + AcpiTableProtocol, > >> + NextHandle, > >> + Level + 1, > >> + Found, > >> + DevNextID, > >> + FoundDev); > >> AcpiTableProtocol->Close(NextHandle); > >> if (!EFI_ERROR(Status)) > >> break; > >> @@ -201,22 +308,28 @@ EFI_STATUS _SearchReplacePackageMACAddress( > >> return Status; > >> } > >> > >> -EFI_STATUS SearchReplacePackageMACAddress( > >> +STATIC > >> +EFI_STATUS > >> +SearchReplacePackageAddress ( > >> IN EFI_ACPI_SDT_PROTOCOL *AcpiTableProtocol, > >> IN EFI_ACPI_HANDLE ChildHandle, > >> - IN UINTN MacNextID) > >> + IN UINTN DevNextID, > >> + IN DSDT_DEVICE_TYPE FoundDev > >> + ) > >> { > >> BOOLEAN Found = FALSE; > >> UINTN Level = 0; > >> > >> - return _SearchReplacePackageMACAddress(AcpiTableProtocol, ChildHandle, Level, &Found, MacNextID); > >> + return UpdateAddressInPackage (AcpiTableProtocol, ChildHandle, Level, > >> + &Found, DevNextID, FoundDev); > >> } > >> > >> EFI_STATUS > >> -GetEthID ( > >> +GetDeviceInfo ( > >> EFI_ACPI_SDT_PROTOCOL *AcpiTableProtocol, > >> EFI_ACPI_HANDLE ChildHandle, > >> - UINTN *EthID > >> + UINTN *DevID, > >> + DSDT_DEVICE_TYPE *FoundDev > >> ) > >> { > >> EFI_STATUS Status; > >> @@ -225,7 +338,7 @@ GetEthID ( > >> CONST VOID *Buffer; > >> UINTN DataSize; > >> > >> - // Get NameString ETHx > >> + // Get NameString > >> Status = AcpiTableProtocol->GetOption (ChildHandle, 1, &DataType, &Buffer, &DataSize); > >> if (EFI_ERROR (Status)) { > >> DEBUG ((EFI_D_ERROR, "[%a:%d] Get NameString failed: %r\n", __FUNCTION__, __LINE__, Status)); > >> @@ -236,14 +349,23 @@ GetEthID ( > >> DBG("Size %p Data %02x %02x %02x %02x\n", DataSize, Data[0], Data[1], Data[2], Data[3]); > >> > >> Data[4] = '\0'; > >> - if (DataSize != 4 || > >> - AsciiStrnCmp ("ETH", Data, 3) != 0 || > >> - Data[3] > '9' || Data[3] < '0') { > >> - DEBUG ((EFI_D_ERROR, "[%a:%d] The NameString %a is not ETHn\n", __FUNCTION__, __LINE__, Data)); > >> + if ((DataSize != 4) || > >> + (Data[3] > '9' || Data[3] < '0')) { > >> + DEBUG ((DEBUG_ERROR, "The NameString %a is not ETHn or SASn\n", Data)); > >> + return EFI_INVALID_PARAMETER; > >> + } > >> + > >> + if (AsciiStrnCmp ("ETH", Data, 3) == 0) { > >> + *FoundDev = DsdtDeviceLan; > >> + } else if (AsciiStrnCmp ("SAS", Data, 3) == 0) { > >> + *FoundDev = DsdtDeviceSas; > >> + } else { > >> + DEBUG ((DEBUG_ERROR, "[%a:%d] The NameString %a is not ETHn or SASn\n", > >> + __FUNCTION__, __LINE__, Data)); > >> return EFI_INVALID_PARAMETER; > >> } > >> > >> - *EthID = Data[3] - '0'; > >> + *DevID = Data[3] - '0'; > >> return EFI_SUCCESS; > >> } > >> > >> @@ -257,8 +379,10 @@ EFI_STATUS ProcessDSDTDevice ( > >> CONST VOID *Buffer; > >> UINTN DataSize; > >> EFI_ACPI_HANDLE DevHandle; > >> - INTN Found = 0; > >> - UINTN MacNextID; > >> + DSDT_DEVICE_TYPE FoundDev = DsdtDeviceUnknown; > >> + UINTN DevNextID; > >> + BOOLEAN HisiAcpiDevNotFound; > >> + UINTN Index; > >> > >> Status = AcpiTableProtocol->GetOption(ChildHandle, 0, &DataType, &Buffer, &DataSize); > >> if (EFI_ERROR(Status)) > >> @@ -280,7 +404,7 @@ EFI_STATUS ProcessDSDTDevice ( > >> break; > >> > >> // > >> - // Search for _HID with Ethernet ID > >> + // Search for _HID with Device ID > >> // > >> Status = AcpiTableProtocol->GetOption(DevHandle, 0, &DataType, &Buffer, &DataSize); > >> if (EFI_ERROR(Status)) > >> @@ -312,23 +436,34 @@ EFI_STATUS ProcessDSDTDevice ( > >> DBG("[%a:%d] - _HID = %a\n", __FUNCTION__, __LINE__, Data); > >> > >> if (EFI_ERROR(Status) || > >> - DataType != EFI_ACPI_DATA_TYPE_STRING || > >> - (AsciiStrCmp((CHAR8 *) Data, D03_ACPI_ETH_ID) != 0)) { > >> - AcpiTableProtocol->Close(ValueHandle); > >> - Found = 0; > >> + DataType != EFI_ACPI_DATA_TYPE_STRING) { > >> + AcpiTableProtocol->Close (ValueHandle); > >> + FoundDev = DsdtDeviceUnknown; > >> + continue; > >> + } > >> + > >> + HisiAcpiDevNotFound = TRUE; > >> + for (Index = 0; Index < ARRAY_SIZE (mHisiAcpiDevId); Index++) { > >> + if (AsciiStrCmp ((CHAR8 *)Data, mHisiAcpiDevId[Index]) == 0) { > >> + HisiAcpiDevNotFound = FALSE; > >> + break; > >> + } > >> + } > >> + if (HisiAcpiDevNotFound) { > >> + AcpiTableProtocol->Close (ValueHandle); > >> + FoundDev = DsdtDeviceUnknown; > >> continue; > >> } > >> > >> - DBG("Found Ethernet device\n"); > >> + DBG("Found device\n"); > >> AcpiTableProtocol->Close(ValueHandle); > >> - Status = GetEthID (AcpiTableProtocol, ChildHandle, &MacNextID); > >> + Status = GetDeviceInfo (AcpiTableProtocol, ChildHandle, &DevNextID, &FoundDev); > >> if (EFI_ERROR (Status)) { > >> continue; > >> } > >> - Found = 1; > >> - } else if (Found == 1 && AsciiStrnCmp((CHAR8 *) Data, "_DSD", 4) == 0) { > >> + } else if ((FoundDev != DsdtDeviceUnknown) && AsciiStrnCmp((CHAR8 *) Data, "_DSD", 4) == 0) { > >> // > >> - // Patch MAC address for open source kernel > >> + // Patch DSD data > >> // > >> EFI_ACPI_HANDLE PkgHandle; > >> Status = AcpiTableProtocol->GetOption(DevHandle, 2, &DataType, &Buffer, &DataSize); > >> @@ -351,12 +486,30 @@ EFI_STATUS ProcessDSDTDevice ( > >> // > >> // Walk the _DSD node > >> // > >> - if (DataSize == 1 && Data[0] == AML_PACKAGE_OP) > >> - Status = SearchReplacePackageMACAddress(AcpiTableProtocol, PkgHandle, MacNextID); > >> + if (DataSize == 1 && Data[0] == AML_PACKAGE_OP) { > >> + Status = SearchReplacePackageAddress (AcpiTableProtocol, PkgHandle, DevNextID, FoundDev); > >> + } > >> > >> AcpiTableProtocol->Close(PkgHandle); > >> + } else if (AsciiStrnCmp ((CHAR8 *) Data, "_ADR", 4) == 0) { > >> + Status = AcpiTableProtocol->GetOption (DevHandle, 2, &DataType, &Buffer, &DataSize); > >> + if (EFI_ERROR (Status)) { > >> + break; > >> + } > >> + > >> + if (DataType != EFI_ACPI_DATA_TYPE_CHILD) { > >> + continue; > >> + } > >> + > >> + Status = GetDeviceInfo (AcpiTableProtocol, ChildHandle, &DevNextID, &FoundDev); > >> + > >> + if (EFI_ERROR (Status)) { > >> + continue; > >> + } > >> } > >> } > >> + } else if ((DataSize == 2) && (Data[0] == AML_EXT_OP) && (Data[1] == AML_EXT_DEVICE_OP)) { > >> + ProcessDSDTDevice (AcpiTableProtocol, DevHandle); > >> } > >> } > >> > >> @@ -457,7 +610,10 @@ AcpiCheckSum ( > >> Buffer[ChecksumOffset] = CalculateCheckSum8 (Buffer, Table->Length); > >> } > >> > >> -EFI_STATUS EthMacInit(void) > >> +EFI_STATUS > >> +UpdateAcpiDsdtTable ( > >> + VOID > >> + ) > >> { > >> EFI_STATUS Status; > >> EFI_ACPI_SDT_PROTOCOL *AcpiTableProtocol; > >> diff --git a/Silicon/Hisilicon/Drivers/AcpiPlatformDxe/EthMac.h b/Silicon/Hisilicon/Drivers/AcpiPlatformDxe/EthMac.h > >> index 0a3e811..a7e1eed 100644 > >> --- a/Silicon/Hisilicon/Drivers/AcpiPlatformDxe/EthMac.h > >> +++ b/Silicon/Hisilicon/Drivers/AcpiPlatformDxe/EthMac.h > >> @@ -10,7 +10,7 @@ > >> #ifndef _ETH_MAC_H_ > >> #define _ETH_MAC_H_ > >> > >> -EFI_STATUS EthMacInit(VOID); > >> +EFI_STATUS UpdateAcpiDsdtTable (VOID); > >> > >> #endif > >> > >> -- > >> 2.8.1 > >> > >> > >> > >> > > > > . > > >