Daocheng: This is a typo? + &gSmmIpmiProtocolGuidx,
Thanks Liming -----Original Message----- From: edk2-devel [mailto:[email protected]] On Behalf Of Daocheng Bu Sent: Wednesday, December 16, 2015 9:51 PM To: [email protected] Cc: Yao, Jiewen Subject: [edk2] [Patch] MdeModulePkg: Add SmmIpmiLibSmmIpmiProtocol Library Class. Add SmmIpmiLibSmmIpmiProtocol Library Class that will depend on Ipmi stack smm driver produces Ipmi Protocol in SMM mode. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Daocheng Bu <[email protected]> CC: Jiewen Yao <[email protected]> --- .../SmmIpmiLibSmmIpmiProtocol.c | 76 ++++++++++++++++++++++ .../SmmIpmiLibSmmIpmiProtocol.inf | 41 ++++++++++++ 2 files changed, 117 insertions(+) create mode 100644 MdeModulePkg/Library/SmmIpmiLibSmmIpmiProtocol/SmmIpmiLibSmmIpmiProtocol.c create mode 100644 MdeModulePkg/Library/SmmIpmiLibSmmIpmiProtocol/SmmIpmiLibSmmIpmiProtocol.inf diff --git a/MdeModulePkg/Library/SmmIpmiLibSmmIpmiProtocol/SmmIpmiLibSmmIpmiProtocol.c b/MdeModulePkg/Library/SmmIpmiLibSmmIpmiProtocol/SmmIpmiLibSmmIpmiProtocol.c new file mode 100644 index 0000000..d9f6365 --- /dev/null +++ b/MdeModulePkg/Library/SmmIpmiLibSmmIpmiProtocol/SmmIpmiLibSmmIpmiPr +++ otocol.c @@ -0,0 +1,76 @@ +/** @file + Implementation of Ipmi Library for SMM. + + Copyright (c) 2009 - 2015, Intel Corporation. All rights + reserved.<BR> This program and the accompanying materials are + licensed and made available under the terms and conditions of the BSD + License which accompanies this distribution. The full text of the + license may be found at http://opensource.org/licenses/bsd-license.php. + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ + +#include <PiDxe.h> +#include <Protocol/IpmiTransportProtocol.h> +#include <Library/IpmiLib.h> +#include <Library/UefiBootServicesTableLib.h> +#include <Library/SmmServicesTableLib.h> #include <Library/DebugLib.h> + +IPMI_PROTOCOL *mIpmiProtocol = NULL; + +/** + This service enables submitting commands via Ipmi. + + @param[in] NetFunction Net function of the command. + @param[in] Command IPMI Command. + @param[in] CommandData Command Data. + @param[in] CommandDataSize Size of Command Data. + @param[out] ResponseData Command Response Data. + @param[in out] ResponseDataSize Size of Command Response Data. + + @retval EFI_SUCCESS The command byte stream was successfully sent to the device and a response was successfully received. + @retval EFI_NOT_FOUND The command was not successfully sent to the device or a response was not successfully received from the device. +**/ +EFI_STATUS +IpmiSubmitCommand ( + IN UINT8 NetFunction, + IN UINT8 Command, + IN UINT8 *CommandData, + IN UINT8 CommandDataSize, + OUT UINT8 *ResponseData, + IN OUT UINT8 *ResponseDataSize +{ + EFI_STATUS Status; + + if (mIpmiProtocol == NULL) { + Status = gSmst->SmmLocateProtocol ( + &gSmmIpmiProtocolGuidx, + NULL, + (VOID **) &mIpmiProtocol + ); + if (EFI_ERROR (Status)) { + // + // Smm Ipmi Protocol is not installed. So, IPMI device is not present. + // + DEBUG ((EFI_D_ERROR, "IpmiSubmitCommand for SMM Status - %r\n", Status)); + return EFI_NOT_FOUND; + } + } + + Status = mIpmiProtocol->SendIpmiCommand ( + mIpmiProtocol, + NetFunction, + Command, + CommandData, + CommandDataSize, + ResponseData, + ResponseDataSize + ); + if (EFI_ERROR (Status)) { + return Status; + } + return EFI_SUCCESS; +} \ No newline at end of file diff --git a/MdeModulePkg/Library/SmmIpmiLibSmmIpmiProtocol/SmmIpmiLibSmmIpmiProtocol.inf b/MdeModulePkg/Library/SmmIpmiLibSmmIpmiProtocol/SmmIpmiLibSmmIpmiProtocol.inf new file mode 100644 index 0000000..34a3888 --- /dev/null +++ b/MdeModulePkg/Library/SmmIpmiLibSmmIpmiProtocol/SmmIpmiLibSmmIpmiPr +++ otocol.inf @@ -0,0 +1,41 @@ +## @file +# Instance of SMM IPMI Library. +# +# Copyright (c) 2009 - 2015, Intel Corporation. All rights +reserved.<BR> # # This program and the accompanying materials # are +licensed and made available under the terms and conditions of the BSD +License # which accompanies this distribution. The full text of the +license may be found at # http://opensource.org/licenses/bsd-license.php. +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" +BASIS, # WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +# +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = SmmIpmiLibSmmIpmiProtocol + FILE_GUID = B422FB70-E835-448D-A921-EBA460E105B6 + MODULE_TYPE = DXE_SMM_DRIVER + VERSION_STRING = 1.0 + LIBRARY_CLASS = IpmiLib|DXE_SMM_DRIVER SMM_CORE + +# +# VALID_ARCHITECTURES = IA32 X64 +# + +[Sources] + SmmIpmiLibSmmIpmiProtocol.c + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + +[LibraryClasses] + UefiBootServicesTableLib + DebugLib + SmmServicesTableLib + +[Protocols] + gSmmIpmiProtocolGuid \ No newline at end of file -- 2.5.1.windows.1 _______________________________________________ edk2-devel mailing list [email protected] https://lists.01.org/mailman/listinfo/edk2-devel _______________________________________________ edk2-devel mailing list [email protected] https://lists.01.org/mailman/listinfo/edk2-devel

