From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (NAM10-MW2-obe.outbound.protection.outlook.com [40.107.94.44]) by mx.groups.io with SMTP id smtpd.web10.97104.1679649938718367233 for ; Fri, 24 Mar 2023 02:25:39 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@nvidia.com header.s=selector2 header.b=gRt9i6Q6; spf=permerror, err=parse error for token &{10 18 %{i}._ip.%{h}._ehlo.%{d}._spf.vali.email}: invalid domain name (domain: nvidia.com, ip: 40.107.94.44, mailfrom: nicklew@nvidia.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=GQVM5TLG8Ios24Xgv9OquidxME/LVDhsWTFVKstM7B/1QQPepXSOltWE7vMxGy/WIic1WK3xC7oDlu/9aA+8dlgUqg+v1MbvBRIITl+zQAGu80VHJ3F09j8rdf+oLqUUlroWmqOwpoHzcOPmyLrQY9OJYQwMyM8E15YKmvdiAKzG4ar+STnZdWEFr+Q3MsQws6xHWBuGW4RkWlU8JnViV3enZzA6iw2gJz3hbnOsff08R/CIGejjUpbIr6pVONnJODKNOLblBbKV1h+pDEmpbr67Hnnk233RcgxI3f1Z+G6zlVdoodsQ4Xrz4OQjRUJYy2lJWnzNAXKUPVV4FSVtlA== 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=vcXWUlRlXgPoIohcPQITi25PhlPx2boMtBc2adGxU4g=; b=BSX+0J/crXNvkIJ+cQKTIf+h3vwmXhUraxyB7XUalO/Oo3A06vzXpwkbdIyq1J7IZ/Tm8LBtHOB+ho5ZKqQQL+sInqsbh0VQVfViGtt6rlWmbzGrcDD6fx0wc878DpMRdEhB1bNbnvlSYW+PzDs3tCedBMX4FSnaKD1T4hkGFL5GM/HV3RbdoNZb/3J6Ip4bNpvLcETqlfHejcJL+edokdjZixH3Bj+oIaNcTqnvS8SGxKs7Eic6IACePVjKahgi7TxHKh7uDdw5sjTnvb6oW02I+uDrf8MZvFKh8jV3hk9ZEI5h1q2oYM6afziV7yproF5+AydR5ra86Ya3/OARqw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nvidia.com; dmarc=pass action=none header.from=nvidia.com; dkim=pass header.d=nvidia.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=vcXWUlRlXgPoIohcPQITi25PhlPx2boMtBc2adGxU4g=; b=gRt9i6Q69gR9GGjd7TQLPddGIwo/O3OlsaEIb64lFSHYJuC+EtYxx8BKFHhbdEGxSZCC6zWi4bGh27hpHLHFF9MKdo0TfkcTflzJrJyqwWc0mj/iWxXwpCZmbLw8WL5908Kz/xDYRP2EliUYKRd+86fk4L4XgC3uZu4JwAbWE67IoELl+3vojcIf+prtfDFdyxVvJL4FKjeVNam5DNBobLrTCcxECQMyxTdDQp8iOCgAz9PzYT2EYuyRzKf+KddUmv8k3vrOi3WXBWyAOSQFpVJ0oSpUXJy78tHQnIoy+uJO37JoqNAMElrovQ9k+Py3rA/mjmX0INBSupcxC/3S5w== Received: from MW4PR12MB7031.namprd12.prod.outlook.com (2603:10b6:303:1ef::6) by BL1PR12MB5730.namprd12.prod.outlook.com (2603:10b6:208:385::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6178.38; Fri, 24 Mar 2023 09:25:34 +0000 Received: from MW4PR12MB7031.namprd12.prod.outlook.com ([fe80::c27a:fa4b:66ea:d266]) by MW4PR12MB7031.namprd12.prod.outlook.com ([fe80::c27a:fa4b:66ea:d266%5]) with mapi id 15.20.6178.037; Fri, 24 Mar 2023 09:25:34 +0000 From: "Nickle Wang" To: "abner.chang@amd.com" , "devel@edk2.groups.io" CC: Liming Gao , Isaac Oram , Nate DeSimone , Abdul Lateef Attar , Igor Kulchytskyy Subject: Re: [PATCH v4 7/9] ManageabilityPkg: Implement Ipmi Protocol/Ppi Thread-Topic: [PATCH v4 7/9] ManageabilityPkg: Implement Ipmi Protocol/Ppi Thread-Index: AQHZXGjpi+UeUKh+skWtVzSfwAvKWq8Jq9bA Date: Fri, 24 Mar 2023 09:25:34 +0000 Message-ID: References: <20230322024840.1629-1-abner.chang@amd.com> <20230322024840.1629-7-abner.chang@amd.com> In-Reply-To: <20230322024840.1629-7-abner.chang@amd.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nvidia.com; x-ms-publictraffictype: Email x-ms-traffictypediagnostic: MW4PR12MB7031:EE_|BL1PR12MB5730:EE_ x-ms-office365-filtering-correlation-id: cc27a32d-a4a4-4500-a8dc-08db2c49b8a5 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: brg3MrtiNZSubIuhxhC27augd35MUe7mJS5AhH9gLCfyDtwxtXpfpDm6cwUz2/7KnGiOzIrUF4KFzEtldS/K8oTjpq9mCDJpuyxKDpsWYr0dXFlLNcK9LqUzPp4LZIRPPvIJgJwwKuIrKAfQX2iareerYsbu0HFNwJKSlCN6vM8SmHencZWHYcXKtc4jw0tOwv9iygSpCiWjHEawJDtJDijfxm3MjVtOldrzGjOUQp8UkqwnEEk2r9IuspLhEOewGe9HPWYtJSLTjwV7EWcLr0frCViiHt7/me91RqWrTdubLtXqLr+qGlbcRa++lAuegwSY8g+ZMwXq29wSTfrHRpuJYafYwfpoNH5kwqomxv/XEcMkTyc1BMaX6PHeKsoOGhPyFYQFc2Ba9FgHax2Wah8iKXxXdZ+US/dL/4U/6OzkhIb7GZSNDK0wmMnTfWXKO5e6hLVQEjjBFKJPth8AhNSAFRqr0AYVOz5rK5yfqgeTUx6SxB83Z9iD98lo6gwvhyZ2ZLuBy4oV4RFV9LPQfWdsompxP5UQQEjUjK6KtfszPJutLzNiT644O4itUab3y39YEIakvfRMe8d/TI06jt+apIFkUC5KmuySs0BZ9D0DxR1UtFaqLthhX0rSe70+MkTrNeQvEjPwNqMebY3Gi1f6oyE1c7JXcTCHYXuByYOj5aUjMx6nXeKR967OUVcAx7dYXIBOiNeJa6CE3LjYJSdZlDcKTXLPbkbuQ3PXiqs= x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:MW4PR12MB7031.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230025)(4636009)(366004)(346002)(39860400002)(376002)(136003)(396003)(451199018)(38070700005)(38100700002)(55016003)(2906002)(83380400001)(478600001)(71200400001)(9686003)(186003)(86362001)(33656002)(7696005)(110136005)(54906003)(30864003)(76116006)(64756008)(66556008)(52536014)(8676002)(66446008)(4326008)(66476007)(66946007)(53546011)(6506007)(26005)(8936002)(316002)(41300700001)(122000001)(5660300002)(579004)(559001)(44824005);DIR:OUT;SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?IiKe7t4PSWzZU41FykvriFPEivZwI/NZ3UxojDaEayUr5vzLsPdRnDKCajTq?= =?us-ascii?Q?LWlBwHWlBeDdtO0B8btDri93CGmdq/pep1WQI9OBsqpmHx26cEwFE2c89TtU?= =?us-ascii?Q?1kBUM9v+i0VAC+Rn2gXI44ac5MYL8o0C+Hdl6c/dXVM3udUpKavQUXI8yMSY?= =?us-ascii?Q?1BA2gu4HwqG/xoQEYKCAHF6F7MudLEgPIrcaA5HJBikeTAOq6y/KGUcvYCcb?= =?us-ascii?Q?3g6xya8I0MA5lNCkMFln8UlvqBVx8x8b8DvDY05pdm3PRRrLNtplc3z5Qefe?= =?us-ascii?Q?qVlpW3v8fkjBIKIVQxUsiOVS+9gHgWv9EI9dFKudBJ5O5cGyPBNrRAIEZxCD?= =?us-ascii?Q?1dd4d1bvWqSuEAkuEvqG3G9WCKl+d++5dUJm8Oeu6fmJkkH7LN4WHKrlp22p?= =?us-ascii?Q?ot/zxt0hX84Z2sduWpIad5fWmePvUCbUsjTa7/Gke6Ev0YpC8+t83UOXBR3A?= =?us-ascii?Q?B/vZ0HlYwpIIghMDT1bhbMnp1EFw7JAmiAMqiKf75sDC/AFChWQXzrV3KFDr?= =?us-ascii?Q?QrmUNKnEpI94clyRngJzU4JA+4lNiPDPhOBOYqapvX0Jx7nKg0Pn0YuuDOZQ?= =?us-ascii?Q?pDnYcdEuCXNp6mEPyMastcEFFmMxCXLBOZnC7bgCC8X8Y+mqGRrvDEzBuunx?= =?us-ascii?Q?oPYV3OUJyikoZXa2nQ5eM/2xGhfN+P3IptxUwknXKZ94en33Ht9SaPGqE99f?= =?us-ascii?Q?Fa7Gee2RE8WnHEyWln590dJRfyUWzYt5ruGaQSRRIzXipo6sKU4bllKXzKCt?= =?us-ascii?Q?wErMQCXl4JM/cYGJ6vah6DKF2lqVg4TwHECxnSzxK4u87VTS+jUNSlCXnhHN?= =?us-ascii?Q?3BCD96l9V+PfBZGfSsHJ9K4McIGEsXDG0btgCSB38UHlQQo5uY4EAeD4Eisj?= =?us-ascii?Q?G5L0crSwDYVjI1/cMdnNnf/LVoLgQEhY5Mf2ajOmCrm0RugmX614Yohc3jhH?= =?us-ascii?Q?z8xppVmzqEX8slz/su2KtqUsfOwj3gvavfj+qofVv9WS5fHTEUajya+kwrxm?= =?us-ascii?Q?SRn1Sq8CxLBKHkeR72XFk06miSRKSOOSGbj+kzIwSoR/ASKo3VYzFOnp+OUN?= =?us-ascii?Q?qrQmWqNcWtb/OtLqB2ektEGT6VyVX0337u/1ngV3gPrswTise5MuelnA/3DI?= =?us-ascii?Q?RpjPfuzdwzPa+JUoSBbPnOdjE5gd0yLatlu6iqr4O/DcwMl0tbW+wWu9N/B1?= =?us-ascii?Q?CDitM/q2HedYw5/oATQJ9L/39ELCHrFtWKQgc+qHoyyWb7zYRjjpJKM8U/Ii?= =?us-ascii?Q?vRFEME/LpI4YlNh//sJR4iAk7vAhXxQRguimHI2eYhp+WuVFVi+jL4Wwvg1u?= =?us-ascii?Q?726nF1u0PKb4By8sHS1yjzOofMWY6y1F9F1iEeNaUN65Ud+nmJ+I0wYTVXaA?= =?us-ascii?Q?ysfK89XzjP9YeuZw+6Xy1OKltWlYabh+8QdfxH9LbvWHtKk/5G8VU8/ijm2X?= =?us-ascii?Q?pSrZJpOoZEtL8h/Dd5hulqtPOBfijRwXFl1TpY06rqSrNWtigrvmgVXMxeel?= =?us-ascii?Q?i1VTw7xH7jcQqXoyp/HpVxDgpFC1a29yDZxz7jMuvLqLxFYFzQ+1nDNR3wTA?= =?us-ascii?Q?I4EnWdQiUi7E51DqjuY=3D?= MIME-Version: 1.0 X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: MW4PR12MB7031.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: cc27a32d-a4a4-4500-a8dc-08db2c49b8a5 X-MS-Exchange-CrossTenant-originalarrivaltime: 24 Mar 2023 09:25:34.4530 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: GkUHgnVnAah0rfE3kkU/2PymxbuL5rAvrJ2UQFbY4Op7FvpKnexqQqbWA7ubLxxdyXcp4qGS6eygfPHd888ytA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL1PR12MB5730 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Nickle Wang Regards, Nickle > -----Original Message----- > From: abner.chang@amd.com > Sent: Wednesday, March 22, 2023 10:49 AM > To: devel@edk2.groups.io > Cc: Liming Gao ; Isaac Oram > ; Nate DeSimone ; > Abdul Lateef Attar ; Nickle Wang ; > Igor Kulchytskyy > Subject: [PATCH v4 7/9] ManageabilityPkg: Implement Ipmi Protocol/Ppi >=20 > External email: Use caution opening links or attachments >=20 >=20 > From: Abner Chang >=20 > Add Ipmi Protocol/Ppi/SMM implementations. > The underlying implementation of transport > interface depends on the binded > ManageabilityTransportLib. >=20 > 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/Common/IpmiProtocolCom > mon.h > create mode 100644 > Features/ManageabilityPkg/Universal/IpmiProtocol/Pei/IpmiPpiInternal.h > create mode 100644 > Features/ManageabilityPkg/Universal/IpmiProtocol/Common/IpmiProtocolCom > mon.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 >=20 > diff --git > a/Features/ManageabilityPkg/Universal/IpmiProtocol/Dxe/IpmiProtocolDxe.in= f > b/Features/ManageabilityPkg/Universal/IpmiProtocol/Dxe/IpmiProtocolDxe.in= f > new file mode 100644 > index 0000000000..ff5ec56c73 > --- /dev/null > +++ > b/Features/ManageabilityPkg/Universal/IpmiProtocol/Dxe/IpmiProtocolDxe.in= f > @@ -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/IpmiPpiPei.inf > b/Features/ManageabilityPkg/Universal/IpmiProtocol/Pei/IpmiPpiPei.inf > 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 > + > +[Ppis] > + gPeiIpmiPpiGuid # PPI ALWAYS PRODUCED > + > +[Guids] > + gManageabilityProtocolIpmiGuid > + gManageabilityTransportKcsGuid > + > +[FixedPcd] > + gEfiMdePkgTokenSpaceGuid.PcdIpmiKcsBaseAddress > + > +[Depex] > + TRUE > diff --git > a/Features/ManageabilityPkg/Universal/IpmiProtocol/Smm/IpmiProtocolSmm.i > nf > b/Features/ManageabilityPkg/Universal/IpmiProtocol/Smm/IpmiProtocolSmm.i > nf > new file mode 100644 > index 0000000000..cae1462f4f > --- /dev/null > +++ > b/Features/ManageabilityPkg/Universal/IpmiProtocol/Smm/IpmiProtocolSmm.i > nf > @@ -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/IpmiProtocolC > ommon.h > b/Features/ManageabilityPkg/Universal/IpmiProtocol/Common/IpmiProtocolC > ommon.h > new file mode 100644 > index 0000000000..57b92cf2be > --- /dev/null > +++ > b/Features/ManageabilityPkg/Universal/IpmiProtocol/Common/IpmiProtocolC > ommon.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_REGISTER_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 > HardwareInformation. > + Caller must free the memory allocated f= or > HardwareInformation > + once it doesn't need it. > + @retval EFI_UNSUPPORTED No hardware information for the > specification specified > + in the transport token. > +**/ > +EFI_STATUS > +SetupIpmiTransportHardwareInformation ( > + IN MANAGEABILITY_TRANSPORT_TOKEN *TransportToken, > + OUT MANAGEABILITY_TRANSPORT_HARDWARE_INFORMATION > *HardwareInformation > + ); > + > +/** > + 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 > completion 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/IpmiPpiInternal.h > b/Features/ManageabilityPkg/Universal/IpmiProtocol/Pei/IpmiPpiInternal.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_PPI_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/IpmiProtocolC > ommon.c > b/Features/ManageabilityPkg/Universal/IpmiProtocol/Common/IpmiProtocolC > ommon.c > new file mode 100644 > index 0000000000..d1294d2f7c > --- /dev/null > +++ > b/Features/ManageabilityPkg/Universal/IpmiProtocol/Common/IpmiProtocolC > ommon.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 > HardwareInformation. > + Caller must free the memory allocated f= or > HardwareInformation > + once it doesn't need it. > + @retval EFI_UNSUPPORTED No hardware information for the > specification specified > + in the transport token. > + #retval EFI_OUT_OF_RESOURCES Not enough memory for > MANAGEABILITY_TRANSPORT_KCS_HARDWARE_INFO. > +**/ > +EFI_STATUS > +SetupIpmiTransportHardwareInformation ( > + IN MANAGEABILITY_TRANSPORT_TOKEN *TransportToken, > + OUT MANAGEABILITY_TRANSPORT_HARDWARE_INFORMATION > *HardwareInformation > + ) > +{ > + 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_TRANSPORT_KCS_HARDWARE_INFO.\n", __FUNCTION__)); > + return EFI_OUT_OF_RESOURCES; > + } > + > + if (CompareGuid (&gManageabilityTransportKcsGuid, TransportToken- > >Transport->ManageabilityTransportSpecification)) { > + // This is KCS transport interface. > + KcsHardwareInfo->MemoryMap =3D > MANAGEABILITY_TRANSPORT_KCS_IO_MAP_IO; > + KcsHardwareInfo->IoBaseAddress.IoAddress16 =3D > IPMI_KCS_BASE_ADDRESS; > + 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_COMMAND; > + 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 > information.", __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- > >Transport->ManageabilityTransportSpecification)) { > + // This is KCS transport interface. > + IpmiHeader =3D AllocateZeroPool (sizeof > (MANAGEABILITY_IPMI_TRANSPORT_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 > completion 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 > SetupIpmiRequestTransportPacket(). > + 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 > MANAGEABILITY_TRANSPORT_NO_TIMEOUT; > + > + // Receive packet. > + TransferToken.ReceivePackage.ReceiveBuffer =3D Response= Data; > + TransferToken.ReceivePackage.ReceiveSizeInByte =3D *Respons= eDataSize; > + TransferToken.ReceivePackage.TransmitTimeoutInMillisecond =3D > MANAGEABILITY_TRANSPORT_NO_TIMEOUT; > + TransportToken->Transport->Function.Version1_0- > >TransportTransmitReceive ( > + 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", > __FUNCTION__)); > + return Status; > + } > + > + if (ResponseDataSize !=3D NULL) { > + *ResponseDataSize =3D TransferToken.ReceivePackage.ReceiveSizeInByte= ; > + } > + return Status; > +} > diff --git > a/Features/ManageabilityPkg/Universal/IpmiProtocol/Dxe/IpmiProtocol.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 > completion 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- > >Transport->ManageabilityTransportSpecification); > + DEBUG ((DEBUG_INFO, "%a: IPMI protocol over %s.\n", __FUNCTION__, > mTransportName)); > + > + // > + // 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 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 > completion 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 > TransportAdditionalStatus; > + MANAGEABILITY_TRANSPORT_HARDWARE_INFORMATION > HardwareInformation; > + > + PeiIpmiPpiinternal =3D (PEI_IPMI_PPI_INTERNAL *)AllocateZeroPool > (sizeof(PEI_IPMI_PPI_INTERNAL)); > + if (PeiIpmiPpiinternal =3D=3D NULL) { > + DEBUG ((DEBUG_ERROR, "%a: Not enough memory for > PEI_IPMI_PPI_INTERNAL.\n", __FUNCTION__)); > + return EFI_OUT_OF_RESOURCES; > + } > + PpiDescriptor =3D (EFI_PEI_PPI_DESCRIPTOR *)AllocateZeroPool > (sizeof(EFI_PEI_PPI_DESCRIPTOR)); > + if (PpiDescriptor =3D=3D NULL) { > + DEBUG ((DEBUG_ERROR, "%a: Not enough memory for > EFI_PEI_PPI_DESCRIPTOR.\n", __FUNCTION__)); > + return EFI_OUT_OF_RESOURCES; > + } > + > + PeiIpmiPpiinternal->Signature =3D > MANAGEABILITY_IPMI_PPI_INTERNAL_SIGNATURE; > + PeiIpmiPpiinternal->PeiIpmiPpi.IpmiSubmitCommand =3D > PeiIpmiSubmitCommand; > + > + PpiDescriptor->Flags =3D EFI_PEI_PPI_DESCRIPTOR_PPI | > EFI_PEI_PPI_DESCRIPTOR_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- > >TransportToken->Transport->ManageabilityTransportSpecification); > + DEBUG ((DEBUG_INFO, "%a: IPMI protocol over %s.\n", __FUNCTION__, > TransportName)); > + > + // > + // 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", > __FUNCTION__, Status)); > + } > + > + return Status; > +} > diff --git > a/Features/ManageabilityPkg/Universal/IpmiProtocol/Smm/IpmiProtocol.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 > completion 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- > >Transport->ManageabilityTransportSpecification); > + DEBUG ((DEBUG_INFO, "%a: IPMI protocol over %s.\n", __FUNCTION__, > mTransportName)); > + > + // > + // 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; > +} > -- > 2.37.1.windows.1