From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (NAM11-CO1-obe.outbound.protection.outlook.com [40.107.220.103]) by mx.groups.io with SMTP id smtpd.web09.9832.1637167864512811204 for ; Wed, 17 Nov 2021 08:51:04 -0800 Authentication-Results: mx.groups.io; dkim=fail reason="body hash did not verify" header.i=@os.amperecomputing.com header.s=selector2 header.b=rfKzYPA2; spf=pass (domain: os.amperecomputing.com, ip: 40.107.220.103, mailfrom: nhi@os.amperecomputing.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=an/l33Bo0s+mtia9HLYGhPv+8kQ5AXdURLrQqdf6t6eo4GNne/usZIdR9A8MVBvwF8XLsKu4ORwGbD9FlDpU9PEAMX8I4fQ0UC09/xmLrkOvnlVyZyPQIFRCHChxdd5CECjHFAF6sMxO7r7MC2FE4Mo8JYiSZyNjJVeRHc1otKixOYRf5HzOj5jg7AxK0dAuSkK5tgvB+TLF3mXdcRVmVDDmbLj6GzMtIxIig5Oyy2gGC9bINSB6oodJa+Sx+nTm2T3BhvQlaLZkt7KcGHDLMr+X8l6DsuNsliHE/oA6yuHzLTxGsgZEz/HE2JpUUt/hm5dJnaqyQilK5GaO8VAX9w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=mEjQOYrEOKpbcNtY3WMegr1vqUZST6m2vUAM2AzxTbQ=; b=MrD1UQyuv2YfgMZHExghtMoGzEgQufyvFveHckPJT9LhOgbMSwYlnJTVMB/yNf+IC3NgqjVex/kF13pk/YYAj2Qbx5F9PYHYzvFtgj7LItUNRaZie37V743p9+JrEZuh5/j7Q7JKSIiD7afMd9LlSXWDQNW0rSiccItxDma0xpU5mScKsIMWn54iFcCSZcAcw+tP5cVPpCI/n08BeDMfIVALgX29ruExyVC6LSoPsCTA629yG5FlOkQx7r3cSlb635uP7jBaRfm6933zJpGCbbrj1O83jW3y7wsEuLDJJ2R+zDjBom93WeLSpF/JcDtSKuUBVZFTvtf9enAmGx0mDA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=os.amperecomputing.com; dmarc=pass action=none header.from=os.amperecomputing.com; dkim=pass header.d=os.amperecomputing.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=os.amperecomputing.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=mEjQOYrEOKpbcNtY3WMegr1vqUZST6m2vUAM2AzxTbQ=; b=rfKzYPA2q1TVOWwDvPWAwR2cx1noI5xml4DbJvoqyhUglCgWjEffjvprBtpj6NeHGUkLOCQsGzQTCPCX2WnvC+Xq5CgRE/Q1rJgTXzpGU6fDjnMY9m3khfCB2AKrE90XAetmQyGvTXxMtYYYYzjl70uDnHovLj5mexkYuNQccDg= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=os.amperecomputing.com; Received: from PH0PR01MB7287.prod.exchangelabs.com (2603:10b6:510:10a::21) by PH0PR01MB7400.prod.exchangelabs.com (2603:10b6:510:10b::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4690.19; Wed, 17 Nov 2021 16:51:03 +0000 Received: from PH0PR01MB7287.prod.exchangelabs.com ([fe80::254c:9533:7f35:aee]) by PH0PR01MB7287.prod.exchangelabs.com ([fe80::254c:9533:7f35:aee%4]) with mapi id 15.20.4713.019; Wed, 17 Nov 2021 16:51:02 +0000 From: "Nhi Pham" To: devel@edk2.groups.io CC: patches@amperecomputing.com, nhi@os.amperecomputing.com, vunguyen@os.amperecomputing.com, Thang Nguyen , Chuong Tran , Phong Vo , Leif Lindholm , Michael D Kinney , Ard Biesheuvel , Nate DeSimone Subject: [edk2-platforms][PATCH v5 27/30] AmpereAltraPkg: Add configuration screen for CPU Date: Wed, 17 Nov 2021 23:47:24 +0700 Message-ID: <20211117164727.10922-28-nhi@os.amperecomputing.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20211117164727.10922-1-nhi@os.amperecomputing.com> References: <20211117164727.10922-1-nhi@os.amperecomputing.com> X-ClientProxiedBy: HKAPR04CA0001.apcprd04.prod.outlook.com (2603:1096:203:d0::11) To PH0PR01MB7287.prod.exchangelabs.com (2603:10b6:510:10a::21) Return-Path: nhi@os.amperecomputing.com MIME-Version: 1.0 Received: from sw004.amperecomputing.com (118.69.219.201) by HKAPR04CA0001.apcprd04.prod.outlook.com (2603:1096:203:d0::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4713.21 via Frontend Transport; Wed, 17 Nov 2021 16:51:00 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 58cb1753-2541-4d3e-6ddc-08d9a9ea70a3 X-MS-TrafficTypeDiagnostic: PH0PR01MB7400: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:69; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 1p659PxOYOAX56jp2S48YtN5NQKWUenj9PjMOwkPz/lp4NtUGcxAd46CYNULwo9suP6DH0o695fZngxslta608hV4BWB+nuaMjEiX4eh6ddfQHDKI52jJpwJiOJQgj5aLrjqphRWxZXUAW6hlSKepMCGR6jeQBd54IcuDbMNtYxnUa5jcorH+mhtIuBImbtnCQYiKXUbgMbPZHB7d6lMlRyQ9Za69FGDd2To3eVkOmaiAzav9vvDPbnjZZ+6Cpl0jebY4oBMhZUuo+PW4dZmfJDM6soLbAYKMTen4EZsT6Jt0V/7ld2eKcECRQX9+kiztVHBfblhJdHqGFk6/rYyo1/dF6VfDX/FFtK26ZIAClE1zjMcDmxG0GXW5k5VhHhb5PBMQDHd6phiZhNQqdEs5V3C+5coMCiFOb/mLI9QiNhvy9KtewsHCANIMOxOZWTHTOAz/BxleMfJkMnClrwBRnortjBm/TjMX3tV5spNKAnCDqp2NcsP0ZBEFY8pKIN3bVlaxbwV5+5NDLqdNPnRBsGrzWmbARitb55RUsWFx35nzwL732z6vGq8stiK3ICvTT9FZq7Muw0ntltBgWWuu863Gz513gZOw82peIm1JxgO1oTgeMkruWml8vaMP4A1YyDfDTxfK7gmUeSvNbVeHCw+gLCPIECmRLTQtR7Arzi9pSzHvI8/ZpNc5YM6QZwjFPtP1r9qC2GGwA4G4lwOMM3JZO1egEFLvJYYmJnvREeH1s5XGo0Vg67aZHytzlPVd0u+eXWFO2TpHNBFlGn28w== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PH0PR01MB7287.prod.exchangelabs.com;PTR:;CAT:NONE;SFS:(4636009)(366004)(30864003)(956004)(508600001)(186003)(38100700002)(6666004)(83380400001)(6486002)(52116002)(66574015)(66476007)(66946007)(2616005)(66556008)(1076003)(54906003)(8676002)(38350700002)(4326008)(316002)(6512007)(8936002)(2906002)(6916009)(5660300002)(6506007)(86362001)(26005)(290074003)(44824005);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?L16x5hEHbGYo4mFzAHQIGzpPLrjITFu5zxjKScr9CsUz8/bH/8hWdj5yAqEI?= =?us-ascii?Q?NsKJHUoXDXw9nkYh3GPeVwxK+vv4nXo70eNEFiOgG8DBDfwSMrRtUH+/l/ce?= =?us-ascii?Q?vPmUwmgO5gCQkv8eRIz45P7D/J5re3hhcH10LVfQhaAC/3xR2LxqspHASC3D?= =?us-ascii?Q?pzA4UOvwuCQjHrtHDmq1P5mtPSzJ6ZdZLKMNffsaUCDA5kqeuV8LNN8OurJS?= =?us-ascii?Q?OfThNnQo1/B71nCYixz4dfKVHWnRHFi0HuyR86xS9GEOysv0L/kA/QsCmW+z?= =?us-ascii?Q?O56Vr3KA3SJSvBhLNHnASO95b5fNW1BnvOf2rbDPJnQ1ndHOlbLw3Cas2jzg?= =?us-ascii?Q?xyzklHp0VoZGK/tXVWkj625+VMzyKyuAA9DSAYKmlOsHuWgl3DqtIlBzvKI8?= =?us-ascii?Q?YmmV3gmgsDLKK1uYUdCJvEnXF3CotFZ44fTeakznViZKufRLddsPefse1XYg?= =?us-ascii?Q?NebRb9AJVFM2asNsL4DQRaqGHNeOd6XK+Fv6nez3jf6j3Jmh4Y3H5RExIOKX?= =?us-ascii?Q?3Xza5jnqDqWAY2Ne3WVW8YFlboOWG670YQzT/vg/o1U08YxkdK5QSfbNILGS?= =?us-ascii?Q?oH0cYfK/SKpSW9jYkOsYlvfvyy7G2/eiof9u+ViM7fJ4fAbyjTJ3sd2l+/nH?= =?us-ascii?Q?noWVEKxxndQYOazxOu8FGeJDwQBB4EqkYrnWZvTMQurSGpQ83l2cfaEc+uuR?= =?us-ascii?Q?NmFv03YDI1j3LhM84yGSB78udQsQFSBaMchpgKScstnMpRgnhTSWDgMpXpra?= =?us-ascii?Q?6jLopcUHegA+hk4geq6wJr/e9Hxm3EGBfqZ/xknleD2W2KXKZvWb6eVFGP8F?= =?us-ascii?Q?hlHo55phY1iESh8LHMPnBZSbSyp6RWCVgDRG//MDw5+ORcIQTAGwR7xtrDtV?= =?us-ascii?Q?LNPXvPLkVlLrclCn9HdVwKKthZeHY2AY51JzWI8SPfxlSJcfrKcs20CEk2FL?= =?us-ascii?Q?Z/LGonQKcY30m4vMpCLvWmkHWdHQTZdoJpo9u0HFokeB3GTYHeagIzFfv3b3?= =?us-ascii?Q?WhklKliB0QEhfxBuOdB5kmbYg5GFKbEbYmYCYPWr76bO84PumyBmzgcvnbYq?= =?us-ascii?Q?UFXKI9tAZmyZ1I/rjXxnVdQFkkM8fWCB1y3zetwBgOwL4FGEY1CF8mVGYzPe?= =?us-ascii?Q?16WzgVKKzC+4X5BVzjnZHnnMR43u81+08DFYRkSXQGzNYvZHsUKJ5Qwuu3LO?= =?us-ascii?Q?nSL7b9NSqR6Z4M9OvG+IBZORLxFTybRRULDL2ou90C8Sj/ezlP4pLAtJsNS/?= =?us-ascii?Q?EmCoU2019b9x7Ha0oAi081Bcy/jfk9CvPHMnP+rAWte+yy9DBkGr3M5dz7Bd?= =?us-ascii?Q?zx1++Gh8PEEP9p3nQBw1+eRM5LQ8kWofASo+l79ZZ/MKZTi2o/vDj/fieZzp?= =?us-ascii?Q?owTnhtpAN3SexwvefYEFtrBhGMQY5gx4XNwCCFZOKbKLpvuoSZolM0QVFLP8?= =?us-ascii?Q?2JqIzqbLuue5jAeDtdmLEyLkh7zaR7JJ/Xug3p2bpyRPRi0oOUL8OS18uzm3?= =?us-ascii?Q?qT+uIrCn8TrtlrFdtTDjd6sZv0ay38WKyr5qvui8RzWFZEU7Od4IAP4h2w4f?= =?us-ascii?Q?WVzh70vkxyXVDWaAtOlKfxCzkbHPR4/vxYCTPid0jFrCQowx5orMMxR7gOs1?= =?us-ascii?Q?9nYVYaml614QNjw1knwUTR5x0WDyO3K948mZ3nAWYI3dAIhMPzklhTn2V/sq?= =?us-ascii?Q?XOo5umGmSm+2JR6LHXiX8IuUOXY=3D?= X-OriginatorOrg: os.amperecomputing.com X-MS-Exchange-CrossTenant-Network-Message-Id: 58cb1753-2541-4d3e-6ddc-08d9a9ea70a3 X-MS-Exchange-CrossTenant-AuthSource: PH0PR01MB7287.prod.exchangelabs.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Nov 2021 16:51:02.9165 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3bc2b170-fd94-476d-b0ce-4229bdc904a7 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: oz2xnJfWAKonHZo3Ct4ee5k7vPKonsQ3z3fT3rHCYKx4PVgSrtPpXV4v+mdvtC8YAQyZ8mOeh87+bgDhP4rYoeis8GUCvYDh1v2P+jzBopg= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR01MB7400 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain This screen is to add configuration regarding CPU. Currently, this screen just adds a option for SubNUMA mode selection. Cc: Thang Nguyen Cc: Chuong Tran Cc: Phong Vo Cc: Leif Lindholm Cc: Michael D Kinney Cc: Ard Biesheuvel Cc: Nate DeSimone Signed-off-by: Nhi Pham Reviewed-by: Leif Lindholm --- Silicon/Ampere/AmpereAltraPkg/AmpereAltraPkg.dec = | 3 + Platform/Ampere/JadePkg/Jade.dsc = | 1 + Platform/Ampere/JadePkg/Jade.fdf = | 1 + Silicon/Ampere/AmpereAltraPkg/Drivers/CpuConfigDxe/CpuConfigDxe.inf = | 58 +++ Silicon/Ampere/AmpereAltraPkg/Drivers/CpuConfigDxe/CpuConfigDxe.h = | 52 ++ Silicon/Ampere/AmpereAltraPkg/Drivers/CpuConfigDxe/CpuConfigNVDataStruc.h = | 19 + Silicon/Ampere/AmpereAltraPkg/Include/Guid/CpuConfigHii.h = | 19 + Silicon/Ampere/AmpereAltraPkg/Drivers/CpuConfigDxe/CpuConfigVfr.vfr = | 43 ++ Silicon/Ampere/AmpereAltraPkg/Drivers/CpuConfigDxe/CpuConfigDxe.c = | 530 ++++++++++++++++++++ Silicon/Ampere/AmpereAltraPkg/Drivers/CpuConfigDxe/CpuConfigStrings.uni = | 17 + 10 files changed, 743 insertions(+) diff --git a/Silicon/Ampere/AmpereAltraPkg/AmpereAltraPkg.dec b/Silicon/Amp= ere/AmpereAltraPkg/AmpereAltraPkg.dec index 460255768aed..68e235b06c0c 100644 --- a/Silicon/Ampere/AmpereAltraPkg/AmpereAltraPkg.dec +++ b/Silicon/Ampere/AmpereAltraPkg/AmpereAltraPkg.dec @@ -64,3 +64,6 @@ [Guids] =20 ## Include/Guid/RootComplexConfigHii.h gRootComplexConfigFormSetGuid =3D { 0xE84E70D6, 0xE4B2, 0x4C6E, { 0x98, = 0x51, 0xCB, 0x2B, 0xAC, 0x77, 0x7D, 0xBB } } + + ## Include/Guid/CpuConfigHii.h + gCpuConfigFormSetGuid =3D { 0x43FAA144, 0xA2DF, 0x4050, { 0xA7, 0= xFD, 0xEE, 0x17, 0xC9, 0xB8, 0x88, 0x8E } } diff --git a/Platform/Ampere/JadePkg/Jade.dsc b/Platform/Ampere/JadePkg/Jad= e.dsc index 5cebd1e9d0c3..4dff28de920a 100644 --- a/Platform/Ampere/JadePkg/Jade.dsc +++ b/Platform/Ampere/JadePkg/Jade.dsc @@ -188,3 +188,4 @@ [Components.common] Silicon/Ampere/AmpereAltraPkg/Drivers/RootComplexConfigDxe/RootComplexCo= nfigDxe.inf Silicon/Ampere/AmpereAltraPkg/Drivers/PlatformInfoDxe/PlatformInfoDxe.in= f Silicon/Ampere/AmpereAltraPkg/Drivers/MemInfoDxe/MemInfoDxe.inf + Silicon/Ampere/AmpereAltraPkg/Drivers/CpuConfigDxe/CpuConfigDxe.inf diff --git a/Platform/Ampere/JadePkg/Jade.fdf b/Platform/Ampere/JadePkg/Jad= e.fdf index 9a3236669858..869d802eccd4 100644 --- a/Platform/Ampere/JadePkg/Jade.fdf +++ b/Platform/Ampere/JadePkg/Jade.fdf @@ -354,5 +354,6 @@ [FV.FvMain] INF Silicon/Ampere/AmpereAltraPkg/Drivers/RootComplexConfigDxe/RootCompl= exConfigDxe.inf INF Silicon/Ampere/AmpereAltraPkg/Drivers/PlatformInfoDxe/PlatformInfoDx= e.inf INF Silicon/Ampere/AmpereAltraPkg/Drivers/MemInfoDxe/MemInfoDxe.inf + INF Silicon/Ampere/AmpereAltraPkg/Drivers/CpuConfigDxe/CpuConfigDxe.inf =20 !include Silicon/Ampere/AmpereSiliconPkg/FvRules.fdf.inc diff --git a/Silicon/Ampere/AmpereAltraPkg/Drivers/CpuConfigDxe/CpuConfigDx= e.inf b/Silicon/Ampere/AmpereAltraPkg/Drivers/CpuConfigDxe/CpuConfigDxe.inf new file mode 100644 index 000000000000..2b13ef526685 --- /dev/null +++ b/Silicon/Ampere/AmpereAltraPkg/Drivers/CpuConfigDxe/CpuConfigDxe.inf @@ -0,0 +1,58 @@ +## @file +# +# Copyright (c) 2020 - 2021, Ampere Computing LLC. All rights reserved. +# +# SPDX-License-Identifier: BSD-2-Clause-Patent +# +## + +[Defines] + INF_VERSION =3D 0x0001001B + BASE_NAME =3D CpuConfigDxe + MODULE_UNI_FILE =3D CpuConfigDxe.uni + FILE_GUID =3D A20D8E6E-EE6C-43C5-809F-19BB930653AE + MODULE_TYPE =3D DXE_DRIVER + VERSION_STRING =3D 1.0 + ENTRY_POINT =3D CpuConfigDxeEntryPoint + +[Sources.common] + CpuConfigDxe.c + CpuConfigDxe.h + CpuConfigNVDataStruc.h + CpuConfigVfr.vfr + CpuConfigStrings.uni + +[Packages] + MdeModulePkg/MdeModulePkg.dec + MdePkg/MdePkg.dec + Silicon/Ampere/AmpereAltraPkg/AmpereAltraPkg.dec + Silicon/Ampere/AmpereSiliconPkg/AmpereSiliconPkg.dec + +[LibraryClasses] + ArmLib + BaseLib + DebugLib + DevicePathLib + HiiLib + HobLib + IoLib + MemoryAllocationLib + NVParamLib + PcdLib + PrintLib + UefiBootServicesTableLib + UefiDriverEntryPoint + UefiLib + UefiRuntimeServicesTableLib + +[Protocols] + gEfiHiiConfigRoutingProtocolGuid ## CONSUMES + gEfiHiiConfigAccessProtocolGuid ## PRODUCES + gEfiDevicePathProtocolGuid ## PRODUCES + +[Guids] + gCpuConfigFormSetGuid + gPlatformManagerFormsetGuid + +[Depex] + TRUE diff --git a/Silicon/Ampere/AmpereAltraPkg/Drivers/CpuConfigDxe/CpuConfigDx= e.h b/Silicon/Ampere/AmpereAltraPkg/Drivers/CpuConfigDxe/CpuConfigDxe.h new file mode 100644 index 000000000000..b7e74a09da5b --- /dev/null +++ b/Silicon/Ampere/AmpereAltraPkg/Drivers/CpuConfigDxe/CpuConfigDxe.h @@ -0,0 +1,52 @@ +/** @file + + Copyright (c) 2020 - 2021, Ampere Computing LLC. All rights reserved. + + SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#ifndef CPU_CONFIG_H_ +#define CPU_CONFIG_H_ + +#include "CpuConfigNVDataStruc.h" + +// +// This is the generated IFR binary data for each formset defined in VFR. +// +extern UINT8 CpuConfigVfrBin[]; + +// +// This is the generated String package data for all .UNI files. +// +extern UINT8 CpuConfigDxeStrings[]; + +#define CPU_CONFIG_PRIVATE_SIGNATURE SIGNATURE_32 ('C', 'P', 'U', '_') + +typedef struct { + UINTN Signature; + + EFI_HANDLE DriverHandle; + EFI_HII_HANDLE HiiHandle; + CPU_VARSTORE_DATA Configuration; + + EFI_HII_CONFIG_ROUTING_PROTOCOL *HiiConfigRouting; + + EFI_HII_CONFIG_ACCESS_PROTOCOL ConfigAccess; +} CPU_CONFIG_PRIVATE_DATA; + +#define CPU_CONFIG_PRIVATE_FROM_THIS(a) CR (a, CPU_CONFIG_PRIVATE_DATA, C= onfigAccess, CPU_CONFIG_PRIVATE_SIGNATURE) + +#pragma pack(1) + +/// +/// HII specific Vendor Device Path definition. +/// +typedef struct { + VENDOR_DEVICE_PATH VendorDevicePath; + EFI_DEVICE_PATH_PROTOCOL End; +} HII_VENDOR_DEVICE_PATH; + +#pragma pack() + +#endif /* CPU_CONFIG_H_ */ diff --git a/Silicon/Ampere/AmpereAltraPkg/Drivers/CpuConfigDxe/CpuConfigNV= DataStruc.h b/Silicon/Ampere/AmpereAltraPkg/Drivers/CpuConfigDxe/CpuConfigN= VDataStruc.h new file mode 100644 index 000000000000..dbcaebded1b7 --- /dev/null +++ b/Silicon/Ampere/AmpereAltraPkg/Drivers/CpuConfigDxe/CpuConfigNVDataStr= uc.h @@ -0,0 +1,19 @@ +/** @file + + Copyright (c) 2020 - 2021, Ampere Computing LLC. All rights reserved. + + SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#ifndef CPU_CONFIG_NV_DATA_STRUC_H_ +#define CPU_CONFIG_NV_DATA_STRUC_H_ + +#pragma pack(1) +typedef struct { + UINT32 CpuSubNumaMode; +} CPU_VARSTORE_DATA; + +#pragma pack() + +#endif /* CPU_CONFIG_NV_DATA_STRUC_H_ */ diff --git a/Silicon/Ampere/AmpereAltraPkg/Include/Guid/CpuConfigHii.h b/Si= licon/Ampere/AmpereAltraPkg/Include/Guid/CpuConfigHii.h new file mode 100644 index 000000000000..71c8492f76a1 --- /dev/null +++ b/Silicon/Ampere/AmpereAltraPkg/Include/Guid/CpuConfigHii.h @@ -0,0 +1,19 @@ +/** @file + + Copyright (c) 2020 - 2021, Ampere Computing LLC. All rights reserved. + + SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#ifndef CPU_CONFIG_HII_H_ +#define CPU_CONFIG_HII_H_ + +#define CPU_CONFIGURATION_FORMSET_GUID \ + { \ + 0x43FAA144, 0xA2DF, 0x4050, { 0xA7, 0xFD, 0xEE, 0x17, 0xC9, 0xB8, 0x88= , 0x8E } \ + } + +extern EFI_GUID gCpuConfigFormSetGuid; + +#endif /* CPU_CONFIG_HII_H_ */ diff --git a/Silicon/Ampere/AmpereAltraPkg/Drivers/CpuConfigDxe/CpuConfigVf= r.vfr b/Silicon/Ampere/AmpereAltraPkg/Drivers/CpuConfigDxe/CpuConfigVfr.vfr new file mode 100644 index 000000000000..8e68b1e9dcb7 --- /dev/null +++ b/Silicon/Ampere/AmpereAltraPkg/Drivers/CpuConfigDxe/CpuConfigVfr.vfr @@ -0,0 +1,43 @@ +/** @file + + Copyright (c) 2020 - 2021, Ampere Computing LLC. All rights reserved. + + SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#include +#include +#include +#include "CpuConfigNVDataStruc.h" + +#define SUBNUMA_MODE_FORM_ID 1 + +formset + guid =3D CPU_CONFIGURATION_FORMSET_GUID, + title =3D STRING_TOKEN(STR_CPU_FORM), + help =3D STRING_TOKEN(STR_CPU_FORM_HELP), + classguid =3D gPlatformManagerFormsetGuid, + + varstore CPU_VARSTORE_DATA, + name =3D CpuConfigNVData, + guid =3D CPU_CONFIGURATION_FORMSET_GUID; + + form + formid =3D SUBNUMA_MODE_FORM_ID, + title =3D STRING_TOKEN(STR_CPU_FORM); + subtitle text =3D STRING_TOKEN(STR_CPU_FORM_HELP); + + oneof + varid =3D CpuConfigNVData.CpuSubNumaMode, + prompt =3D STRING_TOKEN(STR_CPU_SUBNUMA_MODE_PROMPT), + help =3D STRING_TOKEN(STR_CPU_SUBNUMA_MODE_HELP), + flags =3D RESET_REQUIRED, + option text =3D STRING_TOKEN(STR_CPU_SUBNUMA_MODE_MONOLITHIC), value= =3D 0x0, flags =3D DEFAULT; + option text =3D STRING_TOKEN(STR_CPU_SUBNUMA_MODE_HEMISPHERE), value= =3D 0x1, flags =3D 0; + option text =3D STRING_TOKEN(STR_CPU_SUBNUMA_MODE_QUADRANT), value = =3D 0x2, flags =3D 0; + endoneof; + + endform; + +endformset; diff --git a/Silicon/Ampere/AmpereAltraPkg/Drivers/CpuConfigDxe/CpuConfigDx= e.c b/Silicon/Ampere/AmpereAltraPkg/Drivers/CpuConfigDxe/CpuConfigDxe.c new file mode 100644 index 000000000000..c5ba48edadbb --- /dev/null +++ b/Silicon/Ampere/AmpereAltraPkg/Drivers/CpuConfigDxe/CpuConfigDxe.c @@ -0,0 +1,530 @@ +/** @file + + Copyright (c) 2020 - 2021, Ampere Computing LLC. All rights reserved. + + SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "CpuConfigDxe.h" + +// +// Default settings definitions +// +#define NV_SI_SUBNUMA_MODE_DEFAULT 0x00 /* Monolithic mode */ +#define WA_ERRATUM_1542419_DEFAULT 0x00 /* Disable I-Cache coherency */ +#define NEAR_ATOMIC_DISABLE_DEFAULT 0x00 /* Enable Near Atomic */ +#define CPU_SLC_REPLACE_POLICY 0x00 /* eLRU */ + +CHAR16 CpuVarstoreDataName[] =3D L"CpuConfigNVData"; + +EFI_HANDLE mDriverHandle =3D NULL; +CPU_CONFIG_PRIVATE_DATA *mPrivateData =3D NULL; + +HII_VENDOR_DEVICE_PATH mCpuConfigHiiVendorDevicePath =3D { + { + { + HARDWARE_DEVICE_PATH, + HW_VENDOR_DP, + { + (UINT8)(sizeof (VENDOR_DEVICE_PATH)), + (UINT8)((sizeof (VENDOR_DEVICE_PATH)) >> 8) + } + }, + CPU_CONFIGURATION_FORMSET_GUID + }, + { + END_DEVICE_PATH_TYPE, + END_ENTIRE_DEVICE_PATH_SUBTYPE, + { + (UINT8)(END_DEVICE_PATH_LENGTH), + (UINT8)((END_DEVICE_PATH_LENGTH) >> 8) + } + } +}; + +STATIC +EFI_STATUS +CpuNvParamGet ( + OUT CPU_VARSTORE_DATA *Configuration + ) +{ + EFI_STATUS Status; + UINT32 Value; + + ASSERT (Configuration !=3D NULL); + + Status =3D NVParamGet ( + NV_SI_SUBNUMA_MODE, + NV_PERM_ATF | NV_PERM_BIOS | NV_PERM_MANU | NV_PERM_BMC, + &Value + ); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a %d Fail to get NVParam, %r\n", __FUNCTION__, = __LINE__, Status)); + Configuration->CpuSubNumaMode =3D SUBNUMA_MODE_MONOLITHIC; + } else { + Configuration->CpuSubNumaMode =3D Value; + } + + return EFI_SUCCESS; +} + +STATIC +EFI_STATUS +CpuNvParamSet ( + IN CPU_VARSTORE_DATA *Configuration + ) +{ + EFI_STATUS Status; + UINT32 Value; + + ASSERT (Configuration !=3D NULL); + + Status =3D NVParamGet ( + NV_SI_SUBNUMA_MODE, + NV_PERM_ATF | NV_PERM_BIOS | NV_PERM_MANU | NV_PERM_BMC, + &Value + ); + ASSERT_EFI_ERROR (Status); + + if (EFI_ERROR (Status) || Value !=3D Configuration->CpuSubNumaMode) { + Status =3D NVParamSet ( + NV_SI_SUBNUMA_MODE, + NV_PERM_ATF | NV_PERM_BIOS | NV_PERM_MANU | NV_PERM_BMC, + NV_PERM_BIOS | NV_PERM_MANU, + Configuration->CpuSubNumaMode + ); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a %d Fail to set NVParam, %r\n", __FUNCTION__= , __LINE__, Status)); + ASSERT_EFI_ERROR (Status); + return Status; + } + } + + return EFI_SUCCESS; +} + +STATIC +EFI_STATUS +SetupDefaultSettings ( + VOID + ) +{ + EFI_STATUS Status; + UINT32 Value; + + // + // Subnuma Mode + // + Status =3D NVParamGet ( + NV_SI_SUBNUMA_MODE, + NV_PERM_ATF | NV_PERM_BIOS | NV_PERM_MANU | NV_PERM_BMC, + &Value + ); + if (EFI_ERROR (Status)) { + Status =3D NVParamSet ( + NV_SI_SUBNUMA_MODE, + NV_PERM_ATF | NV_PERM_BIOS | NV_PERM_MANU | NV_PERM_BMC, + NV_PERM_BIOS | NV_PERM_MANU, + NV_SI_SUBNUMA_MODE_DEFAULT + ); + if (EFI_ERROR (Status)) { + return Status; + } + } + + // + // ARM ERRATA 1542419 workaround + // + Status =3D NVParamSet ( + NV_SI_ERRATUM_1542419_WA, + NV_PERM_ATF | NV_PERM_BIOS | NV_PERM_MANU | NV_PERM_BMC, + NV_PERM_BIOS | NV_PERM_MANU, + WA_ERRATUM_1542419_DEFAULT + ); + if (EFI_ERROR (Status)) { + return Status; + } + + // + // Near atomic + // + Status =3D NVParamSet ( + NV_SI_NEAR_ATOMIC_DISABLE, + NV_PERM_ATF | NV_PERM_BIOS | NV_PERM_MANU | NV_PERM_BMC, + NV_PERM_BIOS | NV_PERM_MANU, + NEAR_ATOMIC_DISABLE_DEFAULT + ); + if (EFI_ERROR (Status)) { + return Status; + } + + // + // SLC Replacement Policy + // + Status =3D NVParamSet ( + NV_SI_HNF_AUX_CTL_32_63, + NV_PERM_ATF | NV_PERM_BIOS | NV_PERM_MANU | NV_PERM_BMC, + NV_PERM_BIOS | NV_PERM_MANU, + CPU_SLC_REPLACE_POLICY + ); + if (EFI_ERROR (Status)) { + return Status; + } + + return EFI_SUCCESS; +} + +/** + This function allows a caller to extract the current configuration for o= ne + or more named elements from the target driver. + + @param This Points to the EFI_HII_CONFIG_ACCESS_PROTO= COL. + @param Request A null-terminated Unicode string in + format. + @param Progress On return, points to a character in the R= equest + string. Points to the string's null termi= nator if + request was successful. Points to the mos= t recent + '&' before the first failing name/value p= air (or + the beginning of the string if the failur= e is in + the first name/value pair) if the request= was not + successful. + @param Results A null-terminated Unicode string in + format which has all valu= es filled + in for the names in the Request string. S= tring to + be allocated by the called function. + + @retval EFI_SUCCESS The Results is filled with the requested = values. + @retval EFI_OUT_OF_RESOURCES Not enough memory to store the results. + @retval EFI_INVALID_PARAMETER Request is illegal syntax, or unknown nam= e. + @retval EFI_NOT_FOUND Routing data doesn't match any storage in= this + driver. + +**/ +EFI_STATUS +EFIAPI +CpuConfigExtractConfig ( + IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This, + IN CONST EFI_STRING Request, + OUT EFI_STRING *Progress, + OUT EFI_STRING *Results + ) +{ + EFI_STATUS Status; + UINTN BufferSize; + CPU_CONFIG_PRIVATE_DATA *PrivateData; + EFI_HII_CONFIG_ROUTING_PROTOCOL *HiiConfigRouting; + EFI_STRING ConfigRequest; + EFI_STRING ConfigRequestHdr; + UINTN Size; + BOOLEAN AllocatedRequest; + + if (Progress =3D=3D NULL || Results =3D=3D NULL) { + return EFI_INVALID_PARAMETER; + } + // + // Initialize the local variables. + // + ConfigRequestHdr =3D NULL; + ConfigRequest =3D NULL; + Size =3D 0; + *Progress =3D Request; + AllocatedRequest =3D FALSE; + + if ((Request !=3D NULL) && !HiiIsConfigHdrMatch (Request, &gCpuConfigFor= mSetGuid, CpuVarstoreDataName)) { + return EFI_NOT_FOUND; + } + + PrivateData =3D CPU_CONFIG_PRIVATE_FROM_THIS (This); + HiiConfigRouting =3D PrivateData->HiiConfigRouting; + + // + // Get current setting from NVParam. + // + Status =3D CpuNvParamGet (&PrivateData->Configuration); + if (EFI_ERROR (Status)) { + return Status; + } + // + // Convert buffer data to by helper function BlockToConfig(= ) + // + BufferSize =3D sizeof (CPU_VARSTORE_DATA); + ConfigRequest =3D Request; + if ((Request =3D=3D NULL) || (StrStr (Request, L"OFFSET") =3D=3D NULL)) = { + // + // Request has no request element, construct full request string. + // Allocate and fill a buffer large enough to hold the tem= plate + // followed by "&OFFSET=3D0&WIDTH=3DWWWWWWWWWWWWWWWW" followed by a Nu= ll-terminator + // + ConfigRequestHdr =3D HiiConstructConfigHdr (&gCpuConfigFormSetGuid, Cp= uVarstoreDataName, PrivateData->DriverHandle); + Size =3D (StrLen (ConfigRequestHdr) + 32 + 1) * sizeof (CHAR16); + ConfigRequest =3D AllocateZeroPool (Size); + ASSERT (ConfigRequest !=3D NULL); + if (ConfigRequest =3D=3D NULL) { + return EFI_OUT_OF_RESOURCES; + } + AllocatedRequest =3D TRUE; + UnicodeSPrint (ConfigRequest, Size, L"%s&OFFSET=3D0&WIDTH=3D%016LX", C= onfigRequestHdr, (UINT64)BufferSize); + FreePool (ConfigRequestHdr); + } + + // + // Convert buffer data to by helper function BlockToConfig(= ) + // + Status =3D HiiConfigRouting->BlockToConfig ( + HiiConfigRouting, + ConfigRequest, + (UINT8 *)&PrivateData->Configuration, + BufferSize, + Results, + Progress + ); + + // + // Free the allocated config request string. + // + if (AllocatedRequest) { + FreePool (ConfigRequest); + ConfigRequest =3D NULL; + } + + // + // Set Progress string to the original request string. + // + if (Request =3D=3D NULL) { + *Progress =3D NULL; + } else if (StrStr (Request, L"OFFSET") =3D=3D NULL) { + *Progress =3D Request + StrLen (Request); + } + + return Status; +} + +/** + This function processes the results of changes in configuration. + + @param This Points to the EFI_HII_CONFIG_ACCESS_PROTO= COL. + @param Configuration A null-terminated Unicode string in + format. + @param Progress A pointer to a string filled in with the = offset of + the most recent '&' before the first fail= ing + name/value pair (or the beginning of the = string if + the failure is in the first name/value pa= ir) or + the terminating NULL if all was successfu= l. + + @retval EFI_SUCCESS The Results is processed successfully. + @retval EFI_INVALID_PARAMETER Configuration is NULL. + @retval EFI_NOT_FOUND Routing data doesn't match any storage in= this + driver. + +**/ +EFI_STATUS +EFIAPI +CpuConfigRouteConfig ( + IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This, + IN CONST EFI_STRING Configuration, + OUT EFI_STRING *Progress + ) +{ + EFI_STATUS Status; + UINTN BufferSize; + CPU_CONFIG_PRIVATE_DATA *PrivateData; + EFI_HII_CONFIG_ROUTING_PROTOCOL *HiiConfigRouting; + + if (Configuration =3D=3D NULL || Progress =3D=3D NULL) { + return EFI_INVALID_PARAMETER; + } + + PrivateData =3D CPU_CONFIG_PRIVATE_FROM_THIS (This); + HiiConfigRouting =3D PrivateData->HiiConfigRouting; + *Progress =3D Configuration; + + // + // Check routing data in . + // Note: if only one Storage is used, then this checking could be skippe= d. + // + if (!HiiIsConfigHdrMatch (Configuration, &gCpuConfigFormSetGuid, CpuVars= toreDataName)) { + return EFI_NOT_FOUND; + } + + // + // Get configuration data from NVParam + // + Status =3D CpuNvParamGet (&PrivateData->Configuration); + if (EFI_ERROR (Status)) { + return Status; + } + + // + // Convert to buffer data by helper function ConfigToBlock(= ) + // + BufferSize =3D sizeof (CPU_VARSTORE_DATA); + Status =3D HiiConfigRouting->ConfigToBlock ( + HiiConfigRouting, + Configuration, + (UINT8 *)&PrivateData->Configuration, + &BufferSize, + Progress + ); + if (EFI_ERROR (Status)) { + return Status; + } + + // + // Store configuration data back to NVParam + // + Status =3D CpuNvParamSet (&PrivateData->Configuration); + if (EFI_ERROR (Status)) { + return Status; + } + + return Status; +} + +/** + This function processes the results of changes in configuration. + + @param This Points to the EFI_HII_CONFIG_ACCESS_PROTO= COL. + @param Action Specifies the type of action taken by the= browser. + @param QuestionId A unique value which is sent to the origi= nal + exporting driver so that it can identify = the type + of data to expect. + @param Type The type of value for the question. + @param Value A pointer to the data being sent to the o= riginal + exporting driver. + @param ActionRequest On return, points to the action requested= by the + callback function. + + @retval EFI_SUCCESS The callback successfully handled the act= ion. + @retval EFI_INVALID_PARAMETER The setup browser call this function with= invalid parameters. + +**/ +EFI_STATUS +EFIAPI +CpuConfigCallback ( + IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This, + IN EFI_BROWSER_ACTION Action, + IN EFI_QUESTION_ID QuestionId, + IN UINT8 Type, + IN EFI_IFR_TYPE_VALUE *Value, + OUT EFI_BROWSER_ACTION_REQUEST *ActionRequest + ) +{ + if (Action !=3D EFI_BROWSER_ACTION_CHANGING) { + // + // Do nothing for other UEFI Action. Only do call back when data is ch= anged. + // + return EFI_UNSUPPORTED; + } + if (((Value =3D=3D NULL) && (Action !=3D EFI_BROWSER_ACTION_FORM_OPEN) &= & (Action !=3D EFI_BROWSER_ACTION_FORM_CLOSE))|| + (ActionRequest =3D=3D NULL)) + { + return EFI_INVALID_PARAMETER; + } + + return EFI_SUCCESS; +} + +EFI_STATUS +CpuConfigDxeEntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + EFI_HII_HANDLE HiiHandle; + EFI_HII_CONFIG_ROUTING_PROTOCOL *HiiConfigRouting; + + // + // Initialize driver private data + // + mPrivateData =3D AllocateZeroPool (sizeof (CPU_CONFIG_PRIVATE_DATA)); + if (mPrivateData =3D=3D NULL) { + return EFI_OUT_OF_RESOURCES; + } + + mPrivateData->Signature =3D CPU_CONFIG_PRIVATE_SIGNATURE; + + mPrivateData->ConfigAccess.ExtractConfig =3D CpuConfigExtractConfig; + mPrivateData->ConfigAccess.RouteConfig =3D CpuConfigRouteConfig; + mPrivateData->ConfigAccess.Callback =3D CpuConfigCallback; + + // + // Locate ConfigRouting protocol + // + Status =3D gBS->LocateProtocol (&gEfiHiiConfigRoutingProtocolGuid, NULL,= (VOID **)&HiiConfigRouting); + if (EFI_ERROR (Status)) { + return Status; + } + mPrivateData->HiiConfigRouting =3D HiiConfigRouting; + + Status =3D gBS->InstallMultipleProtocolInterfaces ( + &mDriverHandle, + &gEfiDevicePathProtocolGuid, + &mCpuConfigHiiVendorDevicePath, + &gEfiHiiConfigAccessProtocolGuid, + &mPrivateData->ConfigAccess, + NULL + ); + ASSERT_EFI_ERROR (Status); + + mPrivateData->DriverHandle =3D mDriverHandle; + + // + // Publish our HII data + // + HiiHandle =3D HiiAddPackages ( + &gCpuConfigFormSetGuid, + mDriverHandle, + CpuConfigDxeStrings, + CpuConfigVfrBin, + NULL + ); + if (HiiHandle =3D=3D NULL) { + gBS->UninstallMultipleProtocolInterfaces ( + mDriverHandle, + &gEfiDevicePathProtocolGuid, + &mCpuConfigHiiVendorDevicePath, + &gEfiHiiConfigAccessProtocolGuid, + &mPrivateData->ConfigAccess, + NULL + ); + return EFI_OUT_OF_RESOURCES; + } + + mPrivateData->HiiHandle =3D HiiHandle; + + // + // With the fresh system, the NVParam value is invalid (0xFFFFFFFF). + // It causes reading from the NVParam is failed. + // So, the NVParam should be setting with default values if any params i= s invalid. + // + Status =3D SetupDefaultSettings (); + if (EFI_ERROR (Status)) { + return Status; + } + + return EFI_SUCCESS; +} diff --git a/Silicon/Ampere/AmpereAltraPkg/Drivers/CpuConfigDxe/CpuConfigSt= rings.uni b/Silicon/Ampere/AmpereAltraPkg/Drivers/CpuConfigDxe/CpuConfigStr= ings.uni new file mode 100644 index 000000000000..70c01f65e4b6 --- /dev/null +++ b/Silicon/Ampere/AmpereAltraPkg/Drivers/CpuConfigDxe/CpuConfigStrings.u= ni @@ -0,0 +1,17 @@ +// +// Copyright (c) 2020 - 2021, Ampere Computing LLC. All rights reserved. +// +// SPDX-License-Identifier: BSD-2-Clause-Patent +// + +#langdef en-US "English" + +#string STR_CPU_FORM #language en-US "CPU C= onfiguration" +#string STR_CPU_FORM_HELP #language en-US "CPU C= onfiguration" +#string STR_CPU_FORM_SEPERATE_LINE #language en-US "" + +#string STR_CPU_SUBNUMA_MODE_PROMPT #language en-US "ANC m= ode" +#string STR_CPU_SUBNUMA_MODE_HELP #language en-US "Provi= des 3 modes: Monolithic, Hemisphere, Quadrant. System with Monolithic mode = has single NUMA partition per socket. System with Hemisphere has 2 NUMA par= titions per socket. System with Quandrant has 4 NUMA partitions per socket" +#string STR_CPU_SUBNUMA_MODE_MONOLITHIC #language en-US "Monol= ithic" +#string STR_CPU_SUBNUMA_MODE_HEMISPHERE #language en-US "Hemis= phere" +#string STR_CPU_SUBNUMA_MODE_QUADRANT #language en-US "Quadr= ant" --=20 2.17.1