]> git.proxmox.com Git - mirror_edk2.git/blob - MdeModulePkg/Library/DxeIpmiLibIpmiProtocol/DxeIpmiLibIpmiProtocol.c
MdeModulePkg: Replace BSD License with BSD+Patent License
[mirror_edk2.git] / MdeModulePkg / Library / DxeIpmiLibIpmiProtocol / DxeIpmiLibIpmiProtocol.c
1 /** @file
2 Implementation of Ipmi Library in DXE Phase for SMS.
3
4 Copyright (c) 2009 - 2015, Intel Corporation. All rights reserved.<BR>
5 SPDX-License-Identifier: BSD-2-Clause-Patent
6
7 **/
8
9 #include <PiDxe.h>
10 #include <Protocol/IpmiProtocol.h>
11 #include <Library/UefiBootServicesTableLib.h>
12 #include <Library/DebugLib.h>
13
14 IPMI_PROTOCOL *mIpmiProtocol = NULL;
15
16 /**
17 This service enables submitting commands via Ipmi.
18
19 @param[in] NetFunction Net function of the command.
20 @param[in] Command IPMI Command.
21 @param[in] RequestData Command Request Data.
22 @param[in] RequestDataSize Size of Command Request Data.
23 @param[out] ResponseData Command Response Data. The completion code is the first byte of response data.
24 @param[in, out] ResponseDataSize Size of Command Response Data.
25
26 @retval EFI_SUCCESS The command byte stream was successfully submit to the device and a response was successfully received.
27 @retval EFI_NOT_FOUND The command was not successfully sent to the device or a response was not successfully received from the device.
28 @retval EFI_NOT_READY Ipmi Device is not ready for Ipmi command access.
29 @retval EFI_DEVICE_ERROR Ipmi Device hardware error.
30 @retval EFI_TIMEOUT The command time out.
31 @retval EFI_UNSUPPORTED The command was not successfully sent to the device.
32 @retval EFI_OUT_OF_RESOURCES The resource allcation is out of resource or data size error.
33 **/
34 EFI_STATUS
35 EFIAPI
36 IpmiSubmitCommand (
37 IN UINT8 NetFunction,
38 IN UINT8 Command,
39 IN UINT8 *RequestData,
40 IN UINT32 RequestDataSize,
41 OUT UINT8 *ResponseData,
42 IN OUT UINT32 *ResponseDataSize
43 )
44 {
45 EFI_STATUS Status;
46
47 if (mIpmiProtocol == NULL) {
48 Status = gBS->LocateProtocol (
49 &gIpmiProtocolGuid,
50 NULL,
51 (VOID **) &mIpmiProtocol
52 );
53 if (EFI_ERROR (Status)) {
54 //
55 // Dxe Ipmi Protocol is not installed. So, IPMI device is not present.
56 //
57 DEBUG ((EFI_D_ERROR, "IpmiSubmitCommand in Dxe Phase under SMS Status - %r\n", Status));
58 return EFI_NOT_FOUND;
59 }
60 }
61
62 Status = mIpmiProtocol->IpmiSubmitCommand (
63 mIpmiProtocol,
64 NetFunction,
65 Command,
66 RequestData,
67 RequestDataSize,
68 ResponseData,
69 ResponseDataSize
70 );
71 if (EFI_ERROR (Status)) {
72 return Status;
73 }
74 return EFI_SUCCESS;
75 }