IpmiProtocolCommon.h 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. /** @file
  2. IPMI Manageability Protocol common header file.
  3. Copyright (C) 2023 Advanced Micro Devices, Inc. All rights reserved.<BR>
  4. SPDX-License-Identifier: BSD-2-Clause-Patent
  5. **/
  6. #ifndef MANAGEABILITY_IPMI_COMMON_H_
  7. #define MANAGEABILITY_IPMI_COMMON_H_
  8. #include <IndustryStandard/IpmiKcs.h>
  9. #include <Library/ManageabilityTransportLib.h>
  10. ///
  11. /// IPMI KCS hardware information.
  12. ///
  13. #define IPMI_KCS_BASE_ADDRESS PcdGet16 (PcdIpmiKcsIoBaseAddress)
  14. #define IPMI_KCS_REG_DATA_IN IPMI_KCS_BASE_ADDRESS + IPMI_KCS_DATA_IN_REGISTER_OFFSET
  15. #define IPMI_KCS_REG_DATA_OUT IPMI_KCS_BASE_ADDRESS + IPMI_KCS_DATA_OUT_REGISTER_OFFSET
  16. #define IPMI_KCS_REG_COMMAND IPMI_KCS_BASE_ADDRESS + IPMI_KCS_COMMAND_REGISTER_OFFSET
  17. #define IPMI_KCS_REG_STATUS IPMI_KCS_BASE_ADDRESS + IPMI_KCS_STATUS_REGISTER_OFFSET
  18. /**
  19. This functions setup the IPMI transport hardware information according
  20. to the specification of transport token acquired from transport library.
  21. @param[in] TransportToken The transport interface.
  22. @param[out] HardwareInformation Pointer to receive the hardware information.
  23. @retval EFI_SUCCESS Hardware information is returned in HardwareInformation.
  24. Caller must free the memory allocated for HardwareInformation
  25. once it doesn't need it.
  26. @retval EFI_UNSUPPORTED No hardware information for the specification specified
  27. in the transport token.
  28. **/
  29. EFI_STATUS
  30. SetupIpmiTransportHardwareInformation (
  31. IN MANAGEABILITY_TRANSPORT_TOKEN *TransportToken,
  32. OUT MANAGEABILITY_TRANSPORT_HARDWARE_INFORMATION *HardwareInformation
  33. );
  34. /**
  35. This functions setup the final header/body/trailer packets for
  36. the acquired transport interface.
  37. @param[in] TransportToken The transport interface.
  38. @param[in] NetFunction IPMI function.
  39. @param[in] Command IPMI command.
  40. @param[out] PacketHeader The pointer to receive header of request.
  41. @param[in, out] PacketBody The request body.
  42. When IN, it is the caller's request body.
  43. When OUT and NULL, the request body is not
  44. changed.
  45. Whee out and non-NULL, the request body is
  46. changed to comfort the transport interface.
  47. @param[in, out] PacketBodySize The request body size.
  48. When IN and non-zero, it is the new data
  49. length of request body.
  50. When IN and zero, the request body is unchanged.
  51. @param[out] PacketTrailer The pointer to receive trailer of request.
  52. @retval EFI_SUCCESS Request packet is returned.
  53. @retval EFI_UNSUPPORTED Request packet is not returned because
  54. the unsupported transport interface.
  55. **/
  56. EFI_STATUS
  57. SetupIpmiRequestTransportPacket (
  58. IN MANAGEABILITY_TRANSPORT_TOKEN *TransportToken,
  59. IN UINT8 NetFunction,
  60. IN UINT8 Command,
  61. OUT MANAGEABILITY_TRANSPORT_HEADER *PacketHeader OPTIONAL,
  62. IN OUT UINT8 **PacketBody OPTIONAL,
  63. IN OUT UINT32 *PacketBodySize OPTIONAL,
  64. OUT MANAGEABILITY_TRANSPORT_TRAILER *PacketTrailer OPTIONAL
  65. );
  66. /**
  67. Common code to submit IPMI commands
  68. @param[in] TransportToken TRansport token.
  69. @param[in] NetFunction Net function of the command.
  70. @param[in] Command IPMI Command.
  71. @param[in] RequestData Command Request Data.
  72. @param[in] RequestDataSize Size of Command Request Data.
  73. @param[out] ResponseData Command Response Data. The completion code is the first byte of response data.
  74. @param[in, out] ResponseDataSize Size of Command Response Data.
  75. @retval EFI_SUCCESS The command byte stream was successfully submit to the device and a response was successfully received.
  76. @retval EFI_NOT_FOUND The command was not successfully sent to the device or a response was not successfully received from the device.
  77. @retval EFI_NOT_READY Ipmi Device is not ready for Ipmi command access.
  78. @retval EFI_DEVICE_ERROR Ipmi Device hardware error.
  79. @retval EFI_TIMEOUT The command time out.
  80. @retval EFI_UNSUPPORTED The command was not successfully sent to the device.
  81. @retval EFI_OUT_OF_RESOURCES The resource allocation is out of resource or data size error.
  82. **/
  83. EFI_STATUS
  84. CommonIpmiSubmitCommand (
  85. IN MANAGEABILITY_TRANSPORT_TOKEN *TransportToken,
  86. IN UINT8 NetFunction,
  87. IN UINT8 Command,
  88. IN UINT8 *RequestData OPTIONAL,
  89. IN UINT32 RequestDataSize,
  90. OUT UINT8 *ResponseData OPTIONAL,
  91. IN OUT UINT32 *ResponseDataSize OPTIONAL
  92. );
  93. #endif