From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (NAM12-BN8-obe.outbound.protection.outlook.com [40.107.237.114]) by mx.groups.io with SMTP id smtpd.web10.83576.1679600461556007150 for ; Thu, 23 Mar 2023 12:41:02 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="no key for verify" header.i=@amperemail.onmicrosoft.com header.s=selector1-amperemail-onmicrosoft-com header.b=HAILe0sa; spf=pass (domain: os.amperecomputing.com, ip: 40.107.237.114, mailfrom: tinhnguyen@os.amperecomputing.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=FoUlTQ4qcoRFBftVc9wFuvuSdqvi1QDIb2MwM8FSr+vG9dUQ9XCtJGEXdxwi/8nmPoj8xHqKBcX3G550sFfu13NDZHF8ZmI1MGCpWoeKRmodYoPa6O97kjEd7WrGut6wvl7VbDRwu0t61PVe4kSUQx7cEaTJRVPl8Ew0hGASAmATlk2rgcHfRU+I44TK5m8qDoL/08ApF8Zs51/Bn+sSfWnLoXKyLcQs3TkH69LkmI3EbUrqJjSn/3Y0s0lGMqAM6WOGZ1qI6sLw6x8J5AOAf9toLgaeLSyo3vPmwYYjjWCBJzCRtNqfXQSxRBDUbhEgRQxz3Jja1kXkkBP5bwEyIQ== 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=9RZLbeX6MUxx07TmfQnCjdkkrYSMxe9HA14KLu4N3+k=; b=WqO9zE5f5BFmqgyX9qXSBthrJCSo5uh7SuQrgRfRsVrXRiAQZFmzLLmMEbCvJYBNlLerAIfbM4d3Bv0OrLcYSaAXf0w2Wg9zdsTTbezTJaYVAzkpXwecmQn6MV+8vj0TOEj9iGwRJxqS9Gz4SVCxmRHkEpeCnnaNPyVozGkfFRMY+u2aTbh2xB+678t2QoGmJpK37BUWIStHKh5y5yu7QGdR76jZd4ShEFK/NVrItuI++JNmV1koZdmQglavcx2wvhTPZO/c2SPMY1x3PpsQqILpXYwOwEPL6GZ8X/f3c4fPXzhNp8a8nmOdLk7BP4Gf2Hv7SWzQ03/d8K4W8ZnO1g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=os.amperecomputing.com; dmarc=pass action=none header.from=amperemail.onmicrosoft.com; dkim=pass header.d=amperemail.onmicrosoft.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amperemail.onmicrosoft.com; s=selector1-amperemail-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=9RZLbeX6MUxx07TmfQnCjdkkrYSMxe9HA14KLu4N3+k=; b=HAILe0sa4VIIW/UBcE3NIwCSd1wrXJZ6pSADZp1+4uWkr2PLxk+BNNEIPX4/tFQFK40gZTn+sBYJRwy6GpytbQhwp+UlzAaIKjTkOiPClzcupSZ/2IGcolrK0e/sIHAQPo95F7cl2mTwDpC/RzfFFnDzFlU9d+nVyAXR6lLhR6M= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=amperemail.onmicrosoft.com; Received: from MWHPR0101MB2942.prod.exchangelabs.com (2603:10b6:301:2e::14) by SJ0PR01MB6126.prod.exchangelabs.com (2603:10b6:a03:29b::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6222.8; Thu, 23 Mar 2023 19:40:56 +0000 Received: from MWHPR0101MB2942.prod.exchangelabs.com ([fe80::1d06:a51a:ca3d:c2f6]) by MWHPR0101MB2942.prod.exchangelabs.com ([fe80::1d06:a51a:ca3d:c2f6%4]) with mapi id 15.20.6178.024; Thu, 23 Mar 2023 19:40:56 +0000 Message-ID: <4064fa08-dec2-91dd-ba42-42200eec7e55@amperemail.onmicrosoft.com> Date: Fri, 24 Mar 2023 02:40:39 +0700 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.9.0 Subject: Re: [edk2-devel] [PATCH v4 7/9] ManageabilityPkg: Implement Ipmi Protocol/Ppi To: devel@edk2.groups.io, abner.chang@amd.com CC: Liming Gao , Isaac Oram , Nate DeSimone , Abdul Lateef Attar , Nickle Wang , Igor Kulchytskyy References: <20230322024840.1629-1-abner.chang@amd.com> <20230322024840.1629-7-abner.chang@amd.com> From: "Tinh Nguyen" In-Reply-To: <20230322024840.1629-7-abner.chang@amd.com> X-ClientProxiedBy: SI1PR02CA0028.apcprd02.prod.outlook.com (2603:1096:4:1f4::6) To MWHPR0101MB2942.prod.exchangelabs.com (2603:10b6:301:2e::14) Return-Path: tinhnguyen@os.amperecomputing.com MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MWHPR0101MB2942:EE_|SJ0PR01MB6126:EE_ X-MS-Office365-Filtering-Correlation-Id: 89a7058a-5a4d-4abc-ef05-08db2bd68546 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: l5zzDqPZeKzNIy4zsOv+dFvLy5D65Tz7taIXXbvHrYrdyrCN/goOh7QMPFiXXxZ8yJe2dTca6w6eKiO0JqunRj2guD0xwtbjVy1JZCjgZGWEizRoAZ3yPumrrWXjzCjGdUUAZ0sGGANMDxrFLJ85TKlu2uL08j97mdq9OHfu39WnkD58ve1wLXupCqs7bvzPMovqcmneHmpaiDnEAocK+PJLLZtRTIzKvtJKXz/LR/UMlwic9jPzJYA1W2bnjSI+ikRHC91FnE6YigC26anrGEo35n9x6ZWF8yAUmk4jqNZvQSxVKkJc3lywq//zk32fOuBPF9/llN4J00CfM9Zw/MUNeQxRfnbiPOcoh6KDvuVEl5sYrGI3W8Duodpg1b+9m7ShLiP6nJQ6CIokwP6MaxjwxhgfWBVNa5TEtnsIoVMkinb4gPozJ/gHE+wq8o47LxuFTZ9UuI9H4UgjHnFj259rjoxFd0fxvTs/gp9WB0lASsG+dbji9h9SnbnEjLF4lpqdFkrtJwn6/+L69Kttt9TSMJ9fXj6yyq5/bmroF4HG7vGI5cii9ntl11uCTRK4OgO7JzPV4DM+kFHs0kI3ONROR8u3+0YtHslaUln6xHPeogReb3TUcO7W76Vj79EbXGjFbaiRVR5NKcpkWqncpivW2NRj5ftvRPAlpdf469CdjWJ0uObCKiHHZP4bHndfrAZWvwA4TGVnIHlSd00x2QywPuo2uBxu09OK+nihS70= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:MWHPR0101MB2942.prod.exchangelabs.com;PTR:;CAT:NONE;SFS:(13230025)(4636009)(39850400004)(136003)(346002)(366004)(376002)(396003)(451199018)(66556008)(8676002)(66476007)(54906003)(66946007)(4326008)(41300700001)(5660300002)(8936002)(316002)(30864003)(26005)(53546011)(6512007)(6506007)(6666004)(42882007)(186003)(478600001)(83380400001)(2616005)(6486002)(31696002)(38100700002)(83170400001)(2906002)(31686004)(43740500002)(579004)(44824005);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?EI+m9XNwujfc4UPRRbhbPhAFwQ4yn83k3ikb+v8G6TW+lseBO8+6ofdWR2Lz?= =?us-ascii?Q?k52pfqATIaIb4wzSjSt+YdK8MH7crAPaANTxD4zow7/sgCGx883zIjJ4Iyv3?= =?us-ascii?Q?1bneeHMvuduk1aXRT/t+GLLmHE/7x9v1JhwQMJ7YEH5Ff2555S6c3iYgZx9H?= =?us-ascii?Q?Wnbm1MEkmtYl3ErPHlwnZ249XqA+zUFX/4hT4bC1JJC7ICZcfYJ7TYXO++tL?= =?us-ascii?Q?PdIac5jLAiIBDP+QhH3o2z2crxtPnzWx9wOS25NvrFN+jLS3Wzo9QcoJvu0K?= =?us-ascii?Q?vyXBjw8mP5u2vswExPIq5LFv+jg1CrJy8pKGSazjish0L1pey7llpzLNu9HQ?= =?us-ascii?Q?U0/TWRRlJ9m1fsKDzVvWEpJOIOj+3GPIWAdzqeMiC0XdSDoXxhdqltJFXByV?= =?us-ascii?Q?kEkFRC+CNPzIV9SX5yXzpK1qgZwUSICbUeNFkjl7jr21XVwfkdAS3hxHkmk0?= =?us-ascii?Q?WLKaTxKb00KOrHBW5tYmxq354f9238BccY/58CjDoNfJRWgTkRauRhGI6ePw?= =?us-ascii?Q?hpiC1RXgYJNcVfQe7tn1WTRY7wk9WA1+l2+1cPvWUAE/rtYORWl+EVtMfiZi?= =?us-ascii?Q?ZQ5JDS2hhelLQowgY6fEWWFD+iZpilAv7ZcOxs5ov20WwnIU9GYhGxFwIEDC?= =?us-ascii?Q?J0930HuhcQMGwCcjUI1jvpUSwp9VnVFc0cHRNfMvfpyu712JCdsx06KtG4/x?= =?us-ascii?Q?sfMT/c+RpwJdJma7p00l5Mmopx2GK2mk/jXOfCQKLg66fpJHZz487jMxJz02?= =?us-ascii?Q?LNanSJIFO8JJtkQSPif+W3R1Eg4JU88r6H5ItH9Gm2pKsbbCS31k91PA3I1L?= =?us-ascii?Q?itRmCrcCnUQgnx5lDLVxVpKfu/uCEkV+KdQ5IeDzPnI+CdkgSgcDTCGJtZZ9?= =?us-ascii?Q?6hFuHH7RbjpqStneo9PKg4r8L/57lkPjYeufg5Wtp96omxaeNQKmi/lVN1lX?= =?us-ascii?Q?vkZ5d3AYyOu5RyQzIBv1xf/BcqBnI/Z2kCcccZI66XObMq5mGDMA9zK7V4Au?= =?us-ascii?Q?nsW/RnS3G2xDokwUHiW/rw+c0olEZDZ6mYY5e40VUeCrFhwmfg2ajc4mNFL9?= =?us-ascii?Q?y3gCDtf3yWS/Y++x0l3KtJzs2rCel4NfvU/ektVIaDe5V92Incr7aJk6Zq5Y?= =?us-ascii?Q?2LNKHYwQBNYIRHyTVgyBvA06p2HF2C/TCwKMTT/XVjK4YgPhL8+xeOHdgCF3?= =?us-ascii?Q?5LO4XnNaVWjLPNKHadvwEqWcPiBaiYj9d0StLWlAcAVNajCFXKyMTO7kJwdz?= =?us-ascii?Q?aDEV3vbWb6Tv0LoGBGSOZ7p9iaa5hiVafc9XdFzWFIDDXYimGqZ7ioxYQRtW?= =?us-ascii?Q?Um1EBZxsn9yjTlmFUSivhfVbJYgJ7rnjWUWBK715crvFNoncCojkO82pLsDH?= =?us-ascii?Q?s9f/Q0NWvV+XmquPZHE3PntZomMX5VzxPgfuX3bG86cUnTXX6OMFsIrAnzlG?= =?us-ascii?Q?i499JDJgMzTgsgB4uugAgnDpI6goUqLA73y6SvWeaRxF4kemhyBjRagBCbsa?= =?us-ascii?Q?pWWREolL0+vAjoj4YBdxxibeHS67Dpd5lM+AVJtTumPVJGqN7o3S764qSuE1?= =?us-ascii?Q?4aqhjdqc5hx8DCLzZHD0coyAB/dPM3qNj8LIec5FzqPeiImwa4JBQl0ljimX?= =?us-ascii?Q?pC9RryETlT1LAAsIsxCVeXgr/d2JO0U4npHwPY+XJus4?= X-OriginatorOrg: amperemail.onmicrosoft.com X-MS-Exchange-CrossTenant-Network-Message-Id: 89a7058a-5a4d-4abc-ef05-08db2bd68546 X-MS-Exchange-CrossTenant-AuthSource: MWHPR0101MB2942.prod.exchangelabs.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Mar 2023 19:40:56.6133 (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: W8lgLVSoWlCHXMVjtfrftME/OfQL/t5+GhVG53SMutaYLI5ucVfo6eXfJ9XEKDimLW09awLP8W/0gn57du/16wbae7+i3jwJg+jt8usx/wr2C2O6ZXbN8Oy4nXBWej9b X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR01MB6126 Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: quoted-printable Hi Abner, On 3/22/2023 9:48 AM, Chang, Abner via groups.io wrote: > From: Abner Chang > > Add Ipmi Protocol/Ppi/SMM implementations. > The underlying implementation of transport > interface depends on the binded > ManageabilityTransportLib. > > Signed-off-by: Abner Chang > Cc: Liming Gao > Cc: Isaac Oram > Cc: Nate DeSimone > Cc: Abdul Lateef Attar > Cc: Nickle Wang > Cc: Igor Kulchytskyy > --- > .../IpmiProtocol/Dxe/IpmiProtocolDxe.inf | 50 ++++ > .../Universal/IpmiProtocol/Pei/IpmiPpiPei.inf | 53 ++++ > .../IpmiProtocol/Smm/IpmiProtocolSmm.inf | 52 ++++ > .../IpmiProtocol/Common/IpmiProtocolCommon.h | 108 ++++++++ > .../IpmiProtocol/Pei/IpmiPpiInternal.h | 25 ++ > .../IpmiProtocol/Common/IpmiProtocolCommon.c | 252 ++++++++++++++++++ > .../Universal/IpmiProtocol/Dxe/IpmiProtocol.c | 177 ++++++++++++ > .../Universal/IpmiProtocol/Pei/IpmiPpi.c | 159 +++++++++++ > .../Universal/IpmiProtocol/Smm/IpmiProtocol.c | 147 ++++++++++ > 9 files changed, 1023 insertions(+) > create mode 100644 Features/ManageabilityPkg/Universal/IpmiProtocol/Dxe= /IpmiProtocolDxe.inf > create mode 100644 Features/ManageabilityPkg/Universal/IpmiProtocol/Pei= /IpmiPpiPei.inf > create mode 100644 Features/ManageabilityPkg/Universal/IpmiProtocol/Smm= /IpmiProtocolSmm.inf > create mode 100644 Features/ManageabilityPkg/Universal/IpmiProtocol/Com= mon/IpmiProtocolCommon.h > create mode 100644 Features/ManageabilityPkg/Universal/IpmiProtocol/Pei= /IpmiPpiInternal.h > create mode 100644 Features/ManageabilityPkg/Universal/IpmiProtocol/Com= mon/IpmiProtocolCommon.c > create mode 100644 Features/ManageabilityPkg/Universal/IpmiProtocol/Dxe= /IpmiProtocol.c > create mode 100644 Features/ManageabilityPkg/Universal/IpmiProtocol/Pei= /IpmiPpi.c > create mode 100644 Features/ManageabilityPkg/Universal/IpmiProtocol/Smm= /IpmiProtocol.c > > diff --git a/Features/ManageabilityPkg/Universal/IpmiProtocol/Dxe/IpmiPro= tocolDxe.inf b/Features/ManageabilityPkg/Universal/IpmiProtocol/Dxe/IpmiPro= tocolDxe.inf > new file mode 100644 > index 0000000000..ff5ec56c73 > --- /dev/null > +++ b/Features/ManageabilityPkg/Universal/IpmiProtocol/Dxe/IpmiProtocolDx= e.inf > @@ -0,0 +1,50 @@ > +## @file > +# IPMI Protocol DXE Driver. > +# > +# Copyright (C) 2023 Advanced Micro Devices, Inc. All rights reserved. > +# SPDX-License-Identifier: BSD-2-Clause-Patent > +## > + > +[Defines] > + INF_VERSION =3D 0x0001001d > + BASE_NAME =3D IpmiDxe > + FILE_GUID =3D BC41B0C2-9D8A-42B5-A28F-02CE0D4A6C2= 8 > + MODULE_TYPE =3D DXE_DRIVER > + VERSION_STRING =3D 1.0 > + ENTRY_POINT =3D DxeIpmiEntry > + UNLOAD_IMAGE =3D IpmiUnloadImage > + > +# > +# VALID_ARCHITECTURES =3D IA32 X64 ARM AARCH64 > +# > + > +[Sources] > + IpmiProtocol.c > + ../Common/IpmiProtocolCommon.c > + ../Common/IpmiProtocolCommon.h > + > +[Packages] > + MdePkg/MdePkg.dec > + MdeModulePkg/MdeModulePkg.dec > + ManageabilityPkg/ManageabilityPkg.dec > + > +[LibraryClasses] > + BaseMemoryLib > + DebugLib > + ManageabilityTransportHelperLib > + ManageabilityTransportLib > + UefiDriverEntryPoint > + UefiBootServicesTableLib > + > +[Protocols] > + gIpmiProtocolGuid # PROTOCOL ALWAYS_PRODUCED > + > +[Guids] > + gManageabilityProtocolIpmiGuid > + gManageabilityTransportKcsGuid > + > +[FixedPcd] > + gEfiMdePkgTokenSpaceGuid.PcdIpmiKcsBaseAddress > + > +[Depex] > + TRUE > diff --git a/Features/ManageabilityPkg/Universal/IpmiProtocol/Pei/IpmiPpi= Pei.inf b/Features/ManageabilityPkg/Universal/IpmiProtocol/Pei/IpmiPpiPei.i= nf > new file mode 100644 > index 0000000000..4e00693f64 > --- /dev/null > +++ b/Features/ManageabilityPkg/Universal/IpmiProtocol/Pei/IpmiPpiPei.inf > @@ -0,0 +1,53 @@ > +## @file > +# IPMI Protocol PEI Driver. > +# > +# Copyright (C) 2023 Advanced Micro Devices, Inc. All rights reserved. > +# SPDX-License-Identifier: BSD-2-Clause-Patent > +## > + > +[Defines] > + INF_VERSION =3D 0x0001001d > + BASE_NAME =3D IpmiPei > + FILE_GUID =3D 7832F989-CB72-4715-ADCA-35C0B031856= C > + MODULE_TYPE =3D PEIM > + VERSION_STRING =3D 1.0 > + ENTRY_POINT =3D PeiIpmiEntry > + > +# > +# The following information is for reference only and not required by th= e build tools. > +# > +# VALID_ARCHITECTURES =3D IA32 X64 ARM AARCH64 > +# > + > +[Sources] > + IpmiPpi.c > + IpmiPpiInternal.h > + ../Common/IpmiProtocolCommon.c > + ../Common/IpmiProtocolCommon.h > + > +[Packages] > + MdePkg/MdePkg.dec > + MdeModulePkg/MdeModulePkg.dec > + ManageabilityPkg/ManageabilityPkg.dec > + > +[LibraryClasses] > + BaseMemoryLib > + DebugLib > + MemoryAllocationLib > + ManageabilityTransportHelperLib > + ManageabilityTransportLib > + PeimEntryPoint > + ManageabilityTransportLib Duplicate ManageabilityTransportLib > + > +[Ppis] > + gPeiIpmiPpiGuid # PPI ALWAYS PRODUCED > + > +[Guids] > + gManageabilityProtocolIpmiGuid > + gManageabilityTransportKcsGuid > + > +[FixedPcd] > + gEfiMdePkgTokenSpaceGuid.PcdIpmiKcsBaseAddress > + > +[Depex] > + TRUE > diff --git a/Features/ManageabilityPkg/Universal/IpmiProtocol/Smm/IpmiPro= tocolSmm.inf b/Features/ManageabilityPkg/Universal/IpmiProtocol/Smm/IpmiPro= tocolSmm.inf > new file mode 100644 > index 0000000000..cae1462f4f > --- /dev/null > +++ b/Features/ManageabilityPkg/Universal/IpmiProtocol/Smm/IpmiProtocolSm= m.inf > @@ -0,0 +1,52 @@ > +## @file > +# IPMI Protocol SMM Driver. > +# > +# Copyright (C) 2023 Advanced Micro Devices, Inc. All rights reserved. > +# SPDX-License-Identifier: BSD-2-Clause-Patent > +## > + > +# > +# The following information is for reference only and not required by th= e build tools. > +# > +# VALID_ARCHITECTURES =3D IA32 X64 ARM AARCH64 > +# > +[Defines] > + INF_VERSION =3D 0x0001001d > + BASE_NAME =3D IpmiSmm > + FILE_GUID =3D CDD5D1DE-E3D3-4B1F-8689-DCC661= 561BB4 > + MODULE_TYPE =3D DXE_SMM_DRIVER > + PI_SPECIFICATION_VERSION =3D 0x0001000A > + VERSION_STRING =3D 1.0 > + ENTRY_POINT =3D SmmIpmiEntry > + > +[Sources] > + IpmiProtocol.c > + ../Common/IpmiProtocolCommon.c > + ../Common/IpmiProtocolCommon.h > + > +[Packages] > + MdePkg/MdePkg.dec > + MdeModulePkg/MdeModulePkg.dec > + ManageabilityPkg/ManageabilityPkg.dec > + > +[LibraryClasses] > + BaseMemoryLib > + DebugLib > + ManageabilityTransportHelperLib > + ManageabilityTransportLib > + SmmServicesTableLib > + UefiDriverEntryPoint > + UefiBootServicesTableLib > + > +[Protocols] > + gSmmIpmiProtocolGuid # PROTOCOL ALWAYS_PRODUCED > + > +[Guids] > + gManageabilityProtocolIpmiGuid > + gManageabilityTransportKcsGuid > + > +[FixedPcd] > + gEfiMdePkgTokenSpaceGuid.PcdIpmiKcsBaseAddress > + > +[Depex] > + TRUE > diff --git a/Features/ManageabilityPkg/Universal/IpmiProtocol/Common/Ipmi= ProtocolCommon.h b/Features/ManageabilityPkg/Universal/IpmiProtocol/Common/= IpmiProtocolCommon.h > new file mode 100644 > index 0000000000..57b92cf2be > --- /dev/null > +++ b/Features/ManageabilityPkg/Universal/IpmiProtocol/Common/IpmiProtoco= lCommon.h > @@ -0,0 +1,108 @@ > +/** @file > + > + IPMI Manageability Protocol common header file. > + > + Copyright (C) 2023 Advanced Micro Devices, Inc. All rights reserved. > + SPDX-License-Identifier: BSD-2-Clause-Patent > +**/ > + > +#ifndef MANAGEABILITY_IPMI_COMMON_H_ > +#define MANAGEABILITY_IPMI_COMMON_H_ > + > +#include > +#include > + > +/// > +/// IPMI KCS hardware information. > +/// > +#define IPMI_KCS_BASE_ADDRESS PcdGet16 (PcdIpmiKcsBaseAddress) > +#define IPMI_KCS_REG_DATA_IN IPMI_KCS_BASE_ADDRESS + IPMI_KCS_DATA_IN_= REGISTER_OFFSET > +#define IPMI_KCS_REG_DATA_OUT IPMI_KCS_BASE_ADDRESS + IPMI_KCS_DATA_OUT= _REGISTER_OFFSET > +#define IPMI_KCS_REG_COMMAND IPMI_KCS_BASE_ADDRESS + IPMI_KCS_COMMAND_= REGISTER_OFFSET > +#define IPMI_KCS_REG_STATUS IPMI_KCS_BASE_ADDRESS + IPMI_KCS_STATUS_R= EGISTER_OFFSET > + > +/** > + This functions setup the IPMI transport hardware information according > + to the specification of transport token acquired from transport librar= y. > + > + @param[in] TransportToken The transport interface. > + @param[out] HardwareInformation Pointer to receive the hardwar= e information. > + > + @retval EFI_SUCCESS Hardware information is returned in Har= dwareInformation. > + Caller must free the memory allocated f= or HardwareInformation > + once it doesn't need it. > + @retval EFI_UNSUPPORTED No hardware information for the specifi= cation specified > + in the transport token. > +**/ > +EFI_STATUS > +SetupIpmiTransportHardwareInformation ( > + IN MANAGEABILITY_TRANSPORT_TOKEN *TransportToken, > + OUT MANAGEABILITY_TRANSPORT_HARDWARE_INFORMATION *HardwareInformatio= n > + ); > + > +/** > + This functions setup the final header/body/trailer packets for > + the acquired transport interface. > + > + @param[in] TransportToken The transport interface. > + @param[in] NetFunction IPMI function. > + @param[in] Command IPMI command. > + @param[out] PacketHeader The pointer to receive header of re= quest. > + @param[in, out] PacketBody The request body. > + When IN, it is the caller's request= body. > + When OUT and NULL, the request body= is not > + changed. > + Whee out and non-NULL, the request = body is > + changed to comfort the transport in= terface. > + @param[in, out] PacketBodySize The request body size. > + When IN and non-zero, it is the new= data > + length of request body. > + When IN and zero, the request body = is unchanged. > + @param[out] PacketTrailer The pointer to receive trailer of r= equest. > + > + @retval EFI_SUCCESS Request packet is returned. > + @retval EFI_UNSUPPORTED Request packet is not returned because > + the unsupported transport interface. > +**/ > +EFI_STATUS > +SetupIpmiRequestTransportPacket ( > + IN MANAGEABILITY_TRANSPORT_TOKEN *TransportToken, > + IN UINT8 NetFunction, > + IN UINT8 Command, > + OUT MANAGEABILITY_TRANSPORT_HEADER *PacketHeader OPTIONAL, > + IN OUT UINT8 **PacketBody OPTIONAL, > + IN OUT UINT32 *PacketBodySize OPTIONAL, > + OUT MANAGEABILITY_TRANSPORT_TRAILER *PacketTrailer OPTIONAL > + ); > + > +/** > + Common code to submit IPMI commands > + > + @param[in] TransportToken TRansport token. > + @param[in] NetFunction Net function of the command. > + @param[in] Command IPMI Command. > + @param[in] RequestData Command Request Data. > + @param[in] RequestDataSize Size of Command Request Data. > + @param[out] ResponseData Command Response Data. The comple= tion code is the first byte of response data. > + @param[in, out] ResponseDataSize Size of Command Response Data. > + > + @retval EFI_SUCCESS The command byte stream was successfull= y submit to the device and a response was successfully received. > + @retval EFI_NOT_FOUND The command was not successfully sent t= o the device or a response was not successfully received from the device. > + @retval EFI_NOT_READY Ipmi Device is not ready for Ipmi comma= nd access. > + @retval EFI_DEVICE_ERROR Ipmi Device hardware error. > + @retval EFI_TIMEOUT The command time out. > + @retval EFI_UNSUPPORTED The command was not successfully sent t= o the device. > + @retval EFI_OUT_OF_RESOURCES The resource allocation is out of resou= rce or data size error. > +**/ > +EFI_STATUS > +CommonIpmiSubmitCommand ( > + IN MANAGEABILITY_TRANSPORT_TOKEN *TransportToken, > + IN UINT8 NetFunction, > + IN UINT8 Command, > + IN UINT8 *RequestData OPTIONAL, > + IN UINT32 RequestDataSize, > + OUT UINT8 *ResponseData OPTIONAL, > + IN OUT UINT32 *ResponseDataSize OPTIONAL > + ); > + > +#endif > diff --git a/Features/ManageabilityPkg/Universal/IpmiProtocol/Pei/IpmiPpi= Internal.h b/Features/ManageabilityPkg/Universal/IpmiProtocol/Pei/IpmiPpiIn= ternal.h > new file mode 100644 > index 0000000000..bbe0c8c5cb > --- /dev/null > +++ b/Features/ManageabilityPkg/Universal/IpmiProtocol/Pei/IpmiPpiInterna= l.h > @@ -0,0 +1,25 @@ > +/** @file > + > + IPMI Manageability PPI internal header file. > + > + Copyright (C) 2023 Advanced Micro Devices, Inc. All rights reserved. > + SPDX-License-Identifier: BSD-2-Clause-Patent > +**/ > + > +#ifndef MANAGEABILITY_IPMI_PPI_INTERNAL_H_ > +#define MANAGEABILITY_IPMI_PPI_INTERNAL_H_ > + > +#include > +#include > + > +#define MANAGEABILITY_IPMI_PPI_INTERNAL_SIGNATURE SIGNATURE_32 ('I', 'P= ', 'P', 'I') > + > +#define MANAGEABILITY_IPMI_PPI_INTERNAL_FROM_LINK(a) CR (a, PEI_IPMI_PP= I_INTERNAL, PeiIpmiPpi, MANAGEABILITY_IPMI_PPI_INTERNAL_SIGNATURE) > + > +typedef struct { > + UINT32 Signature; > + MANAGEABILITY_TRANSPORT_TOKEN *TransportToken; > + PEI_IPMI_PPI PeiIpmiPpi; > +} PEI_IPMI_PPI_INTERNAL; > + > +#endif // MANAGEABILITY_IPMI_PPI_INTERNAL_H_ > diff --git a/Features/ManageabilityPkg/Universal/IpmiProtocol/Common/Ipmi= ProtocolCommon.c b/Features/ManageabilityPkg/Universal/IpmiProtocol/Common/= IpmiProtocolCommon.c > new file mode 100644 > index 0000000000..d1294d2f7c > --- /dev/null > +++ b/Features/ManageabilityPkg/Universal/IpmiProtocol/Common/IpmiProtoco= lCommon.c > @@ -0,0 +1,252 @@ > +/** @file > + > + IPMI Manageability Protocol common file. > + > + Copyright (C) 2023 Advanced Micro Devices, Inc. All rights reserved. > + SPDX-License-Identifier: BSD-2-Clause-Patent > + > +**/ > +#include > +#include > +#include > +#include > +#include > +#include > + > +#include "IpmiProtocolCommon.h" > + > +/** > + This functions setup the IPMI transport hardware information according > + to the specification of transport token acquired from transport librar= y. > + > + @param[in] TransportToken The transport interface. > + @param[out] HardwareInformation Pointer to receive the hardwar= e information. > + > + @retval EFI_SUCCESS Hardware information is returned in Har= dwareInformation. > + Caller must free the memory allocated f= or HardwareInformation > + once it doesn't need it. > + @retval EFI_UNSUPPORTED No hardware information for the specifi= cation specified > + in the transport token. > + #retval EFI_OUT_OF_RESOURCES Not enough memory for MANAGEABILITY_TRA= NSPORT_KCS_HARDWARE_INFO. > +**/ > +EFI_STATUS > +SetupIpmiTransportHardwareInformation ( > + IN MANAGEABILITY_TRANSPORT_TOKEN *TransportToken, > + OUT MANAGEABILITY_TRANSPORT_HARDWARE_INFORMATION *HardwareInformatio= n > + ) > +{ > + MANAGEABILITY_TRANSPORT_KCS_HARDWARE_INFO *KcsHardwareInfo; > + > + KcsHardwareInfo =3D AllocatePool (sizeof (MANAGEABILITY_TRANSPORT_KCS_= HARDWARE_INFO)); > + if (KcsHardwareInfo =3D=3D NULL) { > + DEBUG ((DEBUG_ERROR, "%a: Not enough memory for MANAGEABILITY_TRANSP= ORT_KCS_HARDWARE_INFO.\n", __FUNCTION__)); > + return EFI_OUT_OF_RESOURCES; > + } > + > + if (CompareGuid (&gManageabilityTransportKcsGuid, TransportToken->Tran= sport->ManageabilityTransportSpecification)) { > + // This is KCS transport interface. > + KcsHardwareInfo->MemoryMap =3D MANAGEABILITY_TRAN= SPORT_KCS_IO_MAP_IO; > + KcsHardwareInfo->IoBaseAddress.IoAddress16 =3D IPMI_KCS_BASE_ADDR= ESS; > + KcsHardwareInfo->IoDataInAddress.IoAddress16 =3D IPMI_KCS_REG_DATA_= IN; > + KcsHardwareInfo->IoDataOutAddress.IoAddress16 =3D IPMI_KCS_REG_DATA_= OUT; > + KcsHardwareInfo->IoCommandAddress.IoAddress16 =3D IPMI_KCS_REG_COMMA= ND; > + KcsHardwareInfo->IoStatusAddress.IoAddress16 =3D IPMI_KCS_REG_STATU= S; > + *HardwareInformation =3D > + (MANAGEABILITY_TRANSPORT_HARDWARE_INFORMATION)KcsHardwareInfo; > + return EFI_SUCCESS; > + } else { > + DEBUG ((DEBUG_ERROR, "%a: No implementation of setting hardware info= rmation.", __FUNCTION__)); > + ASSERT (FALSE); > + } > + > + return EFI_UNSUPPORTED; > +} > + > +/** > + This functions setup the final header/body/trailer packets for > + the acquired transport interface. > + > + @param[in] TransportToken The transport interface. > + @param[in] NetFunction IPMI function. > + @param[in] Command IPMI command. > + @param[out] PacketHeader The pointer to receive header of re= quest. > + @param[in, out] PacketBody The request body. > + When IN, it is the caller's request= body. > + When OUT and NULL, the request body= is not > + changed. > + When OUT and non-NULL, the request = body is > + changed to conform the transport in= terface. > + @param[in, out] PacketBodySize The request body size. > + When OUT and non-zero, it is the ne= w data > + length of request body. > + When OUT and zero, the request body= is unchanged. > + @param[out] PacketTrailer The pointer to receive trailer of r= equest. > + > + @retval EFI_SUCCESS Request packet is returned. > + @retval EFI_UNSUPPORTED Request packet is not returned because > + the unsupported transport interface. > +**/ > +EFI_STATUS > +SetupIpmiRequestTransportPacket ( > + IN MANAGEABILITY_TRANSPORT_TOKEN *TransportToken, > + IN UINT8 NetFunction, > + IN UINT8 Command, > + OUT MANAGEABILITY_TRANSPORT_HEADER *PacketHeader OPTIONAL, > + IN OUT UINT8 **PacketBody OPTIONAL, > + IN OUT UINT32 *PacketBodySize OPTIONAL, > + OUT MANAGEABILITY_TRANSPORT_TRAILER *PacketTrailer OPTIONAL > + ) > +{ > + MANAGEABILITY_IPMI_TRANSPORT_HEADER *IpmiHeader; > + > + if (CompareGuid (&gManageabilityTransportKcsGuid, TransportToken->Tran= sport->ManageabilityTransportSpecification)) { > + // This is KCS transport interface. > + IpmiHeader =3D AllocateZeroPool (sizeof (MANAGEABILITY_IPMI_TRANSPOR= T_HEADER)); > + if (IpmiHeader =3D=3D NULL) { > + return EFI_OUT_OF_RESOURCES; > + } > + > + IpmiHeader->Command =3D Command; > + IpmiHeader->Lun =3D 0; > + IpmiHeader->NetFn =3D NetFunction; > + if (PacketHeader !=3D NULL) { > + *PacketHeader =3D (MANAGEABILITY_TRANSPORT_HEADER *)IpmiHeader; > + } > + if (PacketTrailer !=3D NULL) { > + *PacketTrailer =3D NULL; > + } > + if (PacketBody !=3D NULL) { > + *PacketBody =3D NULL; > + } > + if (PacketBodySize !=3D NULL) { > + *PacketBodySize =3D 0; > + } > + } else { > + DEBUG ((DEBUG_ERROR, "%a: No implementation of building up packet.",= __FUNCTION__)); > + ASSERT (FALSE); > + } > + return EFI_SUCCESS; > +} > + > +/** > + Common code to submit IPMI commands > + > + @param[in] TransportToken TRansport token. > + @param[in] NetFunction Net function of the command. > + @param[in] Command IPMI Command. > + @param[in] RequestData Command Request Data. > + @param[in] RequestDataSize Size of Command Request Data. > + @param[out] ResponseData Command Response Data. The comple= tion code is the first byte of response data. > + @param[in, out] ResponseDataSize Size of Command Response Data. > + > + @retval EFI_SUCCESS The command byte stream was successfull= y submit to the device and a response was successfully received. > + @retval EFI_NOT_FOUND The command was not successfully sent t= o the device or a response was not successfully received from the device. > + @retval EFI_NOT_READY Ipmi Device is not ready for Ipmi comma= nd access. > + @retval EFI_DEVICE_ERROR Ipmi Device hardware error. > + @retval EFI_TIMEOUT The command time out. > + @retval EFI_UNSUPPORTED The command was not successfully sent t= o the device. > + @retval EFI_OUT_OF_RESOURCES The resource allocation is out of resou= rce or data size error. > +**/ > +EFI_STATUS > +CommonIpmiSubmitCommand ( > + IN MANAGEABILITY_TRANSPORT_TOKEN *TransportToken, > + IN UINT8 NetFunction, > + IN UINT8 Command, > + IN UINT8 *RequestData OPTIONAL, > + IN UINT32 RequestDataSize, > + OUT UINT8 *ResponseData OPTIONAL, > + IN OUT UINT32 *ResponseDataSize OPTIONAL > + ) > +{ > + EFI_STATUS Status; > + UINT8 *ThisRequestData; > + UINT32 ThisRequestDataSize; > + MANAGEABILITY_TRANSFER_TOKEN TransferToken; > + MANAGEABILITY_TRANSPORT_HEADER IpmiTransportHeader; > + MANAGEABILITY_TRANSPORT_TRAILER IpmiTransportTrailer; > + MANAGEABILITY_TRANSPORT_ADDITIONAL_STATUS TransportAdditionalStatus; > + > + if (TransportToken =3D=3D NULL) { > + DEBUG ((DEBUG_ERROR, "%a: No transport toke for IPMI\n", __FUNCTION_= _)); > + return EFI_UNSUPPORTED; > + } > + > + Status =3D TransportToken->Transport->Function.Version1_0->TransportSt= atus ( > + TransportTo= ken, > + &TransportA= dditionalStatus > + ); > + if (EFI_ERROR (Status)) { > + DEBUG ((DEBUG_ERROR, "%a: Transport for IPMI has problem - (%r)\n", = __FUNCTION__, Status)); > + return Status; > + } > + > + ThisRequestData =3D RequestData; > + ThisRequestDataSize =3D RequestDataSize; > + IpmiTransportHeader =3D NULL; > + IpmiTransportTrailer =3D NULL; > + Status =3D SetupIpmiRequestTransportPacket ( > + TransportToken, > + NetFunction, > + Command, > + &IpmiTransportHeader, > + &ThisRequestData, > + &ThisRequestDataSize, > + &IpmiTransportTrailer > + ); > + if (EFI_ERROR (Status)) { > + DEBUG ((DEBUG_ERROR, "%a: Fail to build packets - (%r)\n", __FUNCTIO= N__, Status)); > + return Status; > + } > + > + ZeroMem (&TransferToken, sizeof (MANAGEABILITY_TRANSFER_TOKEN)); > + TransferToken.TransmitHeader =3D IpmiTransportHeader; > + TransferToken.TransmitTrailer =3D IpmiTransportTrailer; > + > + // Transmit packet. > + if ((ThisRequestData =3D=3D NULL) || (ThisRequestDataSize =3D=3D 0)) { > + > + // Transmit parameter were not changed by SetupIpmiRequestTransportP= acket(). > + TransferToken.TransmitPackage.TransmitPayload =3D RequestData; > + TransferToken.TransmitPackage.TransmitSizeInByte =3D RequestDataSize= ; > + } else { > + TransferToken.TransmitPackage.TransmitPayload =3D ThisRequestData= ; > + TransferToken.TransmitPackage.TransmitSizeInByte =3D ThisRequestData= Size; > + } > + > + TransferToken.TransmitPackage.TransmitTimeoutInMillisecond =3D MANAGEA= BILITY_TRANSPORT_NO_TIMEOUT; > + > + // Receive packet. > + TransferToken.ReceivePackage.ReceiveBuffer =3D Response= Data; > + TransferToken.ReceivePackage.ReceiveSizeInByte =3D *Respons= eDataSize; > + TransferToken.ReceivePackage.TransmitTimeoutInMillisecond =3D MANAGEAB= ILITY_TRANSPORT_NO_TIMEOUT; > + TransportToken->Transport->Function.Version1_0->TransportTransmitRecei= ve ( > + TransportToken, > + &TransferToken > + ); > + > + if (IpmiTransportHeader !=3D NULL) { > + FreePool ((VOID *)IpmiTransportHeader); > + } > + > + if (IpmiTransportTrailer !=3D NULL) { > + FreePool ((VOID *)IpmiTransportTrailer); > + } > + > + if (ThisRequestData !=3D NULL) { > + FreePool ((VOID *)ThisRequestData); > + } > + > + // Return transfer status. > + // > + Status =3D TransferToken.TransferStatus; > + TransportAdditionalStatus =3D TransferToken.TransportAdditionalStatus; > + if (EFI_ERROR (Status)) { > + DEBUG ((DEBUG_ERROR, "%a: Failed to send IPMI command.\n", __FUNCTIO= N__)); > + return Status; > + } > + > + if (ResponseDataSize !=3D NULL) { > + *ResponseDataSize =3D TransferToken.ReceivePackage.ReceiveSizeInByte= ; > + } > + return Status; > +} > diff --git a/Features/ManageabilityPkg/Universal/IpmiProtocol/Dxe/IpmiPro= tocol.c b/Features/ManageabilityPkg/Universal/IpmiProtocol/Dxe/IpmiProtocol= .c > new file mode 100644 > index 0000000000..05175ee448 > --- /dev/null > +++ b/Features/ManageabilityPkg/Universal/IpmiProtocol/Dxe/IpmiProtocol.c > @@ -0,0 +1,177 @@ > +/** @file > + This file provides IPMI Protocol implementation. > + > + Copyright (C) 2023 Advanced Micro Devices, Inc. All rights reserved. > + SPDX-License-Identifier: BSD-2-Clause-Patent > +**/ > + > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > + > +#include "IpmiProtocolCommon.h" > + > +MANAGEABILITY_TRANSPORT_TOKEN *mTransportToken =3D NULL; > +CHAR16 *mTransportName; > + > +MANAGEABILITY_TRANSPORT_HARDWARE_INFORMATION mHardwareInformation; > + > +/** > + This service enables submitting commands via Ipmi. > + > + @param[in] This This point for IPMI_PROTOCOL stru= cture. > + @param[in] NetFunction Net function of the command. > + @param[in] Command IPMI Command. > + @param[in] RequestData Command Request Data. > + @param[in] RequestDataSize Size of Command Request Data. > + @param[out] ResponseData Command Response Data. The comple= tion code is the first byte of response data. > + @param[in, out] ResponseDataSize Size of Command Response Data. > + > + @retval EFI_SUCCESS The command byte stream was successfull= y submit to the device and a response was successfully received. > + @retval EFI_NOT_FOUND The command was not successfully sent t= o the device or a response was not successfully received from the device. > + @retval EFI_NOT_READY Ipmi Device is not ready for Ipmi comma= nd access. > + @retval EFI_DEVICE_ERROR Ipmi Device hardware error. > + @retval EFI_TIMEOUT The command time out. > + @retval EFI_UNSUPPORTED The command was not successfully sent t= o the device. > + @retval EFI_OUT_OF_RESOURCES The resource allocation is out of resou= rce or data size error. > +**/ > +EFI_STATUS > +EFIAPI > +DxeIpmiSubmitCommand ( > + IN IPMI_PROTOCOL *This, > + IN UINT8 NetFunction, > + IN UINT8 Command, > + IN UINT8 *RequestData, > + IN UINT32 RequestDataSize, > + OUT UINT8 *ResponseData, > + IN OUT UINT32 *ResponseDataSize > + ) > +{ > + EFI_STATUS Status; > + > + Status =3D CommonIpmiSubmitCommand ( > + mTransportToken, > + NetFunction, > + Command, > + RequestData, > + RequestDataSize, > + ResponseData, > + ResponseDataSize > + ); > + return Status; > +} > + > +static IPMI_PROTOCOL mIpmiProtocol =3D { > + DxeIpmiSubmitCommand > +}; > + > +/** > + The entry point of the Ipmi DXE driver. > + > + @param[in] ImageHandle - Handle of this driver image > + @param[in] SystemTable - Table containing standard EFI services > + > + @retval EFI_SUCCESS - IPMI Protocol is installed successfully. > + @retval Otherwise - Other errors. > +**/ > +EFI_STATUS > +EFIAPI > +DxeIpmiEntry ( > + IN EFI_HANDLE ImageHandle, > + IN EFI_SYSTEM_TABLE *SystemTable > + ) > +{ > + EFI_STATUS Status; > + EFI_HANDLE Handle; > + MANAGEABILITY_TRANSPORT_CAPABILITY TransportCapability; > + MANAGEABILITY_TRANSPORT_ADDITIONAL_STATUS TransportAdditionalStatus; > + > + GetTransportCapability (&TransportCapability); > + > + Status =3D HelperAcquireManageabilityTransport ( > + &gManageabilityProtocolIpmiGuid, > + &mTransportToken > + ); > + if (EFI_ERROR (Status)) { > + DEBUG ((DEBUG_ERROR, "%a: Failed to acquire transport interface for = IPMI protocol - %r\n", __FUNCTION__, Status)); > + return Status; > + } > + > + mTransportName =3D HelperManageabilitySpecName (mTransportToken->Trans= port->ManageabilityTransportSpecification); > + DEBUG ((DEBUG_INFO, "%a: IPMI protocol over %s.\n", __FUNCTION__, mTra= nsportName)); > + > + // > + // Setup hardware information according to the transport interface. > + Status =3D SetupIpmiTransportHardwareInformation ( > + mTransportToken, > + &mHardwareInformation > + ); > + if (EFI_ERROR (Status)) { > + if (Status =3D=3D EFI_UNSUPPORTED) { > + DEBUG ((DEBUG_ERROR, "%a: No hardware information of %s transport = interface.\n", __FUNCTION__, mTransportName)); > + } > + > + return Status; > + } > + > + // > + // Initial transport interface with the hardware information assigned. This, I think is not a comment style defined in the EDK2 coding style. > + Status =3D HelperInitManageabilityTransport ( > + mTransportToken, > + mHardwareInformation, > + &TransportAdditionalStatus > + ); > + if (EFI_ERROR (Status)) { > + return Status; > + } > + At here, everything is ready to go. We will install the protocol and=20 done. But what about the "Host's partner"? IPMI protocol is usually to use to communicate between Host and BMC. In=20 some systems, BMC will provide a mechanism to the host to notify it that everything is=20 fine and that it is ready to communicate (the common way is GPIO). What if we issue a request to BMC, and BMC fails to respond or returns=20 dummy data? On one level, it is an enhancement feature, and it is not supported by=20 all platforms.=C2=A0 Why don't we support a library/protocol that allows platforms to choose whether or not to issue a request?.=20 Because the problem could occur at any time, we should check before=20 starting a request. It can be put into CommonIpmiSubmitCommand (). Why not include it in ManageabilityTransportLib? Because that is the=20 IPMI issue, the KCS controller is fine, the I2C controller is fine, and the BMC is=20 ready to communicate via MCTP, but IPMI is stuck I'm happy when you can assist with this. Personally, I love Protocol more - Tinh > + Handle =3D NULL; > + Status =3D gBS->InstallProtocolInterface ( > + &Handle, > + &gIpmiProtocolGuid, > + EFI_NATIVE_INTERFACE, > + (VOID **)&mIpmiProtocol > + ); > + if (EFI_ERROR (Status)) { > + DEBUG ((DEBUG_ERROR, "%a: Failed to install IPMI protocol - %r\n", _= _FUNCTION__, Status)); > + } > + > + return Status; > +} > + > +/** > + This is the unload handler for IPMI protocol module. > + > + Release the MANAGEABILITY_TRANSPORT_TOKEN acquired at entry point. > + > + @param[in] ImageHandle The drivers' driver image. > + > + @retval EFI_SUCCESS The image is unloaded. > + @retval Others Failed to unload the image. > + > +**/ > +EFI_STATUS > +EFIAPI > +IpmiUnloadImage ( > + IN EFI_HANDLE ImageHandle > + ) > +{ > + EFI_STATUS Status; > + > + Status =3D EFI_SUCCESS; > + if (mTransportToken !=3D NULL) { > + Status =3D ReleaseTransportSession (mTransportToken); > + } > + > + if (mHardwareInformation.Pointer !=3D NULL) { > + FreePool (mHardwareInformation.Pointer); > + } > + > + return Status; > +} > diff --git a/Features/ManageabilityPkg/Universal/IpmiProtocol/Pei/IpmiPpi= .c b/Features/ManageabilityPkg/Universal/IpmiProtocol/Pei/IpmiPpi.c > new file mode 100644 > index 0000000000..f839cd7387 > --- /dev/null > +++ b/Features/ManageabilityPkg/Universal/IpmiProtocol/Pei/IpmiPpi.c > @@ -0,0 +1,159 @@ > +/** @file > + This file provides IPMI PPI implementation. > + > + Copyright (C) 2023 Advanced Micro Devices, Inc. All rights reserved. > + SPDX-License-Identifier: BSD-2-Clause-Patent > + > +**/ > + > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > + > +#include > + > +#include "IpmiProtocolCommon.h" > +#include "IpmiPpiInternal.h" > + > +/** > + This service enables submitting commands via Ipmi. > + > + @param[in] This This point for PEI_IPMI_PPI struc= ture. > + @param[in] NetFunction Net function of the command. > + @param[in] Command IPMI Command. > + @param[in] RequestData Command Request Data. > + @param[in] RequestDataSize Size of Command Request Data. > + @param[out] ResponseData Command Response Data. The comple= tion code is the first byte of response data. > + @param[in, out] ResponseDataSize Size of Command Response Data. > + > + @retval EFI_SUCCESS The command byte stream was successfull= y submit to the device and a response was successfully received. > + @retval EFI_NOT_FOUND The command was not successfully sent t= o the device or a response was not successfully received from the device. > + @retval EFI_NOT_READY Ipmi Device is not ready for Ipmi comma= nd access. > + @retval EFI_DEVICE_ERROR Ipmi Device hardware error. > + @retval EFI_TIMEOUT The command time out. > + @retval EFI_UNSUPPORTED The command was not successfully sent t= o the device. > + @retval EFI_OUT_OF_RESOURCES The resource allocation is out of resou= rce or data size error. > +**/ > +EFI_STATUS > +EFIAPI > +PeiIpmiSubmitCommand ( > + IN PEI_IPMI_PPI *This, > + IN UINT8 NetFunction, > + IN UINT8 Command, > + IN UINT8 *RequestData, > + IN UINT32 RequestDataSize, > + OUT UINT8 *ResponseData, > + IN OUT UINT32 *ResponseDataSize > + ) > +{ > + EFI_STATUS Status; > + PEI_IPMI_PPI_INTERNAL *PeiIpmiPpiinternal; > + > + PeiIpmiPpiinternal =3D MANAGEABILITY_IPMI_PPI_INTERNAL_FROM_LINK(This)= ; > + Status =3D CommonIpmiSubmitCommand ( > + PeiIpmiPpiinternal->TransportToken, > + NetFunction, > + Command, > + RequestData, > + RequestDataSize, > + ResponseData, > + ResponseDataSize > + ); > + return Status; > +} > + > +/** > + The entry point of the Ipmi PPI PEIM. > + > + @param FileHandle Handle of the file being invoked. > + @param PeiServices Describes the list of possible PEI Services. > + > + @retval EFI_SUCCESS Indicates that Ipmi initialization completed suc= cessfully. > + @retval Others Indicates that Ipmi initialization could not com= plete successfully. > +**/ > +EFI_STATUS > +EFIAPI > +PeiIpmiEntry ( > + IN EFI_PEI_FILE_HANDLE FileHandle, > + IN CONST EFI_PEI_SERVICES **PeiServices > + ) > +{ > + EFI_STATUS Status; > + CHAR16 *TransportName; > + PEI_IPMI_PPI_INTERNAL *PeiIpmiPpiinternal; > + EFI_PEI_PPI_DESCRIPTOR *PpiDescriptor; > + MANAGEABILITY_TRANSPORT_CAPABILITY TransportCapability; > + MANAGEABILITY_TRANSPORT_ADDITIONAL_STATUS TransportAdditionalStatu= s; > + MANAGEABILITY_TRANSPORT_HARDWARE_INFORMATION HardwareInformation; > + > + PeiIpmiPpiinternal =3D (PEI_IPMI_PPI_INTERNAL *)AllocateZeroPool (size= of(PEI_IPMI_PPI_INTERNAL)); > + if (PeiIpmiPpiinternal =3D=3D NULL) { > + DEBUG ((DEBUG_ERROR, "%a: Not enough memory for PEI_IPMI_PPI_INTERNA= L.\n", __FUNCTION__)); > + return EFI_OUT_OF_RESOURCES; > + } > + PpiDescriptor =3D (EFI_PEI_PPI_DESCRIPTOR *)AllocateZeroPool (sizeof(E= FI_PEI_PPI_DESCRIPTOR)); > + if (PpiDescriptor =3D=3D NULL) { > + DEBUG ((DEBUG_ERROR, "%a: Not enough memory for EFI_PEI_PPI_DESCRIPT= OR.\n", __FUNCTION__)); > + return EFI_OUT_OF_RESOURCES; > + } > + > + PeiIpmiPpiinternal->Signature =3D MANAGEABILITY_IPMI_PPI_INTERNAL_SIGN= ATURE; > + PeiIpmiPpiinternal->PeiIpmiPpi.IpmiSubmitCommand =3D PeiIpmiSubmitComm= and; > + > + PpiDescriptor->Flags =3D EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESC= RIPTOR_TERMINATE_LIST; > + PpiDescriptor->Guid =3D &gPeiIpmiPpiGuid; > + PpiDescriptor->Ppi =3D &PeiIpmiPpiinternal->PeiIpmiPpi; > + > + GetTransportCapability (&TransportCapability); > + Status =3D HelperAcquireManageabilityTransport ( > + &gManageabilityProtocolIpmiGuid, > + &PeiIpmiPpiinternal->TransportToken > + ); > + if (EFI_ERROR (Status)) { > + DEBUG ((DEBUG_ERROR, "%a: Failed to acquire transport interface for = IPMI protocol - %r\n", __FUNCTION__, Status)); > + return Status; > + } > + > + TransportName =3D HelperManageabilitySpecName (PeiIpmiPpiinternal->Tra= nsportToken->Transport->ManageabilityTransportSpecification); > + DEBUG ((DEBUG_INFO, "%a: IPMI protocol over %s.\n", __FUNCTION__, Tran= sportName)); > + > + // > + // Setup hardware information according to the transport interface. > + Status =3D SetupIpmiTransportHardwareInformation ( > + PeiIpmiPpiinternal->TransportToken, > + &HardwareInformation > + ); > + if (EFI_ERROR (Status)) { > + if (Status =3D=3D EFI_UNSUPPORTED) { > + DEBUG ((DEBUG_ERROR, "%a: No hardware information of %s transport = interface.\n", __FUNCTION__, TransportName)); > + } > + > + return Status; > + } > + > + // > + // Initial transport interface with the hardware information assigned. > + Status =3D HelperInitManageabilityTransport ( > + PeiIpmiPpiinternal->TransportToken, > + HardwareInformation, > + &TransportAdditionalStatus > + ); > + if (EFI_ERROR (Status)) { > + return Status; > + } > + > + // > + // Install IPMI PPI. > + // > + Status =3D PeiServicesInstallPpi (PpiDescriptor); > + if (EFI_ERROR (Status)) { > + DEBUG ((DEBUG_ERROR, "%a: Failed to install IPMI PPI - %r\n", __FUNC= TION__, Status)); > + } > + > + return Status; > +} > diff --git a/Features/ManageabilityPkg/Universal/IpmiProtocol/Smm/IpmiPro= tocol.c b/Features/ManageabilityPkg/Universal/IpmiProtocol/Smm/IpmiProtocol= .c > new file mode 100644 > index 0000000000..87a5436bdf > --- /dev/null > +++ b/Features/ManageabilityPkg/Universal/IpmiProtocol/Smm/IpmiProtocol.c > @@ -0,0 +1,147 @@ > +/** @file > + This file provides IPMI SMM Protocol implementation. > + > + Copyright (C) 2023 Advanced Micro Devices, Inc. All rights reserved. > + SPDX-License-Identifier: BSD-2-Clause-Patent > +**/ > + > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > + > +#include > + > +#include "IpmiProtocolCommon.h" > + > +MANAGEABILITY_TRANSPORT_TOKEN *mTransportToken =3D NULL; > +CHAR16 *mTransportName; > + > +MANAGEABILITY_TRANSPORT_HARDWARE_INFORMATION mHardwareInformation; > + > +/** > + This service enables submitting commands via Ipmi. > + > + @param[in] This This point for IPMI_PROTOCOL stru= cture. > + @param[in] NetFunction Net function of the command. > + @param[in] Command IPMI Command. > + @param[in] RequestData Command Request Data. > + @param[in] RequestDataSize Size of Command Request Data. > + @param[out] ResponseData Command Response Data. The comple= tion code is the first byte of response data. > + @param[in, out] ResponseDataSize Size of Command Response Data. > + > + @retval EFI_SUCCESS The command byte stream was successfull= y submit to the device and a response was successfully received. > + @retval EFI_NOT_FOUND The command was not successfully sent t= o the device or a response was not successfully received from the device. > + @retval EFI_NOT_READY Ipmi Device is not ready for Ipmi comma= nd access. > + @retval EFI_DEVICE_ERROR Ipmi Device hardware error. > + @retval EFI_TIMEOUT The command time out. > + @retval EFI_UNSUPPORTED The command was not successfully sent t= o the device. > + @retval EFI_OUT_OF_RESOURCES The resource allocation is out of resou= rce or data size error. > +**/ > +EFI_STATUS > +EFIAPI > +SmmIpmiSubmitCommand ( > + IN IPMI_PROTOCOL *This, > + IN UINT8 NetFunction, > + IN UINT8 Command, > + IN UINT8 *RequestData, > + IN UINT32 RequestDataSize, > + OUT UINT8 *ResponseData, > + IN OUT UINT32 *ResponseDataSize > + ) > +{ > + EFI_STATUS Status; > + > + Status =3D CommonIpmiSubmitCommand ( > + mTransportToken, > + NetFunction, > + Command, > + RequestData, > + RequestDataSize, > + ResponseData, > + ResponseDataSize > + ); > + return Status; > +} > + > +static IPMI_PROTOCOL mIpmiProtocol =3D { > + SmmIpmiSubmitCommand > +}; > + > +/** > + The entry point of the Ipmi DXE driver. > + > + @param[in] ImageHandle - Handle of this driver image > + @param[in] SystemTable - Table containing standard EFI services > + > + @retval EFI_SUCCESS - IPMI Protocol is installed successfully. > + @retval Otherwise - Other errors. > +**/ > +EFI_STATUS > +EFIAPI > +SmmIpmiEntry ( > + IN EFI_HANDLE ImageHandle, > + IN EFI_SYSTEM_TABLE *SystemTable > + ) > +{ > + EFI_STATUS Status; > + EFI_HANDLE Handle; > + MANAGEABILITY_TRANSPORT_CAPABILITY TransportCapability; > + MANAGEABILITY_TRANSPORT_ADDITIONAL_STATUS TransportAdditionalStatus; > + > + GetTransportCapability (&TransportCapability); > + > + Status =3D HelperAcquireManageabilityTransport ( > + &gManageabilityProtocolIpmiGuid, > + &mTransportToken > + ); > + if (EFI_ERROR (Status)) { > + DEBUG ((DEBUG_ERROR, "%a: Failed to acquire transport interface for = IPMI protocol - %r\n", __FUNCTION__, Status)); > + return Status; > + } > + > + mTransportName =3D HelperManageabilitySpecName (mTransportToken->Trans= port->ManageabilityTransportSpecification); > + DEBUG ((DEBUG_INFO, "%a: IPMI protocol over %s.\n", __FUNCTION__, mTra= nsportName)); > + > + // > + // Setup hardware information according to the transport interface. > + Status =3D SetupIpmiTransportHardwareInformation ( > + mTransportToken, > + &mHardwareInformation > + ); > + if (EFI_ERROR (Status)) { > + if (Status =3D=3D EFI_UNSUPPORTED) { > + DEBUG ((DEBUG_ERROR, "%a: No hardware information of %s transport = interface.\n", __FUNCTION__, mTransportName)); > + } > + > + return Status; > + } > + > + // > + // Initial transport interface with the hardware information assigned. > + Status =3D HelperInitManageabilityTransport ( > + mTransportToken, > + mHardwareInformation, > + &TransportAdditionalStatus > + ); > + if (EFI_ERROR (Status)) { > + return Status; > + } > + > + Handle =3D NULL; > + Status =3D gSmst->SmmInstallProtocolInterface ( > + &Handle, > + &gSmmIpmiProtocolGuid, > + EFI_NATIVE_INTERFACE, > + (VOID **)&mIpmiProtocol > + ); > + if (EFI_ERROR (Status)) { > + DEBUG ((DEBUG_ERROR, "%a: Failed to install IPMI SMM protocol - %r\n= ", __FUNCTION__, Status)); > + } > + > + return Status; > +}