Storlead.c 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536
  1. #include <string.h>
  2. #include "OemSMMCmds.h"
  3. #include "com_BmcType.h"
  4. #include "main.h"
  5. #include "Storlead.h"
  6. #include "SensorMonitor.h"
  7. #include "Sensor.h"
  8. #include "com_IPMI_SDRRecord.h"
  9. #include "SDR.h"
  10. #include "SELRecord.h"
  11. int Storlead_GetSysInfo(uint8_t* pReq, uint8_t ReqLen, uint8_t* pRes)
  12. {
  13. char Title[] = "系统信息";
  14. char Text[] = "CPU型号:FT1500;主频:1 GHZ;内存:8 GB;简介:太神奇了,竟然可以传汉字。哈哈哈。。。";
  15. int len = 0,remainLen = 0;
  16. uint16_t offset = (pReq[1]<<8) | pReq[2];
  17. int totalLen = 0;
  18. char *pStr = NULL;
  19. int reqLen = (pReq[3]<<8) | pReq[4];
  20. switch(pReq[0])
  21. {
  22. case 0: //get Title
  23. while(Title[totalLen])
  24. {
  25. totalLen++;
  26. }printf("title total len = %#x\n",totalLen);
  27. pStr = Title;
  28. break;
  29. case 1:
  30. while(Text[totalLen])
  31. {
  32. totalLen++;
  33. }
  34. printf("text total len = %#x\n", totalLen);
  35. pStr = Text;
  36. break;
  37. default:
  38. *pRes = CC_PARAM_OUT_OF_RANGE;
  39. return 1;
  40. }
  41. *pRes= CC_NORMAL;
  42. if(offset > totalLen)
  43. {
  44. printf("Invalid offset: %#x\n", offset);
  45. *pRes= CC_PARAM_OUT_OF_RANGE;
  46. return 1;
  47. }
  48. if(reqLen == 0)
  49. {
  50. len = totalLen - offset;
  51. }
  52. else
  53. {
  54. len = (reqLen > (totalLen-offset)) ? (totalLen-offset) : reqLen;
  55. }
  56. remainLen = totalLen - offset - len;
  57. *(pRes+1) = (len>>8)&0xff;
  58. *(pRes+2) = len&0xff;
  59. *(pRes+3) = (remainLen>>8)&0xff;
  60. *(pRes+4) = remainLen&0xff;
  61. memcpy(pRes+5, pStr+offset, len);
  62. // int i;
  63. // printf("Example 80h: ");
  64. // for(i=0;i<5+len;i++)
  65. // printf("%#x ", pRes[i]);
  66. // printf("\n");
  67. return 5+len;
  68. }
  69. int Storlead_GetSensorInfo(uint8_t* pReq, uint8_t ReqLen, uint8_t* pRes)
  70. {
  71. printf("Storlead_GetSensorInfo\n" );
  72. StorleadGetSensorInfoRes_T *pGetSensorInfoRes = (StorleadGetSensorInfoRes_T *)pRes;
  73. uint8_t* pValidSensor = NULL;
  74. uint16_t SensorIndex = pReq[0];
  75. SensorInfo_T pSensor ;
  76. SenInfo_T SensorInfo;
  77. uint8_t SensorIsSigned = FALSE;
  78. uint16_t SensorReading = 0;
  79. SensorSharedMem_T* pSMSharedMem;
  80. SDRRecHdr_T* pSDRRec;
  81. FullSensorRec_T* FullSDR;
  82. CompactSensorRec_T* CompSDR;
  83. int i = 0;
  84. int totalsize;
  85. /* Get the Sensor Shared Memory */
  86. pSMSharedMem = (SensorSharedMem_T*)&g_BMCInfo.SensorSharedMem;
  87. if(g_BMCInfo.SenConfig.ValidSensorCnt == 0)
  88. {
  89. pGetSensorInfoRes->CompletionCode = OEMCC_SENSOR_INFO_EMPTY;
  90. printf("ValidSensorCnt is 0\n");
  91. return 1;
  92. }
  93. if(SensorIndex >= g_BMCInfo.SenConfig.ValidSensorCnt)
  94. {
  95. pGetSensorInfoRes->CompletionCode = CC_PARAM_OUT_OF_RANGE;
  96. printf("Invalid SenosrIndex %d\n", SensorIndex);
  97. return 1;
  98. }
  99. //pValidSensor = (uint8_t*)(pAMIGetSensorInfoRes+1);
  100. // for(i = 0; i < g_BMCInfo.SenConfig.ValidSensorCnt; i++)
  101. // {
  102. //SensorIndex = g_BMCInfo.SenConfig.ValidSensorList[i];
  103. pSensor = pSMSharedMem->SensorInfo[SensorIndex];
  104. /*Copy the SDR Header*/
  105. memcpy(&pGetSensorInfoRes->SensorInfo.hdr,pSensor.SDRRec,sizeof(SDRRecHdr_T));
  106. pGetSensorInfoRes->SensorInfo.SensorNumber = pSensor.SensorNumber;
  107. pGetSensorInfoRes->SensorInfo.SensorTypeCode = pSensor.SensorTypeCode;
  108. pGetSensorInfoRes->SensorInfo.EventTypeCode = pSensor.EventTypeCode;
  109. pGetSensorInfoRes->SensorInfo.Units1 = pSensor.Units1;
  110. pGetSensorInfoRes->SensorInfo.Units2 = pSensor.Units2;
  111. pGetSensorInfoRes->SensorInfo.Units3 = pSensor.Units3;
  112. pGetSensorInfoRes->SensorInfo.M_LSB = pSensor.M_LSB;
  113. pGetSensorInfoRes->SensorInfo.M_MSB_Tolerance = pSensor.M_MSB_Tolerance;
  114. pGetSensorInfoRes->SensorInfo.B_LSB = pSensor.B_LSB;
  115. pGetSensorInfoRes->SensorInfo.B_MSB_Accuracy = pSensor.B_MSB_Accuracy;
  116. pGetSensorInfoRes->SensorInfo.Accuracy_MSB_Exp = pSensor.Accuracy_MSB_Exp;
  117. pGetSensorInfoRes->SensorInfo.RExp_BExp = pSensor.RExp_BExp;
  118. pGetSensorInfoRes->SensorInfo.LowerNonCritical = pSensor.LowerNonCritical;
  119. pGetSensorInfoRes->SensorInfo.LowerCritical = pSensor.LowerCritical;
  120. pGetSensorInfoRes->SensorInfo.LowerNonRecoverable = pSensor.LowerNonRecoverable;
  121. pGetSensorInfoRes->SensorInfo.UpperNonCritical = pSensor.UpperNonCritical;
  122. pGetSensorInfoRes->SensorInfo.UpperCritical = pSensor.UpperCritical;
  123. pGetSensorInfoRes->SensorInfo.UpperNonRecoverable= pSensor.UpperNonRecoverable;
  124. pGetSensorInfoRes->SensorInfo.Settable_Readable_ThreshMask= pSensor.SettableThreshMask;
  125. pGetSensorInfoRes->SensorInfo.Flags = pSensor.EventFlags & 0xe0;
  126. if((pSensor.EventFlags & BIT5) != 0)
  127. {
  128. pGetSensorInfoRes->SensorInfo.SensorReading = 0;
  129. }
  130. SensorReading = pSensor.SensorReading;
  131. pGetSensorInfoRes->SensorInfo.SensorReading = 0;
  132. SensorIsSigned = ( 0 != (pSensor.InternalFlags & BIT1));
  133. if (THRESHOLD_SENSOR_CLASS == pSensor.EventTypeCode)
  134. {
  135. pGetSensorInfoRes->SensorInfo.SensorReading = (SensorReading & 0x00FF);
  136. pGetSensorInfoRes->SensorInfo.ComparisonStatus = 0;
  137. if((pSensor.DeassertionEventEnablesByte2 & BIT6) == BIT6 )
  138. {
  139. if (CompareValues(SensorIsSigned, pGetSensorInfoRes->SensorInfo.SensorReading, pSensor.UpperNonRecoverable) >= 0)
  140. {
  141. pGetSensorInfoRes->SensorInfo.ComparisonStatus |= BIT5;
  142. }
  143. }
  144. if((pSensor.DeassertionEventEnablesByte2 & BIT5) == BIT5 )
  145. {
  146. if (CompareValues(SensorIsSigned, pGetSensorInfoRes->SensorInfo.SensorReading, pSensor.UpperCritical) >= 0)
  147. {
  148. pGetSensorInfoRes->SensorInfo.ComparisonStatus |= BIT4;
  149. }
  150. }
  151. if((pSensor.DeassertionEventEnablesByte2 & BIT4) == BIT4 )
  152. {
  153. if (CompareValues(SensorIsSigned, pGetSensorInfoRes->SensorInfo.SensorReading, pSensor.UpperNonCritical) >= 0)
  154. {
  155. pGetSensorInfoRes->SensorInfo.ComparisonStatus |= BIT3;
  156. }
  157. }
  158. if((pSensor.AssertionEventEnablesByte2 & BIT6) == BIT6 )
  159. {
  160. if (CompareValues(SensorIsSigned, pGetSensorInfoRes->SensorInfo.SensorReading, pSensor.LowerNonRecoverable) <= 0)
  161. {
  162. pGetSensorInfoRes->SensorInfo.ComparisonStatus |= BIT2;
  163. }
  164. }
  165. if((pSensor.AssertionEventEnablesByte2 & BIT5) == BIT5 )
  166. {
  167. if (CompareValues(SensorIsSigned, pGetSensorInfoRes->SensorInfo.SensorReading, pSensor.LowerCritical) <= 0)
  168. {
  169. pGetSensorInfoRes->SensorInfo.ComparisonStatus |= BIT1;
  170. }
  171. }
  172. if((pSensor.AssertionEventEnablesByte2 & BIT4) == BIT4 )
  173. {
  174. if (CompareValues(SensorIsSigned, pGetSensorInfoRes->SensorInfo.SensorReading, pSensor.LowerNonCritical) <= 0)
  175. {
  176. pGetSensorInfoRes->SensorInfo.ComparisonStatus |= BIT0;
  177. }
  178. }
  179. pGetSensorInfoRes->SensorInfo.ComparisonStatus &= ((pSensor.SettableThreshMask >> 8) & 0xFF);
  180. pGetSensorInfoRes->SensorInfo.OptionalStatus = 0;
  181. // For Threshold sensor, [7:6] - reserved. Returned as 1b. Ignore on read.
  182. pGetSensorInfoRes->SensorInfo.ComparisonStatus |= THRESHOLD_RESERVED_BIT;
  183. }
  184. else
  185. {
  186. pGetSensorInfoRes->SensorInfo.ComparisonStatus = (((uint8_t) (SensorReading & 0x00FF)) & ((uint8_t) (pSensor.SettableThreshMask & 0x00FF)) );
  187. pGetSensorInfoRes->SensorInfo.OptionalStatus = (((uint8_t) (SensorReading >> 8)) & ((uint8_t) (pSensor.SettableThreshMask >> 8)) );
  188. // For Discrete sensor, [7] - reserved. Returned as 1b. Ignore on read.
  189. pGetSensorInfoRes->SensorInfo.OptionalStatus |= DISCRETE_RESERVED_BIT;
  190. }
  191. if((pSensor.EventFlags & BIT7) == 0)
  192. {
  193. pGetSensorInfoRes->SensorInfo.AssertionEventByte1 = 0;
  194. pGetSensorInfoRes->SensorInfo.AssertionEventByte2 = 0;
  195. pGetSensorInfoRes->SensorInfo.DeassertionEventByte1 = 0;
  196. pGetSensorInfoRes->SensorInfo.DeassertionEventByte2 = 0;
  197. }
  198. if((pSensor.SensorCaps & BIT6) == 0)
  199. {
  200. pGetSensorInfoRes->SensorInfo.AssertionEventByte1 = (pSensor.AssertionHistoryByte1 & pSensor.AssertionEventEnablesByte1);
  201. pGetSensorInfoRes->SensorInfo.AssertionEventByte2 = (pSensor.AssertionHistoryByte2 & pSensor.AssertionEventEnablesByte2);
  202. pGetSensorInfoRes->SensorInfo.DeassertionEventByte1 = (pSensor.DeassertionHistoryByte1 & pSensor.DeassertionEventEnablesByte1);
  203. pGetSensorInfoRes->SensorInfo.DeassertionEventByte2 = (pSensor.DeassertionHistoryByte2 & pSensor.DeassertionEventEnablesByte2);
  204. }
  205. else
  206. {
  207. pGetSensorInfoRes->SensorInfo.AssertionEventByte1 = (pSensor.AssertionEventOccuredByte1 & pSensor.AssertionEventEnablesByte1);
  208. pGetSensorInfoRes->SensorInfo.AssertionEventByte2 = (pSensor.AssertionEventOccuredByte2 & pSensor.AssertionEventEnablesByte2);
  209. pGetSensorInfoRes->SensorInfo.DeassertionEventByte1 = (pSensor.DeassertionEventOccuredByte1 & pSensor.DeassertionEventEnablesByte1);
  210. pGetSensorInfoRes->SensorInfo.DeassertionEventByte2 = (pSensor.DeassertionEventOccuredByte2 & pSensor.DeassertionEventEnablesByte2);
  211. }
  212. pSDRRec = GetSDRRec(pSensor.SDRRec->ID);
  213. if(pSensor.SDRRec->Type == FULL_SDR_REC) /*Full SDR*/
  214. {
  215. FullSDR = (FullSensorRec_T *)pSDRRec;
  216. pGetSensorInfoRes->SensorInfo.OwnerID = FullSDR->OwnerID;
  217. pGetSensorInfoRes->SensorInfo.OwnerLUN= FullSDR->OwnerLUN;
  218. pGetSensorInfoRes->SensorInfo.MaxReading = FullSDR->MaxReading;
  219. pGetSensorInfoRes->SensorInfo.MinReading = FullSDR->MinReading;
  220. pGetSensorInfoRes->SensorInfo.Linearization = FullSDR->Linearization;
  221. memset(pGetSensorInfoRes->SensorInfo.SensorName,0,MAX_ID_STR_LEN);
  222. strncpy(pGetSensorInfoRes->SensorInfo.SensorName,FullSDR->IDStr, MAX_ID_STR_LEN - (sizeof(FullSensorRec_T) - sizeof(SDRRecHdr_T) - FullSDR->hdr.Len));
  223. }
  224. else if(pSensor.SDRRec->Type == COMPACT_SDR_REC) /*Compact SDR*/
  225. {
  226. CompSDR = (CompactSensorRec_T *)pSDRRec;
  227. pGetSensorInfoRes->SensorInfo.OwnerID = CompSDR->OwnerID;
  228. pGetSensorInfoRes->SensorInfo.OwnerLUN= CompSDR->OwnerLUN;
  229. pGetSensorInfoRes->SensorInfo.MaxReading = 0;
  230. pGetSensorInfoRes->SensorInfo.MinReading = 0;
  231. pGetSensorInfoRes->SensorInfo.Linearization = 0;
  232. memset(pGetSensorInfoRes->SensorInfo.SensorName,0,MAX_ID_STR_LEN);
  233. strncpy(pGetSensorInfoRes->SensorInfo.SensorName,CompSDR->IDStr, MAX_ID_STR_LEN - (sizeof(CompactSensorRec_T) - sizeof(SDRRecHdr_T) - CompSDR->hdr.Len));
  234. }
  235. //memcpy(pValidSensor,(uint8_t *)&SensorInfo,sizeof(SenInfo_T));
  236. //pValidSensor = pValidSensor + sizeof(SenInfo_T);
  237. //}
  238. pGetSensorInfoRes->CompletionCode = CC_NORMAL;
  239. //pAMIGetSensorInfoRes->Noofentries = g_BMCInfo.SenConfig.ValidSensorCnt;
  240. //totalsize = sizeof(AMIGetSensorInfoRes_T) + (sizeof(SenInfo_T) * 11/*g_BMCInfo.SenConfig.ValidSensorCnt*/);
  241. // printf("return %d :", totalsize);
  242. // for(i=0;i<sizeof(AMIGetSensorInfoRes_T) + (sizeof(SenInfo_T) * g_BMCInfo.SenConfig.ValidSensorCnt);i++)
  243. // printf("%#x ", pRes[i]);
  244. // printf("\n");
  245. return sizeof(StorleadGetSensorInfoRes_T);
  246. }
  247. /*
  248. *@fn AMIGetSELEntires
  249. *@param This function retrieves the SEL entries
  250. *@return Returns CC_NORMAL
  251. */
  252. #define MAX_FULL_SEL_ENTRIES 900 //18*50=900, 50个SEL Entry, 每个18字节
  253. int Storlead_GetSELEntires(uint8_t *pReq, uint8_t ReqLen, uint8_t *pRes)
  254. {
  255. AMIGetSELEntriesReq_T *pAMIGetSelEntriesReq = (AMIGetSELEntriesReq_T *)pReq;
  256. AMIGetSELEntriesRes_T *pAMIGetSelEntiresRes = (AMIGetSELEntriesRes_T *)pRes;
  257. SELRepository_T *m_sel = NULL;
  258. uint16_t NumRecords = 0;
  259. m_sel = (SELRepository_T*)g_BMCInfo.pSEL;
  260. NumRecords = m_sel->NumRecords;
  261. if(((NumRecords - pAMIGetSelEntriesReq->Noofentretrieved) * sizeof(SELRec_T)) < MAX_FULL_SEL_ENTRIES)
  262. {
  263. pAMIGetSelEntiresRes->Status = FULL_SEL_ENTRIES;
  264. pAMIGetSelEntiresRes->Noofentries = NumRecords - pAMIGetSelEntriesReq->Noofentretrieved;
  265. }
  266. else if(NumRecords == SEL_EMPTY_REPOSITORY)
  267. {
  268. pAMIGetSelEntiresRes->CompletionCode = OEMCC_SEL_EMPTY_REPOSITORY;
  269. return sizeof(*pRes);
  270. }
  271. else if (NumRecords < pAMIGetSelEntriesReq->Noofentretrieved)
  272. {
  273. pAMIGetSelEntiresRes->CompletionCode = OEMCC_SEL_CLEARED;
  274. return sizeof(*pRes);
  275. }
  276. else
  277. {
  278. pAMIGetSelEntiresRes->Status = PARTIAL_SEL_ENTRIES;
  279. pAMIGetSelEntiresRes->Noofentries = ((MAX_FULL_SEL_ENTRIES - sizeof(AMIGetSELEntriesRes_T))/sizeof(SELRec_T));
  280. }
  281. memcpy((uint8_t*)(pAMIGetSelEntiresRes + 1),(uint8_t*)&m_sel->SELRecord[pAMIGetSelEntriesReq->Noofentretrieved],
  282. sizeof(SELRec_T)*pAMIGetSelEntiresRes->Noofentries);
  283. pAMIGetSelEntiresRes->LastRecID = m_sel->LastRecID;
  284. pAMIGetSelEntiresRes->CompletionCode = CC_NORMAL;
  285. return sizeof(AMIGetSELEntriesRes_T) + (sizeof(SELRec_T) * pAMIGetSelEntiresRes->Noofentries);
  286. }
  287. int Storlead_AuthorVerify(uint8_t *pReq, uint8_t ReqLen, uint8_t *pRes)
  288. {
  289. AuthorVerify_T *pAuthorVerify = (AuthorVerify_T *)pReq;
  290. int i;
  291. printf("Storlead_AuthorVerify, username: %s, password: %s\n", pAuthorVerify->name, pAuthorVerify->password);
  292. for(i=0;i<MAX_USER_NUM;i++)
  293. {
  294. if(strcmp(g_BMCInfo.UserInfoTbl[i].UserName, pAuthorVerify->name) == 0)
  295. {
  296. if(strcmp(g_BMCInfo.UserInfoTbl[i].UserPassword, pAuthorVerify->password)==0)
  297. {
  298. *pRes = CC_NORMAL;
  299. return 1;
  300. }
  301. else
  302. {
  303. printf("Invalid password!\n");
  304. *pRes = CC_PASSWORD_TEST_FAILED;
  305. return 1;
  306. }
  307. }
  308. }
  309. printf("Invalid username!\n");
  310. *pRes = CC_PASSWORD_TEST_FAILED;
  311. return 1;
  312. }
  313. int Storlead_GetSensorHistory(uint8_t *pReq, uint8_t ReqLen, uint8_t *pRes)
  314. {
  315. uint8_t *pSensorHistory = pRes+3;
  316. uint8_t sensorNum = pReq[0];
  317. uint16_t offset = (pReq[1]<<8) | pReq[2];
  318. uint16_t len = (pReq[3]<<8) | pReq[4];
  319. uint16_t total_len = 480;
  320. *pRes= CC_NORMAL;
  321. if(offset >= total_len)
  322. {
  323. *pRes = CC_PARAM_OUT_OF_RANGE;
  324. return 1;
  325. }
  326. if(getSensorHistory(sensorNum, pSensorHistory) != 0)
  327. {
  328. *pRes = CC_PARAM_OUT_OF_RANGE;
  329. return 1;
  330. };
  331. if(len > (total_len - offset))
  332. len = total_len - offset;
  333. printf("len = %d, offset = %d, total_len = %d\n", len, offset, total_len);
  334. *(pRes+1) = (len>>8)&0xff;
  335. *(pRes+2) = len&0xff;
  336. return len+3;
  337. }
  338. int Storlead_GetFanInfo(uint8_t *pReq, uint8_t ReqLen, uint8_t *pRes)
  339. {
  340. *pRes = CC_NORMAL;
  341. memcpy(pRes+1, (uint8_t*)gFanInfo, FAN_NUMBERS*sizeof(FanInfo_T));
  342. // int i;
  343. // printf("=======FAN==========\n");
  344. // for(i=0;i<FAN_NUMBERS*sizeof(FanInfo_T)+1;i++)
  345. // printf("%02x ", pRes[i]);
  346. // printf("\n");
  347. return FAN_NUMBERS*sizeof(FanInfo_T) + 1;
  348. }
  349. int Storlead_SetFanInfo(uint8_t *pReq, uint8_t ReqLen, uint8_t *pRes)
  350. {
  351. uint8_t index = pReq[0];
  352. uint8_t mode = pReq[1]; //0: 自动, 1:手动
  353. uint8_t level = pReq[2];
  354. *pRes = CC_NORMAL;
  355. if(index >= FAN_NUMBERS)
  356. {
  357. printf("Invalid index %d\n", index);
  358. *pRes = CC_PARAM_OUT_OF_RANGE;
  359. return 1;
  360. }
  361. if(mode > 1)
  362. {
  363. printf("Invalid mode %d\n", mode);
  364. *pRes = CC_PARAM_OUT_OF_RANGE;
  365. return 1;
  366. }
  367. if(level > 100)
  368. level = 100;
  369. gFanInfo[index].mode = mode;
  370. if(mode == 1)
  371. {
  372. gFanInfo[index].level = level;
  373. }
  374. return 1;
  375. }
  376. int Storlead_getAllBladeStatus(uint8_t *pReq, uint8_t ReqLen, uint8_t *pRes)
  377. {
  378. pRes[0] = CC_NORMAL;
  379. memcpy(pRes+1, gBladeStatus, (BLADE_NUMBERS*sizeof(BladeStatus_T)));
  380. return 1+(BLADE_NUMBERS*sizeof(BladeStatus_T));
  381. }
  382. int Storlead_SetBladeManageFn(uint8_t *pReq, uint8_t ReqLen, uint8_t *pRes)
  383. {
  384. if(pReq[0] > 1)
  385. {
  386. printf("Invalid param %d\n", pReq[0]);
  387. pRes[0] = CC_PARAM_OUT_OF_RANGE;
  388. return 1;
  389. }
  390. g_BMCInfo.BladeManageEn = pReq[0];
  391. pRes[0] = CC_NORMAL;
  392. return 1;
  393. }
  394. int Storlead_GetBladeManageFn(uint8_t *pReq, uint8_t ReqLen, uint8_t *pRes)
  395. {
  396. pRes[0] = CC_NORMAL;
  397. pRes[1] = g_BMCInfo.BladeManageEn;
  398. return 2;
  399. }
  400. int Storlead_GetChassisInfo(uint8_t *pReq, uint8_t ReqLen, uint8_t *pRes)
  401. {
  402. /*
  403. typedef struct{
  404. uint8_t slotNum; //total slot numbers of chassis.
  405. uint8_t supportChassisManageFn;
  406. uint8_t chassisManageFnEnable;
  407. uint8_t curIndex;
  408. } OemChassisInfo_T;
  409. */
  410. pRes[0] = CC_NORMAL;
  411. pRes[1] = BLADE_NUMBERS;
  412. pRes[2] = g_BMCInfo.isChMC;
  413. pRes[3] = g_BMCInfo.BladeManageEn;
  414. pRes[4] = g_BMCInfo.IndexInChassis;
  415. return 5;
  416. }
  417. int Storlead_RestoreFactorSettings(uint8_t *pReq, uint8_t ReqLen, uint8_t *pRes)
  418. {
  419. int i;
  420. pRes[0] = CC_NORMAL;
  421. //TODO:擦除Flash
  422. //for(i=0;i<)
  423. //sf_sector_erase(5, CONFIG_FLASH_START);
  424. return 1;
  425. }
  426. int Storlead_GetLanInfo(uint8_t *pReq, uint8_t ReqLen, uint8_t *pRes)
  427. {
  428. pRes[0] = CC_NORMAL;
  429. uint8_t index = pReq[0];
  430. if(index > 0)
  431. {
  432. pRes[0] = CC_PARAM_OUT_OF_RANGE;
  433. return 1;
  434. }
  435. memcpy(pRes+1, &g_BMCInfo.IpmiConfig.LanInfo[index], sizeof(LanInfo_T));
  436. return 1+sizeof(LanInfo_T);
  437. }
  438. int Storlead_SetLanInfo(uint8_t *pReq, uint8_t ReqLen, uint8_t *pRes)
  439. {
  440. MsgPkt_T m_MsgPkt;
  441. uint8_t index = pReq[0];
  442. LanInfo_T *pLanInfo = (LanInfo_T*)&pReq[1];
  443. if(index > 0) //只有一张网卡,index只能是0
  444. {
  445. pRes[0] = CC_PARAM_OUT_OF_RANGE;
  446. return 1;
  447. }
  448. memcpy(&g_BMCInfo.IpmiConfig.LanInfo[index], pLanInfo, sizeof(LanInfo_T));
  449. m_MsgPkt.Param = PARAM_LAN;
  450. m_MsgPkt.NetFnLUN = NETFNLUN_IPMI_STORLEAD;
  451. m_MsgPkt.Cmd = CMD_SET_LAN_INFO;
  452. m_MsgPkt.Size = sizeof(LanInfo_T);
  453. memcpy(m_MsgPkt.Data, pLanInfo, sizeof(LanInfo_T));
  454. PostMsg(gPendActionIfc, &m_MsgPkt);
  455. pRes[0] = CC_NORMAL;
  456. return 1;
  457. }