From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (NAM12-DM6-obe.outbound.protection.outlook.com [40.107.243.46]) by mx.groups.io with SMTP id smtpd.web11.20076.1683885515036413355 for ; Fri, 12 May 2023 02:58:35 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="body hash did not verify" header.i=@amd.com header.s=selector1 header.b=tQCJpnsw; spf=permerror, err=parse error for token &{10 18 %{i}._ip.%{h}._ehlo.%{d}._spf.vali.email}: invalid domain name (domain: amd.com, ip: 40.107.243.46, mailfrom: abner.chang@amd.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=RiZpdPiy7HCr/iZ0/1HxTwu4EGkmUE2pnM/gml9oLgzTEW7gaz2pl2PAg2mwBTZq9h1xON2GsbH8MP+WlTco3z7t5OocWot8lObZ1fp5qV80uRuZ7KILz03pRFxgA5t2jNwqeQC7QsoXfI/ucFcP/viTj6trFzboQBpsHOJCSRtdHZbLZ8ZfalEre7VQmm9vG9wYCtUzYVzipexTDpjDiL3sb/bY/qKlhABl4ywZG9AgmDSzuazQjQf3YV6xe+8mmF4zmtFLj/oqt/LjmHdlKPLhxNfBBqTG+HTDby2gqIXuLPOEjCoL9DeXwOSsnmQDHC0t3QXLCtDheKOktLByVg== 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=73W56E9O2umpJPMa/jSVYEHB41704Q6s141SGRtfTDg=; b=jBEuoxyZ3rNR+ZayecZb2vQQybhp1OPnobrnegT9RWtuCFkeVl+9P9R1zyJ7tGnlZSiQvasvp9rVmDmPbwDwyFsPYIqbMKv9ks5l1m/cWGK4QsfD2xbg83Y9PpObjvM28ecYLOVm47Aj5iQW9G/UJKr40PCOUByjbhItJlwdE+uiK1z2AazoKKDZZfsjBDL7jCG7VKK8hBlacl3gtrf27PBwtpDnoZgLWwwnPhx3LVYejEi+Tn4TeWAC+fo+B93YX8F+CKzmpgUGxDEsTxf7DHKXirTnfODv60Ipj993W+8LXJeU2cWQ7L+FHHOxDbhiHY1XN7ruMFf7T8kxjwgxyQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=edk2.groups.io smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=73W56E9O2umpJPMa/jSVYEHB41704Q6s141SGRtfTDg=; b=tQCJpnsw0JiYR5vUwVJpxQRIrPt66WzbFP3O81k/cunnwVIIyQZtQQTtVRG6eQx5hbm7SqVBxYRKErfgtlAnYKb6xJtuhcPjeO12UT9d2siGKyFJttsLtVLXLRKXQZ+Rww5UK6cEWbxcBCtFbvHiNsGzwnKjupi2ouLOVGO/zdM= Received: from MW4PR03CA0173.namprd03.prod.outlook.com (2603:10b6:303:8d::28) by DM6PR12MB4105.namprd12.prod.outlook.com (2603:10b6:5:217::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6387.23; Fri, 12 May 2023 09:58:33 +0000 Received: from CO1NAM11FT005.eop-nam11.prod.protection.outlook.com (2603:10b6:303:8d:cafe::c1) by MW4PR03CA0173.outlook.office365.com (2603:10b6:303:8d::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6387.24 via Frontend Transport; Fri, 12 May 2023 09:58:32 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by CO1NAM11FT005.mail.protection.outlook.com (10.13.174.147) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6387.24 via Frontend Transport; Fri, 12 May 2023 09:58:32 +0000 Received: from TPE-L1-ABNCHANG.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Fri, 12 May 2023 04:58:30 -0500 From: "Chang, Abner" To: CC: Isaac Oram , Abdul Lateef Attar , Nickle Wang , Tinh Nguyen Subject: [edk2-platforms][PATCH 1/2] ManageabilityPkg/IpmiBmcElog: IPMI BMC Elog Driver Date: Fri, 12 May 2023 17:58:18 +0800 Message-ID: <20230512095819.1898-1-abner.chang@amd.com> X-Mailer: git-send-email 2.37.1.windows.1 MIME-Version: 1.0 Return-Path: Abner.Chang@amd.com X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1NAM11FT005:EE_|DM6PR12MB4105:EE_ X-MS-Office365-Filtering-Correlation-Id: 7c79cd14-7951-427c-77ed-08db52cf71f1 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 2HmZSnqM/JLRMzt2W+rViYe1OWQ5aqVOjbkZuAanxV3Isd6chaQSC0k513R5o7DTqmhhQTG4SQ+O35xq3MGaNmrabbOpoHVELcTd/wzGOg6uG28zYDluYl6h63mFMzzC1JWcsMGdbq81yXWowRFTW8SGKZw8bhO3ctk2l6VQvIGCq7donowqfMQHpr9iCzjJalNrbt4292q74Yg1LhL6MjKzkxDEWraY2nVAPkJdI/FKiOnjKwirNlhX7k2EbccRAAsXRc3fjVwB26ynvs4M6vdIsdAZtHJod3iEeMOyV0lccVyJobwT4S0JPqtzGvOeruFA869EEiGEXpXTouL7vbPZgGlCEXXJN2+pzh+8kry/rkjLPDXLeTklJdhefYLI7kAw0ERA6Od3qyl/RWgjZyllZIFq4qJdHUrZsyxjjz0dsnQsoUO2PftnZ0/bYvB44wK+5qWpYl689oP14CHg2GrOCyA8pf7QfkXy8WIBbWGfHbmK65mdXkYRQ70pn6UkGTv5ZtyHls6rzFXWdg/jS1biSbd9AO4mJn8Df+1bc7eZKMh3yaGxpeyeYj79l2rs6g5o0E8IIIp0JAfNVycVBFdY6B7QoOH+ad9LA6Rj9QLsgcwnUtLvAeN3SMtuDtPMEEGh8XXvJGwHSy+LRQfBm+0lFCP/4PoWXJ1RfFySHzVWeEDkarrI1xPDGNK7qnhULSCz139+lniddBxEL0JMtSS1V4KcvhyKodE/Qos6N1SVOdfmd033SzE2KUbG02IZsuaiW0R4Gbhv+/3zw9iJfg== X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230028)(4636009)(39860400002)(396003)(376002)(346002)(136003)(451199021)(46966006)(40470700004)(36840700001)(478600001)(54906003)(70206006)(2906002)(70586007)(41300700001)(4326008)(6666004)(316002)(6916009)(19627235002)(8936002)(8676002)(5660300002)(186003)(16526019)(26005)(1076003)(2616005)(2876002)(83380400001)(426003)(47076005)(336012)(7696005)(36860700001)(356005)(81166007)(82740400003)(40460700003)(82310400005)(86362001)(36756003)(40480700001)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 May 2023 09:58:32.4852 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 7c79cd14-7951-427c-77ed-08db52cf71f1 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CO1NAM11FT005.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB4105 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain From: Abner Chang IpmiBmcElog is cloned from edk2-platforms/Features/Intel/OutOfBandManagement/ IpmiFeaturePkg/BmcElog in order to consolidate edk2 system manageability support in one place. Uncustify is applied to C files and no functionalities are changed in this patch. We will still keep the one under IpmiFeaturePkg/BmcElog until the reference to this instance are removed from platforms. Signed-off-by: Abner Chang Cc: Isaac Oram Cc: Abdul Lateef Attar Cc: Nickle Wang Cc: Tinh Nguyen --- .../Universal/IpmiBmcElog/BmcElog.inf | 33 +++ .../Universal/IpmiBmcElog/BmcElog.c | 192 ++++++++++++++++++ 2 files changed, 225 insertions(+) create mode 100644 Features/ManageabilityPkg/Universal/IpmiBmcElog/BmcElog= .inf create mode 100644 Features/ManageabilityPkg/Universal/IpmiBmcElog/BmcElog= .c diff --git a/Features/ManageabilityPkg/Universal/IpmiBmcElog/BmcElog.inf b/= Features/ManageabilityPkg/Universal/IpmiBmcElog/BmcElog.inf new file mode 100644 index 0000000000..4c28862fe5 --- /dev/null +++ b/Features/ManageabilityPkg/Universal/IpmiBmcElog/BmcElog.inf @@ -0,0 +1,33 @@ +### @file +# Component description file for BMC ELOG. +# +# Copyright (c) 2018 - 2019, Intel Corporation. All rights reserved.
+# +# SPDX-License-Identifier: BSD-2-Clause-Patent +# +### + +[Defines] + INF_VERSION =3D 0x00010005 + BASE_NAME =3D BmcElog + FILE_GUID =3D A0FF2235-B652-45E3-B3D2-B20F3E714E6F + MODULE_TYPE =3D DXE_DRIVER + PI_SPECIFICATION_VERSION =3D 0x0001000A + VERSION_STRING =3D 1.0 + ENTRY_POINT =3D InitializeBmcElogLayer + +[Sources] + BmcElog.c + +[Packages] + ManageabilityPkg/ManageabilityPkg.dec + MdePkg/MdePkg.dec + +[LibraryClasses] + DebugLib + IpmiCommandLib + UefiBootServicesTableLib + UefiDriverEntryPoint + +[Depex] + TRUE diff --git a/Features/ManageabilityPkg/Universal/IpmiBmcElog/BmcElog.c b/Fe= atures/ManageabilityPkg/Universal/IpmiBmcElog/BmcElog.c new file mode 100644 index 0000000000..ab179e9d49 --- /dev/null +++ b/Features/ManageabilityPkg/Universal/IpmiBmcElog/BmcElog.c @@ -0,0 +1,192 @@ +/** @file + BMC Event Log functions. + +Copyright (c) 2018 - 2019, Intel Corporation. All rights reserved.
+SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#include +#include +#include +#include +#include +#include +#include +#include + +EFI_STATUS +EFIAPI +CheckIfSelIsFull ( + VOID + ); + +/** + This function erases event logs and waits unti complete. + + @param [in] ResvId - Reserved ID + + @retval EFI_STATUS EFI_SUCCESS + EFI_NO_RESPONSE + +**/ +EFI_STATUS +WaitTillErased ( + IN UINT8 *ResvId + ) +{ + INTN Counter; + IPMI_CLEAR_SEL_REQUEST ClearSel; + IPMI_CLEAR_SEL_RESPONSE ClearSelResponse; + + Counter =3D 0x200; + ZeroMem (&ClearSelResponse, sizeof (ClearSelResponse)); + + while (TRUE) { + ZeroMem (&ClearSel, sizeof (ClearSel)); + ClearSel.Reserve[0] =3D ResvId[0]; + ClearSel.Reserve[1] =3D ResvId[1]; + ClearSel.AscC =3D 0x43; + ClearSel.AscL =3D 0x4C; + ClearSel.AscR =3D 0x52; + ClearSel.Erase =3D 0x00; + + IpmiClearSel ( + &ClearSel, + &ClearSelResponse + ); + + if ((ClearSelResponse.ErasureProgress & 0xf) =3D=3D 1) { + return EFI_SUCCESS; + } + + // + // If there is not a response from the BMC controller we need to retu= rn and not hang. + // + --Counter; + if (Counter =3D=3D 0x0) { + return EFI_NO_RESPONSE; + } + } +} + +/** + This function activates BMC event log. + + @param [in] EnableElog Enable/Disable event log + @param [out] ElogStatus return log status + + @retval EFI_STATUS + +**/ +EFI_STATUS +EfiActivateBmcElog ( + IN BOOLEAN *EnableElog, + OUT BOOLEAN *ElogStatus + ) +{ + EFI_STATUS Status; + UINT8 ElogStat; + IPMI_SET_BMC_GLOBAL_ENABLES_REQUEST SetBmcGlobalEnables; + IPMI_GET_BMC_GLOBAL_ENABLES_RESPONSE GetBmcGlobalEnables; + UINT8 CompletionCode; + + Status =3D EFI_SUCCESS; + ElogStat =3D 0; + + Status =3D IpmiGetBmcGlobalEnables (&GetBmcGlobalEnables); + if (EFI_ERROR (Status)) { + return Status; + } + + if (EnableElog =3D=3D NULL) { + *ElogStatus =3D GetBmcGlobalEnables.GetEnables.Bits.SystemEventLogging= ; + } else { + if (Status =3D=3D EFI_SUCCESS) { + if (*EnableElog) { + ElogStat =3D 1; + } + + CopyMem (&SetBmcGlobalEnables, (UINT8 *)&GetBmcGlobalEnables + 1, si= zeof (UINT8)); + SetBmcGlobalEnables.SetEnables.Bits.SystemEventLogging =3D ElogStat; + + Status =3D IpmiSetBmcGlobalEnables (&SetBmcGlobalEnables, &Completio= nCode); + } + } + + return Status; +} + +/** + + @retval EFI_STATUS + +**/ +EFI_STATUS +SetElogRedirInstall ( + VOID + ) +{ + BOOLEAN EnableElog; + BOOLEAN ElogStatus; + + // + // Activate the Event Log (This should depend upon Setup). + // + EfiActivateBmcElog (&EnableElog, &ElogStatus); + return EFI_SUCCESS; +} + +/** + Entry point of BmcElog DXE driver + + @param [in] ImageHandle ImageHandle of the loaded driver + @param [in] SystemTable Pointer to the System Table + + @retval EFI_STATUS + +**/ +EFI_STATUS +EFIAPI +InitializeBmcElogLayer ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + SetElogRedirInstall (); + + CheckIfSelIsFull (); + + return EFI_SUCCESS; +} + +/** + This function verifies the BMC SEL is full and When it is + reports the error to the Error Manager. + + @retval EFI_STATUS + +**/ +EFI_STATUS +EFIAPI +CheckIfSelIsFull ( + VOID + ) +{ + EFI_STATUS Status; + UINT8 SelIsFull; + IPMI_GET_SEL_INFO_RESPONSE SelInfo; + + Status =3D IpmiGetSelInfo (&SelInfo); + if (EFI_ERROR (Status)) { + return EFI_DEVICE_ERROR; + } + + // + // Check the Bit7 of the OperationByte if SEL is OverFlow. + // + SelIsFull =3D (SelInfo.OperationSupport & 0x80); + DEBUG ((DEBUG_INFO, "SelIsFull - 0x%x\n", SelIsFull)); + + return EFI_SUCCESS; +} --=20 2.37.1.windows.1