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