From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=2a00:1450:4864:20::341; helo=mail-wm1-x341.google.com; envelope-from=ard.biesheuvel@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-wm1-x341.google.com (mail-wm1-x341.google.com [IPv6:2a00:1450:4864:20::341]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 1CD302119926B for ; Tue, 11 Dec 2018 07:02:43 -0800 (PST) Received: by mail-wm1-x341.google.com with SMTP id n190so2574851wmd.0 for ; Tue, 11 Dec 2018 07:02:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=4Z88tCHknS8aexAglNIO+B+I6EdkSp3Pd9aCug1Axak=; b=Dw8z57OOa/lqzDbumlENL/JRjxu5A+/3c+TFzqtus9JVnKYz5tDU7I0fOAvKtQsgi8 tjjrMTdLUp6U20EYoBb1kTnENmpbiy4XYf2OMAGfmIBe4sFuzunGQnOK51mQim0JfojB iq1ZwcZVCOgWayT2bpG5/0xiJsyUTnLHywkV8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=4Z88tCHknS8aexAglNIO+B+I6EdkSp3Pd9aCug1Axak=; b=IFo4jmBDTdpd5kPiP6CaQnuwWRY1DamlxgYv6wo64ABiLTQwFyG1ab1/QUUHvhHu0g Ks0QyegSlZd+h6gzUGN7d76/7hwZ8wSjZaosB8VZ+igUtWLFwd1MPrBwiwOu/0yrdAFU 9qvQUjC1Go9/npLKvHtvtzNQ4atylqlWK+sWxdjKvj9thOrf9yY2j++7rEZ/zRbj7F04 rYtHrSUQVn8R7LWYiFiPZIxrqNvxAnovyi3zCPwpssuZ7ky6AIIIm6MKDXwvdSwGi5Y2 FIdBRBQQ8L75BYGZO2x7Ny7IM2zQ7stO5w5KtmqoyPMFkufbiN3itK978DzzgJg4Oq9+ ynlw== X-Gm-Message-State: AA+aEWaM+q5CRDKE+GQ6UZpwNlg1HiEvTGv79+ozW+/k8oDZr8GI+79v XPNAWLy6+VX/kPUOGiOAEP0fvvhPivf3Pg== X-Google-Smtp-Source: AFSGD/Wxac6wX3bQPlEO8FYJ7kwKH+YT2cVoFGxrd/fvLkPIshySr14+BZ6pBNiVzGECjGr+wIZhcw== X-Received: by 2002:a1c:81ca:: with SMTP id c193mr2820744wmd.66.1544540562137; Tue, 11 Dec 2018 07:02:42 -0800 (PST) Received: from harold.home ([2a01:cb1d:112:6f00:8c3:6b9d:cbc9:58c6]) by smtp.gmail.com with ESMTPSA id o9sm285793wmh.3.2018.12.11.07.02.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 11 Dec 2018 07:02:41 -0800 (PST) From: Ard Biesheuvel To: edk2-devel@lists.01.org Cc: leif.lindholm@linaro.org, alan@softiron.co.uk, Ard Biesheuvel Date: Tue, 11 Dec 2018 16:02:32 +0100 Message-Id: <20181211150237.32275-2-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20181211150237.32275-1-ard.biesheuvel@linaro.org> References: <20181211150237.32275-1-ard.biesheuvel@linaro.org> MIME-Version: 1.0 Subject: [PATCH edk2-platforms 1/6] Platform/AMD/OverdriveBoard: fix byte order of default MAC addresses X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 11 Dec 2018 15:02:44 -0000 Content-Transfer-Encoding: 8bit The PCDs containing the default MAC addresses are of type UINT64, and so the byte order needs to be inverted. As they are currently, both default MAC addresses are invalid since they have the multicast bit set. For readability, let's switch to a VOID* type PCD while at it. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Ard Biesheuvel --- Silicon/AMD/Styx/AmdStyx.dec | 4 ++-- Platform/AMD/OverdriveBoard/OverdriveBoard.dsc | 4 ++-- Silicon/AMD/Styx/Drivers/AcpiPlatformDxe/AcpiPlatform.c | 9 ++++---- Silicon/AMD/Styx/Drivers/PlatInitPei/PlatInitPei.c | 24 ++++++++++++-------- Silicon/AMD/Styx/Library/StyxDtbLoaderLib/StyxDtbLoaderLib.c | 8 +++---- 5 files changed, 26 insertions(+), 23 deletions(-) diff --git a/Silicon/AMD/Styx/AmdStyx.dec b/Silicon/AMD/Styx/AmdStyx.dec index 902259dd7267..c2e691cb5ea4 100644 --- a/Silicon/AMD/Styx/AmdStyx.dec +++ b/Silicon/AMD/Styx/AmdStyx.dec @@ -42,8 +42,8 @@ gAmdStyxTokenSpaceGuid.PcdSocCoreCount|1|UINT32|0x00000100 gAmdStyxTokenSpaceGuid.PcdSocCpuId|1|UINT32|0x00000101 - gAmdStyxTokenSpaceGuid.PcdEthMacA|0|UINT64|0x000d0001 - gAmdStyxTokenSpaceGuid.PcdEthMacB|0|UINT64|0x000d0002 + gAmdStyxTokenSpaceGuid.PcdEthMacA|{0x0,0x0,0x0,0x0,0x0,0x0}|VOID*|0x000d0001 + gAmdStyxTokenSpaceGuid.PcdEthMacB|{0x0,0x0,0x0,0x0,0x0,0x0}|VOID*|0x000d0002 [PcdsFixedAtBuild] # CPUID Register diff --git a/Platform/AMD/OverdriveBoard/OverdriveBoard.dsc b/Platform/AMD/OverdriveBoard/OverdriveBoard.dsc index ce909982c39b..3b9d70de2751 100644 --- a/Platform/AMD/OverdriveBoard/OverdriveBoard.dsc +++ b/Platform/AMD/OverdriveBoard/OverdriveBoard.dsc @@ -468,8 +468,8 @@ DEFINE DO_CAPSULE = FALSE gAmdModulePkgTokenSpaceGuid.PcdPort1NetSpeed|1 [PcdsDynamicDefault.common] - gAmdStyxTokenSpaceGuid.PcdEthMacA|0x02A1A2A3A4A5 - gAmdStyxTokenSpaceGuid.PcdEthMacB|0x02B1B2B3B4B5 + gAmdStyxTokenSpaceGuid.PcdEthMacA|{0x2,0xA1,0xA2,0xA3,0xA4,0xA5} + gAmdStyxTokenSpaceGuid.PcdEthMacB|{0x2,0xB1,0xB2,0xB3,0xB4,0xB5} [PcdsPatchableInModule] gAmdModulePkgTokenSpaceGuid.PcdXgbeUseMacFromIscp|TRUE diff --git a/Silicon/AMD/Styx/Drivers/AcpiPlatformDxe/AcpiPlatform.c b/Silicon/AMD/Styx/Drivers/AcpiPlatformDxe/AcpiPlatform.c index f1223ada2444..9c17c38a04bf 100644 --- a/Silicon/AMD/Styx/Drivers/AcpiPlatformDxe/AcpiPlatform.c +++ b/Silicon/AMD/Styx/Drivers/AcpiPlatformDxe/AcpiPlatform.c @@ -60,15 +60,14 @@ STATIC VOID SetPackageAddress ( UINT8 *Package, - UINT64 MacAddress, + UINT8 *MacAddress, UINTN Size ) { UINTN Index; for (Index = PACKAGE_MAC_OFFSET; Index < Size; Index += PACKAGE_MAC_INCR) { - Package[Index] = (UINT8)MacAddress; - MacAddress >>= 8; + Package[Index] = *MacAddress++; } } @@ -165,11 +164,11 @@ InstallSystemDescriptionTables ( // CopyMem (MacPackage, mDefaultMacPackageA, sizeof (MacPackage)); - SetPackageAddress (MacPackage, PcdGet64 (PcdEthMacA), sizeof (MacPackage)); + SetPackageAddress (MacPackage, PcdGetPtr (PcdEthMacA), sizeof (MacPackage)); PatchAmlPackage (mDefaultMacPackageA, MacPackage, sizeof (MacPackage), (UINT8 *)Table, TableSize); - SetPackageAddress (MacPackage, PcdGet64 (PcdEthMacB), sizeof (MacPackage)); + SetPackageAddress (MacPackage, PcdGetPtr (PcdEthMacB), sizeof (MacPackage)); PatchAmlPackage (mDefaultMacPackageB, MacPackage, sizeof (MacPackage), (UINT8 *)Table, TableSize); diff --git a/Silicon/AMD/Styx/Drivers/PlatInitPei/PlatInitPei.c b/Silicon/AMD/Styx/Drivers/PlatInitPei/PlatInitPei.c index 4ea1dd4b3577..3cd650eee36b 100644 --- a/Silicon/AMD/Styx/Drivers/PlatInitPei/PlatInitPei.c +++ b/Silicon/AMD/Styx/Drivers/PlatInitPei/PlatInitPei.c @@ -123,7 +123,7 @@ PlatInitPeiEntryPoint ( ISCP_CPU_RESET_INFO CpuResetInfo = {0}; #if DO_XGBE == 1 ISCP_MAC_INFO MacAddrInfo = {0}; - UINT64 MacAddr0, MacAddr1; + UINTN MacSize; #endif UINTN CpuCoreCount, CpuMap, CpuMapSize; UINTN Index, CoreNum; @@ -223,16 +223,20 @@ PlatInitPeiEntryPoint ( PeiServices, &MacAddrInfo ); ASSERT_EFI_ERROR (Status); - MacAddr0 = MacAddr1 = 0; - for (Index = 0; Index < 6; ++Index) { - MacAddr0 |= (UINT64)MacAddrInfo.MacAddress0[Index] << (Index * 8); - MacAddr1 |= (UINT64)MacAddrInfo.MacAddress1[Index] << (Index * 8); - } - PcdSet64 (PcdEthMacA, MacAddr0); - PcdSet64 (PcdEthMacB, MacAddr1); + MacSize = sizeof(MacAddrInfo.MacAddress0); + Status = PcdSetPtrS (PcdEthMacA, &MacSize, MacAddrInfo.MacAddress0); + ASSERT_EFI_ERROR (Status); + Status = PcdSetPtrS (PcdEthMacB, &MacSize, MacAddrInfo.MacAddress1); + ASSERT_EFI_ERROR (Status); - DEBUG ((EFI_D_ERROR, "EthMacA = 0x%lX\n", PcdGet64 (PcdEthMacA))); - DEBUG ((EFI_D_ERROR, "EthMacB = 0x%lX\n", PcdGet64 (PcdEthMacB))); + DEBUG ((EFI_D_ERROR, "EthMacA = %02x:%02x:%02x:%02x:%02x:%02x\n", + ((UINT8 *)PcdGetPtr (PcdEthMacA))[0], ((UINT8 *)PcdGetPtr (PcdEthMacA))[1], + ((UINT8 *)PcdGetPtr (PcdEthMacA))[2], ((UINT8 *)PcdGetPtr (PcdEthMacA))[3], + ((UINT8 *)PcdGetPtr (PcdEthMacA))[4], ((UINT8 *)PcdGetPtr (PcdEthMacA))[5])); + DEBUG ((EFI_D_ERROR, "EthMacB = %02x:%02x:%02x:%02x:%02x:%02x\n", + ((UINT8 *)PcdGetPtr (PcdEthMacB))[0], ((UINT8 *)PcdGetPtr (PcdEthMacB))[1], + ((UINT8 *)PcdGetPtr (PcdEthMacB))[2], ((UINT8 *)PcdGetPtr (PcdEthMacB))[3], + ((UINT8 *)PcdGetPtr (PcdEthMacB))[4], ((UINT8 *)PcdGetPtr (PcdEthMacB))[5])); #endif // Let other PEI modules know we're done! diff --git a/Silicon/AMD/Styx/Library/StyxDtbLoaderLib/StyxDtbLoaderLib.c b/Silicon/AMD/Styx/Library/StyxDtbLoaderLib/StyxDtbLoaderLib.c index b9dfa2367ab2..4ca5d9bebed6 100644 --- a/Silicon/AMD/Styx/Library/StyxDtbLoaderLib/StyxDtbLoaderLib.c +++ b/Silicon/AMD/Styx/Library/StyxDtbLoaderLib/StyxDtbLoaderLib.c @@ -168,7 +168,7 @@ VOID SetMacAddress ( IN VOID *Fdt, IN CONST CHAR8 *Device, - IN UINT64 MacAddress + IN UINT8 *MacAddress ) { INT32 Node; @@ -179,7 +179,7 @@ SetMacAddress ( if (Node >= 0) { SubNode = fdt_subnode_offset (Fdt, Node, Device); if (SubNode >= 0) { - Rc = fdt_setprop (Fdt, SubNode, "mac-address", (VOID *)&MacAddress, + Rc = fdt_setprop (Fdt, SubNode, "mac-address", MacAddress, MAC_ADDRESS_BYTES); if (Rc) { DEBUG ((DEBUG_ERROR, @@ -289,8 +289,8 @@ SetXgbeStatus ( SetDeviceStatus (Fdt, "xgmac@e0900000", TRUE); SetDeviceStatus (Fdt, "phy@e1240c00", TRUE); - SetMacAddress (Fdt, "xgmac@e0700000", PcdGet64 (PcdEthMacA)); - SetMacAddress (Fdt, "xgmac@e0900000", PcdGet64 (PcdEthMacB)); + SetMacAddress (Fdt, "xgmac@e0700000", PcdGetPtr (PcdEthMacA)); + SetMacAddress (Fdt, "xgmac@e0900000", PcdGetPtr (PcdEthMacB)); #else SetDeviceStatus (Fdt, "xgmac@e0700000", FALSE); SetDeviceStatus (Fdt, "phy@e1240800", FALSE); -- 2.19.2