Sensor.c 105 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546
  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. #define ENABLE_DEBUG_MACROS 0
  23. //#include <dlfcn.h>
  24. #include <math.h>
  25. #include "Types.h"
  26. //#include "Debug.h"
  27. #include "MsgHndlr.h"
  28. //#include "Sensor.h"
  29. #include "Support.h"
  30. //#include "IPMIDefs.h"
  31. #include "IPMI_Sensor.h"
  32. //#include "SensorMonitor.h"
  33. //#include "SDRFunc.h"
  34. //#include "SDR.h"
  35. //#include "Util.h"
  36. #include "IPMI_Main.h"
  37. #include "SharedMem.h"
  38. #include "AppDevice.h"
  39. #include "IPMI_KCS.h"
  40. #include "IPMI_SEL.h"
  41. #include "Message.h"
  42. //#include "OSPort.h"
  43. //#include "PEF.h"
  44. //#include "SEL.h"
  45. //#include "FRU.h"
  46. //#include "PDKAccess.h"
  47. //#include "PDKCmdsAccess.h"
  48. #include "IPMIConf.h"
  49. #include "IPMI_FRU.h"
  50. //#include "sensor_helpers.h"
  51. //#include "featuredef.h"
  52. /* Reserved bit macro definitions */
  53. #define RESERVED_BITS_SETSENSORTYPE 0X80 //(BIT7)
  54. #define RESERVED_BITS_REARMSENSOR_REARMALLEVENTS 0X7F //(BIT6 | BIT5 | BIT4 | BIT3 | BIT2 | BIT1 | BIT0)
  55. #define RESERVED_BITS_REARMSENSOR_REARMASSEVT2_1 0XF0 //(BIT7 | BIT6 | BIT5 | BIT4)
  56. #define RESERVED_BITS_REARMSENSOR_REARMDEASSEVT2_1 0XF0 //(BIT7 | BIT6 | BIT5 | BIT4)
  57. #define RESERVED_BITS_REARMSENSOR_REARMASSEVT2_2 0X80 //(BIT7)
  58. #define RESERVED_BITS_REARMSENSOR_REARMDEASSEVT2_2 0X80 //(BIT7)
  59. #define RESERVED_BITS_SETSENSORTHRESHOLDS 0XC0 //(BIT7 | BIT6)
  60. #define RESERVED_BITS_SETSENEVTEN_FLAGS 0X0F //(BIT3 | BIT2 | BIT1 | BIT0)
  61. #define RESERVED_BITS_SETSENEVTEN_ASSERTIONMASK 0X8000
  62. #define RESERVED_BITS_SETSENEVTEN_DEASSERTIONMASK 0X8000
  63. #define RESERVED_BITS_SETSENRD_ASSEVTOCCBYTE_1 0xF0 //(BIT7 | BIT6 | BIT5 | BIT4)
  64. #define RESERVED_BITS_SETSENRD_DEASSEVTOCCBYTE_1 0xF0 //(BIT7 | BIT6 | BIT5 | BIT4)
  65. #define RESERVED_BITS_SETSENRD_ASSEVTOCCBYTE_2 0x80 //(BIT7)
  66. #define RESERVED_BITS_SETSENRD_DEASSEVTOCCBYTE_2 0x80 //(BIT7)
  67. #define SENSOR_THRESOLD_ACCESS_BITS 0x0c //(BIT2 | BIT3)
  68. #define SENSOR_HYSTERESIS_ACCESS_BITS 0x30 //(BIT4 | BIT5)
  69. #if SENSOR_DEVICE == 1
  70. /*** Local Definitions ***/
  71. #define NUM_SENSORS(BMCInst) (g_BMCInfo[BMCInst].SenConfig.NumThreshSensors + g_BMCInfo[BMCInst].SenConfig.NumNonThreshSensors)
  72. #define FULL_SDR_REC 0x01
  73. #define COMPACT_SDR_REC 0x02
  74. #define OEM_SDR_FRU_REC 0xf1
  75. #define OEM_SDR_NM_REC 0x0D
  76. #define FL_STATIC_SENSOR 0x00
  77. #define FL_NUM_LUN(NUM_LUN) NUM_LUN
  78. #define LWR_NON_CRIT 0x01
  79. #define LWR_CRIT 0x02
  80. #define LWR_NON_REC 0x04
  81. #define UPR_NON_CRIT 0x08
  82. #define UPR_CRIT 0x10
  83. #define UPR_NON_REC 0x20
  84. #define EVENT_MSG_MASK 0x80
  85. #define SCAN_MASK 0x40
  86. #define ENABLE_DISABLE_EVENT_MASK 0x30
  87. #define DO_NOT_CHANGE 0x00
  88. #define ENABLE_SELECTED_EVENT_MSG 0x10
  89. #define DISABLE_SELECTED_EVENT_MSG 0x20
  90. #define CC_INVALID_ATTEMPT_TO_SET 0x80
  91. #define MIN_SET_SEN_READING_CMD_LEN 3
  92. #define LEN_FOR_EVT_DATA 10
  93. #define MAX_SET_SEN_READ_LEN 10
  94. #define LEN_FOR_ASSERT_DATA 5
  95. #define LEN_FOR_DEASSERT_DATA 7
  96. #define LEN_FOR_SETSENSOR_DATA 3
  97. #define NOT_FOUND_SCAN_DISABLED -1
  98. #define NOT_FOUND_SCAN_ENABLED -2
  99. #define ENTITY_FOUND 1
  100. #define ENTITY_NOT_FOUND 0
  101. #define DCMI_TEMP_READING 0x0
  102. #define DCMI_INST_NUMBER 0x1
  103. /*** Local typedefs ***/
  104. /**
  105. * @struct SR_SensorInfo_T
  106. * @brief Sensor Information.
  107. **/
  108. typedef struct
  109. {
  110. /* CAUTION Order of members dependent on Response structures */
  111. INT8U M_LSB;
  112. INT8U M_MSB_Tolerance;
  113. INT8U B_LSB;
  114. INT8U B_MSB_Accuracy;
  115. INT8U Accuracy_MSB_Exp;
  116. INT8U RExp_BExp;
  117. INT8U PositiveHysterisis;
  118. INT8U NegativeHysterisis;
  119. INT8U LowerNonCritical;
  120. INT8U LowerCritical;
  121. INT8U LowerNonRecoverable;
  122. INT8U UpperNonCritical;
  123. INT8U UpperCritical;
  124. INT8U UpperNonRecoverable;
  125. INT8U EventFlags;
  126. INT16U AssertionMask;
  127. INT16U DeAssertionMask;
  128. INT8U EventTypeCode;
  129. INT16U ReadWriteThreshMask;
  130. INT8U SensorInit;
  131. INT8U SensorNum;
  132. } SR_SensorInfo_T;
  133. /*** Global Variables ***/
  134. //_FAR_ INT8U g_NumThreshSensors;
  135. //_FAR_ INT8U g_NumNonThreshSensors;
  136. //_FAR_ INT8U g_FRUInfo[MAX_PDK_FRU_SUPPORTED];
  137. //FRUInfo_T *m_FRUInfo[MAX_PDK_FRU_SUPPORTED];
  138. //INT8U m_total_frus=0;
  139. //Sensor-Type Sensor-specific-offset
  140. //static const INT8U sensor_presence [][2] = {
  141. // {PROCESSOR, PROCESSOR_PRESENCE_DETECTED},
  142. // {POWER_SUPPLY, POWER_SUPPLY_PRESENCE_DETECTED},
  143. // {POWER_SUPPLY, POWER_SUPPLY_OUT_OF_RANGE_PRESENT},
  144. // {MEMORY, MEMORY_PRESENCE_DETECTED},
  145. // {ENTITY_PRESENCE, ENTITY_PRESENCE_ENTITY_PRESENT},
  146. // {BATTERY, BATTERY_PRESENCE_DETECTED}
  147. //};
  148. #define SENSOR_PRESENCE_COUNT (sizeof(sensor_presence)/ sizeof(sensor_presence[0]))
  149. /*** Prototype Declaration ***/
  150. static void FindNumSensors (int BMCInst);
  151. /*---------------------------------------
  152. * InitSensor
  153. *---------------------------------------*/
  154. int
  155. InitSensor (int BMCInst)
  156. {
  157. // _FAR_ SDRRecHdr_T* sr;
  158. // _FAR_ FullSensorRec_T* sfs;
  159. // _FAR_ CompactSensorRec_T* scs;
  160. // _FAR_ FRUDevLocatorRec_T *sfr;
  161. // _FAR_ OEM_FRURec_T* sof;
  162. // INT16U SharedRecs = 0;
  163. // INT8U NodeManager = 0;
  164. // INT16U LUN_SensorNum = 0; /* Multi-LUN support index */
  165. // int i = 0,len=0,fruvalid=0;
  166. // _FAR_ BMCInfo_t* pBMCInfo = &g_BMCInfo[BMCInst];
  167. // INT8U Index=0,FruAddress = 0;
  168. // _FAR_ SensorSharedMem_T* pSenSharedMem;
  169. // char *str,*saveptr,*tempbuf;
  170. //
  171. // memset(&pBMCInfo->SenConfig.HealthState,0, sizeof(HealthState_T));;
  172. // /* If we didnt initalize the g_FRUInfo to 0xff and if SDR type #11 is not present then
  173. // It makes infinity FRU test loop */
  174. // memset(pBMCInfo->FRUConfig.FRUInfo,0xff,MAX_PDK_FRU_SUPPORTED);
  175. //
  176. // /* Get the Sensor Shared Memory */
  177. // pSenSharedMem = (_FAR_ SensorSharedMem_T*)&pBMCInfo->SensorSharedMem; //m_hSensorSharedMem;
  178. //
  179. // /* Create mutex for Sensor shared memory */
  180. // OS_THREAD_MUTEX_INIT(g_BMCInfo[BMCInst].SensorSharedMemMutex, PTHREAD_MUTEX_RECURSIVE);
  181. //
  182. //
  183. // /* Find No.of Threshold and Non Threshold Sensors */
  184. // FindNumSensors (BMCInst);
  185. //
  186. // IPMI_DBG_PRINT ("Init Sensor\n");
  187. //
  188. // if (0 == (g_BMCInfo[BMCInst].SenConfig.NumThreshSensors + g_BMCInfo[BMCInst].SenConfig.NumNonThreshSensors))
  189. // {
  190. // IPMI_WARNING ("Sensor.c : There are no sensors\n");
  191. // return -1;
  192. // }
  193. //
  194. // /* Acquire Shared memory to populate sensor information */
  195. // OS_THREAD_MUTEX_ACQUIRE(&g_BMCInfo[BMCInst].SensorSharedMemMutex, WAIT_INFINITE)
  196. //
  197. // sr = SDR_GetFirstSDRRec (BMCInst);
  198. //
  199. //
  200. // while (0 != sr)
  201. // {
  202. //
  203. // // printf("InitSensor\n");
  204. // // Populater sensor information for Threshold sensors
  205. // if (sr->Type == FULL_SDR_REC)
  206. // {
  207. // sfs = (_FAR_ FullSensorRec_T*) sr;
  208. // if(g_corefeatures.node_manager == ENABLED)
  209. // {
  210. // if (sfs->OwnerID == pBMCInfo->NMConfig.NMDevSlaveAddress)
  211. // {
  212. // NodeManager = 1;
  213. // }
  214. // }
  215. // else
  216. // {
  217. // NodeManager = 0;
  218. // }
  219. //
  220. // LUN_SensorNum = (((sfs->OwnerLUN & VALID_LUN) << 8) | sfs->SensorNum); /* Multi-LUN support */
  221. // IPMI_DBG_PRINT_3("LUN_SensorNum = %x sfs->OwnerLUN = %x sfs->SensorNum = %x \n",LUN_SensorNum, sfs->OwnerLUN, sfs->SensorNum);
  222. //
  223. // if ((sfs->OwnerID == pBMCInfo->IpmiConfig.BMCSlaveAddr) || (NodeManager))
  224. // {
  225. // pSenSharedMem->SensorInfo[LUN_SensorNum].IsSensorPresent = TRUE; /* Multi-LUN support */
  226. // IPMI_DBG_PRINT_1("#### pSensorSharedMem->SensorInfo[%x].IsSensorPresent = TRUE ####\n",LUN_SensorNum);
  227. // SR_LoadSDRDefaults (sr, (SensorInfo_T*)&pSenSharedMem->SensorInfo[LUN_SensorNum],BMCInst); /* Multi-LUN support */
  228. // // SDR Record information
  229. // pSenSharedMem->SensorInfo[LUN_SensorNum].SDRRec = sr; /* Multi-LUN support */
  230. //
  231. // /* Update Init Done flag */
  232. // SET_SM_INIT_DONE(pSenSharedMem->SensorInfo [LUN_SensorNum].EventFlags); /* Multi-LUN support */
  233. //
  234. // if(pBMCInfo->IpmiConfig.DCMISupport == 1)
  235. // {
  236. // pSenSharedMem->SensorInfo[LUN_SensorNum].IsDCMITempsensor = TRUE;
  237. // pSenSharedMem->SensorInfo[LUN_SensorNum].EntityID = sfs->EntityID;
  238. // pSenSharedMem->SensorInfo[LUN_SensorNum].EntiryInstance = sfs->EntityIns;
  239. // pSenSharedMem->SensorInfo[LUN_SensorNum].RecordID = sfs->hdr.ID;
  240. // }
  241. // }
  242. //
  243. // if( SENSOR_TYPE_SYSTEM_EVENT == sfs->SensorType)
  244. // {
  245. // BMC_GET_SHARED_MEM(BMCInst)->SysEvent_SensorNo =sfs->SensorNum;
  246. // }
  247. // }
  248. // else if (sr->Type == COMPACT_SDR_REC)
  249. // {
  250. // scs = (_FAR_ CompactSensorRec_T*) sr;
  251. //
  252. // if(g_corefeatures.node_manager == ENABLED)
  253. // {
  254. // if (scs->OwnerID == pBMCInfo->NMConfig.NMDevSlaveAddress)
  255. // NodeManager = 1;
  256. // }
  257. // else
  258. // {
  259. // NodeManager = 0;
  260. // }
  261. // LUN_SensorNum = ((scs->OwnerLUN & VALID_LUN) << 8 | scs->SensorNum); /* Multi-LUN support */
  262. // IPMI_DBG_PRINT_3("LUN_SensorNum = %x scs->OwnerLUN = %x scs->SensorNum = %x \n",LUN_SensorNum,scs->OwnerLUN,scs->SensorNum);
  263. // if ((scs->OwnerID == pBMCInfo->IpmiConfig.BMCSlaveAddr) || (NodeManager))
  264. // {
  265. // pSenSharedMem->SensorInfo[LUN_SensorNum].IsSensorPresent = TRUE; /* Multi-LUN support */
  266. // IPMI_DBG_PRINT_1("#### pSensorSharedMem->SensorInfo[%x].IsSensorPresent = TRUE ####\n",LUN_SensorNum);
  267. // SR_LoadSDRDefaults (sr, (SensorInfo_T*)&pSenSharedMem->SensorInfo[LUN_SensorNum],BMCInst); /* Multi-LUN support */
  268. //
  269. // // SDR Record information
  270. // pSenSharedMem->SensorInfo[LUN_SensorNum].SDRRec = sr; /* Multi-LUN support */
  271. //
  272. // SharedRecs = ipmitoh_u16 (((_FAR_ CompactSensorRec_T*) sr)->RecordSharing) &
  273. // SHARED_RECD_COUNT;
  274. // IPMI_DBG_PRINT_2 ("Sen %x , Shared Count - %x\n", scs->SensorNum, SharedRecs);
  275. //
  276. // /* Update Init Done flag */
  277. // SET_SM_INIT_DONE(pSenSharedMem->SensorInfo [LUN_SensorNum].EventFlags); /* Multi-LUN support */
  278. //
  279. // /* Check if Record is shared */
  280. // if (SharedRecs > 1)
  281. // {
  282. // for (i = 1; i < SharedRecs; i++)
  283. // {
  284. // pSenSharedMem->SensorInfo[LUN_SensorNum + i].IsSensorPresent = TRUE; /* Multi-LUN support */
  285. // SR_LoadSDRDefaults (sr, (SensorInfo_T*)&pSenSharedMem->SensorInfo[LUN_SensorNum + i],BMCInst); /* Multi-LUN support */
  286. // pSenSharedMem->SensorInfo[LUN_SensorNum + i].SensorNumber = scs->SensorNum + i; /* Multi-LUN support */
  287. //
  288. // // SDR Record information
  289. // pSenSharedMem->SensorInfo[LUN_SensorNum + i].SDRRec = sr; /* Multi-LUN support */
  290. //
  291. // /* Update Init Done flag */
  292. // SET_SM_INIT_DONE(pSenSharedMem->SensorInfo [LUN_SensorNum + i].EventFlags); /* Multi-LUN support */
  293. // }
  294. // }
  295. //
  296. // if(pBMCInfo->IpmiConfig.DCMISupport == 1)
  297. // {
  298. // pSenSharedMem->SensorInfo[LUN_SensorNum].IsDCMITempsensor = TRUE;
  299. // pSenSharedMem->SensorInfo[LUN_SensorNum].EntityID = scs->EntityID;
  300. // pSenSharedMem->SensorInfo[LUN_SensorNum].EntiryInstance = scs->EntityIns;
  301. // pSenSharedMem->SensorInfo[LUN_SensorNum].RecordID = scs->hdr.ID;
  302. // }
  303. //
  304. // }
  305. //
  306. // if( SENSOR_TYPE_SYSTEM_EVENT == scs->SensorType )
  307. // {
  308. // BMC_GET_SHARED_MEM(BMCInst)->SysEvent_SensorNo =scs->SensorNum;
  309. // }
  310. // }
  311. // else if(sr->Type == FRU_DEVICE_LOCATOR_SDR_REC)
  312. // {
  313. // sfr = (_FAR_ FRUDevLocatorRec_T*) sr;
  314. // /* Collecting the Logical FRU Device ID */
  315. // if((sfr->AccessLUNBusID & 0x80) == 0x80)
  316. // {
  317. // if(g_PDKHandle[PDK_FRUGETDEVADDRESS] != NULL)
  318. // {
  319. // if(((int(*)(INT8U,INT8U*,int))g_PDKHandle[PDK_FRUGETDEVADDRESS]) (sfr->FRUIDSlaveAddr,&FruAddress,BMCInst) == -1)
  320. // {
  321. // IPMI_WARNING("FRU Device Address cannot be found for FRU ID %x \n",sfr->FRUIDSlaveAddr);
  322. // sr = SDR_GetNextSDRRec (sr,BMCInst);
  323. // continue;
  324. // }
  325. // }
  326. // else
  327. // {
  328. // sr = SDR_GetNextSDRRec (sr,BMCInst);
  329. // continue;
  330. // }
  331. // pBMCInfo->FRUConfig.FRUInfo[Index++]=sfr->FRUIDSlaveAddr;
  332. // pBMCInfo->FRUConfig.FRUInfo[Index]= 0xff;
  333. // pBMCInfo->FRUConfig.m_FRUInfo[pBMCInfo->FRUConfig.total_frus]=(FRUInfo_T*)malloc(sizeof(FRUInfo_T));
  334. // pBMCInfo->FRUConfig.m_FRUInfo[pBMCInfo->FRUConfig.total_frus]->IsInternalFRU=0;
  335. // pBMCInfo->FRUConfig.m_FRUInfo[pBMCInfo->FRUConfig.total_frus]->Size=FRU_FILE_SIZE;
  336. // pBMCInfo->FRUConfig.m_FRUInfo[pBMCInfo->FRUConfig.total_frus]->AccessType=DEV_ACCESS_MODE_IN_BYTES;
  337. // pBMCInfo->FRUConfig.m_FRUInfo[pBMCInfo->FRUConfig.total_frus]->Offset=0;
  338. // pBMCInfo->FRUConfig.m_FRUInfo[pBMCInfo->FRUConfig.total_frus]->DeviceID=sfr->FRUIDSlaveAddr;
  339. // pBMCInfo->FRUConfig.m_FRUInfo[pBMCInfo->FRUConfig.total_frus]->Type=FRU_TYPE_EEPROM;
  340. // //pBMCInfo->FRUConfig.m_FRUInfo[pBMCInfo->FRUConfig.total_frus]->NVRFile=NULL;
  341. // pBMCInfo->FRUConfig.m_FRUInfo[pBMCInfo->FRUConfig.total_frus]->SlaveAddr=FruAddress;
  342. // pBMCInfo->FRUConfig.m_FRUInfo[pBMCInfo->FRUConfig.total_frus]->DeviceType=sfr->DevType;
  343. // pBMCInfo->FRUConfig.m_FRUInfo[pBMCInfo->FRUConfig.total_frus]->BusNumber = (sfr->AccessLUNBusID & 0x07);
  344. // strcpy((char *)pBMCInfo->FRUConfig.m_FRUInfo[pBMCInfo->FRUConfig.total_frus]->FRUName,sfr->DevIdStr);
  345. // pBMCInfo->FRUConfig.total_frus++;
  346. // }
  347. // }
  348. // else if (sr->Type == OEM_SDRFRU_REC)
  349. // {
  350. // sof=(_FAR_ OEM_FRURec_T*)sr;
  351. //
  352. // if(sof->OEM_Fru==OEM_SDR_FRU_REC)
  353. // {
  354. // for(i=0;i < MAX_FRU_SDR_STR_SIZE;i++)
  355. // {
  356. // if(sof->FilePath[i] == ':')
  357. // {
  358. // fruvalid = TRUE;
  359. // }
  360. // }
  361. //
  362. // if(fruvalid == TRUE)
  363. // {
  364. // pBMCInfo->FRUConfig.FRUInfo[Index++]=sof->DeviceID;
  365. // pBMCInfo->FRUConfig.FRUInfo[Index]=0xff;
  366. // pBMCInfo->FRUConfig.m_FRUInfo[pBMCInfo->FRUConfig.total_frus]=(FRUInfo_T*)malloc(sizeof(FRUInfo_T));
  367. // pBMCInfo->FRUConfig.m_FRUInfo[pBMCInfo->FRUConfig.total_frus]->IsInternalFRU=0;
  368. // pBMCInfo->FRUConfig.m_FRUInfo[pBMCInfo->FRUConfig.total_frus]->Size=sof->Size;
  369. // pBMCInfo->FRUConfig.m_FRUInfo[pBMCInfo->FRUConfig.total_frus]->AccessType=sof->AccessType;
  370. // pBMCInfo->FRUConfig.m_FRUInfo[pBMCInfo->FRUConfig.total_frus]->Offset=0;
  371. // pBMCInfo->FRUConfig.m_FRUInfo[pBMCInfo->FRUConfig.total_frus]->DeviceID=sof->DeviceID;
  372. // pBMCInfo->FRUConfig.m_FRUInfo[pBMCInfo->FRUConfig.total_frus]->Type=FRU_TYPE_NVR;
  373. // str = sof->FilePath;
  374. // tempbuf = strtok_r(str,":",&saveptr);
  375. // strcpy(pBMCInfo->FRUConfig.m_FRUInfo[pBMCInfo->FRUConfig.total_frus]->NVRFile,tempbuf);
  376. // len = strlen(tempbuf);
  377. // strcpy(pBMCInfo->FRUConfig.m_FRUInfo[pBMCInfo->FRUConfig.total_frus]->FRUName,&sof->FilePath[++len]);
  378. // pBMCInfo->FRUConfig.m_FRUInfo[pBMCInfo->FRUConfig.total_frus]->SlaveAddr=0;
  379. // pBMCInfo->FRUConfig.m_FRUInfo[pBMCInfo->FRUConfig.total_frus]->DeviceType=0;
  380. // pBMCInfo->FRUConfig.total_frus++;
  381. // }
  382. // fruvalid = 0;
  383. // }
  384. // }
  385. //
  386. // /* Get the next record */
  387. // sr = SDR_GetNextSDRRec (sr,BMCInst);
  388. // }
  389. //
  390. // /* Release mutex for Sensor shared memory */
  391. // //OS_RELEASE_MUTEX(m_hSensorSharedMemMutex)
  392. // OS_THREAD_MUTEX_RELEASE(&g_BMCInfo[BMCInst].SensorSharedMemMutex);
  393. //
  394. //
  395. // IPMI_DBG_PRINT ("Initilized Sensor\n");
  396. //
  397. // return 0;
  398. }
  399. /*-----------------------------------------
  400. * SR_FindSDR
  401. *-----------------------------------------*/
  402. SDRRecHdr_T*
  403. SR_FindSDR (INT8U SensorNum, INT8U SensorOwnerLUN, int BMCInst) /* Multi-LUN support to find the SDR based on OwnerLUN and Sensor Number */
  404. {
  405. // _FAR_ SDRRecHdr_T* sr = NULL;
  406. // _FAR_ FullSensorRec_T* sfs = NULL;
  407. // _FAR_ CompactSensorRec_T* scs = NULL;
  408. // INT16U SharedRecs = 0;
  409. // INT8U NodeManager = 0;
  410. //
  411. // sr = SDR_GetFirstSDRRec (BMCInst);
  412. // _FAR_ SensorSharedMem_T* pSenSharedMem;
  413. // _FAR_ BMCInfo_t* pBMCInfo = &g_BMCInfo[BMCInst];
  414. // pSenSharedMem = (_FAR_ SensorSharedMem_T*)&pBMCInfo->SensorSharedMem; //m_hSensorSharedMem;
  415. //
  416. //
  417. // while (0 != sr)
  418. // {
  419. //
  420. // // Populater sensor information for Threshold sensors
  421. // if (sr->Type == FULL_SDR_REC)
  422. // {
  423. // sfs = (_FAR_ FullSensorRec_T*) sr;
  424. //
  425. // if ((sfs->SensorNum == SensorNum) && (sfs->OwnerLUN == SensorOwnerLUN) && ((pBMCInfo->IpmiConfig.BMCSlaveAddr == sfs->OwnerID) || (pBMCInfo->NMConfig.NMDevSlaveAddress == sfs->OwnerID)) ){ return sr; } /* Multi-LUN support */
  426. // }
  427. // else if (sr->Type == COMPACT_SDR_REC)
  428. // {
  429. // scs = (_FAR_ CompactSensorRec_T*) sr;
  430. // if(g_corefeatures.node_manager == ENABLED)
  431. // {
  432. // if (pBMCInfo->NMConfig.NMDevSlaveAddress == scs->OwnerID)
  433. // NodeManager = 1;
  434. // }
  435. // else
  436. // {
  437. // NodeManager = 0;
  438. // }
  439. // if ((pBMCInfo->IpmiConfig.BMCSlaveAddr == scs->OwnerID) || (NodeManager))
  440. // {
  441. // SharedRecs = ipmitoh_u16 (((_FAR_ CompactSensorRec_T*) sr)->RecordSharing) &
  442. // SHARED_RECD_COUNT;
  443. // IPMI_DBG_PRINT_2 ("Sen %x , Shared Count - %x\n", scs->SensorNum, SharedRecs);
  444. //
  445. // /* Update Init Done flag */
  446. // SET_SM_INIT_DONE(pSenSharedMem->SensorInfo [((scs->OwnerLUN & VALID_LUN) << 8) | scs->SensorNum].EventFlags); /* Multi-LUN support */
  447. //
  448. // /* Check if Record is shared */
  449. // if (SharedRecs > 1)
  450. // {
  451. // IPMI_DBG_PRINT_2 ("scs->SensorNum - %x, %x\n", scs->SensorNum, SensorNum);
  452. // if ((SensorNum >= scs->SensorNum) && (scs->OwnerLUN == SensorOwnerLUN) && (SensorNum < (scs->SensorNum + SharedRecs))) { return sr; } /* Multi-LUN support */
  453. // }
  454. // else
  455. // {
  456. // if ((scs->SensorNum == SensorNum) && (scs->OwnerLUN == SensorOwnerLUN)) { return sr; } /* Multi-LUN support */
  457. // }
  458. // }
  459. // }
  460. //
  461. // /* Get the next record */
  462. // sr = SDR_GetNextSDRRec (sr,BMCInst);
  463. // }
  464. //
  465. // return NULL;
  466. }
  467. /*-----------------------------------------
  468. * SR_LoadSDRDefaults
  469. * CAUTION !! this function has to be called
  470. * after acquiring a sensor shared memory mutex
  471. *-----------------------------------------*/
  472. extern void
  473. SR_LoadSDRDefaults (SDRRecHdr_T* sr, _FAR_ SensorInfo_T* pSensorInfo,int BMCInst)
  474. {
  475. // _FAR_ FullSensorRec_T* sfs;
  476. // _FAR_ CompactSensorRec_T* scs;
  477. // BMCInfo_t *pBMCInfo = &g_BMCInfo[BMCInst];
  478. //
  479. // // Populater sensor information for Threshold sensors
  480. // if (sr->Type == FULL_SDR_REC)
  481. // {
  482. // sfs = (_FAR_ FullSensorRec_T*) sr;
  483. //
  484. // pSensorInfo->SensorOwnerLun = sfs->OwnerLUN; /* Multi-LUN support */
  485. // pSensorInfo->SensorNumber = sfs->SensorNum;
  486. // pSensorInfo->M_LSB = sfs->M;
  487. // pSensorInfo->M_MSB_Tolerance = sfs->M_Tolerance;
  488. // pSensorInfo->B_LSB = sfs->B;
  489. // pSensorInfo->B_MSB_Accuracy = sfs->B_Accuracy;
  490. // pSensorInfo->Accuracy_MSB_Exp = sfs->Accuracy;
  491. // pSensorInfo->RExp_BExp = sfs->R_B_Exp;
  492. // pSensorInfo->Units1 = sfs->Units1;
  493. // pSensorInfo->Units2 = sfs->Units2;
  494. // pSensorInfo->Units3 = sfs->Units3;
  495. //
  496. // pSensorInfo->PosHysteresis = sfs->PositiveHysterisis;
  497. // pSensorInfo->NegHysteresis = sfs->NegativeHysterisis;
  498. //
  499. // pSensorInfo->SensorInit = sfs->SensorInit;
  500. // pSensorInfo->SettableThreshMask = ipmitoh_u16(sfs->DiscreteReadingMask);
  501. // pSensorInfo->SensorCaps = sfs->SensorCaps;
  502. // pSensorInfo->SensorTypeCode = sfs->SensorType;
  503. // pSensorInfo->OEMField = sfs->OEMField ;
  504. //
  505. // if (pSensorInfo->SensorInit & BIT4)
  506. // {
  507. // if (pSensorInfo->SettableThreshMask & BIT8)
  508. // {
  509. // pSensorInfo->LowerNonCritical = sfs->LowerNonCritical;
  510. // }
  511. // if (pSensorInfo->SettableThreshMask & BIT9)
  512. // {
  513. // pSensorInfo->LowerCritical = sfs->LowerCritical;
  514. // }
  515. // if (pSensorInfo->SettableThreshMask & BIT10)
  516. // {
  517. // pSensorInfo->LowerNonRecoverable = sfs->LowerNonRecoverable;
  518. // }
  519. // if (pSensorInfo->SettableThreshMask & BIT11)
  520. // {
  521. // pSensorInfo->UpperNonCritical = sfs->UpperNonCritical;
  522. // }
  523. // if (pSensorInfo->SettableThreshMask & BIT12)
  524. // {
  525. // pSensorInfo->UpperCritical = sfs->UpperCritical;
  526. // }
  527. // if (pSensorInfo->SettableThreshMask & BIT13)
  528. // {
  529. // pSensorInfo->UpperNonRecoverable = sfs->UpperNonRecoverable;
  530. // }
  531. // }
  532. //
  533. // pSensorInfo->EventFlags = 0;
  534. // pSensorInfo->EventFlags |= sfs->SensorInit & BIT6;
  535. // pSensorInfo->EventFlags |= (sfs->SensorInit & BIT5) << 2;
  536. // pSensorInfo->EventFlags |= sfs->SensorInit & BIT5;
  537. // pSensorInfo->AssertionEventEnablesByte1 = ipmitoh_u16(sfs->AssertionEventMask) & 0xFF;
  538. // pSensorInfo->AssertionEventEnablesByte2 = (ipmitoh_u16(sfs->AssertionEventMask) >> 8) & 0xFF;
  539. //
  540. // pSensorInfo->DeassertionEventEnablesByte1= ipmitoh_u16(sfs->DeAssertionEventMask) & 0xFF;
  541. //
  542. // pSensorInfo->DeassertionEventEnablesByte2= (ipmitoh_u16(sfs->DeAssertionEventMask) >> 8) & 0xFF;
  543. //
  544. // pSensorInfo->EventTypeCode = sfs->EventTypeCode;
  545. // pSensorInfo->SensorReadType = sfs->EventTypeCode;
  546. // pSensorInfo->InternalFlags = 0;
  547. // // pSensorInfo->InternalFlags |= BIT0; // Disable internal scanning by default
  548. //
  549. // // Check for a signed sensor
  550. // if (0x80 == (sfs->Units1 & 0xC0))
  551. // {
  552. // pSensorInfo->InternalFlags |= BIT1;
  553. // }
  554. // if (pBMCInfo->IpmiConfig.OPMASupport == 1)
  555. // {
  556. // pSensorInfo->SensorOwnerLun = sfs->OwnerLUN ;
  557. // OPMA_Config_T* OPMAconfig = &pBMCInfo->OPMAConfig;
  558. // int SensorIdx =0 ;
  559. //
  560. // for ( SensorIdx = 0 ; SensorIdx < MAX_SENSOR_NUMBERS ; SensorIdx++ )
  561. // {
  562. // if (!OPMAconfig->SensorOffsetInfo [SensorIdx] .valid) continue;
  563. // if ( ( OPMAconfig->SensorOffsetInfo [SensorIdx] .SensorNo == pSensorInfo->SensorNumber ) &&
  564. // ( OPMAconfig->SensorOffsetInfo [SensorIdx] .SensorLUN == pSensorInfo->SensorOwnerLun ) )
  565. // {
  566. // pSensorInfo->SenReadingOffset = OPMAconfig->SensorOffsetInfo [SensorIdx] .Offset;
  567. // break;
  568. // }
  569. // }
  570. // }
  571. // }
  572. // else if (sr->Type == COMPACT_SDR_REC)
  573. // {
  574. // scs = (_FAR_ CompactSensorRec_T*) sr;
  575. //
  576. // pSensorInfo->SensorOwnerLun = scs->OwnerLUN; /* Multi-LUN support */
  577. // pSensorInfo->SensorNumber = scs->SensorNum;
  578. // pSensorInfo->EventFlags = 0;
  579. // pSensorInfo->EventFlags |= scs->SensorInit & BIT6;
  580. // pSensorInfo->EventFlags |= (scs->SensorInit & BIT5) << 2;
  581. // pSensorInfo->EventFlags |= scs->SensorInit & BIT5;
  582. // pSensorInfo->AssertionEventEnablesByte1 = ipmitoh_u16(scs->AssertionEventMask) & 0xFF;
  583. // pSensorInfo->AssertionEventEnablesByte2 = (ipmitoh_u16(scs->AssertionEventMask) >> 8) & 0xFF;
  584. //
  585. // pSensorInfo->DeassertionEventEnablesByte1= ipmitoh_u16(scs->DeAssertionEventMask) & 0xFF;
  586. //
  587. // pSensorInfo->DeassertionEventEnablesByte2= (ipmitoh_u16(scs->DeAssertionEventMask) >> 8) & 0xFF;
  588. // pSensorInfo->SensorInit = scs->SensorInit;
  589. // pSensorInfo->SettableThreshMask = ipmitoh_u16(scs->DiscreteReadingMask);
  590. // pSensorInfo->PosHysteresis = scs->PositiveHysteris;
  591. // pSensorInfo->NegHysteresis = scs->NegativeHysterisis;
  592. // pSensorInfo->EventTypeCode = scs->EventTypeCode;
  593. // pSensorInfo->SensorReadType = scs->EventTypeCode;
  594. // pSensorInfo->SensorTypeCode = scs->SensorType;
  595. // pSensorInfo->SensorCaps = scs->SensorCaps;
  596. //
  597. // pSensorInfo->Units1 = scs->Units1;
  598. // pSensorInfo->Units2 = scs->Units2;
  599. // pSensorInfo->Units3 = scs->Units3;
  600. // pSensorInfo->InternalFlags = 0;
  601. // // pSensorInfo->InternalFlags |= BIT0; // Disable internal scanning by default
  602. //
  603. // // Check for a signed sensor
  604. // if (0x80 == (scs->Units1 & 0xC0))
  605. // {
  606. // pSensorInfo->InternalFlags |= BIT1;
  607. // }
  608. // if (pBMCInfo->IpmiConfig.OPMASupport == 1)
  609. // {
  610. // pSensorInfo->SensorOwnerLun = scs->OwnerLUN ;
  611. // BMCInfo_t *pBMCInfo = &g_BMCInfo[BMCInst];
  612. // OPMA_Config_T* OPMAconfig = &pBMCInfo->OPMAConfig;
  613. // int SensorIdx =0 ;
  614. //
  615. // for ( SensorIdx = 0 ; SensorIdx < MAX_SENSOR_NUMBERS ; SensorIdx++ )
  616. // {
  617. // if (!OPMAconfig->SensorOffsetInfo [SensorIdx] .valid) continue;
  618. // if ( ( OPMAconfig->SensorOffsetInfo [SensorIdx] .SensorNo == pSensorInfo->SensorNumber ) &&
  619. // ( OPMAconfig->SensorOffsetInfo [SensorIdx] .SensorLUN == pSensorInfo->SensorOwnerLun ) )
  620. // {
  621. // pSensorInfo->SenReadingOffset = OPMAconfig->SensorOffsetInfo [SensorIdx] .Offset;
  622. // break;
  623. // }
  624. // }
  625. // }
  626. //
  627. // pSensorInfo->OEMField = scs->OEMField ;
  628. // }
  629. // pSensorInfo->pPreMonitor = PreMonitorSensor;
  630. // pSensorInfo->pPostMonitor = PostMonitorSensor;
  631. }
  632. /*-----------------------------------------
  633. * GetDevSDRInfo
  634. *-----------------------------------------*/
  635. void
  636. SR_GetDevSDRInfo (_NEAR_ GetSDRInfoRes_T* GetSDRInfoRes,int BMCInst)
  637. {
  638. // GetSDRInfoRes->NumSensor = NUM_SENSORS(BMCInst);
  639. // GetSDRInfoRes->Flags = FL_STATIC_SENSOR + FL_NUM_LUN(0);
  640. // GetSDRInfoRes->TimeStamp = 0;
  641. // return;
  642. }
  643. /*---------------------------------------
  644. * GetDevSDRInfo
  645. *---------------------------------------*/
  646. int
  647. GetDevSDRInfo (_NEAR_ INT8U* pReq, INT8U ReqLen, _NEAR_ INT8U* pRes,_NEAR_ int BMCInst)
  648. {
  649. // _FAR_ SDRRecHdr_T* SDRRec;
  650. // BMCInfo_t *pBMCInfo = &g_BMCInfo[BMCInst];
  651. // _NEAR_ GetSDRInfoRes_T* pGetDevSDRInfoRes = (_NEAR_ GetSDRInfoRes_T*) pRes;
  652. // INT8U NumSensors = 0;
  653. //
  654. // OS_THREAD_MUTEX_ACQUIRE(&pBMCInfo->SDRConfig.SDRMutex, WAIT_INFINITE);
  655. // /* Count number of full and compact sensors */
  656. // SDRRec = SDR_GetFirstSDRRec (BMCInst);
  657. // while (0 != SDRRec)
  658. // {
  659. // if ((SDRRec->Type == FULL_SDR_REC) || (SDRRec->Type == COMPACT_SDR_REC)) { NumSensors++; }
  660. // /* Get the next record */
  661. // SDRRec = SDR_GetNextSDRRec (SDRRec,BMCInst);
  662. // }
  663. //
  664. // /* Fill in response data */
  665. // pGetDevSDRInfoRes->CompletionCode = CC_NORMAL;
  666. // pGetDevSDRInfoRes->NumSensor = NumSensors;
  667. // pGetDevSDRInfoRes->Flags = 0x01; /* BIT7 = 0 (static sensors), BIT0 = 1 (on LUN 0) */
  668. // pGetDevSDRInfoRes->TimeStamp = 0;
  669. // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->SDRConfig.SDRMutex);
  670. //
  671. // return sizeof (GetSDRInfoRes_T);
  672. }
  673. /*---------------------------------------
  674. * GetDevSDR
  675. *---------------------------------------*/
  676. int
  677. GetDevSDR (_NEAR_ INT8U* pReq, INT8U ReqLen, _NEAR_ INT8U* pRes,_NEAR_ int BMCInst)
  678. {
  679. // return GetSDR (pReq, ReqLen, pRes,BMCInst);
  680. }
  681. /*---------------------------------------
  682. * GetDevSDR
  683. *---------------------------------------*/
  684. int
  685. ReserveDevSDRRepository (_NEAR_ INT8U* pReq, INT8U ReqLen, _NEAR_ INT8U* pRes,_NEAR_ int BMCInst)
  686. {
  687. // return ReserveSDRRepository (pReq, ReqLen, pRes,BMCInst);
  688. }
  689. /*---------------------------------------
  690. * SetSensorType
  691. *---------------------------------------*/
  692. int
  693. SetSensorType (_NEAR_ INT8U* pReq, INT8U ReqLen, _NEAR_ INT8U* pRes,_NEAR_ int BMCInst)
  694. {
  695. // //pRes [0] = CC_INV_CMD;
  696. // //return sizeof (*pRes);
  697. // _NEAR_ SetSensorTypeReq_T * pSetSensorTypeReq=(_NEAR_ SetSensorTypeReq_T *)pReq;
  698. // _NEAR_ SetSensorTypeRes_T * pSetSensorTypeRes=(_NEAR_ SetSensorTypeRes_T *)pRes;
  699. // _FAR_ SensorSharedMem_T* pSenSharedMem;
  700. // _FAR_ BMCInfo_t* pBMCInfo = &g_BMCInfo[BMCInst];
  701. //
  702. //
  703. // /* Check for the reserved bytes should b zero */
  704. //
  705. // if ( 0 != (pSetSensorTypeReq->EventTypeCode & RESERVED_BITS_SETSENSORTYPE ) )
  706. // {
  707. // pSetSensorTypeRes->CompletionCode = CC_INV_DATA_FIELD;
  708. // return sizeof(*pRes);
  709. // }
  710. //
  711. // OS_THREAD_MUTEX_ACQUIRE(&g_BMCInfo[BMCInst].SensorSharedMemMutex, WAIT_INFINITE);
  712. // pSenSharedMem = (_FAR_ SensorSharedMem_T*)&pBMCInfo->SensorSharedMem; //m_hSensorSharedMem;
  713. //
  714. // if (!pSenSharedMem->SensorInfo [pSetSensorTypeReq->SensorNum].IsSensorPresent)
  715. // {
  716. // /* Release mutex for Sensor shared memory */
  717. // OS_THREAD_MUTEX_RELEASE(&g_BMCInfo[BMCInst].SensorSharedMemMutex);
  718. //
  719. // /* return sdr record not present completion code */
  720. // pSetSensorTypeRes->CompletionCode = CC_SDR_REC_NOT_PRESENT;
  721. // return sizeof (*pRes);
  722. // }
  723. //
  724. // pSenSharedMem->SensorInfo[pSetSensorTypeReq->SensorNum].SensorTypeCode=pSetSensorTypeReq->SensorType;
  725. // pSenSharedMem->SensorInfo[pSetSensorTypeReq->SensorNum].EventTypeCode=pSetSensorTypeReq->EventTypeCode;
  726. //
  727. // OS_THREAD_MUTEX_RELEASE(&g_BMCInfo[BMCInst].SensorSharedMemMutex);
  728. //
  729. // pSetSensorTypeRes->CompletionCode=CC_NORMAL;
  730. //
  731. // return sizeof(*pSetSensorTypeRes);
  732. }
  733. /*---------------------------------------
  734. * GetSensorType
  735. *---------------------------------------*/
  736. int
  737. GetSensorType (_NEAR_ INT8U* pReq, INT8U ReqLen, _NEAR_ INT8U* pRes,_NEAR_ int BMCInst)
  738. {
  739. // //pRes [0] = CC_INV_CMD;
  740. // // return sizeof (*pRes);
  741. //
  742. // _NEAR_ GetSensorTypeReq_T * pGetSensorTypeReq=(_NEAR_ GetSensorTypeReq_T *)pReq;
  743. // _NEAR_ GetSensorTypeRes_T * pGetSensorTypeRes=(_NEAR_ GetSensorTypeRes_T *)pRes;
  744. // _FAR_ SensorSharedMem_T* pSenSharedMem;
  745. // _FAR_ BMCInfo_t* pBMCInfo = &g_BMCInfo[BMCInst];
  746. // pSenSharedMem = (_FAR_ SensorSharedMem_T*)&pBMCInfo->SensorSharedMem; //m_hSensorSharedMem;
  747. //
  748. // OS_THREAD_MUTEX_ACQUIRE(&pBMCInfo->SensorSharedMemMutex, WAIT_INFINITE);
  749. //
  750. // if (!pSenSharedMem->SensorInfo [pGetSensorTypeReq->SensorNum].IsSensorPresent)
  751. // {
  752. // /* Release mutex for Sensor shared memory */
  753. // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->SensorSharedMemMutex);
  754. //
  755. // /* return sdr record not present completion code */
  756. // pGetSensorTypeRes->CompletionCode = CC_SDR_REC_NOT_PRESENT;
  757. // return sizeof (*pRes);
  758. // }
  759. //
  760. // pGetSensorTypeRes->CompletionCode=CC_NORMAL;
  761. // pGetSensorTypeRes->SensorType=pSenSharedMem->SensorInfo[pGetSensorTypeReq->SensorNum].SensorTypeCode;
  762. // pGetSensorTypeRes->EventTypeCode=pSenSharedMem->SensorInfo[pGetSensorTypeReq->SensorNum].EventTypeCode;
  763. //
  764. // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->SensorSharedMemMutex);
  765. //
  766. // return sizeof(*pGetSensorTypeRes);
  767. }
  768. /*---------------------------------------
  769. * ReArmSensor
  770. *---------------------------------------*/
  771. int
  772. ReArmSensor (_NEAR_ INT8U* pReq, INT8U ReqLen, _NEAR_ INT8U* pRes,_NEAR_ int BMCInst)
  773. {
  774. // _FAR_ MsgPkt_T Msg;
  775. // HQueue_T hSMHndlr_Q;
  776. // _NEAR_ ReArmSensorReq_T ReArmSensorReq;
  777. // _NEAR_ ReArmSensorReq_T* pReArmSensorReq = &ReArmSensorReq;
  778. // _NEAR_ ReArmSensorRes_T* pReArmSensorRes = (_NEAR_ ReArmSensorRes_T*) pRes;
  779. //
  780. // _fmemset (&ReArmSensorReq, 0, sizeof (ReArmSensorReq_T));
  781. // _fmemcpy (&ReArmSensorReq, pReq, ReqLen);
  782. // _FAR_ SensorSharedMem_T* pSenSharedMem;
  783. // _FAR_ BMCInfo_t* pBMCInfo = &g_BMCInfo[BMCInst];
  784. //
  785. // /* if request length is invalid */
  786. // if ((ReqLen < 2) || (ReqLen > sizeof (ReArmSensorReq_T)))
  787. // {
  788. // /* return request invalid length completion code */
  789. // pReArmSensorRes->CompletionCode = CC_REQ_INV_LEN;
  790. // return sizeof (*pRes);
  791. // }
  792. //
  793. // /* Check for the reserved bytes should b zero */
  794. //
  795. // if ( 0 != (pReArmSensorReq->ReArmAllEvents & RESERVED_BITS_REARMSENSOR_REARMALLEVENTS ) )
  796. // {
  797. // pReArmSensorRes->CompletionCode = CC_INV_DATA_FIELD;
  798. // return sizeof (*pRes);
  799. // }
  800. //
  801. // OS_THREAD_MUTEX_ACQUIRE(&pBMCInfo->SensorSharedMemMutex, WAIT_INFINITE);
  802. // pSenSharedMem = (_FAR_ SensorSharedMem_T*)&pBMCInfo->SensorSharedMem; //m_hSensorSharedMem;
  803. //
  804. // /* Check for the reserved bits */
  805. // if (pSenSharedMem->SensorInfo [pReArmSensorReq->SensorNum].SensorReadType == THRESHOLD_SENSOR_CLASS)
  806. // {
  807. // if ((pReArmSensorReq->ReArmAssertionEvents2 & RESERVED_BITS_REARMSENSOR_REARMASSEVT2_1) ||
  808. // (pReArmSensorReq->ReArmDeassertionEvents2 & RESERVED_BITS_REARMSENSOR_REARMDEASSEVT2_1))
  809. // {
  810. // pReArmSensorRes->CompletionCode = CC_INV_DATA_FIELD;
  811. // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->SensorSharedMemMutex);
  812. // return sizeof (*pRes);
  813. // }
  814. // }
  815. // else
  816. // {
  817. // if ((pReArmSensorReq->ReArmAssertionEvents2 & RESERVED_BITS_REARMSENSOR_REARMASSEVT2_2) ||
  818. // (pReArmSensorReq->ReArmDeassertionEvents2 & RESERVED_BITS_REARMSENSOR_REARMDEASSEVT2_2))
  819. // {
  820. // pReArmSensorRes->CompletionCode = CC_INV_DATA_FIELD;
  821. // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->SensorSharedMemMutex);
  822. // return sizeof (*pRes);
  823. // }
  824. // }
  825. //
  826. // if (pBMCInfo->IpmiConfig.OPMASupport == 1)
  827. // {
  828. // if (pSenSharedMem->GlobalSensorScanningEnable == FALSE)
  829. // {
  830. // pReArmSensorRes->CompletionCode = CC_PARAM_NOT_SUP_IN_CUR_STATE;
  831. // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->SensorSharedMemMutex);
  832. // return sizeof (*pRes);
  833. // }
  834. // }
  835. //
  836. // if (!pSenSharedMem->SensorInfo [pReArmSensorReq->SensorNum].IsSensorPresent)
  837. // {
  838. // /* return sdr record not present completion code */
  839. // pReArmSensorRes->CompletionCode = CC_SDR_REC_NOT_PRESENT;
  840. // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->SensorSharedMemMutex);
  841. // return sizeof (*pRes);
  842. // }
  843. //
  844. //
  845. // Msg.Param = PARAM_REARM_SENSOR;
  846. // Msg.Size = sizeof (ReArmSensorReq_T);
  847. // _fmemcpy(Msg.Data, &ReArmSensorReq, sizeof (ReArmSensorReq_T));
  848. //
  849. // /* Post to sensormonitor task Thread to rearm this sensor */
  850. // GetQueueHandle(SM_HNDLR_Q,&hSMHndlr_Q,BMCInst);
  851. // if ( -1 != hSMHndlr_Q )
  852. // {
  853. // PostMsg(&Msg, SM_HNDLR_Q,BMCInst);
  854. //
  855. // /* return normal completion code */
  856. // pReArmSensorRes->CompletionCode = CC_NORMAL;
  857. // }else
  858. // {
  859. // /* return normal completion code */
  860. // pReArmSensorRes->CompletionCode = 0xFF;
  861. // }
  862. // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->SensorSharedMemMutex);
  863. //
  864. // return (sizeof(ReArmSensorRes_T));
  865. }
  866. /*---------------------------------------
  867. * GetSensorEventStatus
  868. *---------------------------------------*/
  869. int
  870. GetSensorEventStatus (_NEAR_ INT8U* pReq, INT8U ReqLen, _NEAR_ INT8U* pRes,_NEAR_ int BMCInst)
  871. {
  872. // _NEAR_ GetSensorEventStatusReq_T* pSensorEventStatusReq = (_NEAR_ GetSensorEventStatusReq_T*) pReq;
  873. // _NEAR_ GetSensorEventStatusRes_T* pSensorEventStatusRes = (_NEAR_ GetSensorEventStatusRes_T*) pRes;
  874. // _FAR_ SensorSharedMem_T* pSenSharedMem;
  875. // _FAR_ BMCInfo_t* pBMCInfo = &g_BMCInfo[BMCInst];
  876. // pSenSharedMem = (_FAR_ SensorSharedMem_T*)&pBMCInfo->SensorSharedMem; //m_hSensorSharedMem;
  877. //
  878. // if(pBMCInfo->IpmiConfig.OPMASupport == 1)
  879. // {
  880. // if (pSenSharedMem->GlobalSensorScanningEnable == FALSE)
  881. // {
  882. // pSensorEventStatusRes->CompletionCode = CC_PARAM_NOT_SUP_IN_CUR_STATE;
  883. // return sizeof (*pRes);
  884. // }
  885. // }
  886. //
  887. // /* Acquire Shared memory */
  888. // OS_THREAD_MUTEX_ACQUIRE(&pBMCInfo->SensorSharedMemMutex, WAIT_INFINITE);
  889. //
  890. // if (!pSenSharedMem->SensorInfo [pSensorEventStatusReq->SensorNum].IsSensorPresent)
  891. // {
  892. // /* Release mutex for Sensor shared memory */
  893. // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->SensorSharedMemMutex);
  894. //
  895. // /* return sdr record not present completion code */
  896. // pSensorEventStatusRes->CompletionCode = CC_SDR_REC_NOT_PRESENT;
  897. // return sizeof (*pRes);
  898. // }
  899. //
  900. //
  901. // pSensorEventStatusRes->CompletionCode = CC_NORMAL;
  902. // pSensorEventStatusRes->Flags = (pSenSharedMem->SensorInfo [pSensorEventStatusReq->SensorNum].EventFlags & 0xe0);
  903. //
  904. // /* Set optional response bytes to zero if event messages are disabled for this sensor */
  905. // if (0 == ((pSenSharedMem->SensorInfo [pSensorEventStatusReq->SensorNum].EventFlags) & BIT7))
  906. // {
  907. // /* Release mutex for Sensor shared memory */
  908. // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->SensorSharedMemMutex);
  909. //
  910. // pSensorEventStatusRes->AssertionEvents1 = 0;
  911. // pSensorEventStatusRes->AssertionEvents2 = 0;
  912. // pSensorEventStatusRes->DeassertionEvents1 = 0;
  913. // pSensorEventStatusRes->DeassertionEvents2 = 0;
  914. // return sizeof (GetSensorEventStatusRes_T);
  915. // }
  916. //
  917. // if (0 == ((pSenSharedMem->SensorInfo [pSensorEventStatusReq->SensorNum].SensorCaps) & BIT6))
  918. // {
  919. // /* Get sensor event status history */
  920. // pSensorEventStatusRes->AssertionEvents1 =
  921. // (pSenSharedMem->SensorInfo [pSensorEventStatusReq->SensorNum].AssertionHistoryByte1 &
  922. // pSenSharedMem->SensorInfo [pSensorEventStatusReq->SensorNum].AssertionEventEnablesByte1);
  923. // pSensorEventStatusRes->AssertionEvents2 =
  924. // (pSenSharedMem->SensorInfo [pSensorEventStatusReq->SensorNum].AssertionHistoryByte2 &
  925. // pSenSharedMem->SensorInfo [pSensorEventStatusReq->SensorNum].AssertionEventEnablesByte2);
  926. // pSensorEventStatusRes->DeassertionEvents1 =
  927. // (pSenSharedMem->SensorInfo [pSensorEventStatusReq->SensorNum].DeassertionHistoryByte1 &
  928. // pSenSharedMem->SensorInfo [pSensorEventStatusReq->SensorNum].DeassertionEventEnablesByte1);
  929. // pSensorEventStatusRes->DeassertionEvents2 =
  930. // (pSenSharedMem->SensorInfo [pSensorEventStatusReq->SensorNum].DeassertionHistoryByte2 &
  931. // pSenSharedMem->SensorInfo [pSensorEventStatusReq->SensorNum].DeassertionEventEnablesByte2);
  932. // }
  933. // else
  934. // {
  935. // /* Get present sensor event status */
  936. // pSensorEventStatusRes->AssertionEvents1 =
  937. // (pSenSharedMem->SensorInfo [pSensorEventStatusReq->SensorNum].AssertionEventOccuredByte1 &
  938. // pSenSharedMem->SensorInfo [pSensorEventStatusReq->SensorNum].AssertionEventEnablesByte1);
  939. // pSensorEventStatusRes->AssertionEvents2 =
  940. // (pSenSharedMem->SensorInfo [pSensorEventStatusReq->SensorNum].AssertionEventOccuredByte2 &
  941. // pSenSharedMem->SensorInfo [pSensorEventStatusReq->SensorNum].AssertionEventEnablesByte2);
  942. // pSensorEventStatusRes->DeassertionEvents1 =
  943. // (pSenSharedMem->SensorInfo [pSensorEventStatusReq->SensorNum].DeassertionEventOccuredByte1 &
  944. // pSenSharedMem->SensorInfo [pSensorEventStatusReq->SensorNum].DeassertionEventEnablesByte1);
  945. // pSensorEventStatusRes->DeassertionEvents2 =
  946. // (pSenSharedMem->SensorInfo [pSensorEventStatusReq->SensorNum].DeassertionEventOccuredByte2 &
  947. // pSenSharedMem->SensorInfo [pSensorEventStatusReq->SensorNum].DeassertionEventEnablesByte2);
  948. // }
  949. // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->SensorSharedMemMutex);
  950. //
  951. // return sizeof (GetSensorEventStatusRes_T);
  952. }
  953. /*---------------------------------------
  954. * SetSensorHysterisis
  955. *---------------------------------------*/
  956. int
  957. SetSensorHysterisis (_NEAR_ INT8U* pReq, INT8U ReqLen, _NEAR_ INT8U* pRes,_NEAR_ int BMCInst)
  958. {
  959. // _NEAR_ SetSensorHysterisisReq_T* pSensorHysReq =
  960. // (_NEAR_ SetSensorHysterisisReq_T*) pReq;
  961. // _NEAR_ SetSensorHysterisisRes_T* pSensorHysRes =
  962. // (_NEAR_ SetSensorHysterisisRes_T*) pRes;
  963. // _FAR_ SensorSharedMem_T* pSenSharedMem;
  964. // _FAR_ BMCInfo_t* pBMCInfo = &g_BMCInfo[BMCInst];
  965. // pSenSharedMem = (_FAR_ SensorSharedMem_T*)&pBMCInfo->SensorSharedMem; //m_hSensorSharedMem;
  966. //
  967. // if (pBMCInfo->IpmiConfig.OPMASupport == 1)
  968. // {
  969. // if (pSenSharedMem->GlobalSensorScanningEnable == FALSE)
  970. // {
  971. // pSensorHysRes->CompletionCode = CC_PARAM_NOT_SUP_IN_CUR_STATE;
  972. // return sizeof (*pRes);
  973. // }
  974. // }
  975. //
  976. // /* Acquire Shared memory */
  977. // OS_THREAD_MUTEX_ACQUIRE(&pBMCInfo->SensorSharedMemMutex, WAIT_INFINITE);
  978. //
  979. // if (!pSenSharedMem->SensorInfo [pSensorHysReq->SensorNum].IsSensorPresent)
  980. // {
  981. // /* Release mutex for Sensor shared memory */
  982. // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->SensorSharedMemMutex);
  983. //
  984. // pSensorHysRes->CompletionCode = CC_SDR_REC_NOT_PRESENT;
  985. // return sizeof (*pRes);
  986. // }
  987. //
  988. // if (pSenSharedMem->SensorInfo [pSensorHysReq->SensorNum].SensorReadType != THRESHOLD_SENSOR_CLASS)
  989. // {
  990. // /* Release mutex for Sensor shared memory */
  991. // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->SensorSharedMemMutex);
  992. // pSensorHysRes->CompletionCode = CC_ILLEGAL_CMD_FOR_SENSOR_REC;
  993. // return sizeof (*pRes);
  994. // }
  995. //
  996. // if(BIT5 != (pSenSharedMem->SensorInfo[pSensorHysReq->SensorNum].SensorCaps & (BIT5 | BIT4)))
  997. // {
  998. // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->SensorSharedMemMutex);
  999. // //set operation is not allowed
  1000. // *pRes = CC_INV_DATA_FIELD;
  1001. // return sizeof(*pRes);
  1002. // }
  1003. //
  1004. // /* Set the hysterisis values */
  1005. // pSenSharedMem->SensorInfo [pSensorHysReq->SensorNum].PosHysteresis = pSensorHysReq->PositiveHysterisis;
  1006. // pSenSharedMem->SensorInfo [pSensorHysReq->SensorNum].NegHysteresis = pSensorHysReq->NegativeHysterisis;
  1007. //
  1008. // /* Release mutex for Sensor shared memory */
  1009. // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->SensorSharedMemMutex);
  1010. //
  1011. // pSensorHysRes->CompletionCode = CC_NORMAL;
  1012. // return sizeof (SetSensorHysterisisRes_T);
  1013. }
  1014. /*---------------------------------------
  1015. * GetSensorHysterisis
  1016. *---------------------------------------*/
  1017. int
  1018. GetSensorHysterisis (_NEAR_ INT8U* pReq, INT8U ReqLen, _NEAR_ INT8U* pRes,_NEAR_ int BMCInst)
  1019. {
  1020. // _NEAR_ GetSensorHysterisisReq_T* pSensorHysReq =
  1021. // (_NEAR_ GetSensorHysterisisReq_T*) pReq;
  1022. // _NEAR_ GetSensorHysterisisRes_T* pSensorHysRes =
  1023. // (_NEAR_ GetSensorHysterisisRes_T*) pRes;
  1024. // _FAR_ SensorSharedMem_T* pSenSharedMem;
  1025. // _FAR_ BMCInfo_t* pBMCInfo = &g_BMCInfo[BMCInst];
  1026. // pSenSharedMem = (_FAR_ SensorSharedMem_T*)&pBMCInfo->SensorSharedMem; //m_hSensorSharedMem;
  1027. //
  1028. // if (pBMCInfo->IpmiConfig.OPMASupport == 1)
  1029. // {
  1030. // if (pSenSharedMem->GlobalSensorScanningEnable == FALSE)
  1031. // {
  1032. // pSensorHysRes->CompletionCode = CC_PARAM_NOT_SUP_IN_CUR_STATE;
  1033. // return sizeof (*pRes);
  1034. // }
  1035. // }
  1036. //
  1037. // /* Acquire Shared memory */
  1038. // OS_THREAD_MUTEX_ACQUIRE(&pBMCInfo->SensorSharedMemMutex, WAIT_INFINITE);
  1039. //
  1040. // if (!pSenSharedMem->SensorInfo [pSensorHysReq->SensorNum].IsSensorPresent)
  1041. // {
  1042. // /* Release mutex for Sensor shared memory */
  1043. // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->SensorSharedMemMutex);
  1044. //
  1045. // pSensorHysRes->CompletionCode = CC_SDR_REC_NOT_PRESENT;
  1046. // return sizeof (*pRes);
  1047. // }
  1048. //
  1049. // if (pSenSharedMem->SensorInfo [pSensorHysReq->SensorNum].SensorReadType != THRESHOLD_SENSOR_CLASS)
  1050. // {
  1051. // /* Release mutex for Sensor shared memory */
  1052. // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->SensorSharedMemMutex);
  1053. // pSensorHysRes->CompletionCode = CC_ILLEGAL_CMD_FOR_SENSOR_REC;
  1054. // return sizeof (*pRes);
  1055. // }
  1056. //
  1057. // if(SENSOR_HYSTERESIS_ACCESS_BITS == (pSenSharedMem->SensorInfo[pSensorHysReq->SensorNum].SensorCaps & (BIT5 | BIT4)))
  1058. // {
  1059. // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->SensorSharedMemMutex);
  1060. // //set operation is not allowed
  1061. // *pRes = CC_INV_DATA_FIELD;
  1062. // return sizeof(*pRes);
  1063. // }
  1064. //
  1065. // /* Get the hysterisis values */
  1066. // pSensorHysRes->PositiveHysterisis = pSenSharedMem->SensorInfo [pSensorHysReq->SensorNum].PosHysteresis;
  1067. // pSensorHysRes->NegativeHysterisis = pSenSharedMem->SensorInfo [pSensorHysReq->SensorNum].NegHysteresis;
  1068. //
  1069. // /* Release mutex for Sensor shared memory */
  1070. // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->SensorSharedMemMutex);
  1071. //
  1072. // pSensorHysRes->CompletionCode = CC_NORMAL;
  1073. //
  1074. // return sizeof (GetSensorHysterisisRes_T);
  1075. }
  1076. /*---------------------------------------
  1077. * SetSensorThresholds
  1078. *---------------------------------------*/
  1079. int
  1080. SetSensorThresholds (_NEAR_ INT8U* pReq, INT8U ReqLen, _NEAR_ INT8U* pRes,_NEAR_ int BMCInst)
  1081. {
  1082. // _NEAR_ SetSensorThresholdReq_T* pSensorThreshReq =
  1083. // (_NEAR_ SetSensorThresholdReq_T*) pReq;
  1084. // _NEAR_ SetSensorThresholdRes_T* pSensorThreshRes =
  1085. // (_NEAR_ SetSensorThresholdRes_T*) pRes;
  1086. // _FAR_ SensorSharedMem_T* pSenSharedMem;
  1087. // _FAR_ BMCInfo_t* pBMCInfo = &g_BMCInfo[BMCInst];
  1088. // pSenSharedMem = (_FAR_ SensorSharedMem_T*)&pBMCInfo->SensorSharedMem; //m_hSensorSharedMem;
  1089. //
  1090. // _NEAR_ INT8U SettableMask=0;
  1091. //
  1092. // /* Check for the reserved bytes should b zero */
  1093. //
  1094. // if ( 0 != (pSensorThreshReq->SetFlags & RESERVED_BITS_SETSENSORTHRESHOLDS ) )
  1095. // {
  1096. // pSensorThreshRes->CompletionCode = CC_INV_DATA_FIELD;
  1097. // return sizeof (*pRes);
  1098. // }
  1099. //
  1100. // if (pBMCInfo->IpmiConfig.OPMASupport == 1)
  1101. // {
  1102. // if (pSenSharedMem->GlobalSensorScanningEnable == FALSE)
  1103. // {
  1104. // pSensorThreshRes->CompletionCode = CC_PARAM_NOT_SUP_IN_CUR_STATE;
  1105. // return sizeof (*pRes);
  1106. // }
  1107. // }
  1108. //
  1109. // /* Acquire Shared memory */
  1110. // OS_THREAD_MUTEX_ACQUIRE(&pBMCInfo->SensorSharedMemMutex, WAIT_INFINITE);
  1111. //
  1112. // if (!pSenSharedMem->SensorInfo [pSensorThreshReq->SensorNum].IsSensorPresent)
  1113. // {
  1114. // /* Release mutex for Sensor shared memory */
  1115. // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->SensorSharedMemMutex);
  1116. //
  1117. // pSensorThreshRes->CompletionCode = CC_SDR_REC_NOT_PRESENT;
  1118. // return sizeof (*pRes);
  1119. // }
  1120. //
  1121. //
  1122. // if (pSenSharedMem->SensorInfo [pSensorThreshReq->SensorNum].SensorReadType != THRESHOLD_SENSOR_CLASS)
  1123. // {
  1124. // /* Release mutex for Sensor shared memory */
  1125. // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->SensorSharedMemMutex);
  1126. // pSensorThreshRes->CompletionCode = CC_ILLEGAL_CMD_FOR_SENSOR_REC;
  1127. // return sizeof (*pRes);
  1128. // }
  1129. //
  1130. // if(BIT3 != (pSenSharedMem->SensorInfo[pSensorThreshReq->SensorNum].SensorCaps & (BIT2 | BIT3)))
  1131. // {
  1132. // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->SensorSharedMemMutex);
  1133. // //set operation is not allowed
  1134. // *pRes = CC_INV_DATA_FIELD;
  1135. // return sizeof(*pRes);
  1136. // }
  1137. //
  1138. // pSensorThreshRes->CompletionCode = CC_NORMAL;
  1139. // SettableMask=(INT8U)(pSenSharedMem->SensorInfo [pSensorThreshReq->SensorNum].SettableThreshMask >> 8);
  1140. // /* Set the threshold values */
  1141. // //if (pSenSharedMem->SensorInfo [pSensorThreshReq->SensorNum].SensorInit & BIT5)
  1142. // if ( (pSenSharedMem->SensorInfo [pSensorThreshReq->SensorNum].SensorInit & BIT4 ) && (SettableMask | pSensorThreshReq->SetFlags ) == SettableMask) //<<Modified to support "set sensor enable>>
  1143. // {
  1144. // if (pSensorThreshReq->SetFlags & LWR_CRIT)
  1145. // {
  1146. // pSenSharedMem->SensorInfo [pSensorThreshReq->SensorNum].LowerCritical = pSensorThreshReq->LowerCritical;
  1147. // }
  1148. // if (pSensorThreshReq->SetFlags & LWR_NON_CRIT)
  1149. // {
  1150. // pSenSharedMem->SensorInfo [pSensorThreshReq->SensorNum].LowerNonCritical = pSensorThreshReq->LowerNonCritical;
  1151. // }
  1152. // if (pSensorThreshReq->SetFlags & LWR_NON_REC)
  1153. // {
  1154. // pSenSharedMem->SensorInfo [pSensorThreshReq->SensorNum].LowerNonRecoverable = pSensorThreshReq->LowerNonRecoverable;
  1155. // }
  1156. // if (pSensorThreshReq->SetFlags & UPR_CRIT)
  1157. // {
  1158. // pSenSharedMem->SensorInfo [pSensorThreshReq->SensorNum].UpperCritical = pSensorThreshReq->UpperCritical;
  1159. // }
  1160. // if (pSensorThreshReq->SetFlags & UPR_NON_CRIT)
  1161. // {
  1162. // pSenSharedMem->SensorInfo [pSensorThreshReq->SensorNum].UpperNonCritical = pSensorThreshReq->UpperNonCritical;
  1163. // }
  1164. // if (pSensorThreshReq->SetFlags & UPR_NON_REC)
  1165. // {
  1166. // pSenSharedMem->SensorInfo [pSensorThreshReq->SensorNum].UpperNonRecoverable = pSensorThreshReq->UpperNonRecoverable;
  1167. // }
  1168. //
  1169. // if(pBMCInfo->IpmiConfig.RearmSetSensorThreshold == 1)
  1170. // {
  1171. // /* Since Changes in Threshold .We have to monitor the sensor again .*/
  1172. // /* Already the Sensor reached the particular state . so we have to reset for generate the event according to the new Event mask */
  1173. // if ( 0 ==(pSenSharedMem->SensorInfo[pSensorThreshReq->SensorNum].SensorCaps & BIT6))
  1174. // {
  1175. // /* Manual ReARM Sensor */
  1176. // pSenSharedMem->SensorInfo[pSensorThreshReq->SensorNum].AssertionHistoryByte1=0;
  1177. // pSenSharedMem->SensorInfo[pSensorThreshReq->SensorNum].AssertionHistoryByte2=0;
  1178. // pSenSharedMem->SensorInfo[pSensorThreshReq->SensorNum].DeassertionHistoryByte1=0;
  1179. // pSenSharedMem->SensorInfo[pSensorThreshReq->SensorNum].DeassertionHistoryByte2=0;
  1180. // pSenSharedMem->SensorInfo[pSensorThreshReq->SensorNum].EventLevel=SENSOR_STATUS_NORMAL;
  1181. // pSenSharedMem->SensorInfo[pSensorThreshReq->SensorNum].HealthLevel= SENSOR_STATUS_NORMAL;
  1182. // }else
  1183. // {
  1184. // /* Auto ReARM Sensor */
  1185. // pSenSharedMem->SensorInfo[pSensorThreshReq->SensorNum].EventLevel=SENSOR_STATUS_NORMAL;
  1186. // pSenSharedMem->SensorInfo[pSensorThreshReq->SensorNum].HealthLevel = SENSOR_STATUS_NORMAL;
  1187. // pSenSharedMem->SensorInfo[pSensorThreshReq->SensorNum].AssertionEventOccuredByte1 = 0;
  1188. // pSenSharedMem->SensorInfo[pSensorThreshReq->SensorNum].AssertionEventOccuredByte2 = 0;
  1189. // pSenSharedMem->SensorInfo[pSensorThreshReq->SensorNum].DeassertionEventOccuredByte1 = 0;
  1190. // pSenSharedMem->SensorInfo[pSensorThreshReq->SensorNum].DeassertionEventOccuredByte2 = 0;
  1191. // }
  1192. // }
  1193. //
  1194. // pSensorThreshRes->CompletionCode = CC_NORMAL;
  1195. // }else
  1196. // {
  1197. // pSensorThreshRes->CompletionCode = CC_ILLEGAL_CMD_FOR_SENSOR_REC;
  1198. //
  1199. // }
  1200. // /* Release mutex for Sensor shared memory */
  1201. // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->SensorSharedMemMutex);
  1202. //
  1203. // // To send notification to CIM
  1204. // if(g_PDKCIMEventHandle[PDKCIMEVENT_NOTIFYSERVERUPDATETOCIM] != NULL)
  1205. // {
  1206. // uint8 CMD;
  1207. // // Set bits for SDR event & Modify operation
  1208. // CMD = 0x12;
  1209. // ((int(*)(uint8,uint16))g_PDKCIMEventHandle[PDKCIMEVENT_NOTIFYSERVERUPDATETOCIM])(CMD, pSensorThreshReq->SensorNum);
  1210. // }
  1211. //
  1212. // return sizeof (SetSensorThresholdRes_T);
  1213. }
  1214. /*---------------------------------------
  1215. * GetSensorThresholds
  1216. *---------------------------------------*/
  1217. int
  1218. GetSensorThresholds (_NEAR_ INT8U* pReq, INT8U ReqLen, _NEAR_ INT8U* pRes,_NEAR_ int BMCInst)
  1219. {
  1220. _NEAR_ GetSensorThresholdReq_T* pSensorThreshReq =
  1221. (_NEAR_ GetSensorThresholdReq_T*) pReq;
  1222. _NEAR_ GetSensorThresholdRes_T* pSensorThreshRes =
  1223. (_NEAR_ GetSensorThresholdRes_T*) pRes;
  1224. _FAR_ BMCInfo_t* pBMCInfo = &g_BMCInfo;//[BMCInst];
  1225. INT16U LUNSensorNum;
  1226. LUNSensorNum=pSensorThreshReq->SensorNum;
  1227. pSensorThreshRes->CompletionCode=0x00;
  1228. pSensorThreshRes->GetFlags=0x3f;
  1229. pSensorThreshRes->LowerNonCritical=g_BMCInfo.SDRConfig.SDR[LUNSensorNum][0];
  1230. pSensorThreshRes->LowerCritical=g_BMCInfo.SDRConfig.SDR[LUNSensorNum][1];
  1231. pSensorThreshRes->LowerNonRecoverable=g_BMCInfo.SDRConfig.SDR[LUNSensorNum][2];
  1232. pSensorThreshRes->UpperNonCritical=g_BMCInfo.SDRConfig.SDR[LUNSensorNum][3];
  1233. pSensorThreshRes->UpperCritical=g_BMCInfo.SDRConfig.SDR[LUNSensorNum][4];
  1234. pSensorThreshRes->UpperNonRecoverable=g_BMCInfo.SDRConfig.SDR[LUNSensorNum][5];
  1235. SessionSequenceNumberCount=SessionSequenceNumberCount+1;
  1236. return sizeof (GetSensorThresholdRes_T);
  1237. }
  1238. /*---------------------------------------
  1239. * GetSensorReadingFactors
  1240. *---------------------------------------*/
  1241. int
  1242. GetSensorReadingFactors (_NEAR_ INT8U* pReq, INT8U ReqLen, _NEAR_ INT8U* pRes,_NEAR_ int BMCInst)
  1243. {
  1244. // _NEAR_ GetSensorReadingFactorReq_T* pSensorFactorsReq =
  1245. // (_NEAR_ GetSensorReadingFactorReq_T*) pReq;
  1246. // _NEAR_ GetSensorReadingFactorRes_T* pSensorFactorsRes =
  1247. // (_NEAR_ GetSensorReadingFactorRes_T*) pRes;
  1248. // _FAR_ SensorSharedMem_T* pSenSharedMem;
  1249. // _FAR_ BMCInfo_t* pBMCInfo = &g_BMCInfo[BMCInst];
  1250. // pSenSharedMem = (_FAR_ SensorSharedMem_T*)&pBMCInfo->SensorSharedMem; //m_hSensorSharedMem;
  1251. //
  1252. // if (pBMCInfo->IpmiConfig.OPMASupport == 1)
  1253. // {
  1254. // if (pSenSharedMem->GlobalSensorScanningEnable == FALSE)
  1255. // {
  1256. // pSensorFactorsRes->CompletionCode = CC_PARAM_NOT_SUP_IN_CUR_STATE;
  1257. // return sizeof (*pRes);
  1258. // }
  1259. // }
  1260. //
  1261. // /* Acquire Shared memory */
  1262. // OS_THREAD_MUTEX_ACQUIRE(&pBMCInfo->SensorSharedMemMutex, WAIT_INFINITE);
  1263. //
  1264. // if (!pSenSharedMem->SensorInfo [pSensorFactorsReq->SensorNum].IsSensorPresent)
  1265. // {
  1266. // /* Release mutex for Sensor shared memory */
  1267. // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->SensorSharedMemMutex);
  1268. //
  1269. // pSensorFactorsRes->CompletionCode = CC_SDR_REC_NOT_PRESENT;
  1270. // return sizeof (*pRes);
  1271. // }
  1272. //
  1273. // _fmemcpy (&(pSensorFactorsRes->M_LSB), &(pSenSharedMem->SensorInfo [pSensorFactorsReq->SensorNum].M_LSB),
  1274. // sizeof (GetSensorReadingFactorRes_T) - (2 * sizeof (INT8U)));
  1275. // pSensorFactorsRes->CompletionCode = CC_NORMAL;
  1276. //
  1277. // /* Release mutex for Sensor shared memory */
  1278. // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->SensorSharedMemMutex);
  1279. //
  1280. // return sizeof (GetSensorReadingFactorRes_T);
  1281. }
  1282. /*---------------------------------------
  1283. * SetSensorEventEnable
  1284. *---------------------------------------*/
  1285. int
  1286. SetSensorEventEnable (_NEAR_ INT8U* pReq, INT8U ReqLen, _NEAR_ INT8U* pRes,_NEAR_ int BMCInst)
  1287. {
  1288. // _FAR_ SensorInfo_T* pSensorInfo;
  1289. // INT8U LocalReq [6];
  1290. // _NEAR_ SetSensorEventEnableReq_T* pSensorEvtEnReq;
  1291. // _NEAR_ SetSensorEventEnableRes_T* pSensorEvtEnRes =
  1292. // (_NEAR_ SetSensorEventEnableRes_T*) pRes;
  1293. // INT16U AssertMask, DeassertMask;
  1294. // INT16U ValidMask = htoipmi_u16(0x0FFF);
  1295. // _FAR_ SensorSharedMem_T* pSenSharedMem;
  1296. // _FAR_ BMCInfo_t* pBMCInfo = &g_BMCInfo[BMCInst];
  1297. // pSenSharedMem = (_FAR_ SensorSharedMem_T*)&pBMCInfo->SensorSharedMem; //m_hSensorSharedMem;
  1298. // INT16U LUNSensorNum;
  1299. // INT16U *OwnerLUN = 0;
  1300. //
  1301. // if (pBMCInfo->IpmiConfig.OPMASupport == 1)
  1302. // {
  1303. // if (pSenSharedMem->GlobalSensorScanningEnable == FALSE)
  1304. // {
  1305. // pSensorEvtEnRes->CompletionCode = CC_PARAM_NOT_SUP_IN_CUR_STATE;
  1306. // return sizeof (*pRes);
  1307. // }
  1308. // }
  1309. //
  1310. // AssertMask = DeassertMask = 0;
  1311. //
  1312. // memset (LocalReq, 0, sizeof (LocalReq));
  1313. // memcpy (LocalReq, pReq, ReqLen);
  1314. // pSensorEvtEnReq = (_NEAR_ SetSensorEventEnableReq_T*)LocalReq;
  1315. //
  1316. // if(g_corefeatures.more_than_256_sensors == ENABLED)
  1317. // {
  1318. //
  1319. // OS_THREAD_TLS_GET(g_tls.OwnerLUN,OwnerLUN);
  1320. // LUNSensorNum = ((*OwnerLUN & VALID_LUN) << 8 | pSensorEvtEnReq->SensorNum);
  1321. // }
  1322. // else
  1323. // {
  1324. // LUNSensorNum = pSensorEvtEnReq->SensorNum;
  1325. // }
  1326. //
  1327. //
  1328. //
  1329. // /* Atleast two bytes are expected remaining bytes (3,4,5,6) are optional */
  1330. // if ((ReqLen < sizeof(INT16U)) || (ReqLen > sizeof (SetSensorEventEnableReq_T)))
  1331. // {
  1332. // pSensorEvtEnRes->CompletionCode = CC_REQ_INV_LEN;
  1333. // return sizeof (*pRes);
  1334. // }
  1335. //
  1336. // /* Check for the reserved bytes should b zero */
  1337. //
  1338. // if ( 0 != (pSensorEvtEnReq->Flags & RESERVED_BITS_SETSENEVTEN_FLAGS ) )
  1339. // {
  1340. // pSensorEvtEnRes->CompletionCode = CC_INV_DATA_FIELD;
  1341. // return sizeof (*pRes);
  1342. // }
  1343. //
  1344. // if (ReqLen > sizeof(INT16U))
  1345. // {
  1346. // /* Check for the reserved bits */
  1347. // if (pSenSharedMem->SensorInfo [LUNSensorNum].SensorReadType == THRESHOLD_SENSOR_CLASS)
  1348. // {
  1349. // if ((pSensorEvtEnReq->AssertionMask & ~ValidMask) ||
  1350. // (pSensorEvtEnReq->DeAssertionMask & ~ValidMask))
  1351. // {
  1352. // pSensorEvtEnRes->CompletionCode = CC_INV_DATA_FIELD;
  1353. // return sizeof (*pRes);
  1354. // }
  1355. // }
  1356. // else
  1357. // {
  1358. // if ((pSensorEvtEnReq->AssertionMask & RESERVED_BITS_SETSENEVTEN_ASSERTIONMASK) ||
  1359. // (pSensorEvtEnReq->DeAssertionMask & RESERVED_BITS_SETSENEVTEN_DEASSERTIONMASK))
  1360. // {
  1361. // pSensorEvtEnRes->CompletionCode = CC_INV_DATA_FIELD;
  1362. // return sizeof (*pRes);
  1363. // }
  1364. // }
  1365. // }
  1366. //
  1367. // /* Get the sensor Info for the sensor */
  1368. // if(g_corefeatures.more_than_256_sensors == ENABLED)
  1369. // {
  1370. // pSensorInfo = GetSensorInfo (pSensorEvtEnReq->SensorNum, *OwnerLUN, BMCInst);
  1371. // }
  1372. // else
  1373. // {
  1374. // pSensorInfo = GetSensorInfo (pSensorEvtEnReq->SensorNum, 0x0, BMCInst);
  1375. // }
  1376. //
  1377. // if (NULL == pSensorInfo)
  1378. // {
  1379. // pSensorEvtEnRes->CompletionCode = CC_SDR_REC_NOT_PRESENT;
  1380. // return sizeof (*pRes);
  1381. // }
  1382. //
  1383. // // If not threshold, adjust mask
  1384. // if (pSensorInfo->EventTypeCode != 0x01)
  1385. // {
  1386. // ValidMask = htoipmi_u16(0x7FFF);
  1387. // }
  1388. //
  1389. //
  1390. // /* Acquire Shared memory */
  1391. // OS_THREAD_MUTEX_ACQUIRE(&pBMCInfo->SensorSharedMemMutex, WAIT_INFINITE);
  1392. //
  1393. // if (!pSensorInfo->IsSensorPresent)
  1394. // {
  1395. // /* Release mutex for Sensor shared memory */
  1396. // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->SensorSharedMemMutex);
  1397. //
  1398. // pSensorEvtEnRes->CompletionCode = CC_SDR_REC_NOT_PRESENT;
  1399. // return sizeof (*pRes);
  1400. // }
  1401. //
  1402. // /* Disable Events and scanning based on the flags */
  1403. // if (0 == (pSensorEvtEnReq->Flags & EVENT_MSG_MASK))
  1404. // {
  1405. // /* DisableAllEventSensors () */
  1406. // }
  1407. //
  1408. // if ((0 == (pSensorEvtEnReq->Flags & SCAN_MASK)) && (SCAN_MASK == (pSensorInfo->EventFlags & SCAN_MASK)))
  1409. // {
  1410. // // Check sensor accepts the ‘enable/disable scanning’
  1411. // if(0 == (pSensorInfo->SensorInit & BIT6))
  1412. // {
  1413. // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->SensorSharedMemMutex);
  1414. // pSensorEvtEnRes->CompletionCode = CC_INV_DATA_FIELD;
  1415. // return sizeof (*pRes);
  1416. // }
  1417. // pSensorInfo->EventFlags |= BIT5; ///* Bit 5 - Unable to read */
  1418. // }
  1419. // else if((SCAN_MASK == (pSensorEvtEnReq->Flags & SCAN_MASK)) && (0 == (pSensorInfo->EventFlags & SCAN_MASK)))
  1420. // {
  1421. // // Check sensor accepts the ‘enable/disable scanning’
  1422. // if(0 == (pSensorInfo->SensorInit & BIT6))
  1423. // {
  1424. // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->SensorSharedMemMutex);
  1425. // pSensorEvtEnRes->CompletionCode = CC_INV_DATA_FIELD;
  1426. // return sizeof (*pRes);
  1427. // }
  1428. // pSensorInfo->EventFlags &= ~BIT5; ///* Bit 5 - Unable to read */
  1429. // }
  1430. // pSensorInfo->EventFlags &= ~(EVENT_MSG_MASK | SCAN_MASK);
  1431. // pSensorInfo->EventFlags |= (pSensorEvtEnReq->Flags & (EVENT_MSG_MASK | SCAN_MASK));
  1432. //
  1433. // AssertMask =
  1434. // htoipmi_u16(((pSenSharedMem->SensorInfo [LUNSensorNum].AssertionEventEnablesByte2 << 8) |
  1435. // (pSenSharedMem->SensorInfo [LUNSensorNum].AssertionEventEnablesByte1)) & ValidMask);
  1436. //
  1437. // DeassertMask =
  1438. // htoipmi_u16(((pSenSharedMem->SensorInfo [LUNSensorNum].DeassertionEventEnablesByte2 << 8) |
  1439. // (pSenSharedMem->SensorInfo [LUNSensorNum].DeassertionEventEnablesByte1)) & ValidMask);
  1440. //
  1441. // /* Enable disable assertion based on the flag */
  1442. // if(ENABLE_DISABLE_EVENT_MASK == (pSensorEvtEnReq->Flags & ENABLE_DISABLE_EVENT_MASK))
  1443. // {
  1444. // // Flags [5:4] - 11b Reserved.
  1445. // /* Release mutex for Sensor shared memory */
  1446. // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->SensorSharedMemMutex);
  1447. //
  1448. // pSensorEvtEnRes->CompletionCode = CC_INV_DATA_FIELD;
  1449. // return sizeof (*pRes);
  1450. // }
  1451. // else if (ENABLE_SELECTED_EVENT_MSG == (pSensorEvtEnReq->Flags & ENABLE_DISABLE_EVENT_MASK))
  1452. // {
  1453. // AssertMask |= ipmitoh_u16(pSensorEvtEnReq->AssertionMask);
  1454. // DeassertMask |= ipmitoh_u16(pSensorEvtEnReq->DeAssertionMask);
  1455. // }
  1456. // else if (DISABLE_SELECTED_EVENT_MSG == (pSensorEvtEnReq->Flags & ENABLE_DISABLE_EVENT_MASK))
  1457. // {
  1458. // AssertMask &= ~ipmitoh_u16(pSensorEvtEnReq->AssertionMask);
  1459. // DeassertMask &= ~ipmitoh_u16(pSensorEvtEnReq->DeAssertionMask);
  1460. // }
  1461. //
  1462. // //For Threshold class sensors upper word bits are reserved
  1463. // if(pSensorInfo->EventTypeCode == THRESHOLD_SENSOR_CLASS)
  1464. // {
  1465. // pSensorInfo->AssertionEventEnablesByte2 &= 0xF0;
  1466. // pSensorInfo->AssertionEventEnablesByte2 |= (AssertMask >> 8);
  1467. // }
  1468. // else
  1469. // {
  1470. // pSensorInfo->AssertionEventEnablesByte2 = (AssertMask >> 8);
  1471. // }
  1472. // pSensorInfo->AssertionEventEnablesByte1 = (AssertMask) & 0xFF;
  1473. //
  1474. // //For Threshold class sensors upper word bits are reserved
  1475. // if(pSensorInfo->EventTypeCode == THRESHOLD_SENSOR_CLASS)
  1476. // {
  1477. // pSensorInfo->DeassertionEventEnablesByte2 &= 0xF0;
  1478. // pSensorInfo->DeassertionEventEnablesByte2 |= (DeassertMask >> 8);
  1479. // }
  1480. // else
  1481. // {
  1482. // pSensorInfo->DeassertionEventEnablesByte2 = (DeassertMask >> 8);
  1483. // }
  1484. //
  1485. // pSensorInfo->DeassertionEventEnablesByte1 = (DeassertMask);
  1486. //
  1487. // // For threshold sensors, reset the threshold state machine for the sensor
  1488. // // in order to pickup any newly enabled events.
  1489. // if(pSensorInfo->EventTypeCode == THRESHOLD_SENSOR_CLASS)
  1490. // {
  1491. // pSensorInfo->EventLevel=SENSOR_STATUS_NORMAL;
  1492. // pSensorInfo->HealthLevel = SENSOR_STATUS_NORMAL;
  1493. // }
  1494. //
  1495. // pSensorEvtEnRes->CompletionCode = CC_NORMAL;
  1496. //
  1497. // /* Release mutex for Sensor shared memory */
  1498. // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->SensorSharedMemMutex);
  1499. //
  1500. //
  1501. // return sizeof (SetSensorEventEnableRes_T);
  1502. }
  1503. /*---------------------------------------
  1504. * GetSensorEventEnable
  1505. *---------------------------------------*/
  1506. int
  1507. GetSensorEventEnable (_NEAR_ INT8U* pReq, INT8U ReqLen, _NEAR_ INT8U* pRes,_NEAR_ int BMCInst)
  1508. {
  1509. // _NEAR_ GetSensorEventEnableReq_T* pSensorEvtEnReq =
  1510. // (_NEAR_ GetSensorEventEnableReq_T*) pReq;
  1511. // _NEAR_ GetSensorEventEnableRes_T* pSensorEvtEnRes =
  1512. // (_NEAR_ GetSensorEventEnableRes_T*) pRes;
  1513. // _FAR_ SensorSharedMem_T* pSenSharedMem;
  1514. // _FAR_ BMCInfo_t* pBMCInfo = &g_BMCInfo[BMCInst];
  1515. // pSenSharedMem = (_FAR_ SensorSharedMem_T*)&pBMCInfo->SensorSharedMem; //m_hSensorSharedMem;
  1516. //
  1517. // INT16U ValidMask = htoipmi_u16(0x0FFF);
  1518. // if (pBMCInfo->IpmiConfig.OPMASupport == 1)
  1519. // {
  1520. // if (pSenSharedMem->GlobalSensorScanningEnable == FALSE)
  1521. // {
  1522. // pSensorEvtEnRes->CompletionCode = CC_PARAM_NOT_SUP_IN_CUR_STATE;
  1523. // return sizeof (*pRes);
  1524. // }
  1525. // }
  1526. //
  1527. // /* Acquire Shared memory */
  1528. // OS_THREAD_MUTEX_ACQUIRE(&pBMCInfo->SensorSharedMemMutex, WAIT_INFINITE);
  1529. //
  1530. // if (!pSenSharedMem->SensorInfo [pSensorEvtEnReq->SensorNum].IsSensorPresent)
  1531. // {
  1532. // /* Release mutex for Sensor shared memory */
  1533. // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->SensorSharedMemMutex);
  1534. //
  1535. // pSensorEvtEnRes->CompletionCode = CC_SDR_REC_NOT_PRESENT;
  1536. // return sizeof (*pRes);
  1537. // }
  1538. //
  1539. // if (pSenSharedMem->SensorInfo [pSensorEvtEnReq->SensorNum].EventTypeCode != 0x01)
  1540. // {
  1541. // ValidMask = htoipmi_u16(0x7FFF);
  1542. // }
  1543. // /* Get the assertion enables */
  1544. // pSensorEvtEnRes->AssertionMask =
  1545. // htoipmi_u16(((pSenSharedMem->SensorInfo [pSensorEvtEnReq->SensorNum].AssertionEventEnablesByte2 << 8) |
  1546. // (pSenSharedMem->SensorInfo [pSensorEvtEnReq->SensorNum].AssertionEventEnablesByte1)) & ValidMask);
  1547. //
  1548. // /* Get the deassertion enables */
  1549. // pSensorEvtEnRes->DeAssertionMask =
  1550. // htoipmi_u16(((pSenSharedMem->SensorInfo [pSensorEvtEnReq->SensorNum].DeassertionEventEnablesByte2 << 8) |
  1551. // (pSenSharedMem->SensorInfo [pSensorEvtEnReq->SensorNum].DeassertionEventEnablesByte1)) & ValidMask);
  1552. //
  1553. // /* Set the flags */
  1554. // pSensorEvtEnRes->Flags = (pSenSharedMem->SensorInfo [pSensorEvtEnReq->SensorNum].EventFlags & 0xc0);
  1555. //
  1556. // pSensorEvtEnRes->CompletionCode = CC_NORMAL;
  1557. //
  1558. // /* Release mutex for Sensor shared memory */
  1559. // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->SensorSharedMemMutex);
  1560. //
  1561. // return sizeof (GetSensorEventEnableRes_T);
  1562. }
  1563. /**
  1564. * @fn CheckForEntityPresence
  1565. * @brief This function checks for the entity presence bit
  1566. * or the entity presence sensor.
  1567. * @param[in] SensorNum - Sensor number for reading.
  1568. * @param[in] EventTypeCode - Event type code of the sdr.
  1569. * @param[in] SensorType - Sensor type of the sdr.
  1570. * @retval ENTITY_FOUND, if present,
  1571. * ENTITY_NOT_FOUND, if not present,
  1572. * NOT_FOUND_SCAN_DISABLED, if not able to find,
  1573. * NOT_FOUND_SCAN_ENABLED, if Scanning bit enabled but failed.
  1574. */
  1575. static int
  1576. CheckForEntityPresence (INT8U SensorNum, INT8U OwnerLUN, INT8U EventTypeCode, INT8U SensorType,int BMCInst)
  1577. {
  1578. // int RetVal = NOT_FOUND_SCAN_ENABLED;
  1579. // _FAR_ SensorInfo_T* pSensorInfo;
  1580. // int i;
  1581. // _FAR_ BMCInfo_t* pBMCInfo = &g_BMCInfo[BMCInst];
  1582. // _FAR_ SensorSharedMem_T* pSenSharedMem = (_FAR_ SensorSharedMem_T*)&pBMCInfo->SensorSharedMem;
  1583. //
  1584. // pSensorInfo = &(pSenSharedMem->SensorInfo[((OwnerLUN & VALID_LUN) << 8 | SensorNum)]);
  1585. //
  1586. // TDBG("Entered %s : Sensor Type : %x, SensorInit : %x, Reading : %x\n",
  1587. // __func__, SensorType, pSensorInfo->SensorInit,
  1588. // pSensorInfo->SensorReading);
  1589. //
  1590. // if( BIT0 == (BIT0 & pSensorInfo->SensorInit) )
  1591. // {
  1592. // // If Event/Reading type code is 0x08 then look for
  1593. // // reading DEVICE_PRESENT to state the Entity Presence
  1594. // if( GENERIC_EVENT_TYPE_DEV_PRESENCE == EventTypeCode )
  1595. // {
  1596. // if( DEVICE_PRESENT == pSensorInfo->SensorReading )
  1597. // {
  1598. // RetVal = ENTITY_FOUND;
  1599. // }
  1600. // else
  1601. // {
  1602. // RetVal = ENTITY_NOT_FOUND;
  1603. // }
  1604. // }
  1605. // // If Event/Reading type code is 0x09 then look for
  1606. // // reading DEVICE_ENABLED to state the Entity Enabled
  1607. // else if( GENERIC_EVENT_TYPE_DEV_AVAILABLE == EventTypeCode )
  1608. // {
  1609. // if( DEVICE_ENABLED == pSensorInfo->SensorReading )
  1610. // {
  1611. // RetVal = ENTITY_FOUND;
  1612. // }
  1613. // else
  1614. // {
  1615. // RetVal = ENTITY_NOT_FOUND;
  1616. // }
  1617. // }
  1618. // // If Event/Reading Type code is 0x6f then look for the
  1619. // // special sensors like Processor, Memory etc.,
  1620. // else if ( EVENT_TYPE_SENSOR_SPECIFIC == EventTypeCode )
  1621. // {
  1622. // for(i = 0; i < SENSOR_PRESENCE_COUNT; i++)
  1623. // {
  1624. // if( SensorType == sensor_presence[i][0] )
  1625. // {
  1626. // if( pSensorInfo->SensorReading == sensor_presence[i][1] )
  1627. // RetVal = ENTITY_FOUND;
  1628. // else
  1629. // RetVal = ENTITY_NOT_FOUND;
  1630. // }
  1631. // }
  1632. // }
  1633. //
  1634. // TDBG("Leaving : %s with %d\n", __func__, RetVal);
  1635. // return RetVal;
  1636. // }
  1637. // TDBG("Leaving : %s with %d\n", __func__, NOT_FOUND_SCAN_DISABLED);
  1638. // return NOT_FOUND_SCAN_DISABLED;
  1639. }
  1640. /**
  1641. * @fn IsSensorPresence
  1642. * @brief Check the presence bit for the entity or checks with
  1643. * entity presence sensor to identify Entity presence
  1644. * @param[in] EntityID - Entity id of the sensor.
  1645. * @param[in] EntityIns - Entity instance of the sensor.
  1646. * @param[in] SensorNum - Sensor number.
  1647. * @retval 1, if present
  1648. * 0, if not present
  1649. * -1, if not able to find.
  1650. */
  1651. static int
  1652. IsSensorPresence (INT8U EntityID, INT8U EntityIns, INT8U SensorNum, INT8U OwnerLUN, int BMCInst)
  1653. {
  1654. // _FAR_ SDRRecHdr_T* sr = NULL;
  1655. // _FAR_ CommonSensorRec_T* scs = NULL;
  1656. // _FAR_ BMCInfo_t* pBMCInfo = &g_BMCInfo[BMCInst];
  1657. //
  1658. // int RetVal, tmpRet = -1;
  1659. //
  1660. // TDBG("Entered : %s with EntityID : %x, SensorNum : %x, OwnerLUN : %x\n", __func__, EntityID, SensorNum, OwnerLUN);
  1661. //
  1662. // sr = SDR_GetFirstSDRRec (BMCInst);
  1663. //
  1664. // while (0 != sr)
  1665. // {
  1666. // // Populate sensor information for Threshold sensors
  1667. // if (FULL_SDR_REC == sr->Type ||
  1668. // COMPACT_SDR_REC == sr->Type)
  1669. // {
  1670. // /* Populate sensor information for full or Compact Record */
  1671. // scs = (_FAR_ CommonSensorRec_T*) sr;
  1672. // TDBG("COMPACT SDR REC SensorNum : %x, OwnerLUN : %x, EntityID : %x, EventTypeCode : %x\n",
  1673. // scs->SensorNum, scs->OwnerLUN, scs->EntityID, scs->EventTypeCode);
  1674. //
  1675. // // Check for EntityId and EntityIns
  1676. // if( (pBMCInfo->IpmiConfig.BMCSlaveAddr == scs->OwnerID) &&
  1677. // (EntityID == scs->EntityID) &&
  1678. // (EntityIns == scs->EntityIns) &&
  1679. // ((SensorNum != scs->SensorNum) || (OwnerLUN != scs->OwnerLUN)) )
  1680. // {
  1681. // RetVal = CheckForEntityPresence (scs->SensorNum, scs->OwnerLUN, scs->EventTypeCode,
  1682. // scs->SensorType,BMCInst);
  1683. // if( NOT_FOUND_SCAN_DISABLED != RetVal &&
  1684. // NOT_FOUND_SCAN_ENABLED != RetVal)
  1685. // {
  1686. // return RetVal;
  1687. // }
  1688. // else if( NOT_FOUND_SCAN_ENABLED == RetVal)
  1689. // {
  1690. // // An Entity is present if there is at least one active
  1691. // // sensor for the Entity (and there is no explicit sensor saying
  1692. // // the Entity is 'absent').
  1693. // // A sensor is 'active' if scanning is enabled.
  1694. // // We can return this value only after searching all the sensors.
  1695. // tmpRet = 1;
  1696. // }
  1697. // }
  1698. // }
  1699. // /* Get the next record */
  1700. // sr = SDR_GetNextSDRRec (sr,BMCInst);
  1701. // }
  1702. // TDBG("Leaving : %s with %d\n", __func__, tmpRet);
  1703. // return tmpRet;
  1704. }
  1705. /**
  1706. * @fn IsEntityAssociationPresence
  1707. * @brief Check the EntityID and Entity instance to see if the entity is
  1708. * a container entity in an entity-association. If so, check to
  1709. * see if any of the contained entities are present, if so, assume
  1710. * the container entity exists.
  1711. * @param[in] EntityID - Entity id of the sensor.
  1712. * @param[in] EntityIns - Entity instance of the sensor.
  1713. * @retval 1, if present
  1714. * 0, if not present
  1715. * -1, if not able to find.
  1716. */
  1717. static int
  1718. IsEntityAssociationPresence (INT8U EntityID, INT8U EntityIns)
  1719. {
  1720. // TDBG("Entered : %s\n", __func__);
  1721. // // TODO: Entity Association record has to be handle later.
  1722. // TDBG("Leaving : %s with -1\n", __func__);
  1723. // return -1;
  1724. }
  1725. /**
  1726. * @fn IsFRUPresence
  1727. * @brief Check the entity to see if FRU device is present.
  1728. * @param[in] EntityID - Entity id of the sensor.
  1729. * @param[in] EntityIns - Entity instance of the sensor.
  1730. * @retval 1, if present
  1731. * 0, if not present
  1732. * -1, if not able to find.
  1733. */
  1734. static int
  1735. IsFRUPresence (INT8U EntityID, INT8U EntityIns,int BMCInst)
  1736. {
  1737. // _FAR_ SDRRecHdr_T* sr = NULL;
  1738. // _FAR_ FRUDevLocatorRec_T* frudl;
  1739. // FRUReadReq_T FRUReadReq;
  1740. // INT8U FRUReadRes[64];
  1741. //
  1742. // TDBG("Entered : %s\n", __func__);
  1743. //
  1744. // sr = SDR_GetFirstSDRRec (BMCInst);
  1745. // while (0 != sr)
  1746. // {
  1747. // // Check for FRU Device locator SDR Record
  1748. // if (sr->Type == FRU_DEVICE_LOCATOR_SDR_REC)
  1749. // {
  1750. // frudl = (_FAR_ FRUDevLocatorRec_T*) sr;
  1751. // TDBG("if Success : EntityID : %x, EntityIns : %x\n",
  1752. // frudl->EntityID, frudl->EntityIns);
  1753. // // If EntityID and EntityIns are equal try to read the fru data.
  1754. // if(frudl->EntityID == EntityID &&
  1755. // frudl->EntityIns == EntityIns)
  1756. // {
  1757. // FRUReadReq.FRUDeviceID=frudl->FRUIDSlaveAddr;
  1758. // FRUReadReq.Offset=0x0;
  1759. // FRUReadReq.CountToRead=sizeof(FRUCommonHeader_T);
  1760. // ReadFRUData((INT8U *)&FRUReadReq, sizeof(FRUReadReq_T), FRUReadRes,BMCInst);
  1761. // if (((FRUReadRes_T *)FRUReadRes)->CompletionCode == FRU_ACCESSIBLE)
  1762. // {
  1763. // TDBG("Leaving : %s with 1\n", __func__);
  1764. // return 1;
  1765. // }
  1766. // else
  1767. // {
  1768. // TDBG("Leaving : %s with 0\n", __func__);
  1769. // return 0;
  1770. // }
  1771. // }
  1772. // }
  1773. // sr = SDR_GetNextSDRRec (sr,BMCInst);
  1774. // }
  1775. // TDBG("Leaving : %s with -1\n", __func__);
  1776. // return -1;
  1777. }
  1778. /**
  1779. * @fn InitSensorScanningBit
  1780. * @brief Initializes all the sensor's Scanning bit with respect
  1781. * to the presence of the entity
  1782. * @retval 0.
  1783. */
  1784. int InitSensorScanningBit(int BMCInst)
  1785. {
  1786. // _FAR_ SDRRecHdr_T* sr = NULL;
  1787. // _FAR_ CommonSensorRec_T* scs = NULL;
  1788. // int RetVal;
  1789. // _FAR_ BMCInfo_t* pBMCInfo = &g_BMCInfo[BMCInst];
  1790. // _FAR_ SensorSharedMem_T* pSenSharedMem = (_FAR_ SensorSharedMem_T*)&pBMCInfo->SensorSharedMem;
  1791. //
  1792. // TDBG("Entered : %s\n", __func__);
  1793. // sr = SDR_GetFirstSDRRec (BMCInst);
  1794. // INT16U LUNSensorNum;
  1795. // while (0 != sr)
  1796. // {
  1797. // // Populater sensor information for Threshold sensors
  1798. // if (FULL_SDR_REC == sr->Type ||
  1799. // COMPACT_SDR_REC == sr->Type)
  1800. // {
  1801. // scs = (_FAR_ CommonSensorRec_T*) sr;
  1802. //
  1803. // if ((pBMCInfo->IpmiConfig.BMCSlaveAddr == scs->OwnerID))
  1804. // {
  1805. //// TDBG("Check for Entity Presence : SensorNum : %x, EntityId : %x, "
  1806. //// "EntityIns : %x, SensorCaps : %x\n",
  1807. //// scs->SensorNum, scs->EntityID, scs->EntityIns,
  1808. //// (scs->SensorCaps & 0x80));
  1809. // RetVal = 1;
  1810. // if( BIT7 == (BIT7 & scs->SensorCaps) )
  1811. // {
  1812. // /* As per IPMI Spec Section 40.2
  1813. // * Entity presence can be detected if any one of the following point is
  1814. // * Satisfied,
  1815. // * 1. If there is an active sensor that includes a presence bit,
  1816. // * or the entity has an active Entity Presence sensor,
  1817. // * use the sensor to determine the presence of the entity.
  1818. // * 2. Check the SDRs to see if the entity is a container entity
  1819. // * in an entity-association. If so, check to see if any of the
  1820. // * contained entities are present, if so, assume the container
  1821. // * entity exists. Note that this may need to be iterative.
  1822. // * 3. The entity is present is there is a FRU device for the
  1823. // * entity, and the FRU device is present.
  1824. // */
  1825. //
  1826. // RetVal = IsSensorPresence(scs->EntityID, scs->EntityIns, scs->SensorNum, scs->OwnerLUN, BMCInst);
  1827. // if( -1 == RetVal )
  1828. // {
  1829. // RetVal = IsEntityAssociationPresence(scs->EntityID, scs->EntityIns);
  1830. // if( -1 == RetVal )
  1831. // {
  1832. // RetVal = IsFRUPresence(scs->EntityID, scs->EntityIns,BMCInst);
  1833. // }
  1834. // }
  1835. // }
  1836. // LUNSensorNum = ((scs->OwnerLUN & VALID_LUN) << 8 | scs->SensorNum);
  1837. // /*
  1838. // * [7] - 0b = All Event Messages disabled from this sensor
  1839. // * [6] - 0b = sensor scanning disabled
  1840. // * [5] - 1b = reading/state unavailable
  1841. // */
  1842. // if(1 == RetVal)
  1843. // {
  1844. // if((BIT0 | BIT1) == (pSenSharedMem->SensorInfo[LUNSensorNum].SensorInit & (BIT0 | BIT1)))
  1845. // {
  1846. // /* Enabling Sensor Scanning and Event Messages*/
  1847. // pSenSharedMem->SensorInfo[LUNSensorNum].EventFlags = EVENT_AND_SCANNING_ENABLE;
  1848. // }
  1849. // else if(BIT1 == (pSenSharedMem->SensorInfo[LUNSensorNum].SensorInit & BIT1))
  1850. // {
  1851. // /* Enabling Event Messages */
  1852. // pSenSharedMem->SensorInfo[LUNSensorNum].EventFlags = EVENT_MSG_MASK;
  1853. // }
  1854. // else if(BIT0 == (pSenSharedMem->SensorInfo[LUNSensorNum].SensorInit & BIT0))
  1855. // {
  1856. // /*Enabling Scanning*/
  1857. // pSenSharedMem->SensorInfo[LUNSensorNum].EventFlags = SCAN_MASK;
  1858. // }
  1859. // if(0 == (pSenSharedMem->SensorInfo[LUNSensorNum].SensorInit & BIT0))
  1860. // {
  1861. // /* Reading Unavailable */
  1862. // pSenSharedMem->SensorInfo[LUNSensorNum].EventFlags |= READING_UNAVAILABLE;
  1863. // }
  1864. // }
  1865. // else
  1866. // {
  1867. // pSenSharedMem->SensorInfo[LUNSensorNum].EventFlags = READING_UNAVAILABLE;
  1868. // if(BIT1 == (pSenSharedMem->SensorInfo[LUNSensorNum].SensorInit & BIT1))
  1869. // {
  1870. // /* Enabling Event Messages */
  1871. // pSenSharedMem->SensorInfo[LUNSensorNum].EventFlags |= EVENT_MSG_MASK;
  1872. // }
  1873. // }
  1874. //// TDBG("\nSensor Scanning Bit for sensor %x : %x\n", scs->SensorNum,
  1875. //// pSenSharedMem->SensorInfo[scs->SensorNum].EventFlags);
  1876. //
  1877. // }
  1878. // }
  1879. // /* Get the next record */
  1880. // sr = SDR_GetNextSDRRec (sr,BMCInst);
  1881. // }
  1882. // TDBG("Leaving : %s with 0\n", __func__);
  1883. // return 0;
  1884. }
  1885. /* Compare two sensor values.
  1886. * Returns -1 if val1 < val2
  1887. * Returns 0 if val1 == val2
  1888. * Returns 1 if val1 > val2
  1889. */
  1890. int
  1891. CompareValues(BOOL isSigned, INT8U val1, INT8U val2)
  1892. {
  1893. // int retval = 0; // default to equal
  1894. //
  1895. // /* Do comparison based on isSigned flag */
  1896. // if (FALSE == isSigned)
  1897. // {
  1898. // // Unsigned comparison
  1899. // if (val1 < val2)
  1900. // {
  1901. // retval = -1;
  1902. // }
  1903. // else if (val1 > val2)
  1904. // {
  1905. // retval = 1;
  1906. // }
  1907. // }
  1908. // else
  1909. // {
  1910. // // Signed comparison
  1911. // INT8 sval1, sval2;
  1912. //
  1913. // sval1 = (INT8)val1;
  1914. // sval2 = (INT8)val2;
  1915. //
  1916. // if (sval1 < sval2)
  1917. // {
  1918. // retval = -1;
  1919. // }
  1920. // else if (sval1 > sval2)
  1921. // {
  1922. // retval = 1;
  1923. // }
  1924. // }
  1925. //
  1926. // return retval;
  1927. }
  1928. /*-----------------------------------------
  1929. * GetSensorReading
  1930. *-----------------------------------------*/
  1931. int
  1932. GetSensorReading (_NEAR_ INT8U* pReq, INT8U ReqLen, _NEAR_ INT8U* pRes,_NEAR_ int BMCInst)
  1933. {
  1934. _NEAR_ GetSensorReadingReq_T* pSensorReadReq =
  1935. (_NEAR_ GetSensorReadingReq_T*) pReq;
  1936. _NEAR_ GetSensorReadingRes_T* pSensorReadRes =
  1937. (_NEAR_ GetSensorReadingRes_T*) pRes;
  1938. INT16U SensorReading;
  1939. bool SensorIsSigned = FALSE;
  1940. _FAR_ BMCInfo_t* pBMCInfo = &g_BMCInfo;
  1941. uint8_t sensorNum;
  1942. sensorNum=pSensorReadReq->SensorNum;
  1943. pSensorReadRes->CompletionCode=0x00;
  1944. pSensorReadRes->Flags=0xc0;
  1945. pSensorReadRes->ComparisonStatus=0xc0;
  1946. pSensorReadRes->OptionalStatus=0x00;
  1947. pSensorReadRes->SensorReading=g_BMCInfo.sensorInfo[sensorNum].sensorReading;
  1948. SessionSequenceNumberCount=SessionSequenceNumberCount+1;
  1949. return sizeof (GetSensorReadingRes_T);
  1950. }
  1951. /*-----------------------------------------
  1952. * SetSensorReading
  1953. *-----------------------------------------*/
  1954. int
  1955. SetSensorReading (_NEAR_ INT8U* pReq, INT8U ReqLen, _NEAR_ INT8U* pRes,_NEAR_ int BMCInst)
  1956. {
  1957. // _NEAR_ SetSensorReadingReq_T* pSensorReadReq =
  1958. // (_NEAR_ SetSensorReadingReq_T*) pReq;
  1959. // _NEAR_ SetSensorReadingRes_T* pSensorReadRes =
  1960. // (_NEAR_ SetSensorReadingRes_T*) pRes;
  1961. // _FAR_ SensorSharedMem_T* pSenSharedMem;
  1962. // _FAR_ BMCInfo_t* pBMCInfo = &g_BMCInfo[BMCInst];
  1963. // pSenSharedMem = (_FAR_ SensorSharedMem_T*)&pBMCInfo->SensorSharedMem; //m_hSensorSharedMem;
  1964. //
  1965. // /* Check for the reserved bits */
  1966. // if (pSenSharedMem->SensorInfo [pSensorReadReq->SensorNum].SensorReadType == THRESHOLD_SENSOR_CLASS)
  1967. // {
  1968. // if (((ReqLen>=LEN_FOR_ASSERT_DATA) && (pSensorReadReq->AssertionEventOccuredByte2 & RESERVED_BITS_SETSENRD_ASSEVTOCCBYTE_1)) ||
  1969. // ((ReqLen>=LEN_FOR_DEASSERT_DATA) && (pSensorReadReq->DeAssertionEventOccuredByte2 & RESERVED_BITS_SETSENRD_DEASSEVTOCCBYTE_1)))
  1970. // {
  1971. // pSensorReadRes->CompletionCode = CC_INV_DATA_FIELD;
  1972. // return sizeof (*pRes);
  1973. // }
  1974. // }
  1975. // else
  1976. // {
  1977. // if (((ReqLen>=LEN_FOR_ASSERT_DATA) && (pSensorReadReq->AssertionEventOccuredByte2 & RESERVED_BITS_SETSENRD_ASSEVTOCCBYTE_2)) ||
  1978. // ((ReqLen>=LEN_FOR_DEASSERT_DATA) && (pSensorReadReq->DeAssertionEventOccuredByte2 & RESERVED_BITS_SETSENRD_DEASSEVTOCCBYTE_2)))
  1979. // {
  1980. // pSensorReadRes->CompletionCode = CC_INV_DATA_FIELD;
  1981. // return sizeof (*pRes);
  1982. // }
  1983. // }
  1984. //
  1985. // if (pBMCInfo->IpmiConfig.OPMASupport == 1)
  1986. // {
  1987. // if (pSenSharedMem->GlobalSensorScanningEnable == FALSE)
  1988. // {
  1989. // pSensorReadRes->CompletionCode = CC_PARAM_NOT_SUP_IN_CUR_STATE;
  1990. // return sizeof (*pRes);
  1991. // }
  1992. // }
  1993. //
  1994. // /* Acquire Shared memory */
  1995. // OS_THREAD_MUTEX_ACQUIRE(&pBMCInfo->SensorSharedMemMutex, WAIT_INFINITE);
  1996. //
  1997. // if (!pSenSharedMem->SensorInfo [pSensorReadReq->SensorNum].IsSensorPresent)
  1998. // {
  1999. // /* Release mutex for Sensor shared memory */
  2000. // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->SensorSharedMemMutex);
  2001. //
  2002. // pSensorReadRes->CompletionCode = CC_SDR_REC_NOT_PRESENT;
  2003. // return sizeof (*pRes);
  2004. // }
  2005. //
  2006. // if (ReqLen < MIN_SET_SEN_READING_CMD_LEN)
  2007. // {
  2008. // /* Release mutex for Sensor shared memory */
  2009. // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->SensorSharedMemMutex);
  2010. //
  2011. // pSensorReadRes->CompletionCode = CC_REQ_INV_LEN;
  2012. // return sizeof (*pRes);
  2013. // }
  2014. //
  2015. //
  2016. // /* Check if the sensor is settable */
  2017. // if (0 == GET_SETTABLE_SENSOR_BIT(pSenSharedMem->SensorInfo [pSensorReadReq->SensorNum].SensorInit))
  2018. // {
  2019. // /* Release mutex for Sensor shared memory */
  2020. // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->SensorSharedMemMutex);
  2021. //
  2022. // pSensorReadRes->CompletionCode = CC_INVALID_ATTEMPT_TO_SET;
  2023. // return sizeof (*pRes);
  2024. // }
  2025. //
  2026. // pSenSharedMem->SensorInfo [pSensorReadReq->SensorNum].Operation = pSensorReadReq->Operation;
  2027. //
  2028. // /* Set Sensor Event Data based on the Operation byte */
  2029. // switch (GET_EVENT_DATA_OP(pSensorReadReq->Operation))
  2030. // {
  2031. // case WRITE_NO_EVTDATA1:
  2032. // pSensorReadReq->EvtData1 &= 0xF0;
  2033. // /* Intentional Fall thru */
  2034. // case WRITE_EVTDATA1:
  2035. // if (LEN_FOR_EVT_DATA != ReqLen)
  2036. // {
  2037. // /* Release mutex for Sensor shared memory */
  2038. // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->SensorSharedMemMutex);
  2039. //
  2040. // pSensorReadRes->CompletionCode = CC_REQ_INV_LEN;
  2041. // return sizeof (*pRes);
  2042. // }
  2043. // /* Update EvtData fields */
  2044. // pSenSharedMem->SensorInfo [pSensorReadReq->SensorNum].EvtData1 = pSensorReadReq->EvtData1;
  2045. // pSenSharedMem->SensorInfo [pSensorReadReq->SensorNum].EvtData2 = pSensorReadReq->EvtData2;
  2046. // pSenSharedMem->SensorInfo [pSensorReadReq->SensorNum].EvtData3 = pSensorReadReq->EvtData3;
  2047. // break;
  2048. // }
  2049. //
  2050. // /* Check Length for Assertion Set Opetation */
  2051. // if (0 != GET_ASSERT_EVT_OP(pSensorReadReq->Operation))
  2052. // {
  2053. // if ((ReqLen < LEN_FOR_ASSERT_DATA) || (ReqLen > MAX_SET_SEN_READ_LEN))
  2054. // {
  2055. // /* Release mutex for Sensor shared memory */
  2056. // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->SensorSharedMemMutex);
  2057. //
  2058. // pSensorReadRes->CompletionCode = CC_REQ_INV_LEN;
  2059. // return sizeof (*pRes);
  2060. // }
  2061. // }
  2062. //
  2063. // /* Set Sensor Assertion Event based on the Operation byte */
  2064. // switch (GET_ASSERT_EVT_OP(pSensorReadReq->Operation))
  2065. // {
  2066. // case CLEAR_ASSERT_BITS:
  2067. // pSenSharedMem->SensorInfo [pSensorReadReq->SensorNum].AssertionEventOccuredByte1 &= pSensorReadReq->AssertionEventOccuredByte1;
  2068. // pSenSharedMem->SensorInfo [pSensorReadReq->SensorNum].AssertionEventOccuredByte2 &= pSensorReadReq->AssertionEventOccuredByte2;
  2069. // break;
  2070. //
  2071. // case SET_ASSERT_BITS:
  2072. // pSenSharedMem->SensorInfo [pSensorReadReq->SensorNum].AssertionEventOccuredByte1 |= pSensorReadReq->AssertionEventOccuredByte1;
  2073. // pSenSharedMem->SensorInfo [pSensorReadReq->SensorNum].AssertionEventOccuredByte2 |= pSensorReadReq->AssertionEventOccuredByte2;
  2074. // break;
  2075. //
  2076. // case WRITE_ASSERT_BITS:
  2077. // pSenSharedMem->SensorInfo [pSensorReadReq->SensorNum].AssertionEventOccuredByte1 |= pSensorReadReq->AssertionEventOccuredByte1;
  2078. // pSenSharedMem->SensorInfo [pSensorReadReq->SensorNum].AssertionEventOccuredByte2 |= pSensorReadReq->AssertionEventOccuredByte2;
  2079. // break;
  2080. // }
  2081. //
  2082. //
  2083. // /* Check Length for Assertion Set Opetation */
  2084. // if (0 != GET_DEASSERT_EVT_OP(pSensorReadReq->Operation))
  2085. // {
  2086. // if ((ReqLen < LEN_FOR_DEASSERT_DATA) || (ReqLen > MAX_SET_SEN_READ_LEN))
  2087. // {
  2088. // /* Release mutex for Sensor shared memory */
  2089. // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->SensorSharedMemMutex);
  2090. //
  2091. // pSensorReadRes->CompletionCode = CC_REQ_INV_LEN;
  2092. // return sizeof (*pRes);
  2093. // }
  2094. // }
  2095. //
  2096. // /* Set Sensor DeAssertion Event based on the Operation byte */
  2097. // switch (GET_DEASSERT_EVT_OP(pSensorReadReq->Operation))
  2098. // {
  2099. // case CLEAR_DEASSERT_BITS:
  2100. // pSenSharedMem->SensorInfo [pSensorReadReq->SensorNum].DeassertionEventOccuredByte1 &= pSensorReadReq->DeAssertionEventOccuredByte1;
  2101. // pSenSharedMem->SensorInfo [pSensorReadReq->SensorNum].DeassertionEventOccuredByte2 &= pSensorReadReq->DeAssertionEventOccuredByte2;
  2102. // break;
  2103. //
  2104. // case SET_DEASSERT_BITS:
  2105. // pSenSharedMem->SensorInfo [pSensorReadReq->SensorNum].DeassertionEventOccuredByte1 |= pSensorReadReq->DeAssertionEventOccuredByte1;
  2106. // pSenSharedMem->SensorInfo [pSensorReadReq->SensorNum].DeassertionEventOccuredByte2 |= pSensorReadReq->DeAssertionEventOccuredByte2;
  2107. // break;
  2108. //
  2109. // case WRITE_DEASSERT_BITS:
  2110. // pSenSharedMem->SensorInfo [pSensorReadReq->SensorNum].DeassertionEventOccuredByte1 |= pSensorReadReq->DeAssertionEventOccuredByte1;
  2111. // pSenSharedMem->SensorInfo [pSensorReadReq->SensorNum].DeassertionEventOccuredByte2 |= pSensorReadReq->DeAssertionEventOccuredByte2;
  2112. // break;
  2113. // }
  2114. //
  2115. //
  2116. // /* Check Length for Set Sensor Reading Operation */
  2117. // if (0 != GET_SETSENSOR_OP(pSensorReadReq->Operation))
  2118. // {
  2119. // if ((ReqLen < LEN_FOR_SETSENSOR_DATA) || (ReqLen > MAX_SET_SEN_READ_LEN))
  2120. // {
  2121. // /* Release mutex for Sensor shared memory */
  2122. // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->SensorSharedMemMutex);
  2123. //
  2124. // pSensorReadRes->CompletionCode = CC_REQ_INV_LEN;
  2125. // return sizeof (*pRes);
  2126. // }
  2127. //
  2128. // /* Set new Sensor Reading */
  2129. // pSenSharedMem->SensorInfo [pSensorReadReq->SensorNum].SensorReading = pSensorReadReq->SensorReading;
  2130. //
  2131. // }
  2132. //
  2133. // pSensorReadRes->CompletionCode = CC_NORMAL;
  2134. //
  2135. // /* Release mutex for Sensor shared memory */
  2136. // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->SensorSharedMemMutex);
  2137. //
  2138. // return sizeof (SetSensorReadingRes_T);
  2139. }
  2140. /*-------------------------------------------
  2141. * GetSensorSDR
  2142. *-------------------------------------------*/
  2143. _FAR_ SDRRecHdr_T*
  2144. SR_GetSensorSDR (INT8U SensorNum, int BMCInst)
  2145. {
  2146. // _FAR_ SDRRecHdr_T* SDRRec;
  2147. //
  2148. // /* Search for the record containing the sensor */
  2149. // SDRRec = SDR_GetFirstSDRRec (BMCInst);
  2150. // while (0 != SDRRec)
  2151. // {
  2152. // switch (SDRRec->Type)
  2153. // {
  2154. // case FULL_SDR_REC :
  2155. // if (((_FAR_ FullSensorRec_T*) SDRRec)->SensorNum == SensorNum)
  2156. // {
  2157. // return SDRRec;
  2158. // }
  2159. // break;
  2160. //
  2161. // case COMPACT_SDR_REC:
  2162. // {
  2163. // INT16U SharedRecs = ipmitoh_u16 (((_FAR_ CompactSensorRec_T*) SDRRec)->RecordSharing) &
  2164. // SHARED_RECD_COUNT;
  2165. // if ((SensorNum == ((_FAR_ CompactSensorRec_T*) SDRRec)->SensorNum ) ||
  2166. // ((SensorNum >= (((_FAR_ CompactSensorRec_T*) SDRRec)->SensorNum )) &&
  2167. // (SensorNum < (((_FAR_ CompactSensorRec_T*) SDRRec)->SensorNum + SharedRecs)))
  2168. // )
  2169. // {
  2170. // return SDRRec;
  2171. // }
  2172. // }
  2173. // break;
  2174. //
  2175. // default :
  2176. // break;
  2177. // }
  2178. //
  2179. // /* Get the next record */
  2180. // SDRRec = SDR_GetNextSDRRec (SDRRec,BMCInst);
  2181. // if (0 == SDRRec)
  2182. // {
  2183. // return 0;
  2184. // }
  2185. // }
  2186. //
  2187. // return 0;
  2188. }
  2189. /**
  2190. * @brief Update global variables with number sensors.
  2191. **/
  2192. static void
  2193. FindNumSensors (int BMCInst)
  2194. {
  2195. // _FAR_ SDRRecHdr_T* pSDRRec;
  2196. // _FAR_ FullSensorRec_T* pFSR;
  2197. // _FAR_ CompactSensorRec_T* pCSR;
  2198. //
  2199. // pFSR = 0;
  2200. // pCSR = 0;
  2201. //
  2202. // /* Get First SDR Record */
  2203. // pSDRRec = SDR_GetFirstSDRRec (BMCInst);
  2204. // while (0 != pSDRRec)
  2205. // {
  2206. // switch (pSDRRec->Type)
  2207. // {
  2208. // case FULL_SDR_REC :
  2209. //
  2210. // pFSR = (_FAR_ FullSensorRec_T*) pSDRRec;
  2211. // if (THRESHOLD_SENSOR_CLASS == pFSR->EventTypeCode)
  2212. // {
  2213. // g_BMCInfo[BMCInst].SenConfig.NumThreshSensors++;
  2214. // }
  2215. // else
  2216. // {
  2217. // g_BMCInfo[BMCInst].SenConfig.NumNonThreshSensors++;
  2218. // }
  2219. // break;
  2220. //
  2221. // case COMPACT_SDR_REC :
  2222. //
  2223. // pCSR = (_FAR_ CompactSensorRec_T*) pSDRRec;
  2224. // if (THRESHOLD_SENSOR_CLASS == pCSR->EventTypeCode)
  2225. // {
  2226. // g_BMCInfo[BMCInst].SenConfig.NumThreshSensors += (ipmitoh_u16 (pCSR->RecordSharing) &
  2227. // SHARED_RECD_COUNT);
  2228. // }
  2229. // else
  2230. // {
  2231. // g_BMCInfo[BMCInst].SenConfig.NumNonThreshSensors += (ipmitoh_u16 (pCSR->RecordSharing) &
  2232. // SHARED_RECD_COUNT);
  2233. // }
  2234. // break;
  2235. //
  2236. // default:
  2237. //
  2238. // break;
  2239. // }
  2240. //
  2241. // /* Get the next record */
  2242. // pSDRRec = SDR_GetNextSDRRec (pSDRRec,BMCInst);
  2243. //
  2244. // }
  2245. //
  2246. //
  2247. // IPMI_DBG_PRINT_1("Thereshold Sensors = %d\n",g_BMCInfo[BMCInst].SenConfig.NumThreshSensors);
  2248. // IPMI_DBG_PRINT_1("Non Thershold Sensors = %d\n",g_BMCInfo[BMCInst].SenConfig.NumNonThreshSensors);
  2249. //
  2250. //
  2251. // return;
  2252. }
  2253. int
  2254. GetRecordIdsforDCMISensor (INT8U EntityID,INT8U SensorType, INT8U EntityInstance,
  2255. INT8U StartingEntityInstance, INT16U* pBuf, INT8U* pTotalValidInstances,int BMCInst)
  2256. {
  2257. // int i, ValidInstances;
  2258. // _FAR_ SensorSharedMem_T* pSenSharedMem;
  2259. // _FAR_ BMCInfo_t* pBMCInfo = &g_BMCInfo[BMCInst];
  2260. // pSenSharedMem = (_FAR_ SensorSharedMem_T*)&pBMCInfo->SensorSharedMem; //m_hSensorSharedMem;
  2261. //
  2262. // if (0 != EntityInstance)
  2263. // {
  2264. // *pTotalValidInstances = 0;
  2265. // ValidInstances = 0;
  2266. // /* Acquire Shared memory to populate sensor information */
  2267. // //OS_ACQUIRE_MUTEX(m_hSensorSharedMemMutex, SHARED_MEM_TIMEOUT);
  2268. // OS_THREAD_MUTEX_ACQUIRE(&g_BMCInfo[BMCInst].SensorSharedMemMutex, WAIT_INFINITE);
  2269. //
  2270. // for (i = 0; i < MAX_SENSOR_NUMBERS + 1; i++ )
  2271. // {
  2272. // if ((TRUE == pSenSharedMem->SensorInfo [i].IsDCMITempsensor) && (pSenSharedMem->SensorInfo[i].SDRRec->Type == FULL_SDR_REC) )
  2273. // {
  2274. // if(SensorType != pSenSharedMem->SensorInfo[i].SensorTypeCode)
  2275. // {
  2276. // /*Check the Sensor type*/
  2277. // continue;
  2278. // }
  2279. //
  2280. // 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))) ||
  2281. // (((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))) ||
  2282. // (((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))))
  2283. // {
  2284. // *pTotalValidInstances += 1;
  2285. // if (EntityInstance == pSenSharedMem->SensorInfo [i].EntiryInstance)
  2286. // {
  2287. // pBuf [0] = pSenSharedMem->SensorInfo [i].RecordID;
  2288. // ValidInstances = 1;
  2289. // }
  2290. // }
  2291. // }
  2292. // }
  2293. // /* Release mutex for Sensor shared memory */
  2294. // OS_THREAD_MUTEX_RELEASE(&g_BMCInfo[BMCInst].SensorSharedMemMutex);
  2295. // return ValidInstances;
  2296. // }
  2297. // else
  2298. // {
  2299. // *pTotalValidInstances = 0;
  2300. // ValidInstances = 0;
  2301. // /* Acquire Shared memory to populate sensor information */
  2302. // //OS_ACQUIRE_MUTEX(m_hSensorSharedMemMutex, SHARED_MEM_TIMEOUT);
  2303. // OS_THREAD_MUTEX_ACQUIRE(&g_BMCInfo[BMCInst].SensorSharedMemMutex, WAIT_INFINITE);
  2304. //
  2305. // for (i = StartingEntityInstance; i < MAX_SENSOR_NUMBERS + 1; i++ )
  2306. // {
  2307. // if ((TRUE == pSenSharedMem->SensorInfo [i].IsDCMITempsensor) && (pSenSharedMem->SensorInfo[i].SDRRec->Type == FULL_SDR_REC) )
  2308. // {
  2309. // if(SensorType != pSenSharedMem->SensorInfo[i].SensorTypeCode)
  2310. // {
  2311. // /*Check the Sensor type*/
  2312. // continue;
  2313. // }
  2314. //
  2315. // 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))) ||
  2316. // (((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))) ||
  2317. // (((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))))
  2318. // {
  2319. // *pTotalValidInstances += 1;
  2320. // if (ValidInstances < 8)
  2321. // {
  2322. // pBuf [ValidInstances] = pSenSharedMem->SensorInfo [i].RecordID;
  2323. // ValidInstances += 1;
  2324. // }
  2325. // }
  2326. // }
  2327. // }
  2328. // /* Release mutex for Sensor shared memory */
  2329. // //OS_RELEASE_MUTEX(m_hSensorSharedMemMutex);
  2330. // OS_THREAD_MUTEX_RELEASE(&g_BMCInfo[BMCInst].SensorSharedMemMutex);
  2331. // return (ValidInstances > 8) ? 8: ValidInstances;
  2332. // }
  2333. }
  2334. int GetDCMITempReading(INT8U EntityID,INT8U SensorType, INT8U EntityInstance,
  2335. INT8U StartingEntityInstance, INT8U* pBuf, INT8U* pTotalValidInstances,int BMCInst)
  2336. {
  2337. // int i, ValidInstances,j = 0;
  2338. // _FAR_ SensorSharedMem_T* pSenSharedMem;
  2339. // _FAR_ BMCInfo_t* pBMCInfo = &g_BMCInfo[BMCInst];
  2340. // pSenSharedMem = (_FAR_ SensorSharedMem_T*)&pBMCInfo->SensorSharedMem; //m_hSensorSharedMem;
  2341. // _FAR_ SDRRecHdr_T* pSDRRec;
  2342. // _FAR_ FullSensorRec_T* FullSDR;
  2343. // float convreading = 0;
  2344. // INT8U MinReading = 0, MaxReading = 0,Linear = 0;
  2345. //
  2346. // if (0 != EntityInstance)
  2347. // {
  2348. // *pTotalValidInstances = 0;
  2349. // ValidInstances = 0;
  2350. // OS_THREAD_MUTEX_ACQUIRE(&g_BMCInfo[BMCInst].SensorSharedMemMutex, WAIT_INFINITE);
  2351. //
  2352. // for (i = 0; i < MAX_SENSOR_NUMBERS + 1; i++ )
  2353. // {
  2354. // if ((TRUE == pSenSharedMem->SensorInfo [i].IsDCMITempsensor) && (pSenSharedMem->SensorInfo[i].SDRRec->Type == FULL_SDR_REC) )
  2355. // {
  2356. //
  2357. // if(SensorType != pSenSharedMem->SensorInfo[i].SensorTypeCode)
  2358. // {
  2359. // /*Check the Sensor type*/
  2360. // continue;
  2361. // }
  2362. //
  2363. // 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))) ||
  2364. // (((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))) ||
  2365. // (((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))))
  2366. // {
  2367. // *pTotalValidInstances += 1;
  2368. // if (EntityInstance == pSenSharedMem->SensorInfo [i].EntiryInstance)
  2369. // {
  2370. // if( !( pSenSharedMem->SensorInfo[i].EventFlags & 0x40) || (pSenSharedMem->SensorInfo[i].EventFlags & 0x20) )
  2371. // {
  2372. // printf("event flag is disabled\n");
  2373. // pBuf[DCMI_TEMP_READING] = 0;
  2374. // pBuf[DCMI_INST_NUMBER] = 0;
  2375. // }
  2376. // else
  2377. // {
  2378. // pSDRRec = GetSDRRec(pSenSharedMem->SensorInfo[i].SDRRec->ID,BMCInst);
  2379. //
  2380. // FullSDR = (_FAR_ FullSensorRec_T *)pSDRRec;
  2381. // MinReading = FullSDR->MinReading;
  2382. // MaxReading = FullSDR->MaxReading;
  2383. // Linear = FullSDR->Linearization;
  2384. //
  2385. // 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,
  2386. // pSenSharedMem->SensorInfo[i].B_LSB, pSenSharedMem->SensorInfo[i].M_MSB_Tolerance, pSenSharedMem->SensorInfo[i].B_MSB_Accuracy, pSenSharedMem->SensorInfo[i].RExp_BExp);
  2387. //
  2388. // pBuf [DCMI_TEMP_READING] = (INT8)convreading;
  2389. // pBuf [DCMI_INST_NUMBER] = EntityInstance;
  2390. // }
  2391. // ValidInstances = 1;
  2392. // }
  2393. // }
  2394. // }
  2395. // }
  2396. // /* Release mutex for Sensor shared memory */
  2397. // OS_THREAD_MUTEX_RELEASE(&g_BMCInfo[BMCInst].SensorSharedMemMutex);
  2398. // return ValidInstances;
  2399. // }
  2400. // else
  2401. // {
  2402. // *pTotalValidInstances = 0;
  2403. // ValidInstances = 0;
  2404. //
  2405. // OS_THREAD_MUTEX_ACQUIRE(&g_BMCInfo[BMCInst].SensorSharedMemMutex, WAIT_INFINITE);
  2406. //
  2407. // for (i = StartingEntityInstance; i < MAX_SENSOR_NUMBERS + 1; i++ )
  2408. // {
  2409. // if ((TRUE == pSenSharedMem->SensorInfo [i].IsDCMITempsensor) && (pSenSharedMem->SensorInfo[i].SDRRec->Type == FULL_SDR_REC) )
  2410. // {
  2411. //
  2412. // if(SensorType != pSenSharedMem->SensorInfo[i].SensorTypeCode)
  2413. // {
  2414. // /*Check the Sensor type*/
  2415. // continue;
  2416. // }
  2417. //
  2418. // 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))) ||
  2419. // (((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))) ||
  2420. // (((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))))
  2421. // {
  2422. // *pTotalValidInstances += 1;
  2423. // if (ValidInstances < 8)
  2424. // {
  2425. // if( !( pSenSharedMem->SensorInfo[i].EventFlags & 0x40) || (pSenSharedMem->SensorInfo[i].EventFlags & 0x20) )
  2426. // {
  2427. // pBuf[DCMI_TEMP_READING + j] = 0;
  2428. // pBuf[DCMI_INST_NUMBER + j] = 0;
  2429. // j = j+2;
  2430. // }
  2431. // else
  2432. // {
  2433. // pSDRRec = GetSDRRec(pSenSharedMem->SensorInfo[i].SDRRec->ID,BMCInst);
  2434. // FullSDR = (_FAR_ FullSensorRec_T *)pSDRRec;
  2435. // MinReading = FullSDR->MinReading;
  2436. // MaxReading = FullSDR->MaxReading;
  2437. // Linear = FullSDR->Linearization;
  2438. //
  2439. // 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,
  2440. // pSenSharedMem->SensorInfo[i].B_LSB, pSenSharedMem->SensorInfo[i].M_MSB_Tolerance, pSenSharedMem->SensorInfo[i].B_MSB_Accuracy, pSenSharedMem->SensorInfo[i].RExp_BExp);
  2441. //
  2442. // pBuf[ j++] = (INT8)convreading;
  2443. // pBuf[ j++] = pSenSharedMem->SensorInfo[i].EntiryInstance;
  2444. // TDBG("j value %d\n",j);
  2445. // }
  2446. // ValidInstances += 1;
  2447. // }
  2448. // }
  2449. // }
  2450. // }
  2451. //
  2452. // OS_THREAD_MUTEX_RELEASE(&g_BMCInfo[BMCInst].SensorSharedMemMutex);
  2453. // return (ValidInstances > 8) ? 8: ValidInstances;
  2454. //
  2455. // }
  2456. }
  2457. #endif /* SENSOR_DEVICE */