From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from NAM02-DM3-obe.outbound.protection.outlook.com (NAM02-DM3-obe.outbound.protection.outlook.com [40.107.95.105]) by mx.groups.io with SMTP id smtpd.web09.9900.1631721653417356000 for ; Wed, 15 Sep 2021 09:00:53 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="body hash did not verify" header.i=@os.amperecomputing.com header.s=selector2 header.b=Ac+m6FvW; spf=pass (domain: os.amperecomputing.com, ip: 40.107.95.105, mailfrom: nhi@os.amperecomputing.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=KUIzKgzoka7vRS1OAv4Bwjnzgx61nSk3d4QRoPF/mxKjlnT1JOMFrKFx0maRbwsyFnY7UdxXvHu0KeY79NwDgTo6P/KRhZICmYFmkEabL2rGYG7EZ6G/9l8UbBO1lEyk1vY7sgWfDCTpA8ExqhmxsH3tBTwoziAts8uCMyv+7iQb/363UVpFrr325hhVTqD/bOS7+A5PeMqO9SsfNhUKHf/JhZJrrWbTx6AQYvv0KT5QtmCWMQnwR0wx9B7PHd6o2lbmPSvy7qRb3o90EeM1udvwUGPFwoWbqZ9YtZv7m4UAtTIuwgHeOl1VJTVefKPC8ln28Yxnr6t6scOM51uvrg== 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; bh=aLlVog0F1V8f8ABE6ubc/C30C1HiZQ58htf83zTeA20=; b=Xg/wyCC7wgrsxrKdtK1C4G46j/WeeFEO6Gtt3etS4/dEoGp15/7S+RbOFvfbexCZk7cKnIWVlq/lfoXhcPxuTVxw8mb/vVLMFuY5ChEObfY9rUms7UIuHSMUPZbInKVC9/52DGuaG+klTfmNVjYUHBMp9NrZkb6XXeh7axMYc4ndYBEIqGJBxcaso9lQ2KCTybS2AyGgPNYWOkhph9gLpd1ogSqSi12H0ANgU5nsQIOvM7uUT5hyzOs4IvnGrO7380FB++VkB45qZ/4u+SRDNVfT6+2IYrNFUstA/i25X3aB+IIGcK5v+NP4SE8uADELPbRgiONo2q+ZCTPGRdQY0w== 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=aLlVog0F1V8f8ABE6ubc/C30C1HiZQ58htf83zTeA20=; b=Ac+m6FvWn5/NytvqwqjzZPGlObPoISPTLlANdKBLlxyk+Y13dDh6CuwET9e1aM45dCGOsZjL+OLXMC+JF8BuQ5cvnyI1MQ8PejHLq/Rr3q5KJvauw8/oQ7OdA7RDCOoPDA19DgcrMu17x0dL8beimjrs4cNtdp/uZ87/vupafgg= Authentication-Results: edk2.groups.io; dkim=none (message not signed) header.d=none;edk2.groups.io; dmarc=none action=none header.from=os.amperecomputing.com; Received: from DM6PR01MB5849.prod.exchangelabs.com (2603:10b6:5:205::20) by DM5PR01MB2761.prod.exchangelabs.com (2603:10b6:3:fd::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4523.14; Wed, 15 Sep 2021 16:00:51 +0000 Received: from DM6PR01MB5849.prod.exchangelabs.com ([fe80::8eb:704f:2ba7:9bc3]) by DM6PR01MB5849.prod.exchangelabs.com ([fe80::8eb:704f:2ba7:9bc3%4]) with mapi id 15.20.4523.014; Wed, 15 Sep 2021 16:00:51 +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: [PATCH v3 24/28] AmpereAltraPkg: Add configuration screen for CPU Date: Wed, 15 Sep 2021 22:55:23 +0700 Message-ID: <20210915155527.8176-25-nhi@os.amperecomputing.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210915155527.8176-1-nhi@os.amperecomputing.com> References: <20210915155527.8176-1-nhi@os.amperecomputing.com> X-ClientProxiedBy: HK2PR0302CA0012.apcprd03.prod.outlook.com (2603:1096:202::22) To DM6PR01MB5849.prod.exchangelabs.com (2603:10b6:5:205::20) Return-Path: nhi@os.amperecomputing.com MIME-Version: 1.0 Received: from sw004.amperecomputing.com (118.69.219.201) by HK2PR0302CA0012.apcprd03.prod.outlook.com (2603:1096:202::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4544.5 via Frontend Transport; Wed, 15 Sep 2021 16:00:37 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 5701aded-8871-4026-1273-08d97861f71a X-MS-TrafficTypeDiagnostic: DM5PR01MB2761: X-MS-Exchange-Transport-Forked: True 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: NWO1KkJ55nrrrS3GDhsihUUMyCLI8Oh4g2KX+aBb9CPrGHVdRI9K429wuV2OBuMrcVhGC2wxMVg3/LTDL4hV1BbGVUyyaAlQ2gb30SxL6+YhH58Ubj9YDwdPBDW2jezjBaSPHcrwfwyE/26pkCVPuH4sawmnABPekgs6CG9WH8hCR0bs2szw+f5jEUZbJ1gYnqPz9NcuOYsgLJM3/ZlieDaf4+hrrC/vP2vxSKUGkUZC+90mbRiWflR4vAaUkTZMNRMZws4bGsxd72LhVDcNkva9Se61JDSc23HSS+oQSFlg8zZoR0w06Ms80N2GmvL22hBSXYnCqy08VuOCztLg1WpNfYaiPfGp72oNY7uLUYNXHJTq6gRJO7jv/eqVdF6s5gSsAgeA+jXzhEAfTmo0FsvX0+w7+t9bt1jLMqWHvb6u2Npbxock0l+jsg2pWjSRExR+TrkQdOOnVh8wzohQNrrs6c8V2AfjOysFtvcHGI6IoRUkC1LkkDrHmGfyV/gbcvsBxmulsnsp3h3Fkuw73lzuCphQkUeBPsgF1I94FEM9IaJ2dY9v8ee3yOpxWmBRvOCOasP3vAGfTSGtXJdZ4Xyc7bYV1e9BCbgX6yg9HNOrIRuWDhqTeRdrvlmBlGkjV/6sA8wkr1nB0tvOzRCL4euLV8hmQllr7NanEkIRsm13CnYx6XcNalbcpdBkBxx3rqXZGoF521c/OmRH88TGKvVZ4HFswnZRg7hoaG/RXpLCiVc9uC/uuZzP40o33TUc X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM6PR01MB5849.prod.exchangelabs.com;PTR:;CAT:NONE;SFS:(4636009)(366004)(66946007)(956004)(66476007)(66556008)(6666004)(4326008)(8936002)(30864003)(8676002)(316002)(38100700002)(38350700002)(5660300002)(6512007)(508600001)(186003)(52116002)(86362001)(6506007)(6916009)(1076003)(54906003)(2906002)(2616005)(83380400001)(66574015)(26005)(6486002)(290074003)(44824005);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?4NJ2LGTmOFx4dx/PS7+RG2YrYpmZWfbpaNsDy+Soev1kD/WPfNtV7d6xagWU?= =?us-ascii?Q?FYN1dgytDDCfccI0uGejNdYGeRF3p7B8gJHiem2jEHi+91aMcMJmyOCEPyfZ?= =?us-ascii?Q?jTpE+mIKw3EjqZusgDAHyDnCxmMFv2ZmP32wukaU7FzxxcS1R15Tju3LkEYC?= =?us-ascii?Q?3VBABZ03koMGbocEBfjvJtmfcB/Uba/FjNkdaqJVfC8bs1B+U1Th1bgYxS/z?= =?us-ascii?Q?Etl64lvRcDRiUUkNf7TBhyouYWjEiarOJ3xJHAQIaTcYu+bjzcak0N2wbpVv?= =?us-ascii?Q?cgI9laXVmRt0QuCLWWoKP4c1wAstPvr/5d9YThsYMW55aBcNjwORqV301Lr/?= =?us-ascii?Q?1mg5X31OIIV/Pv5uaoENXgi1gActBJqLk4OXx9sqNaj2yqpJBfKfgQQLNZgV?= =?us-ascii?Q?uYWF9CorQlgF+2VTZzkRZf+EeDcJD1aiYqko/jo21/RfEKQRcA3zc9nXnSGZ?= =?us-ascii?Q?AyDGrpkRECBq32B8jIVDtk7Vxe7MuWZoes7inyHVI6PW/GsdtEr3B2ALNGbf?= =?us-ascii?Q?dUmYd5P0hc1KwnKw1xwgjzFXYjdZ5Ph4lbFpqF6frQhlg9OBTLWn74JbtQGJ?= =?us-ascii?Q?+Yhf9VPVvnk6Jfp2LRrQTGgfLNB1WVCX5P8U/1kCLUwWv5Anp8jpFyhpOu2J?= =?us-ascii?Q?Ts9YrtcsX1RHoGyvxH/ugMFWwsuyqRCG+WxNaVFsc4bJc5M7NJRTTUPcD/5u?= =?us-ascii?Q?yRYLi0jIe0ba+pLwyiZVT+k3k69lSIIibeuPpN51+ae93oYmufYVoHAtBnOD?= =?us-ascii?Q?z6ZinhEBy68lWqbqkNZ15+GS5d/VuSqqF9bH6H1XS591gUxg68NQi3aGJAXY?= =?us-ascii?Q?9ADsjVBDJX0P2MWAPOO6Qn4ciMOfMWpis4M0XqMqhDTBYTkAgPy5F+LWMhll?= =?us-ascii?Q?tIWxiBE8wzz/TT9Jw9LDZyj2A0NL0Ieps+UKxWCEjc/SuP0qbhRRbInFyE5N?= =?us-ascii?Q?IG9AvAzu2B7xdyBUsMuZCGZFBzfbp0oGwZaZOmCv0lXsEkeorF77qAgRRcIC?= =?us-ascii?Q?2BpsuOBWzft63IGgOaGd1T10ubOLf3Ao7ReBIeqPU0CeRBTpxlWCgT7TGQ9T?= =?us-ascii?Q?x20c0nJ0nANyNRQiH728KO9zwlfPhjh1SiVZQnnTUt3wi4MRW6e0tgzl+WaX?= =?us-ascii?Q?+6ia+hJH9Hv4FESWuJQG7InVn7PUpWNz8EtAikCWGTn++52hvt+UpPHLeZiZ?= =?us-ascii?Q?AusN4u0kAF8WjQdcY+Dre5n7q1XsTGg9Tj+0uxbL9rdWEpclW+k4zPREMRBH?= =?us-ascii?Q?0QGh+g3hqThhdoUhcmkScrA7qqAZwSN0NxVahRkse48Pvb392r49duAoIEUk?= =?us-ascii?Q?mK/6bLuXUyR+3lZQ6XurF55g?= X-OriginatorOrg: os.amperecomputing.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5701aded-8871-4026-1273-08d97861f71a X-MS-Exchange-CrossTenant-AuthSource: DM6PR01MB5849.prod.exchangelabs.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Sep 2021 16:00:40.5775 (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: n3FeF6t0YbspRb4qvt18JNHu4c/YXGsYLSbzHZezhklg2/71Oq840eNF8oDcLvHcpaGo+48JatQA/MLpvd0SQ+b1ekQdU6vOt/+vNscd2NM= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR01MB2761 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain From: Vu Nguyen 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: Vu Nguyen --- 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 93da9b38def5..6ea247c75e87 100644 --- a/Silicon/Ampere/AmpereAltraPkg/AmpereAltraPkg.dec +++ b/Silicon/Ampere/AmpereAltraPkg/AmpereAltraPkg.dec @@ -50,6 +50,9 @@ [LibraryClasses] TrngLib|Silicon/Ampere/AmpereAltraPkg/Include/Library/TrngLib.h =20 [Guids] + # GUID for the CPU HII configuration form + gCpuConfigFormSetGuid =3D { 0x43FAA144, 0xA2DF, 0x4050, { 0xA7, 0= xFD, 0xEE, 0x17, 0xC9, 0xB8, 0x88, 0x8E } } + ## NVParam MM GUID gNVParamMmGuid =3D { 0xE4AC5024, 0x29BE, 0x4ADC, { 0x93, 0= x36, 0x87, 0xB5, 0xA0, 0x76, 0x23, 0x2D } } =20 diff --git a/Platform/Ampere/JadePkg/Jade.dsc b/Platform/Ampere/JadePkg/Jad= e.dsc index 5fc83745cdbc..8ca3a729728f 100644 --- a/Platform/Ampere/JadePkg/Jade.dsc +++ b/Platform/Ampere/JadePkg/Jade.dsc @@ -198,3 +198,4 @@ [Components.common] # 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 6fe023025034..d9552886fbcf 100644 --- a/Platform/Ampere/JadePkg/Jade.fdf +++ b/Platform/Ampere/JadePkg/Jade.fdf @@ -356,5 +356,6 @@ [FV.FvMain] # 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 Platform/Ampere/AmperePlatformPkg/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..a5cab9eb8d9a --- /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 write NVParam \n", __FUNCTION__, _= _LINE__)); + 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 access NVParam \n", __FUNCTION__= , __LINE__)); + 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