Home | History | Annotate | Download | only in SmmIpmiLibSmmIpmiProtocol
      1 /** @file
      2   Implementation of Ipmi Library for SMM.
      3 
      4   Copyright (c) 2009 - 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 <PiSmm.h>
     16 #include <Protocol/IpmiProtocol.h>
     17 #include <Library/IpmiLib.h>
     18 #include <Library/SmmServicesTableLib.h>
     19 #include <Library/DebugLib.h>
     20 
     21 IPMI_PROTOCOL *mIpmiProtocol = NULL;
     22 
     23 /**
     24   This service enables submitting commands via Ipmi.
     25 
     26   @param[in]         NetFunction       Net function of the command.
     27   @param[in]         Command           IPMI Command.
     28   @param[in]         RequestData       Command Request Data.
     29   @param[in]         RequestDataSize   Size of Command Request Data.
     30   @param[out]        ResponseData      Command Response Data. The completion code is the first byte of response data.
     31   @param[in, out]    ResponseDataSize  Size of Command Response Data.
     32 
     33   @retval EFI_SUCCESS            The command byte stream was successfully submit to the device and a response was successfully received.
     34   @retval EFI_NOT_FOUND          The command was not successfully sent to the device or a response was not successfully received from the device.
     35   @retval EFI_NOT_READY          Ipmi Device is not ready for Ipmi command access.
     36   @retval EFI_DEVICE_ERROR       Ipmi Device hardware error.
     37   @retval EFI_TIMEOUT            The command time out.
     38   @retval EFI_UNSUPPORTED        The command was not successfully sent to the device.
     39   @retval EFI_OUT_OF_RESOURCES   The resource allcation is out of resource or data size error.
     40 **/
     41 EFI_STATUS
     42 EFIAPI
     43 IpmiSubmitCommand (
     44   IN     UINT8     NetFunction,
     45   IN     UINT8     Command,
     46   IN     UINT8     *RequestData,
     47   IN     UINT32    RequestDataSize,
     48      OUT UINT8     *ResponseData,
     49   IN OUT UINT32    *ResponseDataSize
     50   )
     51 {
     52   EFI_STATUS  Status;
     53 
     54   if (mIpmiProtocol == NULL) {
     55     Status = gSmst->SmmLocateProtocol (
     56                   &gSmmIpmiProtocolGuid,
     57                   NULL,
     58                   (VOID **) &mIpmiProtocol
     59                   );
     60     if (EFI_ERROR (Status)) {
     61       //
     62       // Smm Ipmi Protocol is not installed. So, IPMI device is not present.
     63       //
     64       DEBUG ((EFI_D_ERROR, "IpmiSubmitCommand for SMM Status - %r\n", Status));
     65       return EFI_NOT_FOUND;
     66     }
     67   }
     68 
     69   Status = mIpmiProtocol->IpmiSubmitCommand (
     70                             mIpmiProtocol,
     71                             NetFunction,
     72                             Command,
     73                             RequestData,
     74                             RequestDataSize,
     75                             ResponseData,
     76                             ResponseDataSize
     77                             );
     78   if (EFI_ERROR (Status)) {
     79     return Status;
     80   }
     81   return EFI_SUCCESS;
     82 }
     83