PeiIpmiBmcDef.h 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. /** @file
  2. Generic IPMI transport layer common head file during PEI phase
  3. @copyright
  4. Copyright 2016 - 2021 Intel Corporation. <BR>
  5. SPDX-License-Identifier: BSD-2-Clause-Patent
  6. **/
  7. #ifndef _PEI_IPMI_COMMON_BMC_H_
  8. #define _PEI_IPMI_COMMON_BMC_H_
  9. #include <Ppi/IpmiTransportPpi.h>
  10. #define MAX_TEMP_DATA 160
  11. #define BMC_SLAVE_ADDRESS 0x20
  12. #define MAX_SOFT_COUNT 10
  13. #define COMP_CODE_NORMAL 0x00
  14. //
  15. // IPMI command completion codes to check for in the UpdateErrorStatus routine.
  16. // These completion codes indicate a soft error and a running total of the occurrences
  17. // of these errors is maintained.
  18. //
  19. #define COMP_CODE_NODE_BUSY 0xC0
  20. #define COMP_CODE_TIMEOUT 0xC3
  21. #define COMP_CODE_OUT_OF_SPACE 0xC4
  22. #define COMP_CODE_OUT_OF_RANGE 0xC9
  23. #define COMP_CODE_CMD_RESP_NOT_PROVIDED 0xCE
  24. #define COMP_CODE_FAIL_DUP_REQUEST 0xCF
  25. #define COMP_CODE_SDR_REP_IN_UPDATE_MODE 0xD0
  26. #define COMP_CODE_DEV_IN_FW_UPDATE_MODE 0xD1
  27. #define COMP_CODE_BMC_INIT_IN_PROGRESS 0xD2
  28. #define COMP_CODE_UNSPECIFIED 0xFF
  29. #define COMPLETION_CODES \
  30. { \
  31. COMP_CODE_NODE_BUSY, COMP_CODE_TIMEOUT, COMP_CODE_OUT_OF_SPACE, COMP_CODE_OUT_OF_RANGE, \
  32. COMP_CODE_CMD_RESP_NOT_PROVIDED, COMP_CODE_FAIL_DUP_REQUEST, COMP_CODE_SDR_REP_IN_UPDATE_MODE, \
  33. COMP_CODE_DEV_IN_FW_UPDATE_MODE, COMP_CODE_BMC_INIT_IN_PROGRESS, COMP_CODE_UNSPECIFIED \
  34. }
  35. //
  36. // Ensure proper structure formats
  37. //
  38. #pragma pack(1)
  39. //
  40. // Pei Ipmi instance data
  41. //
  42. typedef struct {
  43. UINTN Signature;
  44. UINT64 KcsTimeoutPeriod;
  45. UINT8 SlaveAddress;
  46. BMC_STATUS BmcStatus;
  47. UINT64 ErrorStatus;
  48. UINT8 SoftErrorCount;
  49. UINT16 IpmiIoBase;
  50. PEI_IPMI_TRANSPORT_PPI IpmiTransportPpi;
  51. EFI_PEI_PPI_DESCRIPTOR PeiIpmiBmcDataDesc;
  52. } PEI_IPMI_BMC_INSTANCE_DATA;
  53. //
  54. // Structure of IPMI Command buffer
  55. //
  56. #define IPMI_COMMAND_HEADER_SIZE 2
  57. typedef struct {
  58. UINT8 Lun : 2;
  59. UINT8 NetFunction : 6;
  60. UINT8 Command;
  61. UINT8 CommandData[MAX_TEMP_DATA - IPMI_COMMAND_HEADER_SIZE];
  62. } IPMI_COMMAND;
  63. //
  64. // Structure of IPMI Command response buffer
  65. //
  66. #define IPMI_RESPONSE_HEADER_SIZE 3
  67. typedef struct {
  68. UINT8 Lun : 2;
  69. UINT8 NetFunction : 6;
  70. UINT8 Command;
  71. UINT8 CompletionCode;
  72. UINT8 ResponseData[MAX_TEMP_DATA - IPMI_RESPONSE_HEADER_SIZE];
  73. } IPMI_RESPONSE;
  74. #pragma pack()
  75. EFI_STATUS
  76. PeiIpmiSendCommandToBmc (
  77. IN PEI_IPMI_TRANSPORT_PPI *This,
  78. IN UINT8 NetFunction,
  79. IN UINT8 Lun,
  80. IN UINT8 Command,
  81. IN UINT8 *CommandData,
  82. IN UINT8 CommandDataSize,
  83. IN OUT UINT8 *ResponseData,
  84. IN OUT UINT8 *ResponseDataSize,
  85. IN VOID *Context
  86. )
  87. /*++
  88. Routine Description:
  89. Send IPMI command to BMC
  90. Arguments:
  91. This - Pointer to IPMI protocol instance
  92. NetFunction - Net Function of command to send
  93. Lun - LUN of command to send
  94. Command - IPMI command to send
  95. CommandData - Pointer to command data buffer, if needed
  96. CommandDataSize - Size of command data buffer
  97. ResponseData - Pointer to response data buffer
  98. ResponseDataSize - Pointer to response data buffer size
  99. Context - Context
  100. Returns:
  101. EFI_INVALID_PARAMETER - One of the input values is bad
  102. EFI_DEVICE_ERROR - IPMI command failed
  103. EFI_BUFFER_TOO_SMALL - Response buffer is too small
  104. EFI_SUCCESS - Command completed successfully
  105. --*/
  106. ;
  107. EFI_STATUS
  108. PeiIpmiBmcStatus (
  109. IN PEI_IPMI_TRANSPORT_PPI *This,
  110. OUT BMC_STATUS *BmcStatus,
  111. OUT SM_COM_ADDRESS *ComAddress,
  112. IN VOID *Context
  113. )
  114. /*++
  115. Routine Description:
  116. Updates the BMC status and returns the Com Address
  117. Arguments:
  118. This - Pointer to IPMI protocol instance
  119. BmcStatus - BMC status
  120. ComAddress - Com Address
  121. Context - Context
  122. Returns:
  123. EFI_SUCCESS - Success
  124. --*/
  125. ;
  126. #endif //_PEI_IPMI_COMMON_BMC_H_