PEFDevice.c 43 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147
  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. *
  16. * PEFDevice.c
  17. * PEF Commands Handler
  18. *
  19. * Author: Govind Kothandapani <govindk@ami.com>
  20. * : Rama Bisa <ramab@ami.com>
  21. * : Basavaraj Astekar <basavaraja@ami.com>
  22. * : Bakka Ravinder Reddy <bakkar@ami.com>
  23. *
  24. *****************************************************************/
  25. #define ENABLE_DEBUG_MACROS 0
  26. #include "Types.h"
  27. #include "PEFDevice.h"
  28. #include "Support.h"
  29. #include "Debug.h"
  30. #include "MsgHndlr.h"
  31. #include "IPMIDefs.h"
  32. #include "NVRAccess.h"
  33. #include "SharedMem.h"
  34. #include "IPMI_PEF.h"
  35. #include "IPMI_IPM.h"
  36. #include "PEFTmr.h"
  37. #include "PEF.h"
  38. #include "SEL.h"
  39. #include "IPMI_Main.h"
  40. #include "Util.h"
  41. #include"Ethaddr.h"
  42. #include "IPMIConf.h"
  43. /* Reserved bit macro definitions */
  44. #define RESERVED_BITS_SETLASTPROCESSEDEVENTID 0xFE //(BIT7 | BIT6 | BIT5 | BIT4 | BIT3 | BIT2 | BIT1 | BIT0)
  45. #define RESERVED_BITS_ALERTIMMEDIATE_CH 0xF0 //(BIT7 | BIT6 | BIT5 |BIT4)
  46. #define RESERVED_BITS_ALERTIMMEDIATE_DESTSEL 0x30 //(BIT5 |BIT4)
  47. #if PEF_DEVICE == 1
  48. /*** Local Macro Definitions ***/
  49. #define IPMI_PEF_VERSION 0x51
  50. #define ARM_PEF_TMR_DISABLE 0x00
  51. #define ARM_PEF_TEMP_DISABLE 0xFE
  52. #define ARM_PEF_TMR_REQ_GET_TIME 0xFF
  53. #define ALERT_IMD_OPERATION 0x80
  54. #define ACT_SUPPORT_DIAG_INT 0x20
  55. #define ACT_SUPPORT_OEM_ACTION 0x10
  56. #define ACT_SUPPORT_POWER_CYC 0x08
  57. #define ACT_SUPPORT_RESET 0x04
  58. #define ACT_SUPPORT_POWER_DOWN 0x02
  59. #define ACT_SUPPORT_ALERT 0x01
  60. #define SET_IN_PROGRESS 0
  61. #define PEF_SET_COMPLETE 0
  62. #define PEF_SET_IN_PROGRESS 1
  63. #define PEF_COMMIT_WRITE 2
  64. #define BIT4_BIT0_MASK 0x1f
  65. #define BIT1_BIT0_MASK 0x3
  66. #define RESERVED_VALUE_03 0x3
  67. #define RESERVED_VALUE_01 0x1
  68. #define PRECONFIGURED_FILTER 0x2
  69. #define BIT7_BIT6_MASK 0xC0
  70. /* Reserved Bits */
  71. #define RESERVED_VALUE_80 0x80
  72. /*** Module Variables ***/
  73. static const INT8U m_PEFReqLen[] =
  74. {1, 1, 1, 1, 1, 1, 21, 2, 1, 4, 17, 1, 3}; /**< Contains PEF Coniguration parameter Length */
  75. /* Reserved Bits table */
  76. #define MAX_PEF_PARAMS_DATA 20
  77. typedef struct
  78. {
  79. INT8U Params;
  80. INT8U ReservedBits [MAX_PEF_PARAMS_DATA];
  81. INT8U DataLen;
  82. } PEFCfgRsvdBits_T;
  83. static PEFCfgRsvdBits_T m_RsvdBitsCheck [] = {
  84. /* Param Reserved Bits Data Size */
  85. { 0x00, {0xFC}, 0x01 },
  86. { 0x01, {0xF0 }, 0x01 }, /* Volatile PEF ACtion global control */
  87. { 0x02, {0xC0 }, 0x01 }, /* Non Volatile PEF Action global control */
  88. { 0x06, {0x80}, 0x01 },
  89. { 0x07, {0x80}, 0x01 },
  90. { 0x09, {0x80}, 0x01 },
  91. { 0x0A, {0xFE}, 0x01 },
  92. { 0x0C, {0x80,0x80 ,0x80}, 0x03 },
  93. { 0x0D, {0x80}, 0x01 }
  94. };
  95. static _FAR_ SELEventRecord_T m_AlertImmRecord = /**< Contains Event Record for Alert Immidiate command */
  96. {
  97. {
  98. 0xFFFF, /*Record ID */
  99. 0x2, /*Type of the record */
  100. 1 /*Timestamp */
  101. },
  102. {
  103. 0x40, /*Generator ID */
  104. 0x00
  105. },
  106. 0x4, /*Revision*/
  107. 0x12, /*Sensor type */
  108. 0x51, /*Sensor number */
  109. 0x6f, /*Event type */
  110. 0x04,0xFF,0xFF /*Event Data 1..3 */
  111. };
  112. /*---------------------------------------
  113. * GetPEFCapabilities
  114. *---------------------------------------*/
  115. int
  116. GetPEFCapabilities (_NEAR_ INT8U* pReq, INT8U ReqLen, _NEAR_ INT8U* pRes,_NEAR_ int BMCInst)
  117. {
  118. _NEAR_ GetPEFCapRes_T* pGetPEFCapRes = (_NEAR_ GetPEFCapRes_T*)pRes;
  119. pGetPEFCapRes->CompletionCode = CC_NORMAL;
  120. pGetPEFCapRes->PEFVersion = IPMI_PEF_VERSION;
  121. pGetPEFCapRes->ActionSupport = ACT_SUPPORT_DIAG_INT | ACT_SUPPORT_OEM_ACTION | ACT_SUPPORT_POWER_CYC |
  122. ACT_SUPPORT_RESET | ACT_SUPPORT_POWER_DOWN |
  123. ACT_SUPPORT_ALERT,
  124. pGetPEFCapRes->TotalEntries = MAX_EVT_FILTER_ENTRIES;
  125. return sizeof (GetPEFCapRes_T);
  126. }
  127. /*---------------------------------------
  128. * ArmPEFPostponeTimer
  129. *---------------------------------------*/
  130. int
  131. ArmPEFPostponeTimer (_NEAR_ INT8U* pReq, INT8U ReqLen, _NEAR_ INT8U* pRes,_NEAR_ int BMCInst)
  132. {
  133. _NEAR_ ArmPEFTmrRes_T* pArmPEFTmrRes = (_NEAR_ ArmPEFTmrRes_T*)pRes;
  134. _FAR_ PEFConfig_T* pNVRPEFConfig;
  135. BMCInfo_t *pBMCInfo = &g_BMCInfo[BMCInst];
  136. OS_THREAD_MUTEX_ACQUIRE(&pBMCInfo->PefConfig.PEFSharedMemMutex,WAIT_INFINITE);
  137. pNVRPEFConfig = &pBMCInfo->PEFConfig;
  138. switch (*pReq)
  139. {
  140. case ARM_PEF_TEMP_DISABLE:
  141. IPMI_DBG_PRINT ("ARM_PEF_TMR_DISABLE\n");
  142. /* Disable PEF Temporarily */
  143. g_BMCInfo[BMCInst].PefConfig.PEFTmrMgr.TmrInterval = ARM_PEF_TEMP_DISABLE;
  144. g_BMCInfo[BMCInst].PefConfig.PEFTmrMgr.InitCountDown = ARM_PEF_TEMP_DISABLE;
  145. // Timer Interval and InitCountdown not set to ARM_PEF_TEMP_DISABLE if originally PEF was disabled
  146. g_BMCInfo[BMCInst].PefConfig.PEFTmrMgr.TmrArmed = FALSE;
  147. g_BMCInfo[BMCInst].PefConfig.PEFTmrMgr.StartTmr = FALSE;
  148. g_BMCInfo[BMCInst].PefConfig.PEFTmrMgr.TakePEFAction = FALSE;
  149. break;
  150. case ARM_PEF_TMR_DISABLE:
  151. IPMI_DBG_PRINT ("ARM_PEF_TMR_TEMP_DISABLE\n");
  152. /* Check if PEF Temporary Disable was called earlier and then Disable the PEFTmr */
  153. if (g_BMCInfo[BMCInst].PefConfig.PEFTmrMgr.TmrInterval == ARM_PEF_TEMP_DISABLE)
  154. {
  155. g_BMCInfo[BMCInst].PefConfig.PEFTmrMgr.TakePEFAction = TRUE;
  156. }
  157. else
  158. g_BMCInfo[BMCInst].PefConfig.PEFTmrMgr.TakePEFAction = FALSE;
  159. g_BMCInfo[BMCInst].PefConfig.PEFTmrMgr.TmrArmed = FALSE;
  160. g_BMCInfo[BMCInst].PefConfig.PEFTmrMgr.StartTmr = FALSE;
  161. g_BMCInfo[BMCInst].PefConfig.PEFTmrMgr.TmrInterval = ARM_PEF_TMR_DISABLE;
  162. g_BMCInfo[BMCInst].PefConfig.PEFTmrMgr.InitCountDown = ARM_PEF_TMR_DISABLE;
  163. break;
  164. case ARM_PEF_TMR_REQ_GET_TIME:
  165. IPMI_DBG_PRINT ("ARM_PEF_TMR_REQ_GET_TIME\n");
  166. break;
  167. default:
  168. /* Other values correspond to arm timer */
  169. IPMI_DBG_PRINT ("DEFAULT\n");
  170. /* Check if PEF Temporary Disable was called earlier and then set the PEFTmr */
  171. g_BMCInfo[BMCInst].PefConfig.PEFTmrMgr.InitCountDown = *pReq;
  172. g_BMCInfo[BMCInst].PefConfig.PEFTmrMgr.TmrInterval = *pReq;
  173. g_BMCInfo[BMCInst].PefConfig.PEFTmrMgr.TmrArmed = TRUE;
  174. g_BMCInfo[BMCInst].PefConfig.PEFTmrMgr.StartTmr = FALSE;
  175. g_BMCInfo[BMCInst].PefConfig.PEFTmrMgr.TakePEFAction = FALSE;
  176. }
  177. pArmPEFTmrRes->PresentTmrVal = g_BMCInfo[BMCInst].PefConfig.PEFTmrMgr.TmrInterval;
  178. pArmPEFTmrRes->CompletionCode = CC_NORMAL;
  179. OS_THREAD_MUTEX_RELEASE(&pBMCInfo->PefConfig.PEFSharedMemMutex);
  180. return sizeof (ArmPEFTmrRes_T);
  181. }
  182. /*---------------------------------------
  183. * SetPEFConfigParams
  184. *---------------------------------------*/
  185. int
  186. SetPEFConfigParams (_NEAR_ INT8U* pReq, INT8U ReqLen, _NEAR_ INT8U* pRes,_NEAR_ int BMCInst)
  187. {
  188. INT8U ParamSel;
  189. _FAR_ PEFConfig_T* pNvrPefConfig;
  190. _FAR_ BMCInfo_t* pBMCInfo = &g_BMCInfo[BMCInst];
  191. int i = 0, j = 0;
  192. INT8U tmp=0;
  193. _FAR_ INT8U m_PEF_SetInProgress; /**< Contains setting PEF configuration status */
  194. int ret;
  195. /* Store ParamSel */
  196. ParamSel = pReq[0];
  197. /* Check the Length of the request data */
  198. if (((ParamSel < 13) && ((ReqLen - 1) != m_PEFReqLen[ParamSel])) ||
  199. (ReqLen == 0))
  200. {
  201. *pRes = CC_REQ_INV_LEN;
  202. return sizeof (*pRes);
  203. }
  204. if (pReq[0] & RESERVED_VALUE_80)
  205. {
  206. /* Alarm !!! Somebody is trying to set Reseved Bits */
  207. *pRes = CC_INV_DATA_FIELD;
  208. return sizeof (*pRes);
  209. }
  210. /* Check for Unsupported parameter */
  211. if (ParamSel > 95)
  212. {
  213. *pRes = CC_PEF_PARAM_NOT_SUPPORTED;
  214. return sizeof (*pRes);
  215. }
  216. /* Check for Reserved Bits */
  217. for (i = 0; i < sizeof (m_RsvdBitsCheck)/ sizeof (m_RsvdBitsCheck[0]); i++)
  218. {
  219. /* Check if this Parameter Selector needs Reserved bit checking !! */
  220. if (m_RsvdBitsCheck[i].Params == ParamSel)
  221. {
  222. IPMI_DBG_PRINT_2 ("Param - %x, DataLen - %x\n", ParamSel, m_RsvdBitsCheck[i].DataLen);
  223. for (j = 0; j < m_RsvdBitsCheck[i].DataLen; j++)
  224. {
  225. IPMI_DBG_PRINT_2 ("Cmp %x, %x\n", pReq[1+j], m_RsvdBitsCheck[i].ReservedBits[j]);
  226. if ( 0 != (pReq[1+j] & m_RsvdBitsCheck[i].ReservedBits[j]))
  227. {
  228. /* Alarm !!! Somebody is trying to set Reseved Bits */
  229. *pRes = CC_INV_DATA_FIELD;
  230. return sizeof (*pRes);
  231. }
  232. }
  233. }
  234. }
  235. OS_THREAD_MUTEX_ACQUIRE(&pBMCInfo->PefConfig.PEFSharedMemMutex,WAIT_INFINITE);
  236. /*Get NVRAM PEF Configuration parameters */
  237. pNvrPefConfig = &pBMCInfo->PEFConfig;
  238. if ( g_PDKHandle[PDK_BEFORESETPEFCFG] != NULL )
  239. {
  240. ret =((int(*)(INT8U *, INT8U, INT8U *,int))(g_PDKHandle[PDK_BEFORESETPEFCFG]))(pReq, ReqLen,pRes,BMCInst);
  241. if(ret != 0)
  242. {
  243. return ret;
  244. }
  245. }
  246. switch (ParamSel)
  247. {
  248. case SET_IN_PROGRESS:
  249. /*Parameter 0 volatile */
  250. /* Only Set inProgress and Set Complete are implemented */
  251. if( (PEF_SET_IN_PROGRESS != pReq[1]) && (PEF_SET_COMPLETE != pReq[1]) )
  252. {
  253. *pRes = CC_PARAM_NOT_SUPPORTED;
  254. OS_THREAD_MUTEX_RELEASE(&pBMCInfo->PefConfig.PEFSharedMemMutex);
  255. return sizeof (*pRes);
  256. }
  257. m_PEF_SetInProgress = BMC_GET_SHARED_MEM(BMCInst)->m_PEF_SetInProgress;
  258. if ((m_PEF_SetInProgress == PEF_SET_IN_PROGRESS) &&
  259. (pReq[1] == PEF_SET_IN_PROGRESS))
  260. {
  261. /* Trying to Set in Progress When already in progress */
  262. *pRes = CC_PEF_SET_IN_PROGRESS ;
  263. OS_THREAD_MUTEX_RELEASE(&pBMCInfo->PefConfig.PEFSharedMemMutex);
  264. return sizeof (*pRes);
  265. }
  266. BMC_GET_SHARED_MEM(BMCInst)->m_PEF_SetInProgress = pReq[1];
  267. break;
  268. case PEF_CONTROL:
  269. /*Parameter 1 NVRAM */
  270. pNvrPefConfig->PEFControl = pReq[1];
  271. if((pNvrPefConfig->PEFControl & 0x01) && ( g_BMCInfo[BMCInst].PefConfig.PEFTmrMgr.TmrInterval == ARM_PEF_TEMP_DISABLE))
  272. {
  273. g_BMCInfo[BMCInst].PefConfig.PEFTmrMgr.TakePEFAction = TRUE;
  274. g_BMCInfo[BMCInst].PefConfig.PEFTmrMgr.TmrArmed = FALSE;
  275. g_BMCInfo[BMCInst].PefConfig.PEFTmrMgr.StartTmr = FALSE;
  276. g_BMCInfo[BMCInst].PefConfig.PEFTmrMgr.TmrInterval = ARM_PEF_TMR_DISABLE;
  277. g_BMCInfo[BMCInst].PefConfig.PEFTmrMgr.InitCountDown = ARM_PEF_TMR_DISABLE;
  278. }
  279. break;
  280. case PEF_ACTION_CONTROL:
  281. /*Parameter 2 NVRAM */
  282. pNvrPefConfig->PEFActionGblControl = pReq[1];
  283. break;
  284. case PEF_STARTUP_DELAY:
  285. /* Parameter 3 NVRAM */
  286. pNvrPefConfig->PEFStartupDly = pReq[1];
  287. break;
  288. case PEF_ALERT_STARTUP_DELAY:
  289. /*Parameter 4 NVRAM */
  290. pNvrPefConfig->PEFAlertStartupDly = pReq[1];
  291. break;
  292. case NUM_EVT_ENTRIES:
  293. /* Parameter 5 Read only */
  294. *pRes = CC_PEF_ATTEMPT_TO_SET_READ_ONLY_PARAM;
  295. OS_THREAD_MUTEX_RELEASE(&pBMCInfo->PefConfig.PEFSharedMemMutex);
  296. return sizeof (*pRes);
  297. break;
  298. case EVT_ENTRY:
  299. /* Parameter 6 NVRAM*/
  300. /* set selector 0 is reserved for this parameter */
  301. if (0 == pReq[1])
  302. {
  303. *pRes = CC_INV_DATA_FIELD ;
  304. OS_THREAD_MUTEX_RELEASE(&pBMCInfo->PefConfig.PEFSharedMemMutex);
  305. return sizeof (*pRes);
  306. }
  307. if(pReq [1] > MAX_EVT_FILTER_ENTRIES)
  308. {
  309. *pRes=CC_PARAM_OUT_OF_RANGE;
  310. OS_THREAD_MUTEX_RELEASE(&pBMCInfo->PefConfig.PEFSharedMemMutex);
  311. return sizeof(*pRes);
  312. }
  313. /* Make set selector 0 based for array access */
  314. pReq[1]--;
  315. /* In Event filter table, Data1 BIT0-BIT4 are reserved */
  316. /* In BIT6 ,BIT5 01B and 11B are reserved */
  317. if(((pReq[2] & BIT4_BIT0_MASK) != 0) || (((pReq[2] >> 5) & BIT1_BIT0_MASK )== RESERVED_VALUE_03 ||((pReq[2] >> 5) & BIT1_BIT0_MASK )== RESERVED_VALUE_01 ))
  318. {
  319. *pRes = CC_INV_DATA_FIELD ;
  320. OS_THREAD_MUTEX_RELEASE(&pBMCInfo->PefConfig.PEFSharedMemMutex);
  321. return sizeof (*pRes);
  322. }
  323. /* We cannot configure the Preconfigured filter entry */
  324. /* s/w cannot add the preconfigureable Event filter */
  325. //188564 - Per FW architect's interpretation, this flag should be settable and clearable
  326. // by system software. It shall serve as a warning to other software that the entry
  327. // was set purposefully, but shall not interfere with resetting the entry.
  328. // This is an interpretation of a "gray area" in the IPMI spec.
  329. if(pBMCInfo->IpmiConfig.AlterPreConfiguredEntries == 0)
  330. {
  331. if(PRECONFIGURED_FILTER == GetBits(pReq[2],0x60) || PRECONFIGURED_FILTER == GetBits(pNvrPefConfig->EvtFilterTblEntry[pReq[1]].FilterConfig,0x60))
  332. {
  333. *pRes = CC_INV_DATA_FIELD ;
  334. OS_THREAD_MUTEX_RELEASE(&pBMCInfo->PefConfig.PEFSharedMemMutex);
  335. return sizeof (*pRes);
  336. }
  337. }
  338. /* Severity Should be 0 2 4 8 10 0x20 */
  339. /* Logic : 2's complement of 2 power n is same given no */
  340. tmp=pReq[5];
  341. if((((~tmp) + 1) & pReq[5]) != pReq[5])
  342. {
  343. *pRes = CC_INV_DATA_FIELD ;
  344. OS_THREAD_MUTEX_RELEASE(&pBMCInfo->PefConfig.PEFSharedMemMutex);
  345. return sizeof (*pRes);
  346. }
  347. /* According to the Severity 0x40 and 0x80 is undefined */
  348. if(0!=(pReq[5] & BIT7_BIT6_MASK))
  349. {
  350. *pRes = CC_INV_DATA_FIELD ;
  351. OS_THREAD_MUTEX_RELEASE(&pBMCInfo->PefConfig.PEFSharedMemMutex);
  352. return sizeof (*pRes);
  353. }
  354. /*Set respective Event Filter Entry*/
  355. _fmemcpy(&pNvrPefConfig->EvtFilterTblEntry[pReq[1]],
  356. &pReq[2],
  357. sizeof (EvtFilterTblEntry_T));
  358. break;
  359. case EVT_ENTRY_BYTE1:
  360. /* Parameter 7 NVRAM*/
  361. /* set selector 0 is reserved for this parameter */
  362. if (0 == pReq[1])
  363. {
  364. *pRes = CC_INV_DATA_FIELD ;
  365. OS_THREAD_MUTEX_RELEASE(&pBMCInfo->PefConfig.PEFSharedMemMutex);
  366. return sizeof (*pRes);
  367. }
  368. /* Make set selector 0 based for array access */
  369. pReq[1]--;
  370. /* In Event filter table, Data1 BIT0-BIT4 are reserved */
  371. /* In BIT6 ,BIT5 01B and 11B are reserved */
  372. if(((pReq[2] & 0x1f) != 0) || (((pReq[2] >> 5) & 0x3 )== 0x3 ||((pReq[2] >>5) & 0x3 )== 0x1 ))
  373. {
  374. *pRes = CC_INV_DATA_FIELD ;
  375. OS_THREAD_MUTEX_RELEASE(&pBMCInfo->PefConfig.PEFSharedMemMutex);
  376. return sizeof (*pRes);
  377. }
  378. if( GetBits(pReq[2],0x60) != GetBits( pNvrPefConfig->EvtFilterTblEntry[pReq[1]].FilterConfig ,0x60))
  379. {
  380. /* We should not change the Event filter Configuration (i.e) s/w configurable , Preconfigurable Event filter */
  381. *pRes = CC_INV_DATA_FIELD ;
  382. OS_THREAD_MUTEX_RELEASE(&pBMCInfo->PefConfig.PEFSharedMemMutex);
  383. return sizeof (*pRes);
  384. }
  385. /* Load first byte(Filter config) only */
  386. pNvrPefConfig->EvtFilterTblEntry[pReq[1]].FilterConfig = pReq[2];
  387. break;
  388. case GUID:
  389. /* Parameter 10 NVRAM */
  390. /* Fill the data that describes the use of GUID field */
  391. _fmemcpy (pNvrPefConfig->SystemGUID, &pReq[1], MAX_SIZE_PET_GUID);
  392. break;
  393. case NUM_ALERT_ENTRIES:
  394. /* Parameter 8 NVRAM */
  395. *pRes = CC_PEF_ATTEMPT_TO_SET_READ_ONLY_PARAM;
  396. OS_THREAD_MUTEX_RELEASE(&pBMCInfo->PefConfig.PEFSharedMemMutex);
  397. return sizeof (*pRes);
  398. break;
  399. case ALERT_ENTRY:
  400. /* Parameter 9 NVRAM */
  401. /* set selector 0 is reserved for this parameter */
  402. /* Invalid Policy .It should be 0-4 */
  403. /* Policy number 0 is reserved */
  404. if( (0 == pReq[1]) ||( ( pReq[2] & 0x7 ) > 4) || ((pReq[2] & 0xF0) == 0 ))
  405. {
  406. *pRes = CC_INV_DATA_FIELD ;
  407. OS_THREAD_MUTEX_RELEASE(&pBMCInfo->PefConfig.PEFSharedMemMutex);
  408. return sizeof (*pRes);
  409. }
  410. /* Make set selector 0 based for array access */
  411. pReq[1]--;
  412. /*Set specified Alert Entry */
  413. _fmemcpy(&pNvrPefConfig->AlertPolicyTblEntry[pReq[1]],
  414. &pReq[2],
  415. sizeof (AlertPolicyTblEntry_T));
  416. break;
  417. case NUM_ALERT_STR:
  418. /* Parameter 11 Read only*/
  419. *pRes = CC_PEF_ATTEMPT_TO_SET_READ_ONLY_PARAM;
  420. OS_THREAD_MUTEX_RELEASE(&pBMCInfo->PefConfig.PEFSharedMemMutex);
  421. return sizeof (*pRes);
  422. break;
  423. case ALERT_STRING_KEYS:
  424. /* parameter 12 */
  425. /* if Set selector is 0 then set for volatile else non volatile */
  426. /* Boundary condtion for check Set selector within MAx_ALERT_STR */
  427. if(pReq[1]> MAX_ALERT_STRINGS)
  428. {
  429. *pRes = CC_PARAM_OUT_OF_RANGE ;
  430. OS_THREAD_MUTEX_RELEASE(&pBMCInfo->PefConfig.PEFSharedMemMutex);
  431. return sizeof (*pRes);
  432. }
  433. if( (pReq[2] > MAX_EVT_FILTER_ENTRIES) || (pReq[3] >MAX_ALERT_STRINGS))
  434. {
  435. *pRes = CC_PARAM_OUT_OF_RANGE;
  436. OS_THREAD_MUTEX_RELEASE(&pBMCInfo->PefConfig.PEFSharedMemMutex);
  437. return sizeof (*pRes);
  438. }
  439. if (0 != pReq[1])
  440. {
  441. /* Make set selector 0 based for array access */
  442. pReq[1]--;
  443. /*Set the Event Filter No & Alert string Set parameters */
  444. pNvrPefConfig->AlertStringEntry[pReq[1]].EventFilterSel = pReq[2];
  445. pNvrPefConfig->AlertStringEntry[pReq[1]].AlertStringSet = pReq[3];
  446. }
  447. else
  448. {
  449. /* Volatile settings */
  450. BMC_GET_SHARED_MEM (BMCInst)->AlertStringEntry.EventFilterSel = pReq[2];
  451. BMC_GET_SHARED_MEM (BMCInst)->AlertStringEntry.AlertStringSet = pReq[3];
  452. }
  453. break;
  454. case ALERT_STRINGS:
  455. /* Parameter 13 NVRAM */
  456. if(ReqLen < 4)
  457. {
  458. *pRes = CC_REQ_INV_LEN;
  459. OS_THREAD_MUTEX_RELEASE(&pBMCInfo->PefConfig.PEFSharedMemMutex);
  460. return sizeof (*pRes);
  461. }
  462. /* Boundary condtion for check Set selector within MAx_ALERT_STR */
  463. if(pReq[1]> MAX_ALERT_STRINGS)
  464. {
  465. *pRes = CC_PARAM_OUT_OF_RANGE ;
  466. OS_THREAD_MUTEX_RELEASE(&pBMCInfo->PefConfig.PEFSharedMemMutex);
  467. return sizeof (*pRes);
  468. }
  469. /* Boundary condition to check the block selector within MAX_LIMIT */
  470. if(0 == pReq[2] || pReq[2] >ALERT_STR_MAX_BLOCKS)
  471. {
  472. *pRes = CC_PARAM_OUT_OF_RANGE ;
  473. OS_THREAD_MUTEX_RELEASE(&pBMCInfo->PefConfig.PEFSharedMemMutex);
  474. return sizeof (*pRes);
  475. }
  476. /* Boundary Condition to check Alert string with in Limit */
  477. if(ReqLen -3 > ALERT_STR_BLOCK_SIZE)
  478. {
  479. *pRes = CC_REQ_INV_LEN ;
  480. OS_THREAD_MUTEX_RELEASE(&pBMCInfo->PefConfig.PEFSharedMemMutex);
  481. return sizeof (*pRes);
  482. }
  483. /* Make Block selector 0 based for array access */
  484. pReq[2]--;
  485. /* if Set selector is 0 then set for volatile else non volatile */
  486. if (0 != pReq[1])
  487. {
  488. /* Make set selector 0 based for array access */
  489. pReq[1]--;
  490. /* Load the appropriate block */
  491. memset(pNvrPefConfig->AlertStringEntry[pReq[1]].AlertString[pReq[2]],0,ALERT_STR_BLOCK_SIZE);
  492. _fmemcpy(pNvrPefConfig->AlertStringEntry[pReq[1]].AlertString[pReq[2]],
  493. &pReq[3],
  494. ReqLen - 3);
  495. }
  496. else
  497. {
  498. /* volatile setting */
  499. AlertStringTbl_T* pAlertStr = &BMC_GET_SHARED_MEM (BMCInst)->AlertStringEntry;
  500. memset(pAlertStr->AlertString[pReq[2]],0,ALERT_STR_BLOCK_SIZE);
  501. _fmemcpy(pAlertStr->AlertString[pReq[2]], &pReq[3], ReqLen - 3);
  502. }
  503. break;
  504. default:
  505. *pRes = CC_INV_DATA_FIELD;
  506. OS_THREAD_MUTEX_RELEASE(&pBMCInfo->PefConfig.PEFSharedMemMutex);
  507. return sizeof (*pRes);
  508. }
  509. FlushIPMI((INT8U*)&pBMCInfo->PEFConfig,(INT8U*)&pBMCInfo->PEFConfig,
  510. pBMCInfo->IPMIConfLoc.PEFConfigAddr,sizeof(PEFConfig_T),BMCInst);
  511. OS_THREAD_MUTEX_RELEASE(&pBMCInfo->PefConfig.PEFSharedMemMutex);
  512. *pRes = CC_NORMAL;
  513. return sizeof (*pRes);
  514. }
  515. /*---------------------------------------
  516. * GetPEFConfigParams
  517. *---------------------------------------*/
  518. int
  519. GetPEFConfigParams (_NEAR_ INT8U* pReq, INT8U ReqLen, _NEAR_ INT8U* pRes,_NEAR_ int BMCInst)
  520. {
  521. _NEAR_ GetPEFConfigReq_T* pGetConfigReq = (_NEAR_ GetPEFConfigReq_T*)pReq;
  522. _FAR_ PEFConfig_T* pNvrPefConfig;
  523. INT8U ParamSel, Index=0;
  524. BMCInfo_t *pBMCInfo = &g_BMCInfo[BMCInst];
  525. /* Store ParamSel */
  526. ParamSel = pGetConfigReq->ParamSel & 0x7F;
  527. /* Check for Unsupported parameter */
  528. if (ParamSel > 95)
  529. {
  530. *pRes = CC_PEF_PARAM_NOT_SUPPORTED;
  531. return sizeof (*pRes);
  532. }
  533. /*Load completion code & revision */
  534. pRes[Index++] = CC_NORMAL;
  535. pRes[Index++] = PARAMETER_REVISION_FORMAT ;
  536. /* Check Revision only parameter */
  537. if (pGetConfigReq->ParamSel & 0x80)
  538. {
  539. if((MAX_PEF_CONF_PARAM < ParamSel))
  540. {
  541. *pRes = CC_PARAM_NOT_SUPPORTED;
  542. return sizeof (*pRes);
  543. }
  544. return (Index * sizeof (INT8U));
  545. }
  546. OS_THREAD_MUTEX_ACQUIRE(&pBMCInfo->PefConfig.PEFSharedMemMutex,WAIT_INFINITE);
  547. /* Get Pef config parameters from NVRAM */
  548. pNvrPefConfig = &pBMCInfo->PEFConfig;
  549. switch (ParamSel)
  550. {
  551. case EVT_ENTRY:
  552. /*Parameter 6 NVRAM */
  553. case EVT_ENTRY_BYTE1:
  554. /*Parameter 7 NVRAM */
  555. case ALERT_ENTRY:
  556. /*Parameter 9 NVRAM */
  557. case ALERT_STRING_KEYS:
  558. /*Parameter 12 NVRAM */
  559. case ALERT_STRINGS:
  560. /*Parameter 13 NVRAM */
  561. break;
  562. default:
  563. if((pGetConfigReq->SetSel != 0) || (pGetConfigReq->BlockSel !=0))
  564. {
  565. *pRes = CC_INV_DATA_FIELD ;
  566. return sizeof (*pRes);
  567. }
  568. break;
  569. }
  570. switch (ParamSel)
  571. {
  572. case SET_IN_PROGRESS:
  573. /*Parameter 0 volatile*/
  574. pRes[Index++] = BMC_GET_SHARED_MEM(BMCInst)->m_PEF_SetInProgress;
  575. break;
  576. case PEF_CONTROL:
  577. /*Parameter 1 Non volatile*/
  578. pRes[Index++] = pNvrPefConfig->PEFControl;
  579. break;
  580. case PEF_ACTION_CONTROL:
  581. /* Parameter 2 NVRAM */
  582. pRes[Index++] = pNvrPefConfig->PEFActionGblControl;
  583. break;
  584. case PEF_STARTUP_DELAY:
  585. /* Parameter 3 NVRAM */
  586. pRes[Index++] = pNvrPefConfig->PEFStartupDly;
  587. break;
  588. case PEF_ALERT_STARTUP_DELAY:
  589. /*Parameter 4 NVRAM */
  590. pRes[Index++] = pNvrPefConfig->PEFAlertStartupDly;
  591. break;
  592. case NUM_EVT_ENTRIES:
  593. /*Parameter 5 Read only */
  594. pRes[Index++] = MAX_EVT_FILTER_ENTRIES;
  595. break;
  596. case EVT_ENTRY:
  597. /*Parameter 6 NVRAM */
  598. /* set selector 0 is reserved for this parameter */
  599. /* Block Selector should be zero for this parameter */
  600. if ((0 == pGetConfigReq->SetSel) ||(0 !=pGetConfigReq->BlockSel ))
  601. {
  602. *pRes = CC_INV_DATA_FIELD ;
  603. OS_THREAD_MUTEX_RELEASE(&pBMCInfo->PefConfig.PEFSharedMemMutex);
  604. return sizeof (*pRes);
  605. }
  606. if(pGetConfigReq->SetSel > MAX_EVT_FILTER_ENTRIES)
  607. {
  608. *pRes = CC_PARAM_OUT_OF_RANGE ;
  609. OS_THREAD_MUTEX_RELEASE(&pBMCInfo->PefConfig.PEFSharedMemMutex);
  610. return sizeof (*pRes);
  611. }
  612. /*Add set selector */
  613. pRes[Index++] = pGetConfigReq->SetSel;
  614. /*Make set selector 0 based for array access*/
  615. pGetConfigReq->SetSel--;
  616. /*Fill response with the required parameter from Event Filter Table*/
  617. _fmemcpy(&pRes[Index],
  618. &pNvrPefConfig->EvtFilterTblEntry[pReq[1]],
  619. sizeof (EvtFilterTblEntry_T));
  620. Index += sizeof (EvtFilterTblEntry_T);
  621. break;
  622. case EVT_ENTRY_BYTE1:
  623. /*Parameter 7 NVRAM */
  624. /* set selector 0 is reserved for this parameter */
  625. if (0 == pGetConfigReq->SetSel)
  626. {
  627. *pRes = CC_INV_DATA_FIELD ;
  628. OS_THREAD_MUTEX_RELEASE(&pBMCInfo->PefConfig.PEFSharedMemMutex);
  629. return sizeof (*pRes);
  630. }
  631. //#30993
  632. if(pGetConfigReq->SetSel > MAX_EVT_FILTER_ENTRIES)
  633. {
  634. *pRes = CC_PARAM_OUT_OF_RANGE ;
  635. OS_THREAD_MUTEX_RELEASE(&pBMCInfo->PefConfig.PEFSharedMemMutex);
  636. return sizeof (*pRes);
  637. }
  638. /* Block Selector should be zero for this parameter */
  639. if(0 !=pGetConfigReq->BlockSel )
  640. {
  641. *pRes = CC_INV_DATA_FIELD ;
  642. OS_THREAD_MUTEX_RELEASE(&pBMCInfo->PefConfig.PEFSharedMemMutex);
  643. return sizeof (*pRes);
  644. }
  645. /*Load set selector */
  646. pRes[Index++] = pGetConfigReq->SetSel;
  647. /*Make set selector 0 based for array access*/
  648. pGetConfigReq->SetSel--;
  649. /*Load filter configuration */
  650. pRes[Index++] = pNvrPefConfig->EvtFilterTblEntry[pGetConfigReq->SetSel].FilterConfig;
  651. break;
  652. case GUID:
  653. /*Parameter 10 Read only */
  654. /* Add Global Unique ID and its usage field (first byte) */
  655. _fmemcpy(&pRes[Index], pNvrPefConfig->SystemGUID, MAX_SIZE_PET_GUID);
  656. Index += MAX_SIZE_PET_GUID;
  657. break;
  658. case NUM_ALERT_ENTRIES:
  659. /*Parameter 8 Read only */
  660. pRes[Index++] = MAX_ALERT_POLICY_ENTRIES;
  661. break;
  662. case ALERT_ENTRY:
  663. /*Parameter 9 NVRAM */
  664. /* set selector 0 is reserved for this parameter */
  665. /* Block Selector should be zero for this parameter */
  666. if ( (0 == pGetConfigReq->SetSel ) || (0 !=pGetConfigReq->BlockSel ))
  667. {
  668. *pRes = CC_INV_DATA_FIELD ;
  669. OS_THREAD_MUTEX_RELEASE(&pBMCInfo->PefConfig.PEFSharedMemMutex);
  670. return sizeof (*pRes);
  671. }
  672. if(MAX_ALERT_POLICY_ENTRIES < pGetConfigReq->SetSel)
  673. {
  674. *pRes = CC_PARAM_OUT_OF_RANGE ;
  675. OS_THREAD_MUTEX_RELEASE(&pBMCInfo->PefConfig.PEFSharedMemMutex);
  676. return sizeof (*pRes);
  677. }
  678. /* Wehave to check the Block number only If it require the block selector */
  679. /* Check for block number */
  680. /* Since Block Selector is 1 Based . we have to support 1-MAX */
  681. if (pGetConfigReq->BlockSel > ALERT_STR_MAX_BLOCKS)
  682. {
  683. *pRes = CC_PARAM_OUT_OF_RANGE;
  684. OS_THREAD_MUTEX_RELEASE(&pBMCInfo->PefConfig.PEFSharedMemMutex);
  685. return sizeof (*pRes);
  686. }
  687. /* Load Set Selector */
  688. pRes[Index++] = pGetConfigReq->SetSel;
  689. /*Make set selector 0 based for array access*/
  690. pGetConfigReq->SetSel--;
  691. /* Load Alert entry */
  692. _fmemcpy(&pRes[Index],
  693. &pNvrPefConfig->AlertPolicyTblEntry[pGetConfigReq->SetSel],
  694. sizeof (AlertPolicyTblEntry_T));
  695. Index += sizeof (AlertPolicyTblEntry_T);
  696. break;
  697. case NUM_ALERT_STR:
  698. /*Parameter 11 Read only */
  699. /*Load Total Strings */
  700. pRes[Index++] = MAX_ALERT_STRINGS;
  701. break;
  702. case ALERT_STRING_KEYS:
  703. /*Parameter 12 NVRAM */
  704. if((pGetConfigReq->BlockSel != 0) || ((pGetConfigReq->SetSel & 0x80) == 0x80))
  705. {
  706. *pRes = CC_INV_DATA_FIELD;
  707. OS_THREAD_MUTEX_RELEASE(&pBMCInfo->PefConfig.PEFSharedMemMutex);
  708. return sizeof (*pRes);
  709. }
  710. if(pGetConfigReq->SetSel > MAX_ALERT_STRINGS)
  711. {
  712. *pRes = CC_PARAM_OUT_OF_RANGE;
  713. OS_THREAD_MUTEX_RELEASE(&pBMCInfo->PefConfig.PEFSharedMemMutex);
  714. return sizeof (*pRes);
  715. }
  716. /*Load Alert string keys response */
  717. pRes[Index++] = pGetConfigReq->SetSel;
  718. /* if Set selector 0 then volatile setting else non volatile */
  719. if (0 != pGetConfigReq->SetSel)
  720. {
  721. /*Make set selector 0 based for array access*/
  722. pGetConfigReq->SetSel--;
  723. pRes[Index++] = pNvrPefConfig->AlertStringEntry[pReq[1]].EventFilterSel;
  724. pRes[Index++] = pNvrPefConfig->AlertStringEntry[pReq[1]].AlertStringSet;
  725. }
  726. else
  727. {
  728. /* Get setting from volatile */
  729. pRes[Index++] = BMC_GET_SHARED_MEM (BMCInst)->AlertStringEntry.EventFilterSel;
  730. pRes[Index++] = BMC_GET_SHARED_MEM (BMCInst)->AlertStringEntry.AlertStringSet;
  731. }
  732. break;
  733. case ALERT_STRINGS:
  734. /*Parameter 13 NVRAM */
  735. if (pGetConfigReq->BlockSel == 0)
  736. {
  737. *pRes = CC_INV_DATA_FIELD ;
  738. OS_THREAD_MUTEX_RELEASE(&pBMCInfo->PefConfig.PEFSharedMemMutex);
  739. return sizeof (*pRes);
  740. }
  741. /* Wehave to check the Block number only If it require the block selector */
  742. /* Check for block number */
  743. /* Since Block Selector is 1 Based . we have to support 1-MAX */
  744. if ((pGetConfigReq->BlockSel > ALERT_STR_MAX_BLOCKS) || (pGetConfigReq->SetSel > MAX_ALERT_STRINGS ))
  745. {
  746. *pRes = CC_PARAM_OUT_OF_RANGE;
  747. OS_THREAD_MUTEX_RELEASE(&pBMCInfo->PefConfig.PEFSharedMemMutex);
  748. return sizeof (*pRes);
  749. }
  750. /*Copy Set Selector */
  751. pRes[Index++] = pGetConfigReq->SetSel;
  752. /*Copy block selector */
  753. pRes[Index++] = pGetConfigReq->BlockSel;
  754. /*Make block selector 0 based for array access*/
  755. pGetConfigReq->BlockSel--;
  756. /* if Set selector 0 then volatile setting else non volatile */
  757. if (0 != pGetConfigReq->SetSel)
  758. {
  759. /*Make set selector 0 based for array access*/
  760. pGetConfigReq->SetSel--;
  761. /*Copy the specified block */
  762. _fmemcpy ((_FAR_ char*)&pRes[Index],
  763. (_FAR_ const char*)pNvrPefConfig->AlertStringEntry[pGetConfigReq->SetSel].AlertString[pGetConfigReq->BlockSel],ALERT_STR_BLOCK_SIZE);
  764. }
  765. else
  766. {
  767. /*Copy the specified block */
  768. _fmemcpy((_FAR_ char*)&pRes[Index],
  769. (_FAR_ const char*)BMC_GET_SHARED_MEM (BMCInst)->AlertStringEntry.AlertString[pGetConfigReq->BlockSel],
  770. ALERT_STR_BLOCK_SIZE);
  771. }
  772. Index += ALERT_STR_BLOCK_SIZE;
  773. break;
  774. default:
  775. *pRes = CC_INV_DATA_FIELD;
  776. OS_THREAD_MUTEX_RELEASE(&pBMCInfo->PefConfig.PEFSharedMemMutex);
  777. return sizeof (*pRes);
  778. }
  779. OS_THREAD_MUTEX_RELEASE(&pBMCInfo->PefConfig.PEFSharedMemMutex);
  780. return (Index * sizeof (INT8U));
  781. }
  782. /*---------------------------------------
  783. * SetLastProcessedEventId
  784. *---------------------------------------*/
  785. int
  786. SetLastProcessedEventId (_NEAR_ INT8U* pReq, INT8U ReqLen, _NEAR_ INT8U* pRes,_NEAR_ int BMCInst)
  787. {
  788. _NEAR_ SetLastEvtIDReq_T* pSetLastEvtIDReq = (_NEAR_ SetLastEvtIDReq_T*)pReq;
  789. _FAR_ PEFRecordDetailsConfig_T* pNvrPEFRecordDetailsConfig;
  790. BMCInfo_t *pBMCInfo = &g_BMCInfo[BMCInst];
  791. struct SELEventNode *SELNode= NULL;
  792. IPMI_DBG_PRINT ("SetLastProcessedEventId\n");
  793. /* Check for the reserved bytes should b zero */
  794. if ( 0 != (pSetLastEvtIDReq->SetRecIDType & RESERVED_BITS_SETLASTPROCESSEDEVENTID ) )
  795. {
  796. pRes[0] = CC_INV_DATA_FIELD;
  797. return sizeof(*pRes);
  798. }
  799. TDBG("%d\n",pSetLastEvtIDReq->RecordID);
  800. OS_THREAD_MUTEX_ACQUIRE(&pBMCInfo->PefConfig.PEFSharedMemMutex,WAIT_INFINITE);
  801. if(g_corefeatures.del_sel_reclaim_support == ENABLED)
  802. {
  803. if(pBMCInfo->SELConfig.MaxSELRecord > pSetLastEvtIDReq->RecordID)
  804. {
  805. SELNode = SEL_RECORD_ADDR(BMCInst,pSetLastEvtIDReq->RecordID).RecAddr;
  806. }
  807. if(SELNode==NULL && pSetLastEvtIDReq->RecordID != 0xFFFF )
  808. {
  809. /* the record ID does not exists so not allowing it to set*/
  810. TDBG("Record does not exists\n");
  811. goto SUCCESS;
  812. }
  813. }
  814. /*Get non volatile PEF configuration */
  815. pNvrPEFRecordDetailsConfig = &pBMCInfo->PEFRecordDetailsConfig;
  816. /*Check whose Record ID to set(SW or BMC) */
  817. if (pSetLastEvtIDReq->SetRecIDType & 0x01)
  818. {
  819. /*Set Last BMC processed Event ID */
  820. pNvrPEFRecordDetailsConfig->LastBMCProcessedEventID = pSetLastEvtIDReq->RecordID;
  821. /*Write to NVRAM*/
  822. FlushIPMI((INT8U*)&pBMCInfo->PEFRecordDetailsConfig,(INT8U*)&pBMCInfo->PEFRecordDetailsConfig.LastBMCProcessedEventID,
  823. pBMCInfo->IPMIConfLoc.PEFRecordDetailsConfigAddr,sizeof(pBMCInfo->PEFRecordDetailsConfig.LastBMCProcessedEventID),BMCInst);
  824. }
  825. else
  826. {
  827. /*Set Last SW processed Event ID */
  828. pNvrPEFRecordDetailsConfig->LastSWProcessedEventID = pSetLastEvtIDReq->RecordID;
  829. /*Write to NVRAM*/
  830. FlushIPMI((INT8U*)&pBMCInfo->PEFRecordDetailsConfig,(INT8U*)&pBMCInfo->PEFRecordDetailsConfig.LastBMCProcessedEventID,
  831. pBMCInfo->IPMIConfLoc.PEFRecordDetailsConfigAddr,sizeof(pBMCInfo->PEFRecordDetailsConfig.LastBMCProcessedEventID),BMCInst);
  832. }
  833. SUCCESS:
  834. OS_THREAD_MUTEX_RELEASE(&pBMCInfo->PefConfig.PEFSharedMemMutex);
  835. *pRes = CC_NORMAL;
  836. return sizeof (*pRes);
  837. }
  838. /*---------------------------------------
  839. * GetLastProcessedEventId
  840. *---------------------------------------*/
  841. int
  842. GetLastProcessedEventId (_NEAR_ INT8U* pReq, INT8U ReqLen, _NEAR_ INT8U* pRes,_NEAR_ int BMCInst)
  843. {
  844. _NEAR_ GetLastEvtIDRes_T* pGetLastEvtIDRes = (_NEAR_ GetLastEvtIDRes_T*)pRes;
  845. _FAR_ PEFRecordDetailsConfig_T* pNvrPEFRecordDetailsConfig;
  846. BMCInfo_t *pBMCInfo = &g_BMCInfo[BMCInst];
  847. /*Get non volatile PEF configuration */
  848. pNvrPEFRecordDetailsConfig = &pBMCInfo->PEFRecordDetailsConfig;
  849. OS_THREAD_MUTEX_ACQUIRE(&pBMCInfo->PefConfig.PEFSharedMemMutex,WAIT_INFINITE);
  850. /* Load response information */
  851. pGetLastEvtIDRes->CompletionCode = CC_NORMAL;
  852. pGetLastEvtIDRes->LastSELRecord = pNvrPEFRecordDetailsConfig->LastSELRecordID;
  853. pGetLastEvtIDRes->LastSWProcessedID = pNvrPEFRecordDetailsConfig->LastSWProcessedEventID;
  854. pGetLastEvtIDRes->LastBMCProcessedID = pNvrPEFRecordDetailsConfig->LastBMCProcessedEventID;
  855. pGetLastEvtIDRes->RecentTimestamp = pNvrPEFRecordDetailsConfig->LastProcessedTimestamp;
  856. OS_THREAD_MUTEX_RELEASE(&pBMCInfo->PefConfig.PEFSharedMemMutex);
  857. /*return length */
  858. return sizeof (GetLastEvtIDRes_T);
  859. }
  860. /*---------------------------------------
  861. * AlertImmediate
  862. *---------------------------------------*/
  863. int
  864. AlertImmediate (_NEAR_ INT8U* pReq, INT8U ReqLen, _NEAR_ INT8U* pRes,_NEAR_ int BMCInst)
  865. {
  866. MsgPkt_T MsgPkt;
  867. INT8U EthIndex=0;
  868. BMCInfo_t *pBMCInfo = &g_BMCInfo[BMCInst];
  869. _NEAR_ AlertImmReq_T* pAlertImmReq = (_NEAR_ AlertImmReq_T*)pReq;
  870. _NEAR_ AlertImmRes_T* pAlertImmRes = (_NEAR_ AlertImmRes_T*)pRes;
  871. _NEAR_ SELEventRecord_T* pAlertSELRec = (_NEAR_ SELEventRecord_T*)MsgPkt.Data;
  872. //ChannelInfo_T* pChannelInfo;
  873. if(0x3 != ReqLen && 0xB != ReqLen) //0x3 for mandatory field and with 0xb for optional field
  874. {
  875. pAlertImmRes->CompletionCode = CC_REQ_INV_LEN;
  876. return sizeof (*pRes);
  877. }
  878. /* Check for the reserved bytes should b zero */
  879. if ( ( 0 != (pAlertImmReq->ChannelNo & RESERVED_BITS_ALERTIMMEDIATE_CH ) ) ||
  880. ( 0 != (pAlertImmReq->DestSel & RESERVED_BITS_ALERTIMMEDIATE_DESTSEL ) ) )
  881. {
  882. pAlertImmRes->CompletionCode = CC_INV_DATA_FIELD;
  883. return sizeof (*pRes);
  884. }
  885. #if 0 //Excluding to fix "Send Test Alert" option from WebUI
  886. /* check if any IPMI messaging session is already in progress */
  887. pChannelInfo = getChannelInfo (pAlertImmReq->ChannelNo & 0x0F,BMCInst);
  888. if(pChannelInfo->ActiveSession > 0)
  889. {
  890. pAlertImmRes->CompletionCode = CC_SESSION_IN_PROGRESS;
  891. return sizeof (*pRes);
  892. }
  893. #endif
  894. EthIndex= GetEthIndex((pAlertImmReq->ChannelNo & 0x0F), BMCInst);
  895. if(0xff == EthIndex)
  896. {
  897. *pRes = CC_DEST_UNAVAILABLE;
  898. return sizeof (INT8U);
  899. }
  900. OS_THREAD_MUTEX_ACQUIRE(&pBMCInfo->PefConfig.PEFSharedMemMutex,WAIT_INFINITE);
  901. if(SEND_ALERT_IMM ==GetBits (pAlertImmReq->DestSel, 0xC0))
  902. {
  903. /*set the alert Immediate in Progress */
  904. if( ALERT_IMM_IN_PROGRESS == BMC_GET_SHARED_MEM(BMCInst)->LANAlertStatus[EthIndex] )
  905. {
  906. pAlertImmRes->CompletionCode = CC_SET_IN_PROGRESS;
  907. OS_THREAD_MUTEX_RELEASE(&pBMCInfo->PefConfig.PEFSharedMemMutex);
  908. return sizeof (*pRes);
  909. }
  910. BMC_GET_SHARED_MEM(BMCInst)->LANAlertStatus[EthIndex] = ALERT_IMM_IN_PROGRESS;
  911. MsgPkt.Channel = pAlertImmReq->ChannelNo & 0x0F;
  912. MsgPkt.Channel |= ( pAlertImmReq->DestSel & 0x0F )<< 4;
  913. MsgPkt.Cmd = pAlertImmReq->AlertStrSel;
  914. MsgPkt.Param = PARAM_ALERT_IMM;
  915. strcpy ((char *)MsgPkt.SrcQ, PEF_RES_Q);
  916. if( ReqLen ==sizeof(AlertImmReq_T))
  917. {
  918. pAlertSELRec->hdr.TimeStamp = GetSelTimeStamp (BMCInst);
  919. pAlertSELRec->hdr.Type= 0x2;
  920. pAlertSELRec->hdr.ID =0xFFFF;
  921. _fmemcpy (&MsgPkt.Data[sizeof(SELRecHdr_T)+1], &(pAlertImmReq->GenID),(sizeof (SELEventRecord_T) -sizeof(SELRecHdr_T)));
  922. }else
  923. {
  924. m_AlertImmRecord.hdr.TimeStamp = GetSelTimeStamp (BMCInst);
  925. _fmemcpy (MsgPkt.Data, &m_AlertImmRecord, sizeof (SELEventRecord_T));
  926. }
  927. MsgPkt.Size = sizeof (SELEventRecord_T);
  928. /* Send to PEF queue */
  929. if (0 != PostMsgNonBlock (&MsgPkt, PEF_TASK_Q,BMCInst))
  930. {
  931. pAlertImmRes->CompletionCode = CC_COULD_NOT_PROVIDE_RESP;
  932. OS_THREAD_MUTEX_RELEASE(&pBMCInfo->PefConfig.PEFSharedMemMutex);
  933. return sizeof (*pRes);
  934. }
  935. /* Wait for response */
  936. pAlertImmRes->CompletionCode = CC_NORMAL;
  937. OS_THREAD_MUTEX_RELEASE(&pBMCInfo->PefConfig.PEFSharedMemMutex);
  938. if (0 != GetMsg (&MsgPkt, PEF_RES_Q, WAIT_INFINITE, BMCInst))
  939. {
  940. IPMI_DBG_PRINT ("In AlertImmediate - What's wrong here?\n");
  941. }
  942. return sizeof (*pRes);
  943. }
  944. else if (GET_ALERT_IMM_STATUS ==GetBits (pAlertImmReq->DestSel, 0xC0))
  945. {
  946. pAlertImmRes->Status = BMC_GET_SHARED_MEM(BMCInst)->LANAlertStatus[EthIndex];
  947. pAlertImmRes->CompletionCode = CC_NORMAL;
  948. OS_THREAD_MUTEX_RELEASE(&pBMCInfo->PefConfig.PEFSharedMemMutex);
  949. return sizeof (AlertImmRes_T);
  950. }
  951. else if( CLEAR_ALERT_IMM_STATUS ==GetBits (pAlertImmReq->DestSel, 0xC0))
  952. {
  953. BMC_GET_SHARED_MEM(BMCInst)->LANAlertStatus[EthIndex] = 0x0;
  954. pAlertImmRes->CompletionCode = CC_NORMAL;
  955. OS_THREAD_MUTEX_RELEASE(&pBMCInfo->PefConfig.PEFSharedMemMutex);
  956. return sizeof (*pRes);
  957. }else
  958. {
  959. pAlertImmRes->CompletionCode = CC_INV_DATA_FIELD;
  960. OS_THREAD_MUTEX_RELEASE(&pBMCInfo->PefConfig.PEFSharedMemMutex);
  961. return sizeof (*pRes);
  962. }
  963. }
  964. /*---------------------------------------
  965. * PETAcknowledge
  966. *---------------------------------------*/
  967. int PETAcknowledge (_NEAR_ INT8U* pReq, INT8U ReqLen, _NEAR_ INT8U* pRes,_NEAR_ int BMCInst)
  968. {
  969. BMCInfo_t *pBMCInfo = &g_BMCInfo[BMCInst];
  970. _NEAR_ PETAckReq_T* pPETAckReq = (_NEAR_ PETAckReq_T*)pReq;
  971. MsgPkt_T MsgPkt;
  972. IPMI_DBG_PRINT ("PETAcknowledge\n");
  973. OS_THREAD_MUTEX_ACQUIRE(&pBMCInfo->PefConfig.PEFSharedMemMutex,WAIT_INFINITE);
  974. MsgPkt.Param = PARAM_PET_ACK;
  975. MsgPkt.Size = sizeof (PETAckReq_T);
  976. strcpy ((char *)MsgPkt.SrcQ, PEF_RES_Q);
  977. _fmemcpy (MsgPkt.Data, pPETAckReq, sizeof (PETAckReq_T));
  978. if (0 != PostMsgNonBlock (&MsgPkt, PEF_TASK_Q,BMCInst))
  979. {
  980. *pRes = CC_COULD_NOT_PROVIDE_RESP;
  981. OS_THREAD_MUTEX_RELEASE(&pBMCInfo->PefConfig.PEFSharedMemMutex);
  982. return sizeof (*pRes);
  983. }
  984. if (0 != GetMsg (&MsgPkt, PEF_RES_Q, WAIT_INFINITE, BMCInst))
  985. {
  986. IPMI_DBG_PRINT ("What's wrong here?\n");
  987. }
  988. *pRes = MsgPkt.Param;
  989. OS_THREAD_MUTEX_RELEASE(&pBMCInfo->PefConfig.PEFSharedMemMutex);
  990. return sizeof (*pRes);
  991. }
  992. #endif /* PEF_DEVICE */