]> git.proxmox.com Git - mirror_edk2.git/blame - MdeModulePkg/Library/SmmIpmiLibSmmIpmiProtocol/SmmIpmiLibSmmIpmiProtocol.c
MdeModulePkg/FaultTolerantWriteDxe: implement standalone MM version
[mirror_edk2.git] / MdeModulePkg / Library / SmmIpmiLibSmmIpmiProtocol / SmmIpmiLibSmmIpmiProtocol.c
CommitLineData
12166c2f
DB
1/** @file\r
2 Implementation of Ipmi Library for SMM.\r
3\r
4 Copyright (c) 2009 - 2015, Intel Corporation. All rights reserved.<BR>\r
5 This program and the accompanying materials\r
6 are licensed and made available under the terms and conditions of the BSD License\r
7 which accompanies this distribution. The full text of the license may be found at\r
8 http://opensource.org/licenses/bsd-license.php.\r
9\r
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
12\r
13**/\r
14\r
15#include <PiSmm.h>\r
16#include <Protocol/IpmiProtocol.h>\r
17#include <Library/IpmiLib.h>\r
18#include <Library/SmmServicesTableLib.h>\r
19#include <Library/DebugLib.h>\r
20\r
21IPMI_PROTOCOL *mIpmiProtocol = NULL;\r
22\r
23/**\r
24 This service enables submitting commands via Ipmi.\r
25\r
26 @param[in] NetFunction Net function of the command.\r
27 @param[in] Command IPMI Command.\r
28 @param[in] RequestData Command Request Data.\r
29 @param[in] RequestDataSize Size of Command Request Data.\r
30 @param[out] ResponseData Command Response Data. The completion code is the first byte of response data.\r
31 @param[in, out] ResponseDataSize Size of Command Response Data.\r
32\r
33 @retval EFI_SUCCESS The command byte stream was successfully submit to the device and a response was successfully received.\r
34 @retval EFI_NOT_FOUND The command was not successfully sent to the device or a response was not successfully received from the device.\r
35 @retval EFI_NOT_READY Ipmi Device is not ready for Ipmi command access.\r
36 @retval EFI_DEVICE_ERROR Ipmi Device hardware error.\r
37 @retval EFI_TIMEOUT The command time out.\r
38 @retval EFI_UNSUPPORTED The command was not successfully sent to the device.\r
39 @retval EFI_OUT_OF_RESOURCES The resource allcation is out of resource or data size error.\r
40**/\r
41EFI_STATUS\r
42EFIAPI\r
43IpmiSubmitCommand (\r
44 IN UINT8 NetFunction,\r
45 IN UINT8 Command,\r
46 IN UINT8 *RequestData,\r
47 IN UINT32 RequestDataSize,\r
48 OUT UINT8 *ResponseData,\r
49 IN OUT UINT32 *ResponseDataSize\r
50 )\r
51{\r
52 EFI_STATUS Status;\r
53\r
54 if (mIpmiProtocol == NULL) {\r
55 Status = gSmst->SmmLocateProtocol (\r
56 &gSmmIpmiProtocolGuid,\r
57 NULL,\r
58 (VOID **) &mIpmiProtocol\r
59 );\r
60 if (EFI_ERROR (Status)) {\r
61 //\r
62 // Smm Ipmi Protocol is not installed. So, IPMI device is not present.\r
63 //\r
64 DEBUG ((EFI_D_ERROR, "IpmiSubmitCommand for SMM Status - %r\n", Status));\r
65 return EFI_NOT_FOUND;\r
66 }\r
67 }\r
68\r
69 Status = mIpmiProtocol->IpmiSubmitCommand (\r
70 mIpmiProtocol,\r
71 NetFunction,\r
72 Command,\r
73 RequestData,\r
74 RequestDataSize,\r
75 ResponseData,\r
76 ResponseDataSize\r
77 );\r
78 if (EFI_ERROR (Status)) {\r
79 return Status;\r
80 }\r
81 return EFI_SUCCESS;\r
82}\r