IPMDevice.c 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222
  1. /****************************************************************
  2. ****************************************************************
  3. ** **
  4. ** (C)Copyright 2005-2006, American Megatrends Inc. **
  5. ** **
  6. ** All Rights Reserved. **
  7. ** **
  8. ** 6145-F, Northbelt Parkway, Norcross, **
  9. ** **
  10. ** Georgia - 30071, USA. Phone-(770)-246-8600. **
  11. ** **
  12. ****************************************************************
  13. *****************************************************************
  14. *
  15. * IPMdevice.c
  16. * IPMDevice Commands Handler
  17. *
  18. * Author: Govind Kothandapani <govindk@ami.com>
  19. * : Rama Bisa <ramab@ami.com>
  20. * : Basavaraj Astekar <basavaraja@ami.com>
  21. * : Bakka Ravinder Reddy <bakkar@ami.com>
  22. *
  23. *****************************************************************/
  24. #include <string.h>
  25. #include <stdio.h>
  26. #include "IPMDevice.h"
  27. #include "MsgHndlr.h"
  28. #include "Support.h"
  29. #include "com_IPMIDefs.h"
  30. #include "com_IPMI_IPM.h"
  31. #include "Sensor.h"
  32. #include "main.h"
  33. #include "WDT.h"
  34. //#include "IPMIDef.h"
  35. #include "ChassisTimerTask.h"
  36. #include "com_IPMI_App.h"
  37. #if IPM_DEVICE == 1
  38. /*** Local macro definitions ***/
  39. #define ACPI_SET_SYS_PWR_STATE 0x80
  40. #define ACPI_SET_DEV_PWR_STATE 0x80
  41. #define ACPI_SYS_PWR_STATE_MASK 0x7F
  42. #define ACPI_DEV_PWR_STATE_MASK 0x7F
  43. #define ACPI_MAX_SYS_PWR_STATE 16
  44. #define ACPI_MAX_DEV_PWR_STATE 7
  45. #define ACPI_FLAG_SET 1
  46. #define ACPI_FLAG_UNSET 0
  47. /*** Global Variables ***/
  48. extern WDTTmrMgr_T g_WDTTmrMgr;
  49. //To get the data across the processes added in Shared memory structure in SharedMem.h
  50. // uint8_t g_ACPISysPwrState;
  51. // uint8_t g_ACPIDevPwrState;
  52. /*** Module Variables ***/
  53. #define WORKING_STATE 0x0
  54. #define S1_SLEEPING_STATE 0x1
  55. //notice
  56. static uint8_t MfgID[] = {0x12,0x34,0x56};// /**< Contains Manufacturer ID */
  57. static uint16_t g_ProdID = 0xaabb;
  58. static void GetFirmwareVersion(unsigned int* Major,unsigned int* Minor,unsigned int* Rev)
  59. {
  60. *Major = g_BMCInfo.FwMajorVer;
  61. *Minor = g_BMCInfo.FwMinorVer;
  62. *Rev = 0;
  63. }
  64. /*---------------------------------------
  65. * GetDevID
  66. *---------------------------------------*/
  67. int
  68. GetDevID ( uint8_t* pReq, uint8_t ReqLen, uint8_t* pRes)
  69. {
  70. GetDevIDRes_T* pGetDevIDRes = ( GetDevIDRes_T*) pRes;
  71. static unsigned int Major,Minor,Rev;
  72. static unsigned char MinorBCD;
  73. static int firsttime = 1;
  74. if(firsttime == 1)
  75. {
  76. // printf("Calling get firmware version only for first time\n");
  77. GetFirmwareVersion(&Major,&Minor,&Rev);
  78. MinorBCD = ((Minor/10)<<4)+(Minor%10);
  79. firsttime = 0;
  80. }
  81. pGetDevIDRes->CompletionCode = CC_NORMAL;
  82. pGetDevIDRes->DeviceID = DEVICE_ID;
  83. pGetDevIDRes->DevRevision = IPMI_DEV_REVISION;
  84. pGetDevIDRes->FirmwareRevision1 = Major ;
  85. pGetDevIDRes->FirmwareRevision2 = MinorBCD; //DO NOT CHANGE THIS ASSIGNMENT. INSTEAD SET THE VALUE OF THE VARIABLE Minor IN THE FIRSTTIME LOOP
  86. pGetDevIDRes->IPMIVersion = IPMI_VERSION;
  87. pGetDevIDRes->DevSupport = DEV_SUPPORT;
  88. pGetDevIDRes->ProdID = (g_ProdID);
  89. pGetDevIDRes->AuxFirmwareRevision = Rev;
  90. memcpy (pGetDevIDRes->MfgID, MfgID, sizeof (MfgID));
  91. return sizeof (GetDevIDRes_T);
  92. }
  93. /*---------------------------------------
  94. * ColdReset
  95. *---------------------------------------*/
  96. int
  97. ColdReset ( uint8_t* pReq, uint8_t ReqLen, uint8_t* pRes)
  98. {
  99. MsgPkt_T MsgPkt;
  100. MsgPkt.Param = PARAM_MC;
  101. MsgPkt.NetFnLUN = NETFN_APP<<2;
  102. MsgPkt.Cmd = CMD_COLD_RESET;
  103. PostMsg(gPendActionIfc, &MsgPkt);
  104. *pRes = CC_NORMAL;
  105. return sizeof (*pRes);
  106. }
  107. /*---------------------------------------
  108. * WarmReset
  109. *---------------------------------------*/
  110. int
  111. WarmReset ( uint8_t* pReq, uint8_t ReqLen, uint8_t* pRes)
  112. {
  113. MsgPkt_T MsgPkt;
  114. MsgPkt.Param = PARAM_MC;
  115. MsgPkt.NetFnLUN = NETFN_APP<<2;
  116. MsgPkt.Cmd = CMD_WARM_RESET;
  117. PostMsg(gPendActionIfc, &MsgPkt);
  118. *pRes = CC_NORMAL;
  119. return sizeof (*pRes);
  120. }
  121. /*---------------------------------------
  122. * GetSelfTestResults
  123. *---------------------------------------*/
  124. int
  125. GetSelfTestResults ( uint8_t* pReq, uint8_t ReqLen, uint8_t* pRes)
  126. {
  127. GetSelfTestRes_T* pGetSelfTest = ( GetSelfTestRes_T*) pRes;
  128. pGetSelfTest->CompletionCode = CC_NORMAL;
  129. pGetSelfTest->TestResultByte1 = ( 0 == g_BMCInfo.SelfTestByte ) ?
  130. GST_NO_ERROR: GST_CORRUPTED_DEVICES;
  131. pGetSelfTest->TestResultByte2 = g_BMCInfo.SelfTestByte;
  132. return sizeof (GetSelfTestRes_T);
  133. }
  134. /*---------------------------------------
  135. * MfgTestOn
  136. *---------------------------------------*/
  137. int
  138. MfgTestOn ( uint8_t* pReq, uint8_t ReqLen, uint8_t* pRes)
  139. {
  140. printf("MfgTestOn not implement\r\n");
  141. *pRes = CC_NORMAL;
  142. return sizeof (*pRes);
  143. }
  144. /*---------------------------------------
  145. * SetACPIPwrState
  146. *---------------------------------------*/
  147. int
  148. SetACPIPwrState ( uint8_t* pReq, uint8_t ReqLen, uint8_t* pRes)
  149. {
  150. printf("SetACPIPwrState not implement\r\n");
  151. *pRes = CC_NORMAL;
  152. return sizeof (*pRes);
  153. }
  154. /*---------------------------------------
  155. * GetACPIPwrState
  156. *---------------------------------------*/
  157. int
  158. GetACPIPwrState ( uint8_t* pReq, uint8_t ReqLen, uint8_t* pRes)
  159. {
  160. GetACPIPwrStateRes_T* pGetACPIRes = ( GetACPIPwrStateRes_T*) pRes;
  161. printf("GetACPIPwrState not implement\r\n");
  162. pGetACPIRes->CompletionCode = CC_NORMAL;
  163. pGetACPIRes->ACPISysPwrState = 0;//BMC_GET_SHARED_MEM (BMCInst)-> m_ACPISysPwrState;
  164. pGetACPIRes->ACPIDevPwrState = 0;//BMC_GET_SHARED_MEM (BMCInst)->m_ACPIDevPwrState;
  165. return sizeof (GetACPIPwrStateRes_T);
  166. }
  167. /*---------------------------------------
  168. * GetDevGUID
  169. *---------------------------------------*/
  170. int
  171. GetDevGUID ( uint8_t* pReq, uint8_t ReqLen, uint8_t* pRes)
  172. {
  173. GetDevGUIDRes_T* pGetDevGUIDRes = ( GetDevGUIDRes_T*) pRes;
  174. pGetDevGUIDRes->CompletionCode = CC_NORMAL;
  175. memcpy (pGetDevGUIDRes->Node, g_BMCInfo.DeviceGUID, 16);
  176. return sizeof (GetDevGUIDRes_T);
  177. }
  178. #endif /* IPM_DEVICE */