Sensor.c 78 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114
  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. * sensor.c
  17. * Sensor functions.
  18. *
  19. * Author: Govind Kothandapani <govindk@ami.com>
  20. * Bakka Ravinder Reddy <bakkar@ami.com>
  21. ******************************************************************/
  22. #include "MsgHndlr.h"
  23. #include "sensor_tbl.h"
  24. #include "com_IPMI_Sensor.h"
  25. #include "Support.h"
  26. #include "Sensor.h"
  27. #include "SDRFunc.h"
  28. #include "SensorEvent.h"
  29. #include <string.h>
  30. #include "main.h"
  31. /* Reserved bit macro definitions */
  32. #define RESERVED_BITS_SETSENSORTYPE 0X80 //(BIT7)
  33. #define RESERVED_BITS_REARMSENSOR_REARMALLEVENTS 0X7F //(BIT6 | BIT5 | BIT4 | BIT3 | BIT2 | BIT1 | BIT0)
  34. #define RESERVED_BITS_REARMSENSOR_REARMASSEVT2_1 0XF0 //(BIT7 | BIT6 | BIT5 | BIT4)
  35. #define RESERVED_BITS_REARMSENSOR_REARMDEASSEVT2_1 0XF0 //(BIT7 | BIT6 | BIT5 | BIT4)
  36. #define RESERVED_BITS_REARMSENSOR_REARMASSEVT2_2 0X80 //(BIT7)
  37. #define RESERVED_BITS_REARMSENSOR_REARMDEASSEVT2_2 0X80 //(BIT7)
  38. #define RESERVED_BITS_SETSENSORTHRESHOLDS 0XC0 //(BIT7 | BIT6)
  39. #define RESERVED_BITS_SETSENEVTEN_FLAGS 0X0F //(BIT3 | BIT2 | BIT1 | BIT0)
  40. #define RESERVED_BITS_SETSENEVTEN_ASSERTIONMASK 0X8000
  41. #define RESERVED_BITS_SETSENEVTEN_DEASSERTIONMASK 0X8000
  42. #define RESERVED_BITS_SETSENRD_ASSEVTOCCBYTE_1 0xF0 //(BIT7 | BIT6 | BIT5 | BIT4)
  43. #define RESERVED_BITS_SETSENRD_DEASSEVTOCCBYTE_1 0xF0 //(BIT7 | BIT6 | BIT5 | BIT4)
  44. #define RESERVED_BITS_SETSENRD_ASSEVTOCCBYTE_2 0x80 //(BIT7)
  45. #define RESERVED_BITS_SETSENRD_DEASSEVTOCCBYTE_2 0x80 //(BIT7)
  46. #define SENSOR_THRESOLD_ACCESS_BITS 0x0c //(BIT2 | BIT3)
  47. #define SENSOR_HYSTERESIS_ACCESS_BITS 0x30 //(BIT4 | BIT5)
  48. #if SENSOR_DEVICE == 1
  49. /*** Local Definitions ***/
  50. //#define NUM_SENSORS() (g_BMCInfo.SenConfig.NumThreshSensors + g_BMCInfo.SenConfig.NumNonThreshSensors)
  51. #define FULL_SDR_REC 0x01
  52. #define COMPACT_SDR_REC 0x02
  53. #define OEM_SDR_FRU_REC 0xf1
  54. #define OEM_SDR_NM_REC 0x0D
  55. #define FL_STATIC_SENSOR 0x00
  56. #define FL_NUM_LUN(NUM_LUN) NUM_LUN
  57. #define LWR_NON_CRIT 0x01
  58. #define LWR_CRIT 0x02
  59. #define LWR_NON_REC 0x04
  60. #define UPR_NON_CRIT 0x08
  61. #define UPR_CRIT 0x10
  62. #define UPR_NON_REC 0x20
  63. #define EVENT_MSG_MASK 0x80
  64. #define SCAN_MASK 0x40
  65. #define ENABLE_DISABLE_EVENT_MASK 0x30
  66. #define DO_NOT_CHANGE 0x00
  67. #define ENABLE_SELECTED_EVENT_MSG 0x10
  68. #define DISABLE_SELECTED_EVENT_MSG 0x20
  69. #define CC_INVALID_ATTEMPT_TO_SET 0x80
  70. #define MIN_SET_SEN_READING_CMD_LEN 3
  71. #define LEN_FOR_EVT_DATA 10
  72. #define MAX_SET_SEN_READ_LEN 10
  73. #define LEN_FOR_ASSERT_DATA 5
  74. #define LEN_FOR_DEASSERT_DATA 7
  75. #define LEN_FOR_SETSENSOR_DATA 3
  76. #define NOT_FOUND_SCAN_DISABLED -1
  77. #define NOT_FOUND_SCAN_ENABLED -2
  78. #define ENTITY_FOUND 1
  79. #define ENTITY_NOT_FOUND 0
  80. #define DCMI_TEMP_READING 0x0
  81. #define DCMI_INST_NUMBER 0x1
  82. /*** Local typedefs ***/
  83. /**
  84. * @struct SR_SensorInfo_T
  85. * @brief Sensor Information.
  86. **/
  87. typedef struct
  88. {
  89. /* CAUTION Order of members dependent on Response structures */
  90. uint8_t M_LSB;
  91. uint8_t M_MSB_Tolerance;
  92. uint8_t B_LSB;
  93. uint8_t B_MSB_Accuracy;
  94. uint8_t Accuracy_MSB_Exp;
  95. uint8_t RExp_BExp;
  96. uint8_t PositiveHysterisis;
  97. uint8_t NegativeHysterisis;
  98. uint8_t LowerNonCritical;
  99. uint8_t LowerCritical;
  100. uint8_t LowerNonRecoverable;
  101. uint8_t UpperNonCritical;
  102. uint8_t UpperCritical;
  103. uint8_t UpperNonRecoverable;
  104. uint8_t EventFlags;
  105. uint16_t AssertionMask;
  106. uint16_t DeAssertionMask;
  107. uint8_t EventTypeCode;
  108. uint16_t ReadWriteThreshMask;
  109. uint8_t SensorInit;
  110. uint8_t SensorNum;
  111. } SR_SensorInfo_T;
  112. /*** Global Variables ***/
  113. // uint8_t g_NumThreshSensors;
  114. // uint8_t g_NumNonThreshSensors;
  115. // uint8_t g_FRUInfo[MAX_PDK_FRU_SUPPORTED];
  116. //FRUInfo_T *m_FRUInfo[MAX_PDK_FRU_SUPPORTED];
  117. //uint8_t m_total_frus=0;
  118. //Sensor-Type Sensor-specific-offset
  119. static const uint8_t sensor_presence [][2] = {
  120. {PROCESSOR, PROCESSOR_PRESENCE_DETECTED},
  121. {POWER_SUPPLY, POWER_SUPPLY_PRESENCE_DETECTED},
  122. {POWER_SUPPLY, POWER_SUPPLY_OUT_OF_RANGE_PRESENT},
  123. {MEMORY, MEMORY_PRESENCE_DETECTED},
  124. {ENTITY_PRESENCE, ENTITY_PRESENCE_ENTITY_PRESENT},
  125. {BATTERY, BATTERY_PRESENCE_DETECTED}
  126. };
  127. #define SENSOR_PRESENCE_COUNT (sizeof(sensor_presence)/ sizeof(sensor_presence[0]))
  128. /*** Prototype Declaration ***/
  129. //static void FindNumSensors (void);
  130. /*---------------------------------------
  131. * InitSensor
  132. *---------------------------------------*/
  133. int
  134. InitSensorInfo ()
  135. {
  136. SensorInfo_T* pSensorInfo;
  137. SensorSharedMem_T* pSMSharedMem;
  138. SDRRecHdr_T* pSDRRec;
  139. int i;
  140. pSMSharedMem = ( SensorSharedMem_T*)&g_BMCInfo.SensorSharedMem;
  141. /* Update Sensor Properties & Get SDR & initialize sensors */
  142. for (i = 0; i < g_BMCInfo.SenConfig.ValidSensorCnt; i++)
  143. {
  144. pSensorInfo = (SensorInfo_T*)&pSMSharedMem->SensorInfo [i];
  145. g_BMCInfo.SenConfig.ValidSensorList[i] = sensor_tbl[i].sensor_number;
  146. pSensorInfo->SensorNumber = sensor_tbl[i].sensor_number;
  147. pSensorInfo->SensorReading = 0;
  148. pSensorInfo->SensorMonitorInterval = sensor_tbl[i].monitor_interval;
  149. pSensorInfo->SensorState = sensor_tbl[i].monitor_state;
  150. pSensorInfo->PowerOnDelay = sensor_tbl[i].poweron_delay;
  151. pSensorInfo->SysResetDelay = sensor_tbl[i].reset_delay;
  152. pSDRRec = SR_FindSDR(pSensorInfo->SensorNumber);
  153. SR_LoadSDRDefaults(pSDRRec, pSensorInfo);
  154. pSensorInfo->SDRRec = (SDRRecHdr_T*)pSDRRec;
  155. }
  156. return 0;
  157. }
  158. /*---------------------------------------
  159. * InitSensor
  160. *---------------------------------------*/
  161. int
  162. InitSensorDev ()
  163. {
  164. int i;
  165. sensor_tbl_t* pSensorDev = NULL;
  166. for(i=0;i<g_BMCInfo.SenConfig.ValidSensorCnt;i++)
  167. {
  168. pSensorDev = (sensor_tbl_t*)getSensorDev(g_BMCInfo.SenConfig.ValidSensorList[i]);
  169. pSensorDev->device_init();
  170. }
  171. return 0;
  172. }
  173. /*-----------------------------------------
  174. * SR_FindSDR
  175. *-----------------------------------------*/
  176. SDRRecHdr_T* SR_FindSDR (uint8_t SensorNum)
  177. {
  178. SDRRecHdr_T* sr = SDR_GetFirstSDRRec ();
  179. FullSensorRec_T* sfs = NULL;
  180. CompactSensorRec_T* scs = NULL;
  181. while(sr != 0)
  182. {
  183. if (sr->Type == FULL_SDR_REC)
  184. {
  185. sfs = (FullSensorRec_T*) sr;
  186. if (sfs->SensorNum == SensorNum) { return sr; }
  187. }
  188. else if (sr->Type == COMPACT_SDR_REC)
  189. {
  190. scs = (CompactSensorRec_T*) sr;
  191. if (scs->SensorNum == SensorNum) { return sr; }
  192. }
  193. /* Get the next record */
  194. sr = SDR_GetNextSDRRec (sr);
  195. }
  196. return NULL;
  197. }
  198. /*-----------------------------------------
  199. * SR_LoadSDRDefaults
  200. * CAUTION !! this function has to be called
  201. * after acquiring a sensor shared memory mutex
  202. *-----------------------------------------*/
  203. extern void
  204. SR_LoadSDRDefaults (SDRRecHdr_T* sr, SensorInfo_T* pSensorInfo)
  205. {
  206. FullSensorRec_T* sfs;
  207. CompactSensorRec_T* scs;
  208. // Populater sensor information for Threshold sensors
  209. if (sr->Type == FULL_SDR_REC)
  210. {
  211. sfs = ( FullSensorRec_T*) sr;
  212. pSensorInfo->SensorOwnerLun = sfs->OwnerLUN; /* Multi-LUN support */
  213. pSensorInfo->SensorNumber = sfs->SensorNum;
  214. pSensorInfo->M_LSB = sfs->M;
  215. pSensorInfo->M_MSB_Tolerance = sfs->M_Tolerance;
  216. pSensorInfo->B_LSB = sfs->B;
  217. pSensorInfo->B_MSB_Accuracy = sfs->B_Accuracy;
  218. pSensorInfo->Accuracy_MSB_Exp = sfs->Accuracy;
  219. pSensorInfo->RExp_BExp = sfs->R_B_Exp;
  220. pSensorInfo->Units1 = sfs->Units1;
  221. pSensorInfo->Units2 = sfs->Units2;
  222. pSensorInfo->Units3 = sfs->Units3;
  223. pSensorInfo->RecordID = sfs->hdr.ID;
  224. pSensorInfo->PosHysteresis = sfs->PositiveHysterisis;
  225. pSensorInfo->NegHysteresis = sfs->NegativeHysterisis;
  226. pSensorInfo->SensorInit = sfs->SensorInit;
  227. pSensorInfo->SettableThreshMask = (sfs->DiscreteReadingMask);
  228. pSensorInfo->SensorCaps = sfs->SensorCaps;
  229. pSensorInfo->SensorTypeCode = sfs->SensorType;
  230. pSensorInfo->OEMField = sfs->OEMField ;
  231. if (pSensorInfo->SensorInit & BIT4)
  232. {
  233. if (pSensorInfo->SettableThreshMask & BIT8)
  234. {
  235. pSensorInfo->LowerNonCritical = sfs->LowerNonCritical;
  236. }
  237. if (pSensorInfo->SettableThreshMask & BIT9)
  238. {
  239. pSensorInfo->LowerCritical = sfs->LowerCritical;
  240. }
  241. if (pSensorInfo->SettableThreshMask & BIT10)
  242. {
  243. pSensorInfo->LowerNonRecoverable = sfs->LowerNonRecoverable;
  244. }
  245. if (pSensorInfo->SettableThreshMask & BIT11)
  246. {
  247. pSensorInfo->UpperNonCritical = sfs->UpperNonCritical;
  248. }
  249. if (pSensorInfo->SettableThreshMask & BIT12)
  250. {
  251. pSensorInfo->UpperCritical = sfs->UpperCritical;
  252. }
  253. if (pSensorInfo->SettableThreshMask & BIT13)
  254. {
  255. pSensorInfo->UpperNonRecoverable = sfs->UpperNonRecoverable;
  256. }
  257. }
  258. pSensorInfo->EventFlags = 0;
  259. pSensorInfo->EventFlags |= sfs->SensorInit & BIT6;
  260. pSensorInfo->EventFlags |= (sfs->SensorInit & BIT5) << 2;
  261. pSensorInfo->EventFlags |= sfs->SensorInit & BIT5;
  262. pSensorInfo->AssertionEventEnablesByte1 = (sfs->AssertionEventMask) & 0xFF;
  263. pSensorInfo->AssertionEventEnablesByte2 = ((sfs->AssertionEventMask) >> 8) & 0xFF;
  264. pSensorInfo->DeassertionEventEnablesByte1= (sfs->DeAssertionEventMask) & 0xFF;
  265. pSensorInfo->DeassertionEventEnablesByte2= ((sfs->DeAssertionEventMask) >> 8) & 0xFF;
  266. pSensorInfo->EventTypeCode = sfs->EventTypeCode;
  267. pSensorInfo->SensorReadType = sfs->EventTypeCode;
  268. }
  269. else if (sr->Type == COMPACT_SDR_REC)
  270. {
  271. scs = ( CompactSensorRec_T*) sr;
  272. pSensorInfo->SensorOwnerLun = scs->OwnerLUN; /* Multi-LUN support */
  273. pSensorInfo->SensorNumber = scs->SensorNum;
  274. pSensorInfo->EventFlags = 0;
  275. pSensorInfo->EventFlags |= scs->SensorInit & BIT6;
  276. pSensorInfo->EventFlags |= (scs->SensorInit & BIT5) << 2;
  277. pSensorInfo->EventFlags |= scs->SensorInit & BIT5;
  278. pSensorInfo->AssertionEventEnablesByte1 = (scs->AssertionEventMask) & 0xFF;
  279. pSensorInfo->AssertionEventEnablesByte2 = ((scs->AssertionEventMask) >> 8) & 0xFF;
  280. pSensorInfo->DeassertionEventEnablesByte1= (scs->DeAssertionEventMask) & 0xFF;
  281. pSensorInfo->DeassertionEventEnablesByte2= ((scs->DeAssertionEventMask) >> 8) & 0xFF;
  282. pSensorInfo->SensorInit = scs->SensorInit;
  283. pSensorInfo->SettableThreshMask = (scs->DiscreteReadingMask);
  284. pSensorInfo->PosHysteresis = scs->PositiveHysteris;
  285. pSensorInfo->NegHysteresis = scs->NegativeHysterisis;
  286. pSensorInfo->EventTypeCode = scs->EventTypeCode;
  287. pSensorInfo->SensorReadType = scs->EventTypeCode;
  288. pSensorInfo->SensorTypeCode = scs->SensorType;
  289. pSensorInfo->SensorCaps = scs->SensorCaps;
  290. pSensorInfo->Units1 = scs->Units1;
  291. pSensorInfo->Units2 = scs->Units2;
  292. pSensorInfo->Units3 = scs->Units3;
  293. pSensorInfo->OEMField = scs->OEMField ;
  294. }
  295. }
  296. /*---------------------------------------
  297. * GetDevSDRInfo
  298. *---------------------------------------*/
  299. int
  300. GetDevSDRInfo ( uint8_t* pReq, uint8_t ReqLen, uint8_t* pRes)
  301. {
  302. GetSDRInfoRes_T* pGetDevSDRInfoRes = (GetSDRInfoRes_T*) pRes;
  303. /* Fill in response data */
  304. pGetDevSDRInfoRes->CompletionCode = CC_NORMAL;
  305. pGetDevSDRInfoRes->NumSensor = g_BMCInfo.SenConfig.ValidSensorCnt;
  306. pGetDevSDRInfoRes->Flags = 0x01; /* BIT7 = 0 (static sensors), BIT0 = 1 (on LUN 0) */
  307. pGetDevSDRInfoRes->TimeStamp = 0;
  308. return sizeof (GetSDRInfoRes_T);
  309. }
  310. /*---------------------------------------
  311. * GetDevSDR
  312. *---------------------------------------*/
  313. int
  314. GetDevSDR ( uint8_t* pReq, uint8_t ReqLen, uint8_t* pRes)
  315. {
  316. return GetSDR (pReq, ReqLen, pRes);
  317. }
  318. /*---------------------------------------
  319. * GetDevSDR
  320. *---------------------------------------*/
  321. int
  322. ReserveDevSDRRepository ( uint8_t* pReq, uint8_t ReqLen, uint8_t* pRes)
  323. {
  324. return ReserveSDRRepository (pReq, ReqLen, pRes);
  325. }
  326. /*---------------------------------------
  327. * SetSensorType
  328. *---------------------------------------*/
  329. int
  330. SetSensorType ( uint8_t* pReq, uint8_t ReqLen, uint8_t* pRes)
  331. {
  332. printf("SetSensorType not implement\r\n");
  333. // //pRes [0] = CC_INV_CMD;
  334. // //return sizeof (*pRes);
  335. // SetSensorTypeReq_T * pSetSensorTypeReq=( SetSensorTypeReq_T *)pReq;
  336. // SetSensorTypeRes_T * pSetSensorTypeRes=( SetSensorTypeRes_T *)pRes;
  337. // SensorSharedMem_T* pSenSharedMem;
  338. // BMCInfo_t* pBMCInfo = &g_BMCInfo[BMCInst];
  339. // /* Check for the reserved bytes should b zero */
  340. // if ( 0 != (pSetSensorTypeReq->EventTypeCode & RESERVED_BITS_SETSENSORTYPE ) )
  341. // {
  342. // pSetSensorTypeRes->CompletionCode = CC_INV_DATA_FIELD;
  343. // return sizeof(*pRes);
  344. // }
  345. // OS_THREAD_MUTEX_ACQUIRE(&g_BMCInfo[BMCInst].SensorSharedMemMutex, WAIT_INFINITE);
  346. // pSenSharedMem = ( SensorSharedMem_T*)&g_BMCInfo.SensorSharedMem; //m_hSensorSharedMem;
  347. // if (!pSenSharedMem->SensorInfo [pSetSensorTypeReq->SensorNum].IsSensorPresent)
  348. // {
  349. // /* Release mutex for Sensor shared memory */
  350. // OS_THREAD_MUTEX_RELEASE(&g_BMCInfo[BMCInst].SensorSharedMemMutex);
  351. // /* return sdr record not present completion code */
  352. // pSetSensorTypeRes->CompletionCode = CC_SDR_REC_NOT_PRESENT;
  353. // return sizeof (*pRes);
  354. // }
  355. // pSenSharedMem->SensorInfo[pSetSensorTypeReq->SensorNum].SensorTypeCode=pSetSensorTypeReq->SensorType;
  356. // pSenSharedMem->SensorInfo[pSetSensorTypeReq->SensorNum].EventTypeCode=pSetSensorTypeReq->EventTypeCode;
  357. // OS_THREAD_MUTEX_RELEASE(&g_BMCInfo[BMCInst].SensorSharedMemMutex);
  358. // pSetSensorTypeRes->CompletionCode=CC_NORMAL;
  359. // return sizeof(*pSetSensorTypeRes);
  360. return 0;
  361. }
  362. /*---------------------------------------
  363. * GetSensorType
  364. *---------------------------------------*/
  365. int
  366. GetSensorType ( uint8_t* pReq, uint8_t ReqLen, uint8_t* pRes)
  367. {
  368. //pRes [0] = CC_INV_CMD;
  369. // return sizeof (*pRes);
  370. GetSensorTypeReq_T * pGetSensorTypeReq=( GetSensorTypeReq_T *)pReq;
  371. GetSensorTypeRes_T * pGetSensorTypeRes=( GetSensorTypeRes_T *)pRes;
  372. SensorInfo_T* pSensorInfo = NULL;
  373. pSensorInfo = getSensorInfo(pGetSensorTypeReq->SensorNum);
  374. pGetSensorTypeRes->CompletionCode=CC_NORMAL;
  375. pGetSensorTypeRes->SensorType=pSensorInfo->SensorTypeCode;
  376. pGetSensorTypeRes->EventTypeCode=pSensorInfo->EventTypeCode;
  377. return sizeof(*pGetSensorTypeRes);
  378. }
  379. /*---------------------------------------
  380. * ReArmSensor
  381. *---------------------------------------*/
  382. int
  383. ReArmSensor ( uint8_t* pReq, uint8_t ReqLen, uint8_t* pRes)
  384. {
  385. printf("ReArmSensor not implement\r\n");
  386. // MsgPkt_T Msg;
  387. // HQueue_T hSMHndlr_Q;
  388. // ReArmSensorReq_T ReArmSensorReq;
  389. // ReArmSensorReq_T* pReArmSensorReq = &ReArmSensorReq;
  390. // ReArmSensorRes_T* pReArmSensorRes = ( ReArmSensorRes_T*) pRes;
  391. // _fmemset (&ReArmSensorReq, 0, sizeof (ReArmSensorReq_T));
  392. // _fmemcpy (&ReArmSensorReq, pReq, ReqLen);
  393. // SensorSharedMem_T* pSenSharedMem;
  394. // BMCInfo_t* pBMCInfo = &g_BMCInfo[BMCInst];
  395. // /* if request length is invalid */
  396. // if ((ReqLen < 2) || (ReqLen > sizeof (ReArmSensorReq_T)))
  397. // {
  398. // /* return request invalid length completion code */
  399. // pReArmSensorRes->CompletionCode = CC_REQ_INV_LEN;
  400. // return sizeof (*pRes);
  401. // }
  402. // /* Check for the reserved bytes should b zero */
  403. // if ( 0 != (pReArmSensorReq->ReArmAllEvents & RESERVED_BITS_REARMSENSOR_REARMALLEVENTS ) )
  404. // {
  405. // pReArmSensorRes->CompletionCode = CC_INV_DATA_FIELD;
  406. // return sizeof (*pRes);
  407. // }
  408. // OS_THREAD_MUTEX_ACQUIRE(&g_BMCInfo.SensorSharedMemMutex, WAIT_INFINITE);
  409. // pSenSharedMem = ( SensorSharedMem_T*)&g_BMCInfo.SensorSharedMem; //m_hSensorSharedMem;
  410. // /* Check for the reserved bits */
  411. // if (pSenSharedMem->SensorInfo [pReArmSensorReq->SensorNum].SensorReadType == THRESHOLD_SENSOR_CLASS)
  412. // {
  413. // if ((pReArmSensorReq->ReArmAssertionEvents2 & RESERVED_BITS_REARMSENSOR_REARMASSEVT2_1) ||
  414. // (pReArmSensorReq->ReArmDeassertionEvents2 & RESERVED_BITS_REARMSENSOR_REARMDEASSEVT2_1))
  415. // {
  416. // pReArmSensorRes->CompletionCode = CC_INV_DATA_FIELD;
  417. // OS_THREAD_MUTEX_RELEASE(&g_BMCInfo.SensorSharedMemMutex);
  418. // return sizeof (*pRes);
  419. // }
  420. // }
  421. // else
  422. // {
  423. // if ((pReArmSensorReq->ReArmAssertionEvents2 & RESERVED_BITS_REARMSENSOR_REARMASSEVT2_2) ||
  424. // (pReArmSensorReq->ReArmDeassertionEvents2 & RESERVED_BITS_REARMSENSOR_REARMDEASSEVT2_2))
  425. // {
  426. // pReArmSensorRes->CompletionCode = CC_INV_DATA_FIELD;
  427. // OS_THREAD_MUTEX_RELEASE(&g_BMCInfo.SensorSharedMemMutex);
  428. // return sizeof (*pRes);
  429. // }
  430. // }
  431. // if (g_BMCInfo.IpmiConfig.OPMASupport == 1)
  432. // {
  433. // if (pSenSharedMem->GlobalSensorScanningEnable == FALSE)
  434. // {
  435. // pReArmSensorRes->CompletionCode = CC_PARAM_NOT_SUP_IN_CUR_STATE;
  436. // OS_THREAD_MUTEX_RELEASE(&g_BMCInfo.SensorSharedMemMutex);
  437. // return sizeof (*pRes);
  438. // }
  439. // }
  440. // if (!pSenSharedMem->SensorInfo [pReArmSensorReq->SensorNum].IsSensorPresent)
  441. // {
  442. // /* return sdr record not present completion code */
  443. // pReArmSensorRes->CompletionCode = CC_SDR_REC_NOT_PRESENT;
  444. // OS_THREAD_MUTEX_RELEASE(&g_BMCInfo.SensorSharedMemMutex);
  445. // return sizeof (*pRes);
  446. // }
  447. // Msg.Param = PARAM_REARM_SENSOR;
  448. // Msg.Size = sizeof (ReArmSensorReq_T);
  449. // _fmemcpy(Msg.Data, &ReArmSensorReq, sizeof (ReArmSensorReq_T));
  450. // /* Post to sensormonitor task Thread to rearm this sensor */
  451. // GetQueueHandle(SM_HNDLR_Q,&hSMHndlr_Q,BMCInst);
  452. // if ( -1 != hSMHndlr_Q )
  453. // {
  454. // PostMsg(&Msg, SM_HNDLR_Q,BMCInst);
  455. // /* return normal completion code */
  456. // pReArmSensorRes->CompletionCode = CC_NORMAL;
  457. // }else
  458. // {
  459. // /* return normal completion code */
  460. // pReArmSensorRes->CompletionCode = 0xFF;
  461. // }
  462. // OS_THREAD_MUTEX_RELEASE(&g_BMCInfo.SensorSharedMemMutex);
  463. // return (sizeof(ReArmSensorRes_T));
  464. return 1;
  465. }
  466. /*---------------------------------------
  467. * GetSensorEventStatus
  468. *---------------------------------------*/
  469. int
  470. GetSensorEventStatus ( uint8_t* pReq, uint8_t ReqLen, uint8_t* pRes)
  471. {
  472. GetSensorEventStatusReq_T* pSensorEventStatusReq = ( GetSensorEventStatusReq_T*) pReq;
  473. GetSensorEventStatusRes_T* pSensorEventStatusRes = ( GetSensorEventStatusRes_T*) pRes;
  474. SensorInfo_T* pSensorInfo = getSensorInfo(pSensorEventStatusReq->SensorNum);
  475. pSensorEventStatusRes->CompletionCode = CC_NORMAL;
  476. pSensorEventStatusRes->Flags = (pSensorInfo->EventFlags & 0xe0);
  477. /* Set optional response bytes to zero if event messages are disabled for this sensor */
  478. if (0 == ((pSensorInfo->EventFlags) & BIT7))
  479. {
  480. pSensorEventStatusRes->AssertionEvents1 = 0;
  481. pSensorEventStatusRes->AssertionEvents2 = 0;
  482. pSensorEventStatusRes->DeassertionEvents1 = 0;
  483. pSensorEventStatusRes->DeassertionEvents2 = 0;
  484. return sizeof (GetSensorEventStatusRes_T);
  485. }
  486. if (0 == ((pSensorInfo->SensorCaps) & BIT6))
  487. {
  488. /* Get sensor event status history */
  489. pSensorEventStatusRes->AssertionEvents1 = (pSensorInfo->AssertionHistoryByte1 & pSensorInfo->AssertionEventEnablesByte1);
  490. pSensorEventStatusRes->AssertionEvents2 = (pSensorInfo->AssertionHistoryByte2 & pSensorInfo->AssertionEventEnablesByte2);
  491. pSensorEventStatusRes->DeassertionEvents1 = (pSensorInfo->DeassertionHistoryByte1 & pSensorInfo->DeassertionEventEnablesByte1);
  492. pSensorEventStatusRes->DeassertionEvents2 = (pSensorInfo->DeassertionHistoryByte2 & pSensorInfo->DeassertionEventEnablesByte2);
  493. }
  494. else
  495. {
  496. /* Get present sensor event status */
  497. pSensorEventStatusRes->AssertionEvents1 = (pSensorInfo->AssertionEventOccuredByte1 & pSensorInfo->AssertionEventEnablesByte1);
  498. pSensorEventStatusRes->AssertionEvents2 = (pSensorInfo->AssertionEventOccuredByte2 & pSensorInfo->AssertionEventEnablesByte2);
  499. pSensorEventStatusRes->DeassertionEvents1 = (pSensorInfo->DeassertionEventOccuredByte1 & pSensorInfo->DeassertionEventEnablesByte1);
  500. pSensorEventStatusRes->DeassertionEvents2 =(pSensorInfo->DeassertionEventOccuredByte2 & pSensorInfo->DeassertionEventEnablesByte2);
  501. }
  502. return sizeof (GetSensorEventStatusRes_T);
  503. }
  504. /*---------------------------------------
  505. * SetSensorHysterisis
  506. *---------------------------------------*/
  507. int
  508. SetSensorHysterisis ( uint8_t* pReq, uint8_t ReqLen, uint8_t* pRes)
  509. {
  510. // SetSensorHysterisisReq_T* pSensorHysReq =
  511. // ( SetSensorHysterisisReq_T*) pReq;
  512. SetSensorHysterisisRes_T* pSensorHysRes =
  513. ( SetSensorHysterisisRes_T*) pRes;
  514. printf("SetSensorHysterisis not implement\r\n");
  515. // SensorSharedMem_T* pSenSharedMem;
  516. // BMCInfo_t* pBMCInfo = &g_BMCInfo[BMCInst];
  517. // pSenSharedMem = ( SensorSharedMem_T*)&g_BMCInfo.SensorSharedMem; //m_hSensorSharedMem;
  518. // if (g_BMCInfo.IpmiConfig.OPMASupport == 1)
  519. // {
  520. // if (pSenSharedMem->GlobalSensorScanningEnable == FALSE)
  521. // {
  522. // pSensorHysRes->CompletionCode = CC_PARAM_NOT_SUP_IN_CUR_STATE;
  523. // return sizeof (*pRes);
  524. // }
  525. // }
  526. // /* Acquire Shared memory */
  527. // OS_THREAD_MUTEX_ACQUIRE(&g_BMCInfo.SensorSharedMemMutex, WAIT_INFINITE);
  528. // if (!pSenSharedMem->SensorInfo [pSensorHysReq->SensorNum].IsSensorPresent)
  529. // {
  530. // /* Release mutex for Sensor shared memory */
  531. // OS_THREAD_MUTEX_RELEASE(&g_BMCInfo.SensorSharedMemMutex);
  532. // pSensorHysRes->CompletionCode = CC_SDR_REC_NOT_PRESENT;
  533. // return sizeof (*pRes);
  534. // }
  535. // if (pSenSharedMem->SensorInfo [pSensorHysReq->SensorNum].SensorReadType != THRESHOLD_SENSOR_CLASS)
  536. // {
  537. // /* Release mutex for Sensor shared memory */
  538. // OS_THREAD_MUTEX_RELEASE(&g_BMCInfo.SensorSharedMemMutex);
  539. // pSensorHysRes->CompletionCode = CC_ILLEGAL_CMD_FOR_SENSOR_REC;
  540. // return sizeof (*pRes);
  541. // }
  542. // if(BIT5 != (pSenSharedMem->SensorInfo[pSensorHysReq->SensorNum].SensorCaps & (BIT5 | BIT4)))
  543. // {
  544. // OS_THREAD_MUTEX_RELEASE(&g_BMCInfo.SensorSharedMemMutex);
  545. // //set operation is not allowed
  546. // *pRes = CC_INV_DATA_FIELD;
  547. // return sizeof(*pRes);
  548. // }
  549. // /* Set the hysterisis values */
  550. // pSenSharedMem->SensorInfo [pSensorHysReq->SensorNum].PosHysteresis = pSensorHysReq->PositiveHysterisis;
  551. // pSenSharedMem->SensorInfo [pSensorHysReq->SensorNum].NegHysteresis = pSensorHysReq->NegativeHysterisis;
  552. // /* Release mutex for Sensor shared memory */
  553. // OS_THREAD_MUTEX_RELEASE(&g_BMCInfo.SensorSharedMemMutex);
  554. pSensorHysRes->CompletionCode = CC_NORMAL;
  555. return sizeof (SetSensorHysterisisRes_T);
  556. }
  557. /*---------------------------------------
  558. * GetSensorHysterisis
  559. *---------------------------------------*/
  560. int
  561. GetSensorHysterisis ( uint8_t* pReq, uint8_t ReqLen, uint8_t* pRes)
  562. {
  563. GetSensorHysterisisReq_T* pSensorHysReq =
  564. ( GetSensorHysterisisReq_T*) pReq;
  565. GetSensorHysterisisRes_T* pSensorHysRes =
  566. ( GetSensorHysterisisRes_T*) pRes;
  567. SensorInfo_T* pSensorInfo = getSensorInfo(pSensorHysReq->SensorNum);
  568. if (pSensorInfo->SensorReadType != THRESHOLD_SENSOR_CLASS)
  569. {
  570. pSensorHysRes->CompletionCode = CC_ILLEGAL_CMD_FOR_SENSOR_REC;
  571. return sizeof (*pRes);
  572. }
  573. if(SENSOR_HYSTERESIS_ACCESS_BITS == (pSensorInfo->SensorCaps & (BIT5 | BIT4)))
  574. {
  575. //set operation is not allowed
  576. *pRes = CC_INV_DATA_FIELD;
  577. return sizeof(*pRes);
  578. }
  579. /* Get the hysterisis values */
  580. pSensorHysRes->PositiveHysterisis = pSensorInfo->PosHysteresis;
  581. pSensorHysRes->NegativeHysterisis = pSensorInfo->NegHysteresis;
  582. pSensorHysRes->CompletionCode = CC_NORMAL;
  583. return sizeof (GetSensorHysterisisRes_T);
  584. }
  585. /*---------------------------------------
  586. * SetSensorThresholds
  587. *---------------------------------------*/
  588. int
  589. SetSensorThresholds ( uint8_t* pReq, uint8_t ReqLen, uint8_t* pRes)
  590. {
  591. SetSensorThresholdReq_T* pSensorThreshReq =
  592. ( SetSensorThresholdReq_T*) pReq;
  593. SetSensorThresholdRes_T* pSensorThreshRes =
  594. ( SetSensorThresholdRes_T*) pRes;
  595. uint8_t SettableMask=0;
  596. SensorInfo_T* pSensorInfo = getSensorInfo(pSensorThreshReq->SensorNum);
  597. SDRRecHdr_T* pSDRRec = SR_FindSDR(pSensorThreshReq->SensorNum);
  598. FullSensorRec_T* sfs = NULL;
  599. //CompactSensorRec_T* scs = NULL;
  600. if(pSDRRec->Type == FULL_SDR_REC)
  601. {
  602. sfs = (FullSensorRec_T*)pSDRRec;
  603. }
  604. /* Check for the reserved bytes should b zero */
  605. if ( 0 != (pSensorThreshReq->SetFlags & RESERVED_BITS_SETSENSORTHRESHOLDS ) )
  606. {
  607. pSensorThreshRes->CompletionCode = CC_INV_DATA_FIELD;
  608. return sizeof (*pRes);
  609. }
  610. if (pSensorInfo->SensorReadType != THRESHOLD_SENSOR_CLASS)
  611. {
  612. pSensorThreshRes->CompletionCode = CC_ILLEGAL_CMD_FOR_SENSOR_REC;
  613. return sizeof (*pRes);
  614. }
  615. if(BIT3 != (pSensorInfo->SensorCaps & (BIT2 | BIT3)))
  616. {
  617. //set operation is not allowed
  618. *pRes = CC_INV_DATA_FIELD;
  619. return sizeof(*pRes);
  620. }
  621. pSensorThreshRes->CompletionCode = CC_NORMAL;
  622. SettableMask=(uint8_t)(pSensorInfo->SettableThreshMask >> 8);
  623. /* Set the threshold values */
  624. //if (pSenSharedMem->SensorInfo [pSensorThreshReq->SensorNum].SensorInit & BIT5)
  625. if ( (pSensorInfo->SensorInit & BIT4 ) && (SettableMask | pSensorThreshReq->SetFlags ) == SettableMask) //<<Modified to support "set sensor enable>>
  626. {
  627. if (pSensorThreshReq->SetFlags & LWR_CRIT)
  628. {
  629. pSensorInfo->LowerCritical = pSensorThreshReq->LowerCritical;
  630. if(sfs != NULL) {sfs->LowerCritical = pSensorThreshReq->LowerCritical;}
  631. }
  632. if (pSensorThreshReq->SetFlags & LWR_NON_CRIT)
  633. {
  634. pSensorInfo->LowerNonCritical = pSensorThreshReq->LowerNonCritical;
  635. if(sfs != NULL) {sfs->LowerNonCritical = pSensorThreshReq->LowerNonCritical;}
  636. }
  637. if (pSensorThreshReq->SetFlags & LWR_NON_REC)
  638. {
  639. pSensorInfo->LowerNonRecoverable = pSensorThreshReq->LowerNonRecoverable;
  640. if(sfs != NULL) {sfs->LowerNonRecoverable = pSensorThreshReq->LowerNonRecoverable;}
  641. }
  642. if (pSensorThreshReq->SetFlags & UPR_CRIT)
  643. {
  644. pSensorInfo->UpperCritical = pSensorThreshReq->UpperCritical;
  645. if(sfs != NULL) {sfs->UpperCritical = pSensorThreshReq->UpperCritical;}
  646. }
  647. if (pSensorThreshReq->SetFlags & UPR_NON_CRIT)
  648. {
  649. pSensorInfo->UpperNonCritical = pSensorThreshReq->UpperNonCritical;
  650. if(sfs != NULL) {sfs->UpperNonCritical = pSensorThreshReq->UpperNonCritical;}
  651. }
  652. if (pSensorThreshReq->SetFlags & UPR_NON_REC)
  653. {
  654. pSensorInfo->UpperNonRecoverable = pSensorThreshReq->UpperNonRecoverable;
  655. if(sfs != NULL) {sfs->UpperNonRecoverable = pSensorThreshReq->UpperNonRecoverable;}
  656. }
  657. if(g_BMCInfo.IpmiConfig.RearmSetSensorThreshold == 1)
  658. {
  659. /* Since Changes in Threshold .We have to monitor the sensor again .*/
  660. /* Already the Sensor reached the particular state . so we have to reset for generate the event according to the new Event mask */
  661. if ( 0 ==(pSensorInfo->SensorCaps & BIT6))
  662. {
  663. /* Manual ReARM Sensor */
  664. pSensorInfo->AssertionHistoryByte1=0;
  665. pSensorInfo->AssertionHistoryByte2=0;
  666. pSensorInfo->DeassertionHistoryByte1=0;
  667. pSensorInfo->DeassertionHistoryByte2=0;
  668. pSensorInfo->EventLevel=SENSOR_STATUS_NORMAL;
  669. pSensorInfo->HealthLevel= SENSOR_STATUS_NORMAL;
  670. }else
  671. {
  672. /* Auto ReARM Sensor */
  673. pSensorInfo->EventLevel=SENSOR_STATUS_NORMAL;
  674. pSensorInfo->HealthLevel = SENSOR_STATUS_NORMAL;
  675. pSensorInfo->AssertionEventOccuredByte1 = 0;
  676. pSensorInfo->AssertionEventOccuredByte2 = 0;
  677. pSensorInfo->DeassertionEventOccuredByte1 = 0;
  678. pSensorInfo->DeassertionEventOccuredByte2 = 0;
  679. }
  680. }
  681. pSensorThreshRes->CompletionCode = CC_NORMAL;
  682. UpdateFlash();
  683. }
  684. else
  685. {
  686. pSensorThreshRes->CompletionCode = CC_ILLEGAL_CMD_FOR_SENSOR_REC;
  687. }
  688. return sizeof (SetSensorThresholdRes_T);
  689. }
  690. /*---------------------------------------
  691. * GetSensorThresholds
  692. *---------------------------------------*/
  693. int
  694. GetSensorThresholds ( uint8_t* pReq, uint8_t ReqLen, uint8_t* pRes)
  695. {
  696. GetSensorThresholdReq_T* pSensorThreshReq =
  697. ( GetSensorThresholdReq_T*) pReq;
  698. GetSensorThresholdRes_T* pSensorThreshRes =
  699. ( GetSensorThresholdRes_T*) pRes;
  700. SensorInfo_T* pSensorInfo = getSensorInfo(pSensorThreshReq->SensorNum);
  701. if (pSensorInfo->SensorReadType != THRESHOLD_SENSOR_CLASS)
  702. {
  703. pSensorThreshRes->CompletionCode = CC_ILLEGAL_CMD_FOR_SENSOR_REC;
  704. return sizeof (*pRes);
  705. }
  706. memset (pSensorThreshRes, 0, sizeof (GetSensorThresholdRes_T));
  707. if(SENSOR_THRESOLD_ACCESS_BITS != (pSensorInfo->SensorCaps & (BIT2 | BIT3)))
  708. {
  709. pSensorThreshRes->GetFlags = pSensorInfo->SettableThreshMask & 0xFF;
  710. /* Get the Threshold values according to readable threshold flag */
  711. if( pSensorThreshRes->GetFlags & BIT0 )
  712. pSensorThreshRes->LowerNonCritical = pSensorInfo->LowerNonCritical;
  713. if( pSensorThreshRes->GetFlags & BIT1 )
  714. pSensorThreshRes->LowerCritical = pSensorInfo->LowerCritical;
  715. if( pSensorThreshRes->GetFlags & BIT2 )
  716. pSensorThreshRes->LowerNonRecoverable = pSensorInfo->LowerNonRecoverable;
  717. if( pSensorThreshRes->GetFlags & BIT3 )
  718. pSensorThreshRes->UpperNonCritical = pSensorInfo->UpperNonCritical;
  719. if( pSensorThreshRes->GetFlags & BIT4 )
  720. pSensorThreshRes->UpperCritical = pSensorInfo->UpperCritical;
  721. if( pSensorThreshRes->GetFlags & BIT5 )
  722. pSensorThreshRes->UpperNonRecoverable = pSensorInfo->UpperNonRecoverable;
  723. }
  724. pSensorThreshRes->CompletionCode = CC_NORMAL;
  725. return sizeof (GetSensorThresholdRes_T);
  726. }
  727. /*---------------------------------------
  728. * GetSensorReadingFactors
  729. *---------------------------------------*/
  730. int
  731. GetSensorReadingFactors ( uint8_t* pReq, uint8_t ReqLen, uint8_t* pRes)
  732. {
  733. GetSensorReadingFactorReq_T* pSensorFactorsReq =
  734. ( GetSensorReadingFactorReq_T*) pReq;
  735. GetSensorReadingFactorRes_T* pSensorFactorsRes =
  736. ( GetSensorReadingFactorRes_T*) pRes;
  737. SensorInfo_T* pSensorInfo = getSensorInfo(pSensorFactorsReq->SensorNum);
  738. memcpy (&(pSensorFactorsRes->M_LSB), &(pSensorInfo->M_LSB),
  739. sizeof (GetSensorReadingFactorRes_T) - (2 * sizeof (uint8_t)));
  740. pSensorFactorsRes->CompletionCode = CC_NORMAL;
  741. return sizeof (GetSensorReadingFactorRes_T);
  742. }
  743. /*---------------------------------------
  744. * SetSensorEventEnable
  745. *---------------------------------------*/
  746. int
  747. SetSensorEventEnable ( uint8_t* pReq, uint8_t ReqLen, uint8_t* pRes)
  748. {
  749. // SensorInfo_T* pSensorInfo;
  750. // uint8_t LocalReq [6];
  751. // SetSensorEventEnableReq_T* pSensorEvtEnReq;
  752. // SetSensorEventEnableRes_T* pSensorEvtEnRes =
  753. // ( SetSensorEventEnableRes_T*) pRes;
  754. printf("SetSensorEventEnable not implement\r\n");
  755. // uint16_t AssertMask, DeassertMask;
  756. // uint16_t ValidMask = htoipmi_u16(0x0FFF);
  757. // SensorSharedMem_T* pSenSharedMem;
  758. // BMCInfo_t* pBMCInfo = &g_BMCInfo[BMCInst];
  759. // pSenSharedMem = ( SensorSharedMem_T*)&g_BMCInfo.SensorSharedMem; //m_hSensorSharedMem;
  760. // uint16_t LUNSensorNum;
  761. // uint16_t *OwnerLUN = 0;
  762. // if (g_BMCInfo.IpmiConfig.OPMASupport == 1)
  763. // {
  764. // if (pSenSharedMem->GlobalSensorScanningEnable == FALSE)
  765. // {
  766. // pSensorEvtEnRes->CompletionCode = CC_PARAM_NOT_SUP_IN_CUR_STATE;
  767. // return sizeof (*pRes);
  768. // }
  769. // }
  770. // AssertMask = DeassertMask = 0;
  771. // memset (LocalReq, 0, sizeof (LocalReq));
  772. // memcpy (LocalReq, pReq, ReqLen);
  773. // pSensorEvtEnReq = ( SetSensorEventEnableReq_T*)LocalReq;
  774. // if(g_corefeatures.more_than_256_sensors == ENABLED)
  775. // {
  776. // OS_THREAD_TLS_GET(g_tls.OwnerLUN,OwnerLUN);
  777. // LUNSensorNum = ((*OwnerLUN & VALID_LUN) << 8 | pSensorEvtEnReq->SensorNum);
  778. // }
  779. // else
  780. // {
  781. // LUNSensorNum = pSensorEvtEnReq->SensorNum;
  782. // }
  783. // /* Atleast two bytes are expected remaining bytes (3,4,5,6) are optional */
  784. // if ((ReqLen < sizeof(uint16_t)) || (ReqLen > sizeof (SetSensorEventEnableReq_T)))
  785. // {
  786. // pSensorEvtEnRes->CompletionCode = CC_REQ_INV_LEN;
  787. // return sizeof (*pRes);
  788. // }
  789. // /* Check for the reserved bytes should b zero */
  790. // if ( 0 != (pSensorEvtEnReq->Flags & RESERVED_BITS_SETSENEVTEN_FLAGS ) )
  791. // {
  792. // pSensorEvtEnRes->CompletionCode = CC_INV_DATA_FIELD;
  793. // return sizeof (*pRes);
  794. // }
  795. // if (ReqLen > sizeof(uint16_t))
  796. // {
  797. // /* Check for the reserved bits */
  798. // if (pSenSharedMem->SensorInfo [LUNSensorNum].SensorReadType == THRESHOLD_SENSOR_CLASS)
  799. // {
  800. // if ((pSensorEvtEnReq->AssertionMask & ~ValidMask) ||
  801. // (pSensorEvtEnReq->DeAssertionMask & ~ValidMask))
  802. // {
  803. // pSensorEvtEnRes->CompletionCode = CC_INV_DATA_FIELD;
  804. // return sizeof (*pRes);
  805. // }
  806. // }
  807. // else
  808. // {
  809. // if ((pSensorEvtEnReq->AssertionMask & RESERVED_BITS_SETSENEVTEN_ASSERTIONMASK) ||
  810. // (pSensorEvtEnReq->DeAssertionMask & RESERVED_BITS_SETSENEVTEN_DEASSERTIONMASK))
  811. // {
  812. // pSensorEvtEnRes->CompletionCode = CC_INV_DATA_FIELD;
  813. // return sizeof (*pRes);
  814. // }
  815. // }
  816. // }
  817. // /* Get the sensor Info for the sensor */
  818. // if(g_corefeatures.more_than_256_sensors == ENABLED)
  819. // {
  820. // pSensorInfo = GetSensorInfo (pSensorEvtEnReq->SensorNum, *OwnerLUN, BMCInst);
  821. // }
  822. // else
  823. // {
  824. // pSensorInfo = GetSensorInfo (pSensorEvtEnReq->SensorNum, 0x0, BMCInst);
  825. // }
  826. // if (NULL == pSensorInfo)
  827. // {
  828. // pSensorEvtEnRes->CompletionCode = CC_SDR_REC_NOT_PRESENT;
  829. // return sizeof (*pRes);
  830. // }
  831. // // If not threshold, adjust mask
  832. // if (pSensorInfo->EventTypeCode != 0x01)
  833. // {
  834. // ValidMask = htoipmi_u16(0x7FFF);
  835. // }
  836. // /* Acquire Shared memory */
  837. // OS_THREAD_MUTEX_ACQUIRE(&g_BMCInfo.SensorSharedMemMutex, WAIT_INFINITE);
  838. // if (!pSensorInfo->IsSensorPresent)
  839. // {
  840. // /* Release mutex for Sensor shared memory */
  841. // OS_THREAD_MUTEX_RELEASE(&g_BMCInfo.SensorSharedMemMutex);
  842. // pSensorEvtEnRes->CompletionCode = CC_SDR_REC_NOT_PRESENT;
  843. // return sizeof (*pRes);
  844. // }
  845. // /* Disable Events and scanning based on the flags */
  846. // if (0 == (pSensorEvtEnReq->Flags & EVENT_MSG_MASK))
  847. // {
  848. // /* DisableAllEventSensors () */
  849. // }
  850. // if ((0 == (pSensorEvtEnReq->Flags & SCAN_MASK)) && (SCAN_MASK == (pSensorInfo->EventFlags & SCAN_MASK)))
  851. // {
  852. // // Check sensor accepts the ‘enable/disable scanning’
  853. // if(0 == (pSensorInfo->SensorInit & BIT6))
  854. // {
  855. // OS_THREAD_MUTEX_RELEASE(&g_BMCInfo.SensorSharedMemMutex);
  856. // pSensorEvtEnRes->CompletionCode = CC_INV_DATA_FIELD;
  857. // return sizeof (*pRes);
  858. // }
  859. // pSensorInfo->EventFlags |= BIT5; ///* Bit 5 - Unable to read */
  860. // }
  861. // else if((SCAN_MASK == (pSensorEvtEnReq->Flags & SCAN_MASK)) && (0 == (pSensorInfo->EventFlags & SCAN_MASK)))
  862. // {
  863. // // Check sensor accepts the ‘enable/disable scanning’
  864. // if(0 == (pSensorInfo->SensorInit & BIT6))
  865. // {
  866. // OS_THREAD_MUTEX_RELEASE(&g_BMCInfo.SensorSharedMemMutex);
  867. // pSensorEvtEnRes->CompletionCode = CC_INV_DATA_FIELD;
  868. // return sizeof (*pRes);
  869. // }
  870. // pSensorInfo->EventFlags &= ~BIT5; ///* Bit 5 - Unable to read */
  871. // }
  872. // pSensorInfo->EventFlags &= ~(EVENT_MSG_MASK | SCAN_MASK);
  873. // pSensorInfo->EventFlags |= (pSensorEvtEnReq->Flags & (EVENT_MSG_MASK | SCAN_MASK));
  874. // AssertMask =
  875. // htoipmi_u16(((pSenSharedMem->SensorInfo [LUNSensorNum].AssertionEventEnablesByte2 << 8) |
  876. // (pSenSharedMem->SensorInfo [LUNSensorNum].AssertionEventEnablesByte1)) & ValidMask);
  877. // DeassertMask =
  878. // htoipmi_u16(((pSenSharedMem->SensorInfo [LUNSensorNum].DeassertionEventEnablesByte2 << 8) |
  879. // (pSenSharedMem->SensorInfo [LUNSensorNum].DeassertionEventEnablesByte1)) & ValidMask);
  880. // /* Enable disable assertion based on the flag */
  881. // if(ENABLE_DISABLE_EVENT_MASK == (pSensorEvtEnReq->Flags & ENABLE_DISABLE_EVENT_MASK))
  882. // {
  883. // // Flags [5:4] - 11b Reserved.
  884. // /* Release mutex for Sensor shared memory */
  885. // OS_THREAD_MUTEX_RELEASE(&g_BMCInfo.SensorSharedMemMutex);
  886. // pSensorEvtEnRes->CompletionCode = CC_INV_DATA_FIELD;
  887. // return sizeof (*pRes);
  888. // }
  889. // else if (ENABLE_SELECTED_EVENT_MSG == (pSensorEvtEnReq->Flags & ENABLE_DISABLE_EVENT_MASK))
  890. // {
  891. // AssertMask |= ipmitoh_u16(pSensorEvtEnReq->AssertionMask);
  892. // DeassertMask |= ipmitoh_u16(pSensorEvtEnReq->DeAssertionMask);
  893. // }
  894. // else if (DISABLE_SELECTED_EVENT_MSG == (pSensorEvtEnReq->Flags & ENABLE_DISABLE_EVENT_MASK))
  895. // {
  896. // AssertMask &= ~ipmitoh_u16(pSensorEvtEnReq->AssertionMask);
  897. // DeassertMask &= ~ipmitoh_u16(pSensorEvtEnReq->DeAssertionMask);
  898. // }
  899. // //For Threshold class sensors upper word bits are reserved
  900. // if(pSensorInfo->EventTypeCode == THRESHOLD_SENSOR_CLASS)
  901. // {
  902. // pSensorInfo->AssertionEventEnablesByte2 &= 0xF0;
  903. // pSensorInfo->AssertionEventEnablesByte2 |= (AssertMask >> 8);
  904. // }
  905. // else
  906. // {
  907. // pSensorInfo->AssertionEventEnablesByte2 = (AssertMask >> 8);
  908. // }
  909. // pSensorInfo->AssertionEventEnablesByte1 = (AssertMask) & 0xFF;
  910. // //For Threshold class sensors upper word bits are reserved
  911. // if(pSensorInfo->EventTypeCode == THRESHOLD_SENSOR_CLASS)
  912. // {
  913. // pSensorInfo->DeassertionEventEnablesByte2 &= 0xF0;
  914. // pSensorInfo->DeassertionEventEnablesByte2 |= (DeassertMask >> 8);
  915. // }
  916. // else
  917. // {
  918. // pSensorInfo->DeassertionEventEnablesByte2 = (DeassertMask >> 8);
  919. // }
  920. // pSensorInfo->DeassertionEventEnablesByte1 = (DeassertMask);
  921. // // For threshold sensors, reset the threshold state machine for the sensor
  922. // // in order to pickup any newly enabled events.
  923. // if(pSensorInfo->EventTypeCode == THRESHOLD_SENSOR_CLASS)
  924. // {
  925. // pSensorInfo->EventLevel=SENSOR_STATUS_NORMAL;
  926. // pSensorInfo->HealthLevel = SENSOR_STATUS_NORMAL;
  927. // }
  928. // pSensorEvtEnRes->CompletionCode = CC_NORMAL;
  929. // /* Release mutex for Sensor shared memory */
  930. // OS_THREAD_MUTEX_RELEASE(&g_BMCInfo.SensorSharedMemMutex);
  931. return sizeof (SetSensorEventEnableRes_T);
  932. }
  933. /*---------------------------------------
  934. * GetSensorEventEnable
  935. *---------------------------------------*/
  936. int
  937. GetSensorEventEnable ( uint8_t* pReq, uint8_t ReqLen, uint8_t* pRes)
  938. {
  939. GetSensorEventEnableReq_T* pSensorEvtEnReq =
  940. ( GetSensorEventEnableReq_T*) pReq;
  941. GetSensorEventEnableRes_T* pSensorEvtEnRes =
  942. ( GetSensorEventEnableRes_T*) pRes;
  943. SensorInfo_T* pSensorInfo = getSensorInfo(pSensorEvtEnReq->SensorNum);
  944. uint16_t ValidMask = (0x0FFF);
  945. if (pSensorInfo->EventTypeCode != 0x01)
  946. {
  947. ValidMask = (0x7FFF);
  948. }
  949. /* Get the assertion enables */
  950. pSensorEvtEnRes->AssertionMask =
  951. (((pSensorInfo->AssertionEventEnablesByte2 << 8) | (pSensorInfo->AssertionEventEnablesByte1)) & ValidMask);
  952. /* Get the deassertion enables */
  953. pSensorEvtEnRes->DeAssertionMask =
  954. (((pSensorInfo->DeassertionEventEnablesByte2 << 8) | (pSensorInfo->DeassertionEventEnablesByte1)) & ValidMask);
  955. /* Set the flags */
  956. pSensorEvtEnRes->Flags = (pSensorInfo->EventFlags & 0xc0);
  957. pSensorEvtEnRes->CompletionCode = CC_NORMAL;
  958. return sizeof (GetSensorEventEnableRes_T);
  959. }
  960. /**
  961. * @fn CheckForEntityPresence
  962. * @brief This function checks for the entity presence bit
  963. * or the entity presence sensor.
  964. * @param[in] SensorNum - Sensor number for reading.
  965. * @param[in] EventTypeCode - Event type code of the sdr.
  966. * @param[in] SensorType - Sensor type of the sdr.
  967. * @retval ENTITY_FOUND, if present,
  968. * ENTITY_NOT_FOUND, if not present,
  969. * NOT_FOUND_SCAN_DISABLED, if not able to find,
  970. * NOT_FOUND_SCAN_ENABLED, if Scanning bit enabled but failed.
  971. */
  972. static int
  973. CheckForEntityPresence (uint8_t SensorNum, uint8_t OwnerLUN, uint8_t EventTypeCode, uint8_t SensorType)
  974. {
  975. int RetVal = NOT_FOUND_SCAN_ENABLED;
  976. SensorInfo_T* pSensorInfo;
  977. int i;
  978. pSensorInfo = getSensorInfo(SensorNum);
  979. if( BIT0 == (BIT0 & pSensorInfo->SensorInit) )
  980. {
  981. // If Event/Reading type code is 0x08 then look for
  982. // reading DEVICE_PRESENT to state the Entity Presence
  983. if( GENERIC_EVENT_TYPE_DEV_PRESENCE == EventTypeCode )
  984. {
  985. if( DEVICE_PRESENT == pSensorInfo->SensorReading )
  986. {
  987. RetVal = ENTITY_FOUND;
  988. }
  989. else
  990. {
  991. RetVal = ENTITY_NOT_FOUND;
  992. }
  993. }
  994. // If Event/Reading type code is 0x09 then look for
  995. // reading DEVICE_ENABLED to state the Entity Enabled
  996. else if( GENERIC_EVENT_TYPE_DEV_AVAILABLE == EventTypeCode )
  997. {
  998. if( DEVICE_ENABLED == pSensorInfo->SensorReading )
  999. {
  1000. RetVal = ENTITY_FOUND;
  1001. }
  1002. else
  1003. {
  1004. RetVal = ENTITY_NOT_FOUND;
  1005. }
  1006. }
  1007. // If Event/Reading Type code is 0x6f then look for the
  1008. // special sensors like Processor, Memory etc.,
  1009. else if ( EVENT_TYPE_SENSOR_SPECIFIC == EventTypeCode )
  1010. {
  1011. for(i = 0; i < SENSOR_PRESENCE_COUNT; i++)
  1012. {
  1013. if( SensorType == sensor_presence[i][0] )
  1014. {
  1015. if( pSensorInfo->SensorReading == sensor_presence[i][1] )
  1016. RetVal = ENTITY_FOUND;
  1017. else
  1018. RetVal = ENTITY_NOT_FOUND;
  1019. }
  1020. }
  1021. }
  1022. return RetVal;
  1023. }
  1024. return NOT_FOUND_SCAN_DISABLED;
  1025. }
  1026. /**
  1027. * @fn IsSensorPresence
  1028. * @brief Check the presence bit for the entity or checks with
  1029. * entity presence sensor to identify Entity presence
  1030. * @param[in] EntityID - Entity id of the sensor.
  1031. * @param[in] EntityIns - Entity instance of the sensor.
  1032. * @param[in] SensorNum - Sensor number.
  1033. * @retval 1, if present
  1034. * 0, if not present
  1035. * -1, if not able to find.
  1036. */
  1037. static int
  1038. IsSensorPresence (uint8_t EntityID, uint8_t EntityIns, uint8_t SensorNum, uint8_t OwnerLUN)
  1039. {
  1040. SDRRecHdr_T* sr = NULL;
  1041. CommonSensorRec_T* scs = NULL;
  1042. int RetVal, tmpRet = -1;
  1043. sr = SDR_GetFirstSDRRec ();
  1044. while (0 != sr)
  1045. {
  1046. // Populate sensor information for Threshold sensors
  1047. if (FULL_SDR_REC == sr->Type || COMPACT_SDR_REC == sr->Type)
  1048. {
  1049. /* Populate sensor information for full or Compact Record */
  1050. scs = ( CommonSensorRec_T*) sr;
  1051. // Check for EntityId and EntityIns
  1052. if((EntityID == scs->EntityID) && (EntityIns == scs->EntityIns) &&
  1053. ((SensorNum != scs->SensorNum) || (OwnerLUN != scs->OwnerLUN)) )
  1054. {
  1055. RetVal = CheckForEntityPresence (scs->SensorNum, scs->OwnerLUN, scs->EventTypeCode,
  1056. scs->SensorType);
  1057. if( NOT_FOUND_SCAN_DISABLED != RetVal && NOT_FOUND_SCAN_ENABLED != RetVal)
  1058. {
  1059. return RetVal;
  1060. }
  1061. else if( NOT_FOUND_SCAN_ENABLED == RetVal)
  1062. {
  1063. // An Entity is present if there is at least one active
  1064. // sensor for the Entity (and there is no explicit sensor saying
  1065. // the Entity is 'absent').
  1066. // A sensor is 'active' if scanning is enabled.
  1067. // We can return this value only after searching all the sensors.
  1068. tmpRet = 1;
  1069. }
  1070. }
  1071. }
  1072. /* Get the next record */
  1073. sr = SDR_GetNextSDRRec (sr);
  1074. }
  1075. return tmpRet;
  1076. }
  1077. /**
  1078. * @fn IsEntityAssociationPresence
  1079. * @brief Check the EntityID and Entity instance to see if the entity is
  1080. * a container entity in an entity-association. If so, check to
  1081. * see if any of the contained entities are present, if so, assume
  1082. * the container entity exists.
  1083. * @param[in] EntityID - Entity id of the sensor.
  1084. * @param[in] EntityIns - Entity instance of the sensor.
  1085. * @retval 1, if present
  1086. * 0, if not present
  1087. * -1, if not able to find.
  1088. */
  1089. static int
  1090. IsEntityAssociationPresence (uint8_t EntityID, uint8_t EntityIns)
  1091. {
  1092. //TODO
  1093. return -1;
  1094. }
  1095. /**
  1096. * @fn IsFRUPresence
  1097. * @brief Check the entity to see if FRU device is present.
  1098. * @param[in] EntityID - Entity id of the sensor.
  1099. * @param[in] EntityIns - Entity instance of the sensor.
  1100. * @retval 1, if present
  1101. * 0, if not present
  1102. * -1, if not able to find.
  1103. */
  1104. static int
  1105. IsFRUPresence (uint8_t EntityID, uint8_t EntityIns)
  1106. {
  1107. printf("IsFRUPresence not implement\r\n");
  1108. // SDRRecHdr_T* sr = NULL;
  1109. // FRUDevLocatorRec_T* frudl;
  1110. // FRUReadReq_T FRUReadReq;
  1111. // uint8_t FRUReadRes[64];
  1112. // sr = SDR_GetFirstSDRRec (BMCInst);
  1113. // while (0 != sr)
  1114. // {
  1115. // // Check for FRU Device locator SDR Record
  1116. // if (sr->Type == FRU_DEVICE_LOCATOR_SDR_REC)
  1117. // {
  1118. // frudl = ( FRUDevLocatorRec_T*) sr;
  1119. // frudl->EntityID, frudl->EntityIns);
  1120. // // If EntityID and EntityIns are equal try to read the fru data.
  1121. // if(frudl->EntityID == EntityID &&
  1122. // frudl->EntityIns == EntityIns)
  1123. // {
  1124. // FRUReadReq.FRUDeviceID=frudl->FRUIDSlaveAddr;
  1125. // FRUReadReq.Offset=0x0;
  1126. // FRUReadReq.CountToRead=sizeof(FRUCommonHeader_T);
  1127. // ReadFRUData((uint8_t *)&FRUReadReq, sizeof(FRUReadReq_T), FRUReadRes);
  1128. // if (((FRUReadRes_T *)FRUReadRes)->CompletionCode == FRU_ACCESSIBLE)
  1129. // {
  1130. // return 1;
  1131. // }
  1132. // else
  1133. // {
  1134. // return 0;
  1135. // }
  1136. // }
  1137. // }
  1138. // sr = SDR_GetNextSDRRec (sr);
  1139. // }
  1140. return -1;
  1141. }
  1142. /**
  1143. * @fn InitSensorScanningBit
  1144. * @brief Initializes all the sensor's Scanning bit with respect
  1145. * to the presence of the entity
  1146. * @retval 0.
  1147. */
  1148. int InitSensorScanningBit()
  1149. {
  1150. SDRRecHdr_T* sr = NULL;
  1151. CommonSensorRec_T* scs = NULL;
  1152. int RetVal;
  1153. SensorInfo_T* pSensorInfo = NULL;
  1154. uint16_t LUNSensorNum;
  1155. sr = SDR_GetFirstSDRRec ();
  1156. while (0 != sr)
  1157. {
  1158. // Populater sensor information for Threshold sensors
  1159. if (FULL_SDR_REC == sr->Type || COMPACT_SDR_REC == sr->Type)
  1160. {
  1161. scs = ( CommonSensorRec_T*) sr;
  1162. RetVal = 1;
  1163. if( BIT7 == (BIT7 & scs->SensorCaps) )
  1164. {
  1165. /* As per IPMI Spec Section 40.2
  1166. * Entity presence can be detected if any one of the following point is
  1167. * Satisfied,
  1168. * 1. If there is an active sensor that includes a presence bit,
  1169. * or the entity has an active Entity Presence sensor,
  1170. * use the sensor to determine the presence of the entity.
  1171. * 2. Check the SDRs to see if the entity is a container entity
  1172. * in an entity-association. If so, check to see if any of the
  1173. * contained entities are present, if so, assume the container
  1174. * entity exists. Note that this may need to be iterative.
  1175. * 3. The entity is present is there is a FRU device for the
  1176. * entity, and the FRU device is present.
  1177. */
  1178. RetVal = IsSensorPresence(scs->EntityID, scs->EntityIns, scs->SensorNum, scs->OwnerLUN);
  1179. if( -1 == RetVal )
  1180. {
  1181. RetVal = IsEntityAssociationPresence(scs->EntityID, scs->EntityIns);
  1182. if( -1 == RetVal )
  1183. {
  1184. RetVal = IsFRUPresence(scs->EntityID, scs->EntityIns);
  1185. }
  1186. }
  1187. }
  1188. LUNSensorNum = (scs->SensorNum);
  1189. /*
  1190. * [7] - 0b = All Event Messages disabled from this sensor
  1191. * [6] - 0b = sensor scanning disabled
  1192. * [5] - 1b = reading/state unavailable
  1193. */
  1194. if(1 == RetVal)
  1195. {
  1196. pSensorInfo = getSensorInfo(LUNSensorNum);
  1197. if((BIT0 | BIT1) == (pSensorInfo->SensorInit & (BIT0 | BIT1)))
  1198. {
  1199. /* Enabling Sensor Scanning and Event Messages*/
  1200. pSensorInfo->EventFlags = EVENT_AND_SCANNING_ENABLE;
  1201. }
  1202. else if(BIT1 == (pSensorInfo->SensorInit & BIT1))
  1203. {
  1204. /* Enabling Event Messages */
  1205. pSensorInfo->EventFlags = EVENT_MSG_MASK;
  1206. }
  1207. else if(BIT0 == (pSensorInfo->SensorInit & BIT0))
  1208. {
  1209. /*Enabling Scanning*/
  1210. pSensorInfo->EventFlags = SCAN_MASK;
  1211. }
  1212. if(0 == (pSensorInfo->SensorInit & BIT0))
  1213. {
  1214. /* Reading Unavailable */
  1215. pSensorInfo->EventFlags |= READING_UNAVAILABLE;
  1216. }
  1217. }
  1218. else
  1219. {
  1220. pSensorInfo->EventFlags = READING_UNAVAILABLE;
  1221. if(BIT1 == (pSensorInfo->SensorInit & BIT1))
  1222. {
  1223. /* Enabling Event Messages */
  1224. pSensorInfo->EventFlags |= EVENT_MSG_MASK;
  1225. }
  1226. }
  1227. }
  1228. /* Get the next record */
  1229. sr = SDR_GetNextSDRRec (sr);
  1230. }
  1231. printf("Leaving : %s with 0\n", __func__);
  1232. return 0;
  1233. }
  1234. /* Compare two sensor values.
  1235. * Returns -1 if val1 < val2
  1236. * Returns 0 if val1 == val2
  1237. * Returns 1 if val1 > val2
  1238. */
  1239. int
  1240. CompareValues(uint8_t isSigned, uint8_t val1, uint8_t val2)
  1241. {
  1242. int retval = 0; // default to equal
  1243. // Signed comparison
  1244. int8_t sval1, sval2;
  1245. /* Do comparison based on isSigned flag */
  1246. if (FALSE == isSigned)
  1247. {
  1248. // Unsigned comparison
  1249. if (val1 < val2)
  1250. {
  1251. retval = -1;
  1252. }
  1253. else if (val1 > val2)
  1254. {
  1255. retval = 1;
  1256. }
  1257. }
  1258. else
  1259. {
  1260. sval1 = (int8_t)val1;
  1261. sval2 = (int8_t)val2;
  1262. if (sval1 < sval2)
  1263. {
  1264. retval = -1;
  1265. }
  1266. else if (sval1 > sval2)
  1267. {
  1268. retval = 1;
  1269. }
  1270. }
  1271. return retval;
  1272. }
  1273. /*-----------------------------------------
  1274. * GetSensorReading
  1275. *-----------------------------------------*/
  1276. int
  1277. GetSensorReading ( uint8_t* pReq, uint8_t ReqLen, uint8_t* pRes)
  1278. {
  1279. GetSensorReadingReq_T* pSensorReadReq =
  1280. ( GetSensorReadingReq_T*) pReq;
  1281. GetSensorReadingRes_T* pSensorReadRes =
  1282. ( GetSensorReadingRes_T*) pRes;
  1283. uint16_t SensorReading;
  1284. uint8_t SensorIsSigned = FALSE;
  1285. SensorInfo_T * pSensorInfo = NULL;
  1286. pSensorInfo = getSensorInfo(pSensorReadReq->SensorNum);
  1287. pSensorReadRes->Flags = pSensorInfo->EventFlags & 0xe0;
  1288. if (0 != (pSensorInfo->EventFlags & BIT5))
  1289. {
  1290. pSensorReadRes->SensorReading = 0;
  1291. pSensorReadRes->CompletionCode = CC_NORMAL;
  1292. pSensorReadRes->ComparisonStatus = (((uint8_t) (pSensorReadRes->SensorReading & 0x00FF)) & ((uint8_t) (pSensorInfo->SettableThreshMask & 0x00FF)) );
  1293. pSensorReadRes->OptionalStatus = (((uint8_t) (pSensorReadRes->SensorReading >> 8)) & ((uint8_t)(pSensorInfo->SettableThreshMask >> 8)) );
  1294. // For Discrete sensor, [7] - reserved. Returned as 1b. Ignore on read.
  1295. pSensorReadRes->OptionalStatus |= 0x80;
  1296. return sizeof (GetSensorReadingRes_T);
  1297. }
  1298. pSensorReadRes->CompletionCode = CC_NORMAL;
  1299. SensorReading = pSensorInfo->SensorReading;
  1300. pSensorReadRes->SensorReading = 0;
  1301. SensorIsSigned = (0 != (pSensorInfo->Units1 & 0xC0)) ? TRUE : FALSE;
  1302. if (THRESHOLD_SENSOR_CLASS == pSensorInfo->EventTypeCode)
  1303. {
  1304. pSensorReadRes->SensorReading = (SensorReading & 0x00FF); //notice
  1305. pSensorReadRes->ComparisonStatus = 0x00;
  1306. if((pSensorInfo->DeassertionEventEnablesByte2 & BIT6) == BIT6 )
  1307. {
  1308. if (CompareValues(SensorIsSigned, pSensorReadRes->SensorReading,
  1309. pSensorInfo->UpperNonRecoverable) >= 0)
  1310. {
  1311. pSensorReadRes->ComparisonStatus |= BIT5;
  1312. }
  1313. }
  1314. if((pSensorInfo->DeassertionEventEnablesByte2 & BIT5) == BIT5 )
  1315. {
  1316. if (CompareValues(SensorIsSigned, pSensorReadRes->SensorReading,
  1317. pSensorInfo->UpperCritical) >= 0)
  1318. {
  1319. pSensorReadRes->ComparisonStatus |= BIT4;
  1320. }
  1321. }
  1322. if((pSensorInfo->DeassertionEventEnablesByte2 & BIT4) == BIT4 )
  1323. {
  1324. if (CompareValues(SensorIsSigned, pSensorReadRes->SensorReading,
  1325. pSensorInfo->UpperNonCritical) >= 0)
  1326. {
  1327. pSensorReadRes->ComparisonStatus |= BIT3;
  1328. }
  1329. }
  1330. if((pSensorInfo->AssertionEventEnablesByte2 & BIT6) == BIT6 )
  1331. {
  1332. if (CompareValues(SensorIsSigned, pSensorReadRes->SensorReading,
  1333. pSensorInfo->LowerNonRecoverable) <= 0)
  1334. {
  1335. pSensorReadRes->ComparisonStatus |= BIT2;
  1336. }
  1337. }
  1338. if((pSensorInfo->AssertionEventEnablesByte2 & BIT5) == BIT5 )
  1339. {
  1340. if (CompareValues(SensorIsSigned, pSensorReadRes->SensorReading,
  1341. pSensorInfo->LowerCritical) <= 0)
  1342. {
  1343. pSensorReadRes->ComparisonStatus |= BIT1;
  1344. }
  1345. }
  1346. if((pSensorInfo->AssertionEventEnablesByte2 & BIT4) == BIT4 )
  1347. {
  1348. if (CompareValues(SensorIsSigned, pSensorReadRes->SensorReading,
  1349. pSensorInfo->LowerNonCritical) <= 0)
  1350. {
  1351. pSensorReadRes->ComparisonStatus |= BIT0;
  1352. }
  1353. }
  1354. pSensorReadRes->ComparisonStatus &=
  1355. ((pSensorInfo->SettableThreshMask >> 8) & 0xFF);
  1356. pSensorReadRes->OptionalStatus = 0;
  1357. // For Threshold sensor, [7:6] - reserved. Returned as 1b. Ignore on read.
  1358. pSensorReadRes->ComparisonStatus |= 0xC0;
  1359. }
  1360. else
  1361. {
  1362. pSensorReadRes->ComparisonStatus = (((uint8_t) (SensorReading & 0x00FF)) & ((uint8_t) (pSensorInfo->SettableThreshMask & 0x00FF)) );
  1363. pSensorReadRes->OptionalStatus = (((uint8_t) (SensorReading >> 8)) & ((uint8_t)(pSensorInfo->SettableThreshMask >> 8)) );
  1364. // For Discrete sensor, [7] - reserved. Returned as 1b. Ignore on read.
  1365. pSensorReadRes->OptionalStatus |= 0x80;
  1366. }
  1367. return sizeof (GetSensorReadingRes_T);
  1368. }
  1369. /*-----------------------------------------
  1370. * SetSensorReading
  1371. *-----------------------------------------*/
  1372. int
  1373. SetSensorReading ( uint8_t* pReq, uint8_t ReqLen, uint8_t* pRes)
  1374. {
  1375. printf("SetSensorReading not implement\r\n");
  1376. // SetSensorReadingReq_T* pSensorReadReq =
  1377. // ( SetSensorReadingReq_T*) pReq;
  1378. // SetSensorReadingRes_T* pSensorReadRes =
  1379. // ( SetSensorReadingRes_T*) pRes;
  1380. // SensorSharedMem_T* pSenSharedMem;
  1381. // BMCInfo_t* pBMCInfo = &g_BMCInfo[BMCInst];
  1382. // pSenSharedMem = ( SensorSharedMem_T*)&g_BMCInfo.SensorSharedMem; //m_hSensorSharedMem;
  1383. // /* Check for the reserved bits */
  1384. // if (pSenSharedMem->SensorInfo [pSensorReadReq->SensorNum].SensorReadType == THRESHOLD_SENSOR_CLASS)
  1385. // {
  1386. // if (((ReqLen>=LEN_FOR_ASSERT_DATA) && (pSensorReadReq->AssertionEventOccuredByte2 & RESERVED_BITS_SETSENRD_ASSEVTOCCBYTE_1)) ||
  1387. // ((ReqLen>=LEN_FOR_DEASSERT_DATA) && (pSensorReadReq->DeAssertionEventOccuredByte2 & RESERVED_BITS_SETSENRD_DEASSEVTOCCBYTE_1)))
  1388. // {
  1389. // pSensorReadRes->CompletionCode = CC_INV_DATA_FIELD;
  1390. // return sizeof (*pRes);
  1391. // }
  1392. // }
  1393. // else
  1394. // {
  1395. // if (((ReqLen>=LEN_FOR_ASSERT_DATA) && (pSensorReadReq->AssertionEventOccuredByte2 & RESERVED_BITS_SETSENRD_ASSEVTOCCBYTE_2)) ||
  1396. // ((ReqLen>=LEN_FOR_DEASSERT_DATA) && (pSensorReadReq->DeAssertionEventOccuredByte2 & RESERVED_BITS_SETSENRD_DEASSEVTOCCBYTE_2)))
  1397. // {
  1398. // pSensorReadRes->CompletionCode = CC_INV_DATA_FIELD;
  1399. // return sizeof (*pRes);
  1400. // }
  1401. // }
  1402. // if (g_BMCInfo.IpmiConfig.OPMASupport == 1)
  1403. // {
  1404. // if (pSenSharedMem->GlobalSensorScanningEnable == FALSE)
  1405. // {
  1406. // pSensorReadRes->CompletionCode = CC_PARAM_NOT_SUP_IN_CUR_STATE;
  1407. // return sizeof (*pRes);
  1408. // }
  1409. // }
  1410. // /* Acquire Shared memory */
  1411. // OS_THREAD_MUTEX_ACQUIRE(&g_BMCInfo.SensorSharedMemMutex, WAIT_INFINITE);
  1412. // if (!pSenSharedMem->SensorInfo [pSensorReadReq->SensorNum].IsSensorPresent)
  1413. // {
  1414. // /* Release mutex for Sensor shared memory */
  1415. // OS_THREAD_MUTEX_RELEASE(&g_BMCInfo.SensorSharedMemMutex);
  1416. // pSensorReadRes->CompletionCode = CC_SDR_REC_NOT_PRESENT;
  1417. // return sizeof (*pRes);
  1418. // }
  1419. // if (ReqLen < MIN_SET_SEN_READING_CMD_LEN)
  1420. // {
  1421. // /* Release mutex for Sensor shared memory */
  1422. // OS_THREAD_MUTEX_RELEASE(&g_BMCInfo.SensorSharedMemMutex);
  1423. // pSensorReadRes->CompletionCode = CC_REQ_INV_LEN;
  1424. // return sizeof (*pRes);
  1425. // }
  1426. // /* Check if the sensor is settable */
  1427. // if (0 == GET_SETTABLE_SENSOR_BIT(pSenSharedMem->SensorInfo [pSensorReadReq->SensorNum].SensorInit))
  1428. // {
  1429. // /* Release mutex for Sensor shared memory */
  1430. // OS_THREAD_MUTEX_RELEASE(&g_BMCInfo.SensorSharedMemMutex);
  1431. // pSensorReadRes->CompletionCode = CC_INVALID_ATTEMPT_TO_SET;
  1432. // return sizeof (*pRes);
  1433. // }
  1434. // pSenSharedMem->SensorInfo [pSensorReadReq->SensorNum].Operation = pSensorReadReq->Operation;
  1435. // /* Set Sensor Event Data based on the Operation byte */
  1436. // switch (GET_EVENT_DATA_OP(pSensorReadReq->Operation))
  1437. // {
  1438. // case WRITE_NO_EVTDATA1:
  1439. // pSensorReadReq->EvtData1 &= 0xF0;
  1440. // /* Intentional Fall thru */
  1441. // case WRITE_EVTDATA1:
  1442. // if (LEN_FOR_EVT_DATA != ReqLen)
  1443. // {
  1444. // /* Release mutex for Sensor shared memory */
  1445. // OS_THREAD_MUTEX_RELEASE(&g_BMCInfo.SensorSharedMemMutex);
  1446. // pSensorReadRes->CompletionCode = CC_REQ_INV_LEN;
  1447. // return sizeof (*pRes);
  1448. // }
  1449. // /* Update EvtData fields */
  1450. // pSenSharedMem->SensorInfo [pSensorReadReq->SensorNum].EvtData1 = pSensorReadReq->EvtData1;
  1451. // pSenSharedMem->SensorInfo [pSensorReadReq->SensorNum].EvtData2 = pSensorReadReq->EvtData2;
  1452. // pSenSharedMem->SensorInfo [pSensorReadReq->SensorNum].EvtData3 = pSensorReadReq->EvtData3;
  1453. // break;
  1454. // }
  1455. // /* Check Length for Assertion Set Opetation */
  1456. // if (0 != GET_ASSERT_EVT_OP(pSensorReadReq->Operation))
  1457. // {
  1458. // if ((ReqLen < LEN_FOR_ASSERT_DATA) || (ReqLen > MAX_SET_SEN_READ_LEN))
  1459. // {
  1460. // /* Release mutex for Sensor shared memory */
  1461. // OS_THREAD_MUTEX_RELEASE(&g_BMCInfo.SensorSharedMemMutex);
  1462. // pSensorReadRes->CompletionCode = CC_REQ_INV_LEN;
  1463. // return sizeof (*pRes);
  1464. // }
  1465. // }
  1466. // /* Set Sensor Assertion Event based on the Operation byte */
  1467. // switch (GET_ASSERT_EVT_OP(pSensorReadReq->Operation))
  1468. // {
  1469. // case CLEAR_ASSERT_BITS:
  1470. // pSenSharedMem->SensorInfo [pSensorReadReq->SensorNum].AssertionEventOccuredByte1 &= pSensorReadReq->AssertionEventOccuredByte1;
  1471. // pSenSharedMem->SensorInfo [pSensorReadReq->SensorNum].AssertionEventOccuredByte2 &= pSensorReadReq->AssertionEventOccuredByte2;
  1472. // break;
  1473. // case SET_ASSERT_BITS:
  1474. // pSenSharedMem->SensorInfo [pSensorReadReq->SensorNum].AssertionEventOccuredByte1 |= pSensorReadReq->AssertionEventOccuredByte1;
  1475. // pSenSharedMem->SensorInfo [pSensorReadReq->SensorNum].AssertionEventOccuredByte2 |= pSensorReadReq->AssertionEventOccuredByte2;
  1476. // break;
  1477. // case WRITE_ASSERT_BITS:
  1478. // pSenSharedMem->SensorInfo [pSensorReadReq->SensorNum].AssertionEventOccuredByte1 |= pSensorReadReq->AssertionEventOccuredByte1;
  1479. // pSenSharedMem->SensorInfo [pSensorReadReq->SensorNum].AssertionEventOccuredByte2 |= pSensorReadReq->AssertionEventOccuredByte2;
  1480. // break;
  1481. // }
  1482. // /* Check Length for Assertion Set Opetation */
  1483. // if (0 != GET_DEASSERT_EVT_OP(pSensorReadReq->Operation))
  1484. // {
  1485. // if ((ReqLen < LEN_FOR_DEASSERT_DATA) || (ReqLen > MAX_SET_SEN_READ_LEN))
  1486. // {
  1487. // /* Release mutex for Sensor shared memory */
  1488. // OS_THREAD_MUTEX_RELEASE(&g_BMCInfo.SensorSharedMemMutex);
  1489. // pSensorReadRes->CompletionCode = CC_REQ_INV_LEN;
  1490. // return sizeof (*pRes);
  1491. // }
  1492. // }
  1493. // /* Set Sensor DeAssertion Event based on the Operation byte */
  1494. // switch (GET_DEASSERT_EVT_OP(pSensorReadReq->Operation))
  1495. // {
  1496. // case CLEAR_DEASSERT_BITS:
  1497. // pSenSharedMem->SensorInfo [pSensorReadReq->SensorNum].DeassertionEventOccuredByte1 &= pSensorReadReq->DeAssertionEventOccuredByte1;
  1498. // pSenSharedMem->SensorInfo [pSensorReadReq->SensorNum].DeassertionEventOccuredByte2 &= pSensorReadReq->DeAssertionEventOccuredByte2;
  1499. // break;
  1500. // case SET_DEASSERT_BITS:
  1501. // pSenSharedMem->SensorInfo [pSensorReadReq->SensorNum].DeassertionEventOccuredByte1 |= pSensorReadReq->DeAssertionEventOccuredByte1;
  1502. // pSenSharedMem->SensorInfo [pSensorReadReq->SensorNum].DeassertionEventOccuredByte2 |= pSensorReadReq->DeAssertionEventOccuredByte2;
  1503. // break;
  1504. // case WRITE_DEASSERT_BITS:
  1505. // pSenSharedMem->SensorInfo [pSensorReadReq->SensorNum].DeassertionEventOccuredByte1 |= pSensorReadReq->DeAssertionEventOccuredByte1;
  1506. // pSenSharedMem->SensorInfo [pSensorReadReq->SensorNum].DeassertionEventOccuredByte2 |= pSensorReadReq->DeAssertionEventOccuredByte2;
  1507. // break;
  1508. // }
  1509. // /* Check Length for Set Sensor Reading Operation */
  1510. // if (0 != GET_SETSENSOR_OP(pSensorReadReq->Operation))
  1511. // {
  1512. // if ((ReqLen < LEN_FOR_SETSENSOR_DATA) || (ReqLen > MAX_SET_SEN_READ_LEN))
  1513. // {
  1514. // /* Release mutex for Sensor shared memory */
  1515. // OS_THREAD_MUTEX_RELEASE(&g_BMCInfo.SensorSharedMemMutex);
  1516. // pSensorReadRes->CompletionCode = CC_REQ_INV_LEN;
  1517. // return sizeof (*pRes);
  1518. // }
  1519. // /* Set new Sensor Reading */
  1520. // pSenSharedMem->SensorInfo [pSensorReadReq->SensorNum].SensorReading = pSensorReadReq->SensorReading;
  1521. // }
  1522. // pSensorReadRes->CompletionCode = CC_NORMAL;
  1523. // /* Release mutex for Sensor shared memory */
  1524. // OS_THREAD_MUTEX_RELEASE(&g_BMCInfo.SensorSharedMemMutex);
  1525. // return sizeof (SetSensorReadingRes_T);
  1526. return 0;
  1527. }
  1528. /*-------------------------------------------
  1529. * GetSensorSDR
  1530. *-------------------------------------------*/
  1531. SDRRecHdr_T*
  1532. SR_GetSensorSDR (uint8_t SensorNum)
  1533. {
  1534. SDRRecHdr_T* SDRRec;
  1535. /* Search for the record containing the sensor */
  1536. SDRRec = SDR_GetFirstSDRRec ();
  1537. while (0 != SDRRec)
  1538. {
  1539. switch (SDRRec->Type)
  1540. {
  1541. case FULL_SDR_REC :
  1542. if ((( FullSensorRec_T*) SDRRec)->SensorNum == SensorNum)
  1543. {
  1544. return SDRRec;
  1545. }
  1546. break;
  1547. case COMPACT_SDR_REC:
  1548. {
  1549. uint16_t SharedRecs = ((( CompactSensorRec_T*) SDRRec)->RecordSharing) &
  1550. SHARED_RECD_COUNT;
  1551. if ((SensorNum == (( CompactSensorRec_T*) SDRRec)->SensorNum ) ||
  1552. ((SensorNum >= ((( CompactSensorRec_T*) SDRRec)->SensorNum )) &&
  1553. (SensorNum < ((( CompactSensorRec_T*) SDRRec)->SensorNum + SharedRecs)))
  1554. )
  1555. {
  1556. return SDRRec;
  1557. }
  1558. }
  1559. break;
  1560. default :
  1561. break;
  1562. }
  1563. /* Get the next record */
  1564. SDRRec = SDR_GetNextSDRRec (SDRRec);
  1565. if (0 == SDRRec)
  1566. {
  1567. return 0;
  1568. }
  1569. }
  1570. return 0;
  1571. }
  1572. ///**
  1573. // * @brief Update global variables with number sensors.
  1574. //**/
  1575. //static void
  1576. //FindNumSensors ()
  1577. //{
  1578. // SDRRecHdr_T* pSDRRec;
  1579. // FullSensorRec_T* pFSR;
  1580. // CompactSensorRec_T* pCSR;
  1581. // pFSR = 0;
  1582. // pCSR = 0;
  1583. // /* Get First SDR Record */
  1584. // pSDRRec = SDR_GetFirstSDRRec ();
  1585. // while (0 != pSDRRec)
  1586. // {
  1587. // switch (pSDRRec->Type)
  1588. // {
  1589. // case FULL_SDR_REC :
  1590. // pFSR = ( FullSensorRec_T*) pSDRRec;
  1591. // if (THRESHOLD_SENSOR_CLASS == pFSR->EventTypeCode)
  1592. // {
  1593. // g_BMCInfo.SenConfig.NumThreshSensors++;
  1594. // }
  1595. // else
  1596. // {
  1597. // g_BMCInfo.SenConfig.NumNonThreshSensors++;
  1598. // }
  1599. // break;
  1600. // case COMPACT_SDR_REC :
  1601. // pCSR = ( CompactSensorRec_T*) pSDRRec;
  1602. // if (THRESHOLD_SENSOR_CLASS == pCSR->EventTypeCode)
  1603. // {
  1604. // g_BMCInfo.SenConfig.NumThreshSensors += ( (pCSR->RecordSharing) & SHARED_RECD_COUNT);
  1605. // }
  1606. // else
  1607. // {
  1608. // g_BMCInfo.SenConfig.NumNonThreshSensors += ( (pCSR->RecordSharing) & SHARED_RECD_COUNT);
  1609. // }
  1610. // break;
  1611. // default:
  1612. // break;
  1613. // }
  1614. // /* Get the next record */
  1615. // pSDRRec = SDR_GetNextSDRRec (pSDRRec);
  1616. // }
  1617. // printf("Thereshold Sensors = %d\n",g_BMCInfo.SenConfig.NumThreshSensors);
  1618. // printf("Non Thershold Sensors = %d\n",g_BMCInfo.SenConfig.NumNonThreshSensors);
  1619. // return;
  1620. //}
  1621. int
  1622. GetRecordIdsforDCMISensor (uint8_t EntityID,uint8_t SensorType, uint8_t EntityInstance,
  1623. uint8_t StartingEntityInstance, uint16_t* pBuf, uint8_t* pTotalValidInstances)
  1624. {
  1625. printf("GetRecordIdsforDCMISensor not implement\r\n");
  1626. // int i, ValidInstances;
  1627. // SensorSharedMem_T* pSenSharedMem;
  1628. // BMCInfo_t* pBMCInfo = &g_BMCInfo[BMCInst];
  1629. // pSenSharedMem = ( SensorSharedMem_T*)&g_BMCInfo.SensorSharedMem; //m_hSensorSharedMem;
  1630. // if (0 != EntityInstance)
  1631. // {
  1632. // *pTotalValidInstances = 0;
  1633. // ValidInstances = 0;
  1634. // /* Acquire Shared memory to populate sensor information */
  1635. // //OS_ACQUIRE_MUTEX(m_hSensorSharedMemMutex, SHARED_MEM_TIMEOUT);
  1636. // OS_THREAD_MUTEX_ACQUIRE(&g_BMCInfo[BMCInst].SensorSharedMemMutex, WAIT_INFINITE);
  1637. // for (i = 0; i < MAX_SENSOR_NUMBERS + 1; i++ )
  1638. // {
  1639. // if ((TRUE == pSenSharedMem->SensorInfo [i].IsDCMITempsensor) && (pSenSharedMem->SensorInfo[i].SDRRec->Type == FULL_SDR_REC) )
  1640. // {
  1641. // if(SensorType != pSenSharedMem->SensorInfo[i].SensorTypeCode)
  1642. // {
  1643. // /*Check the Sensor type*/
  1644. // continue;
  1645. // }
  1646. // if ((((EntityID == DCMI_INLET_TEMP_ENTITY_ID) || (EntityID == IPMI_INLET_TEMP_ENTITY_ID)) && ((pSenSharedMem->SensorInfo [i].EntityID == DCMI_INLET_TEMP_ENTITY_ID) || (pSenSharedMem->SensorInfo [i].EntityID == IPMI_INLET_TEMP_ENTITY_ID))) ||
  1647. // (((EntityID == DCMI_CPU_TEMP_ENTITY_ID) || (EntityID == IPMI_CPU_TEMP_ENTITY_ID)) && ((pSenSharedMem->SensorInfo [i].EntityID == DCMI_CPU_TEMP_ENTITY_ID) || (pSenSharedMem->SensorInfo [i].EntityID == IPMI_CPU_TEMP_ENTITY_ID))) ||
  1648. // (((EntityID == DCMI_BASEBOARD_TEMP_ENTITY_ID) || (EntityID == IPMI_BASEBOARD_TEMP_ENTITY_ID)) && ((pSenSharedMem->SensorInfo [i].EntityID == DCMI_BASEBOARD_TEMP_ENTITY_ID) || (pSenSharedMem->SensorInfo [i].EntityID == IPMI_BASEBOARD_TEMP_ENTITY_ID))))
  1649. // {
  1650. // *pTotalValidInstances += 1;
  1651. // if (EntityInstance == pSenSharedMem->SensorInfo [i].EntiryInstance)
  1652. // {
  1653. // pBuf [0] = pSenSharedMem->SensorInfo [i].RecordID;
  1654. // ValidInstances = 1;
  1655. // }
  1656. // }
  1657. // }
  1658. // }
  1659. // /* Release mutex for Sensor shared memory */
  1660. // OS_THREAD_MUTEX_RELEASE(&g_BMCInfo[BMCInst].SensorSharedMemMutex);
  1661. // return ValidInstances;
  1662. // }
  1663. // else
  1664. // {
  1665. // *pTotalValidInstances = 0;
  1666. // ValidInstances = 0;
  1667. // /* Acquire Shared memory to populate sensor information */
  1668. // //OS_ACQUIRE_MUTEX(m_hSensorSharedMemMutex, SHARED_MEM_TIMEOUT);
  1669. // OS_THREAD_MUTEX_ACQUIRE(&g_BMCInfo[BMCInst].SensorSharedMemMutex, WAIT_INFINITE);
  1670. // for (i = StartingEntityInstance; i < MAX_SENSOR_NUMBERS + 1; i++ )
  1671. // {
  1672. // if ((TRUE == pSenSharedMem->SensorInfo [i].IsDCMITempsensor) && (pSenSharedMem->SensorInfo[i].SDRRec->Type == FULL_SDR_REC) )
  1673. // {
  1674. // if(SensorType != pSenSharedMem->SensorInfo[i].SensorTypeCode)
  1675. // {
  1676. // /*Check the Sensor type*/
  1677. // continue;
  1678. // }
  1679. // if ((((EntityID == DCMI_INLET_TEMP_ENTITY_ID) || (EntityID == IPMI_INLET_TEMP_ENTITY_ID)) && ((pSenSharedMem->SensorInfo [i].EntityID == DCMI_INLET_TEMP_ENTITY_ID) || (pSenSharedMem->SensorInfo [i].EntityID == IPMI_INLET_TEMP_ENTITY_ID))) ||
  1680. // (((EntityID == DCMI_CPU_TEMP_ENTITY_ID) || (EntityID == IPMI_CPU_TEMP_ENTITY_ID)) && ((pSenSharedMem->SensorInfo [i].EntityID == DCMI_CPU_TEMP_ENTITY_ID) || (pSenSharedMem->SensorInfo [i].EntityID == IPMI_CPU_TEMP_ENTITY_ID))) ||
  1681. // (((EntityID == DCMI_BASEBOARD_TEMP_ENTITY_ID) || (EntityID == IPMI_BASEBOARD_TEMP_ENTITY_ID)) && ((pSenSharedMem->SensorInfo [i].EntityID == DCMI_BASEBOARD_TEMP_ENTITY_ID) || (pSenSharedMem->SensorInfo [i].EntityID == IPMI_BASEBOARD_TEMP_ENTITY_ID))))
  1682. // {
  1683. // *pTotalValidInstances += 1;
  1684. // if (ValidInstances < 8)
  1685. // {
  1686. // pBuf [ValidInstances] = pSenSharedMem->SensorInfo [i].RecordID;
  1687. // ValidInstances += 1;
  1688. // }
  1689. // }
  1690. // }
  1691. // }
  1692. // /* Release mutex for Sensor shared memory */
  1693. // //OS_RELEASE_MUTEX(m_hSensorSharedMemMutex);
  1694. // OS_THREAD_MUTEX_RELEASE(&g_BMCInfo[BMCInst].SensorSharedMemMutex);
  1695. // return (ValidInstances > 8) ? 8: ValidInstances;
  1696. // }
  1697. return 0;
  1698. }
  1699. int GetDCMITempReading(uint8_t EntityID,uint8_t SensorType, uint8_t EntityInstance,
  1700. uint8_t StartingEntityInstance, uint8_t* pBuf, uint8_t* pTotalValidInstances)
  1701. {
  1702. printf("GetDCMITempReading not implement\r\n");
  1703. // int i, ValidInstances,j = 0;
  1704. // SensorSharedMem_T* pSenSharedMem;
  1705. // BMCInfo_t* pBMCInfo = &g_BMCInfo[BMCInst];
  1706. // pSenSharedMem = ( SensorSharedMem_T*)&g_BMCInfo.SensorSharedMem; //m_hSensorSharedMem;
  1707. // SDRRecHdr_T* pSDRRec;
  1708. // FullSensorRec_T* FullSDR;
  1709. // float convreading = 0;
  1710. // uint8_t MinReading = 0, MaxReading = 0,Linear = 0;
  1711. // if (0 != EntityInstance)
  1712. // {
  1713. // *pTotalValidInstances = 0;
  1714. // ValidInstances = 0;
  1715. // OS_THREAD_MUTEX_ACQUIRE(&g_BMCInfo[BMCInst].SensorSharedMemMutex, WAIT_INFINITE);
  1716. // for (i = 0; i < MAX_SENSOR_NUMBERS + 1; i++ )
  1717. // {
  1718. // if ((TRUE == pSenSharedMem->SensorInfo [i].IsDCMITempsensor) && (pSenSharedMem->SensorInfo[i].SDRRec->Type == FULL_SDR_REC) )
  1719. // {
  1720. // if(SensorType != pSenSharedMem->SensorInfo[i].SensorTypeCode)
  1721. // {
  1722. // /*Check the Sensor type*/
  1723. // continue;
  1724. // }
  1725. // if ((((EntityID == DCMI_INLET_TEMP_ENTITY_ID) || (EntityID == IPMI_INLET_TEMP_ENTITY_ID)) && ((pSenSharedMem->SensorInfo [i].EntityID == DCMI_INLET_TEMP_ENTITY_ID) || (pSenSharedMem->SensorInfo [i].EntityID == IPMI_INLET_TEMP_ENTITY_ID))) ||
  1726. // (((EntityID == DCMI_CPU_TEMP_ENTITY_ID) || (EntityID == IPMI_CPU_TEMP_ENTITY_ID)) && ((pSenSharedMem->SensorInfo [i].EntityID == DCMI_CPU_TEMP_ENTITY_ID) || (pSenSharedMem->SensorInfo [i].EntityID == IPMI_CPU_TEMP_ENTITY_ID))) ||
  1727. // (((EntityID == DCMI_BASEBOARD_TEMP_ENTITY_ID) || (EntityID == IPMI_BASEBOARD_TEMP_ENTITY_ID)) && ((pSenSharedMem->SensorInfo [i].EntityID == DCMI_BASEBOARD_TEMP_ENTITY_ID) || (pSenSharedMem->SensorInfo [i].EntityID == IPMI_BASEBOARD_TEMP_ENTITY_ID))))
  1728. // {
  1729. // *pTotalValidInstances += 1;
  1730. // if (EntityInstance == pSenSharedMem->SensorInfo [i].EntiryInstance)
  1731. // {
  1732. // if( !( pSenSharedMem->SensorInfo[i].EventFlags & 0x40) || (pSenSharedMem->SensorInfo[i].EventFlags & 0x20) )
  1733. // {
  1734. // printf("event flag is disabled\n");
  1735. // pBuf[DCMI_TEMP_READING] = 0;
  1736. // pBuf[DCMI_INST_NUMBER] = 0;
  1737. // }
  1738. // else
  1739. // {
  1740. // pSDRRec = GetSDRRec(pSenSharedMem->SensorInfo[i].SDRRec->ID,BMCInst);
  1741. //
  1742. // FullSDR = ( FullSensorRec_T *)pSDRRec;
  1743. // MinReading = FullSDR->MinReading;
  1744. // MaxReading = FullSDR->MaxReading;
  1745. // Linear = FullSDR->Linearization;
  1746. //
  1747. // ipmi_conv_reading(pSenSharedMem->SensorInfo[i].SDRRec->Type, pSenSharedMem->SensorInfo[i].SensorReading, &convreading, MinReading,MaxReading, pSenSharedMem->SensorInfo[i].Units1,Linear, pSenSharedMem->SensorInfo[i].M_LSB,
  1748. // pSenSharedMem->SensorInfo[i].B_LSB, pSenSharedMem->SensorInfo[i].M_MSB_Tolerance, pSenSharedMem->SensorInfo[i].B_MSB_Accuracy, pSenSharedMem->SensorInfo[i].RExp_BExp);
  1749. // pBuf [DCMI_TEMP_READING] = (int8_t)convreading;
  1750. // pBuf [DCMI_INST_NUMBER] = EntityInstance;
  1751. // }
  1752. // ValidInstances = 1;
  1753. // }
  1754. // }
  1755. // }
  1756. // }
  1757. // /* Release mutex for Sensor shared memory */
  1758. // OS_THREAD_MUTEX_RELEASE(&g_BMCInfo[BMCInst].SensorSharedMemMutex);
  1759. // return ValidInstances;
  1760. // }
  1761. // else
  1762. // {
  1763. // *pTotalValidInstances = 0;
  1764. // ValidInstances = 0;
  1765. // OS_THREAD_MUTEX_ACQUIRE(&g_BMCInfo[BMCInst].SensorSharedMemMutex, WAIT_INFINITE);
  1766. // for (i = StartingEntityInstance; i < MAX_SENSOR_NUMBERS + 1; i++ )
  1767. // {
  1768. // if ((TRUE == pSenSharedMem->SensorInfo [i].IsDCMITempsensor) && (pSenSharedMem->SensorInfo[i].SDRRec->Type == FULL_SDR_REC) )
  1769. // {
  1770. // if(SensorType != pSenSharedMem->SensorInfo[i].SensorTypeCode)
  1771. // {
  1772. // /*Check the Sensor type*/
  1773. // continue;
  1774. // }
  1775. // if ((((EntityID == DCMI_INLET_TEMP_ENTITY_ID) || (EntityID == IPMI_INLET_TEMP_ENTITY_ID)) && ((pSenSharedMem->SensorInfo [i].EntityID == DCMI_INLET_TEMP_ENTITY_ID) || (pSenSharedMem->SensorInfo [i].EntityID == IPMI_INLET_TEMP_ENTITY_ID))) ||
  1776. // (((EntityID == DCMI_CPU_TEMP_ENTITY_ID) || (EntityID == IPMI_CPU_TEMP_ENTITY_ID)) && ((pSenSharedMem->SensorInfo [i].EntityID == DCMI_CPU_TEMP_ENTITY_ID) || (pSenSharedMem->SensorInfo [i].EntityID == IPMI_CPU_TEMP_ENTITY_ID))) ||
  1777. // (((EntityID == DCMI_BASEBOARD_TEMP_ENTITY_ID) || (EntityID == IPMI_BASEBOARD_TEMP_ENTITY_ID)) && ((pSenSharedMem->SensorInfo [i].EntityID == DCMI_BASEBOARD_TEMP_ENTITY_ID) || (pSenSharedMem->SensorInfo [i].EntityID == IPMI_BASEBOARD_TEMP_ENTITY_ID))))
  1778. // {
  1779. // *pTotalValidInstances += 1;
  1780. // if (ValidInstances < 8)
  1781. // {
  1782. // if( !( pSenSharedMem->SensorInfo[i].EventFlags & 0x40) || (pSenSharedMem->SensorInfo[i].EventFlags & 0x20) )
  1783. // {
  1784. // pBuf[DCMI_TEMP_READING + j] = 0;
  1785. // pBuf[DCMI_INST_NUMBER + j] = 0;
  1786. // j = j+2;
  1787. // }
  1788. // else
  1789. // {
  1790. // pSDRRec = GetSDRRec(pSenSharedMem->SensorInfo[i].SDRRec->ID,BMCInst);
  1791. // FullSDR = ( FullSensorRec_T *)pSDRRec;
  1792. // MinReading = FullSDR->MinReading;
  1793. // MaxReading = FullSDR->MaxReading;
  1794. // Linear = FullSDR->Linearization;
  1795. //
  1796. // ipmi_conv_reading(pSenSharedMem->SensorInfo[i].SDRRec->Type, pSenSharedMem->SensorInfo[i].SensorReading, &convreading, MinReading,MaxReading, pSenSharedMem->SensorInfo[i].Units1,Linear, pSenSharedMem->SensorInfo[i].M_LSB,
  1797. // pSenSharedMem->SensorInfo[i].B_LSB, pSenSharedMem->SensorInfo[i].M_MSB_Tolerance, pSenSharedMem->SensorInfo[i].B_MSB_Accuracy, pSenSharedMem->SensorInfo[i].RExp_BExp);
  1798. //
  1799. // pBuf[ j++] = (int8_t)convreading;
  1800. // pBuf[ j++] = pSenSharedMem->SensorInfo[i].EntiryInstance;
  1801. // TDBG("j value %d\n",j);
  1802. // }
  1803. // ValidInstances += 1;
  1804. // }
  1805. // }
  1806. // }
  1807. // }
  1808. // OS_THREAD_MUTEX_RELEASE(&g_BMCInfo[BMCInst].SensorSharedMemMutex);
  1809. // return (ValidInstances > 8) ? 8: ValidInstances;
  1810. // }
  1811. return 0;
  1812. }
  1813. #endif /* SENSOR_DEVICE */