Sensor.c 79 KB

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