12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546 |
- /*****************************************************************
- *****************************************************************
- *** **
- *** (C)Copyright 2005-2006, American Megatrends Inc. **
- *** **
- *** All Rights Reserved. **
- *** **
- *** 6145-F, Northbelt Parkway, Norcross, **
- *** **
- *** Georgia - 30071, USA. Phone-(770)-246-8600. **
- *** **
- *****************************************************************
- *****************************************************************
- ******************************************************************
- *
- * sensor.c
- * Sensor functions.
- *
- * Author: Govind Kothandapani <govindk@ami.com>
- * Bakka Ravinder Reddy <bakkar@ami.com>
- ******************************************************************/
- #define ENABLE_DEBUG_MACROS 0
- //#include <dlfcn.h>
- #include <math.h>
- #include "Types.h"
- //#include "Debug.h"
- #include "MsgHndlr.h"
- //#include "Sensor.h"
- #include "Support.h"
- //#include "IPMIDefs.h"
- #include "IPMI_Sensor.h"
- //#include "SensorMonitor.h"
- //#include "SDRFunc.h"
- //#include "SDR.h"
- //#include "Util.h"
- #include "IPMI_Main.h"
- #include "SharedMem.h"
- #include "AppDevice.h"
- #include "IPMI_KCS.h"
- #include "IPMI_SEL.h"
- #include "Message.h"
- //#include "OSPort.h"
- //#include "PEF.h"
- //#include "SEL.h"
- //#include "FRU.h"
- //#include "PDKAccess.h"
- //#include "PDKCmdsAccess.h"
- #include "IPMIConf.h"
- #include "IPMI_FRU.h"
- //#include "sensor_helpers.h"
- //#include "featuredef.h"
- /* Reserved bit macro definitions */
- #define RESERVED_BITS_SETSENSORTYPE 0X80 //(BIT7)
- #define RESERVED_BITS_REARMSENSOR_REARMALLEVENTS 0X7F //(BIT6 | BIT5 | BIT4 | BIT3 | BIT2 | BIT1 | BIT0)
- #define RESERVED_BITS_REARMSENSOR_REARMASSEVT2_1 0XF0 //(BIT7 | BIT6 | BIT5 | BIT4)
- #define RESERVED_BITS_REARMSENSOR_REARMDEASSEVT2_1 0XF0 //(BIT7 | BIT6 | BIT5 | BIT4)
- #define RESERVED_BITS_REARMSENSOR_REARMASSEVT2_2 0X80 //(BIT7)
- #define RESERVED_BITS_REARMSENSOR_REARMDEASSEVT2_2 0X80 //(BIT7)
- #define RESERVED_BITS_SETSENSORTHRESHOLDS 0XC0 //(BIT7 | BIT6)
- #define RESERVED_BITS_SETSENEVTEN_FLAGS 0X0F //(BIT3 | BIT2 | BIT1 | BIT0)
- #define RESERVED_BITS_SETSENEVTEN_ASSERTIONMASK 0X8000
- #define RESERVED_BITS_SETSENEVTEN_DEASSERTIONMASK 0X8000
- #define RESERVED_BITS_SETSENRD_ASSEVTOCCBYTE_1 0xF0 //(BIT7 | BIT6 | BIT5 | BIT4)
- #define RESERVED_BITS_SETSENRD_DEASSEVTOCCBYTE_1 0xF0 //(BIT7 | BIT6 | BIT5 | BIT4)
- #define RESERVED_BITS_SETSENRD_ASSEVTOCCBYTE_2 0x80 //(BIT7)
- #define RESERVED_BITS_SETSENRD_DEASSEVTOCCBYTE_2 0x80 //(BIT7)
- #define SENSOR_THRESOLD_ACCESS_BITS 0x0c //(BIT2 | BIT3)
- #define SENSOR_HYSTERESIS_ACCESS_BITS 0x30 //(BIT4 | BIT5)
- #if SENSOR_DEVICE == 1
- /*** Local Definitions ***/
- #define NUM_SENSORS(BMCInst) (g_BMCInfo[BMCInst].SenConfig.NumThreshSensors + g_BMCInfo[BMCInst].SenConfig.NumNonThreshSensors)
- #define FULL_SDR_REC 0x01
- #define COMPACT_SDR_REC 0x02
- #define OEM_SDR_FRU_REC 0xf1
- #define OEM_SDR_NM_REC 0x0D
- #define FL_STATIC_SENSOR 0x00
- #define FL_NUM_LUN(NUM_LUN) NUM_LUN
- #define LWR_NON_CRIT 0x01
- #define LWR_CRIT 0x02
- #define LWR_NON_REC 0x04
- #define UPR_NON_CRIT 0x08
- #define UPR_CRIT 0x10
- #define UPR_NON_REC 0x20
- #define EVENT_MSG_MASK 0x80
- #define SCAN_MASK 0x40
- #define ENABLE_DISABLE_EVENT_MASK 0x30
- #define DO_NOT_CHANGE 0x00
- #define ENABLE_SELECTED_EVENT_MSG 0x10
- #define DISABLE_SELECTED_EVENT_MSG 0x20
- #define CC_INVALID_ATTEMPT_TO_SET 0x80
- #define MIN_SET_SEN_READING_CMD_LEN 3
- #define LEN_FOR_EVT_DATA 10
- #define MAX_SET_SEN_READ_LEN 10
- #define LEN_FOR_ASSERT_DATA 5
- #define LEN_FOR_DEASSERT_DATA 7
- #define LEN_FOR_SETSENSOR_DATA 3
- #define NOT_FOUND_SCAN_DISABLED -1
- #define NOT_FOUND_SCAN_ENABLED -2
- #define ENTITY_FOUND 1
- #define ENTITY_NOT_FOUND 0
- #define DCMI_TEMP_READING 0x0
- #define DCMI_INST_NUMBER 0x1
- /*** Local typedefs ***/
- /**
- * @struct SR_SensorInfo_T
- * @brief Sensor Information.
- **/
- typedef struct
- {
- /* CAUTION Order of members dependent on Response structures */
- INT8U M_LSB;
- INT8U M_MSB_Tolerance;
- INT8U B_LSB;
- INT8U B_MSB_Accuracy;
- INT8U Accuracy_MSB_Exp;
- INT8U RExp_BExp;
- INT8U PositiveHysterisis;
- INT8U NegativeHysterisis;
- INT8U LowerNonCritical;
- INT8U LowerCritical;
- INT8U LowerNonRecoverable;
- INT8U UpperNonCritical;
- INT8U UpperCritical;
- INT8U UpperNonRecoverable;
- INT8U EventFlags;
- INT16U AssertionMask;
- INT16U DeAssertionMask;
- INT8U EventTypeCode;
- INT16U ReadWriteThreshMask;
- INT8U SensorInit;
- INT8U SensorNum;
- } SR_SensorInfo_T;
- /*** Global Variables ***/
- //_FAR_ INT8U g_NumThreshSensors;
- //_FAR_ INT8U g_NumNonThreshSensors;
- //_FAR_ INT8U g_FRUInfo[MAX_PDK_FRU_SUPPORTED];
- //FRUInfo_T *m_FRUInfo[MAX_PDK_FRU_SUPPORTED];
- //INT8U m_total_frus=0;
- //Sensor-Type Sensor-specific-offset
- //static const INT8U sensor_presence [][2] = {
- // {PROCESSOR, PROCESSOR_PRESENCE_DETECTED},
- // {POWER_SUPPLY, POWER_SUPPLY_PRESENCE_DETECTED},
- // {POWER_SUPPLY, POWER_SUPPLY_OUT_OF_RANGE_PRESENT},
- // {MEMORY, MEMORY_PRESENCE_DETECTED},
- // {ENTITY_PRESENCE, ENTITY_PRESENCE_ENTITY_PRESENT},
- // {BATTERY, BATTERY_PRESENCE_DETECTED}
- //};
- #define SENSOR_PRESENCE_COUNT (sizeof(sensor_presence)/ sizeof(sensor_presence[0]))
- /*** Prototype Declaration ***/
- static void FindNumSensors (int BMCInst);
- /*---------------------------------------
- * InitSensor
- *---------------------------------------*/
- int
- InitSensor (int BMCInst)
- {
- // _FAR_ SDRRecHdr_T* sr;
- // _FAR_ FullSensorRec_T* sfs;
- // _FAR_ CompactSensorRec_T* scs;
- // _FAR_ FRUDevLocatorRec_T *sfr;
- // _FAR_ OEM_FRURec_T* sof;
- // INT16U SharedRecs = 0;
- // INT8U NodeManager = 0;
- // INT16U LUN_SensorNum = 0; /* Multi-LUN support index */
- // int i = 0,len=0,fruvalid=0;
- // _FAR_ BMCInfo_t* pBMCInfo = &g_BMCInfo[BMCInst];
- // INT8U Index=0,FruAddress = 0;
- // _FAR_ SensorSharedMem_T* pSenSharedMem;
- // char *str,*saveptr,*tempbuf;
- //
- // memset(&pBMCInfo->SenConfig.HealthState,0, sizeof(HealthState_T));;
- // /* If we didnt initalize the g_FRUInfo to 0xff and if SDR type #11 is not present then
- // It makes infinity FRU test loop */
- // memset(pBMCInfo->FRUConfig.FRUInfo,0xff,MAX_PDK_FRU_SUPPORTED);
- //
- // /* Get the Sensor Shared Memory */
- // pSenSharedMem = (_FAR_ SensorSharedMem_T*)&pBMCInfo->SensorSharedMem; //m_hSensorSharedMem;
- //
- // /* Create mutex for Sensor shared memory */
- // OS_THREAD_MUTEX_INIT(g_BMCInfo[BMCInst].SensorSharedMemMutex, PTHREAD_MUTEX_RECURSIVE);
- //
- //
- // /* Find No.of Threshold and Non Threshold Sensors */
- // FindNumSensors (BMCInst);
- //
- // IPMI_DBG_PRINT ("Init Sensor\n");
- //
- // if (0 == (g_BMCInfo[BMCInst].SenConfig.NumThreshSensors + g_BMCInfo[BMCInst].SenConfig.NumNonThreshSensors))
- // {
- // IPMI_WARNING ("Sensor.c : There are no sensors\n");
- // return -1;
- // }
- //
- // /* Acquire Shared memory to populate sensor information */
- // OS_THREAD_MUTEX_ACQUIRE(&g_BMCInfo[BMCInst].SensorSharedMemMutex, WAIT_INFINITE)
- //
- // sr = SDR_GetFirstSDRRec (BMCInst);
- //
- //
- // while (0 != sr)
- // {
- //
- // // printf("InitSensor\n");
- // // Populater sensor information for Threshold sensors
- // if (sr->Type == FULL_SDR_REC)
- // {
- // sfs = (_FAR_ FullSensorRec_T*) sr;
- // if(g_corefeatures.node_manager == ENABLED)
- // {
- // if (sfs->OwnerID == pBMCInfo->NMConfig.NMDevSlaveAddress)
- // {
- // NodeManager = 1;
- // }
- // }
- // else
- // {
- // NodeManager = 0;
- // }
- //
- // LUN_SensorNum = (((sfs->OwnerLUN & VALID_LUN) << 8) | sfs->SensorNum); /* Multi-LUN support */
- // IPMI_DBG_PRINT_3("LUN_SensorNum = %x sfs->OwnerLUN = %x sfs->SensorNum = %x \n",LUN_SensorNum, sfs->OwnerLUN, sfs->SensorNum);
- //
- // if ((sfs->OwnerID == pBMCInfo->IpmiConfig.BMCSlaveAddr) || (NodeManager))
- // {
- // pSenSharedMem->SensorInfo[LUN_SensorNum].IsSensorPresent = TRUE; /* Multi-LUN support */
- // IPMI_DBG_PRINT_1("#### pSensorSharedMem->SensorInfo[%x].IsSensorPresent = TRUE ####\n",LUN_SensorNum);
- // SR_LoadSDRDefaults (sr, (SensorInfo_T*)&pSenSharedMem->SensorInfo[LUN_SensorNum],BMCInst); /* Multi-LUN support */
- // // SDR Record information
- // pSenSharedMem->SensorInfo[LUN_SensorNum].SDRRec = sr; /* Multi-LUN support */
- //
- // /* Update Init Done flag */
- // SET_SM_INIT_DONE(pSenSharedMem->SensorInfo [LUN_SensorNum].EventFlags); /* Multi-LUN support */
- //
- // if(pBMCInfo->IpmiConfig.DCMISupport == 1)
- // {
- // pSenSharedMem->SensorInfo[LUN_SensorNum].IsDCMITempsensor = TRUE;
- // pSenSharedMem->SensorInfo[LUN_SensorNum].EntityID = sfs->EntityID;
- // pSenSharedMem->SensorInfo[LUN_SensorNum].EntiryInstance = sfs->EntityIns;
- // pSenSharedMem->SensorInfo[LUN_SensorNum].RecordID = sfs->hdr.ID;
- // }
- // }
- //
- // if( SENSOR_TYPE_SYSTEM_EVENT == sfs->SensorType)
- // {
- // BMC_GET_SHARED_MEM(BMCInst)->SysEvent_SensorNo =sfs->SensorNum;
- // }
- // }
- // else if (sr->Type == COMPACT_SDR_REC)
- // {
- // scs = (_FAR_ CompactSensorRec_T*) sr;
- //
- // if(g_corefeatures.node_manager == ENABLED)
- // {
- // if (scs->OwnerID == pBMCInfo->NMConfig.NMDevSlaveAddress)
- // NodeManager = 1;
- // }
- // else
- // {
- // NodeManager = 0;
- // }
- // LUN_SensorNum = ((scs->OwnerLUN & VALID_LUN) << 8 | scs->SensorNum); /* Multi-LUN support */
- // IPMI_DBG_PRINT_3("LUN_SensorNum = %x scs->OwnerLUN = %x scs->SensorNum = %x \n",LUN_SensorNum,scs->OwnerLUN,scs->SensorNum);
- // if ((scs->OwnerID == pBMCInfo->IpmiConfig.BMCSlaveAddr) || (NodeManager))
- // {
- // pSenSharedMem->SensorInfo[LUN_SensorNum].IsSensorPresent = TRUE; /* Multi-LUN support */
- // IPMI_DBG_PRINT_1("#### pSensorSharedMem->SensorInfo[%x].IsSensorPresent = TRUE ####\n",LUN_SensorNum);
- // SR_LoadSDRDefaults (sr, (SensorInfo_T*)&pSenSharedMem->SensorInfo[LUN_SensorNum],BMCInst); /* Multi-LUN support */
- //
- // // SDR Record information
- // pSenSharedMem->SensorInfo[LUN_SensorNum].SDRRec = sr; /* Multi-LUN support */
- //
- // SharedRecs = ipmitoh_u16 (((_FAR_ CompactSensorRec_T*) sr)->RecordSharing) &
- // SHARED_RECD_COUNT;
- // IPMI_DBG_PRINT_2 ("Sen %x , Shared Count - %x\n", scs->SensorNum, SharedRecs);
- //
- // /* Update Init Done flag */
- // SET_SM_INIT_DONE(pSenSharedMem->SensorInfo [LUN_SensorNum].EventFlags); /* Multi-LUN support */
- //
- // /* Check if Record is shared */
- // if (SharedRecs > 1)
- // {
- // for (i = 1; i < SharedRecs; i++)
- // {
- // pSenSharedMem->SensorInfo[LUN_SensorNum + i].IsSensorPresent = TRUE; /* Multi-LUN support */
- // SR_LoadSDRDefaults (sr, (SensorInfo_T*)&pSenSharedMem->SensorInfo[LUN_SensorNum + i],BMCInst); /* Multi-LUN support */
- // pSenSharedMem->SensorInfo[LUN_SensorNum + i].SensorNumber = scs->SensorNum + i; /* Multi-LUN support */
- //
- // // SDR Record information
- // pSenSharedMem->SensorInfo[LUN_SensorNum + i].SDRRec = sr; /* Multi-LUN support */
- //
- // /* Update Init Done flag */
- // SET_SM_INIT_DONE(pSenSharedMem->SensorInfo [LUN_SensorNum + i].EventFlags); /* Multi-LUN support */
- // }
- // }
- //
- // if(pBMCInfo->IpmiConfig.DCMISupport == 1)
- // {
- // pSenSharedMem->SensorInfo[LUN_SensorNum].IsDCMITempsensor = TRUE;
- // pSenSharedMem->SensorInfo[LUN_SensorNum].EntityID = scs->EntityID;
- // pSenSharedMem->SensorInfo[LUN_SensorNum].EntiryInstance = scs->EntityIns;
- // pSenSharedMem->SensorInfo[LUN_SensorNum].RecordID = scs->hdr.ID;
- // }
- //
- // }
- //
- // if( SENSOR_TYPE_SYSTEM_EVENT == scs->SensorType )
- // {
- // BMC_GET_SHARED_MEM(BMCInst)->SysEvent_SensorNo =scs->SensorNum;
- // }
- // }
- // else if(sr->Type == FRU_DEVICE_LOCATOR_SDR_REC)
- // {
- // sfr = (_FAR_ FRUDevLocatorRec_T*) sr;
- // /* Collecting the Logical FRU Device ID */
- // if((sfr->AccessLUNBusID & 0x80) == 0x80)
- // {
- // if(g_PDKHandle[PDK_FRUGETDEVADDRESS] != NULL)
- // {
- // if(((int(*)(INT8U,INT8U*,int))g_PDKHandle[PDK_FRUGETDEVADDRESS]) (sfr->FRUIDSlaveAddr,&FruAddress,BMCInst) == -1)
- // {
- // IPMI_WARNING("FRU Device Address cannot be found for FRU ID %x \n",sfr->FRUIDSlaveAddr);
- // sr = SDR_GetNextSDRRec (sr,BMCInst);
- // continue;
- // }
- // }
- // else
- // {
- // sr = SDR_GetNextSDRRec (sr,BMCInst);
- // continue;
- // }
- // pBMCInfo->FRUConfig.FRUInfo[Index++]=sfr->FRUIDSlaveAddr;
- // pBMCInfo->FRUConfig.FRUInfo[Index]= 0xff;
- // pBMCInfo->FRUConfig.m_FRUInfo[pBMCInfo->FRUConfig.total_frus]=(FRUInfo_T*)malloc(sizeof(FRUInfo_T));
- // pBMCInfo->FRUConfig.m_FRUInfo[pBMCInfo->FRUConfig.total_frus]->IsInternalFRU=0;
- // pBMCInfo->FRUConfig.m_FRUInfo[pBMCInfo->FRUConfig.total_frus]->Size=FRU_FILE_SIZE;
- // pBMCInfo->FRUConfig.m_FRUInfo[pBMCInfo->FRUConfig.total_frus]->AccessType=DEV_ACCESS_MODE_IN_BYTES;
- // pBMCInfo->FRUConfig.m_FRUInfo[pBMCInfo->FRUConfig.total_frus]->Offset=0;
- // pBMCInfo->FRUConfig.m_FRUInfo[pBMCInfo->FRUConfig.total_frus]->DeviceID=sfr->FRUIDSlaveAddr;
- // pBMCInfo->FRUConfig.m_FRUInfo[pBMCInfo->FRUConfig.total_frus]->Type=FRU_TYPE_EEPROM;
- // //pBMCInfo->FRUConfig.m_FRUInfo[pBMCInfo->FRUConfig.total_frus]->NVRFile=NULL;
- // pBMCInfo->FRUConfig.m_FRUInfo[pBMCInfo->FRUConfig.total_frus]->SlaveAddr=FruAddress;
- // pBMCInfo->FRUConfig.m_FRUInfo[pBMCInfo->FRUConfig.total_frus]->DeviceType=sfr->DevType;
- // pBMCInfo->FRUConfig.m_FRUInfo[pBMCInfo->FRUConfig.total_frus]->BusNumber = (sfr->AccessLUNBusID & 0x07);
- // strcpy((char *)pBMCInfo->FRUConfig.m_FRUInfo[pBMCInfo->FRUConfig.total_frus]->FRUName,sfr->DevIdStr);
- // pBMCInfo->FRUConfig.total_frus++;
- // }
- // }
- // else if (sr->Type == OEM_SDRFRU_REC)
- // {
- // sof=(_FAR_ OEM_FRURec_T*)sr;
- //
- // if(sof->OEM_Fru==OEM_SDR_FRU_REC)
- // {
- // for(i=0;i < MAX_FRU_SDR_STR_SIZE;i++)
- // {
- // if(sof->FilePath[i] == ':')
- // {
- // fruvalid = TRUE;
- // }
- // }
- //
- // if(fruvalid == TRUE)
- // {
- // pBMCInfo->FRUConfig.FRUInfo[Index++]=sof->DeviceID;
- // pBMCInfo->FRUConfig.FRUInfo[Index]=0xff;
- // pBMCInfo->FRUConfig.m_FRUInfo[pBMCInfo->FRUConfig.total_frus]=(FRUInfo_T*)malloc(sizeof(FRUInfo_T));
- // pBMCInfo->FRUConfig.m_FRUInfo[pBMCInfo->FRUConfig.total_frus]->IsInternalFRU=0;
- // pBMCInfo->FRUConfig.m_FRUInfo[pBMCInfo->FRUConfig.total_frus]->Size=sof->Size;
- // pBMCInfo->FRUConfig.m_FRUInfo[pBMCInfo->FRUConfig.total_frus]->AccessType=sof->AccessType;
- // pBMCInfo->FRUConfig.m_FRUInfo[pBMCInfo->FRUConfig.total_frus]->Offset=0;
- // pBMCInfo->FRUConfig.m_FRUInfo[pBMCInfo->FRUConfig.total_frus]->DeviceID=sof->DeviceID;
- // pBMCInfo->FRUConfig.m_FRUInfo[pBMCInfo->FRUConfig.total_frus]->Type=FRU_TYPE_NVR;
- // str = sof->FilePath;
- // tempbuf = strtok_r(str,":",&saveptr);
- // strcpy(pBMCInfo->FRUConfig.m_FRUInfo[pBMCInfo->FRUConfig.total_frus]->NVRFile,tempbuf);
- // len = strlen(tempbuf);
- // strcpy(pBMCInfo->FRUConfig.m_FRUInfo[pBMCInfo->FRUConfig.total_frus]->FRUName,&sof->FilePath[++len]);
- // pBMCInfo->FRUConfig.m_FRUInfo[pBMCInfo->FRUConfig.total_frus]->SlaveAddr=0;
- // pBMCInfo->FRUConfig.m_FRUInfo[pBMCInfo->FRUConfig.total_frus]->DeviceType=0;
- // pBMCInfo->FRUConfig.total_frus++;
- // }
- // fruvalid = 0;
- // }
- // }
- //
- // /* Get the next record */
- // sr = SDR_GetNextSDRRec (sr,BMCInst);
- // }
- //
- // /* Release mutex for Sensor shared memory */
- // //OS_RELEASE_MUTEX(m_hSensorSharedMemMutex)
- // OS_THREAD_MUTEX_RELEASE(&g_BMCInfo[BMCInst].SensorSharedMemMutex);
- //
- //
- // IPMI_DBG_PRINT ("Initilized Sensor\n");
- //
- // return 0;
- }
- /*-----------------------------------------
- * SR_FindSDR
- *-----------------------------------------*/
- SDRRecHdr_T*
- SR_FindSDR (INT8U SensorNum, INT8U SensorOwnerLUN, int BMCInst) /* Multi-LUN support to find the SDR based on OwnerLUN and Sensor Number */
- {
- // _FAR_ SDRRecHdr_T* sr = NULL;
- // _FAR_ FullSensorRec_T* sfs = NULL;
- // _FAR_ CompactSensorRec_T* scs = NULL;
- // INT16U SharedRecs = 0;
- // INT8U NodeManager = 0;
- //
- // sr = SDR_GetFirstSDRRec (BMCInst);
- // _FAR_ SensorSharedMem_T* pSenSharedMem;
- // _FAR_ BMCInfo_t* pBMCInfo = &g_BMCInfo[BMCInst];
- // pSenSharedMem = (_FAR_ SensorSharedMem_T*)&pBMCInfo->SensorSharedMem; //m_hSensorSharedMem;
- //
- //
- // while (0 != sr)
- // {
- //
- // // Populater sensor information for Threshold sensors
- // if (sr->Type == FULL_SDR_REC)
- // {
- // sfs = (_FAR_ FullSensorRec_T*) sr;
- //
- // if ((sfs->SensorNum == SensorNum) && (sfs->OwnerLUN == SensorOwnerLUN) && ((pBMCInfo->IpmiConfig.BMCSlaveAddr == sfs->OwnerID) || (pBMCInfo->NMConfig.NMDevSlaveAddress == sfs->OwnerID)) ){ return sr; } /* Multi-LUN support */
- // }
- // else if (sr->Type == COMPACT_SDR_REC)
- // {
- // scs = (_FAR_ CompactSensorRec_T*) sr;
- // if(g_corefeatures.node_manager == ENABLED)
- // {
- // if (pBMCInfo->NMConfig.NMDevSlaveAddress == scs->OwnerID)
- // NodeManager = 1;
- // }
- // else
- // {
- // NodeManager = 0;
- // }
- // if ((pBMCInfo->IpmiConfig.BMCSlaveAddr == scs->OwnerID) || (NodeManager))
- // {
- // SharedRecs = ipmitoh_u16 (((_FAR_ CompactSensorRec_T*) sr)->RecordSharing) &
- // SHARED_RECD_COUNT;
- // IPMI_DBG_PRINT_2 ("Sen %x , Shared Count - %x\n", scs->SensorNum, SharedRecs);
- //
- // /* Update Init Done flag */
- // SET_SM_INIT_DONE(pSenSharedMem->SensorInfo [((scs->OwnerLUN & VALID_LUN) << 8) | scs->SensorNum].EventFlags); /* Multi-LUN support */
- //
- // /* Check if Record is shared */
- // if (SharedRecs > 1)
- // {
- // IPMI_DBG_PRINT_2 ("scs->SensorNum - %x, %x\n", scs->SensorNum, SensorNum);
- // if ((SensorNum >= scs->SensorNum) && (scs->OwnerLUN == SensorOwnerLUN) && (SensorNum < (scs->SensorNum + SharedRecs))) { return sr; } /* Multi-LUN support */
- // }
- // else
- // {
- // if ((scs->SensorNum == SensorNum) && (scs->OwnerLUN == SensorOwnerLUN)) { return sr; } /* Multi-LUN support */
- // }
- // }
- // }
- //
- // /* Get the next record */
- // sr = SDR_GetNextSDRRec (sr,BMCInst);
- // }
- //
- // return NULL;
- }
- /*-----------------------------------------
- * SR_LoadSDRDefaults
- * CAUTION !! this function has to be called
- * after acquiring a sensor shared memory mutex
- *-----------------------------------------*/
- extern void
- SR_LoadSDRDefaults (SDRRecHdr_T* sr, _FAR_ SensorInfo_T* pSensorInfo,int BMCInst)
- {
- // _FAR_ FullSensorRec_T* sfs;
- // _FAR_ CompactSensorRec_T* scs;
- // BMCInfo_t *pBMCInfo = &g_BMCInfo[BMCInst];
- //
- // // Populater sensor information for Threshold sensors
- // if (sr->Type == FULL_SDR_REC)
- // {
- // sfs = (_FAR_ FullSensorRec_T*) sr;
- //
- // pSensorInfo->SensorOwnerLun = sfs->OwnerLUN; /* Multi-LUN support */
- // pSensorInfo->SensorNumber = sfs->SensorNum;
- // pSensorInfo->M_LSB = sfs->M;
- // pSensorInfo->M_MSB_Tolerance = sfs->M_Tolerance;
- // pSensorInfo->B_LSB = sfs->B;
- // pSensorInfo->B_MSB_Accuracy = sfs->B_Accuracy;
- // pSensorInfo->Accuracy_MSB_Exp = sfs->Accuracy;
- // pSensorInfo->RExp_BExp = sfs->R_B_Exp;
- // pSensorInfo->Units1 = sfs->Units1;
- // pSensorInfo->Units2 = sfs->Units2;
- // pSensorInfo->Units3 = sfs->Units3;
- //
- // pSensorInfo->PosHysteresis = sfs->PositiveHysterisis;
- // pSensorInfo->NegHysteresis = sfs->NegativeHysterisis;
- //
- // pSensorInfo->SensorInit = sfs->SensorInit;
- // pSensorInfo->SettableThreshMask = ipmitoh_u16(sfs->DiscreteReadingMask);
- // pSensorInfo->SensorCaps = sfs->SensorCaps;
- // pSensorInfo->SensorTypeCode = sfs->SensorType;
- // pSensorInfo->OEMField = sfs->OEMField ;
- //
- // if (pSensorInfo->SensorInit & BIT4)
- // {
- // if (pSensorInfo->SettableThreshMask & BIT8)
- // {
- // pSensorInfo->LowerNonCritical = sfs->LowerNonCritical;
- // }
- // if (pSensorInfo->SettableThreshMask & BIT9)
- // {
- // pSensorInfo->LowerCritical = sfs->LowerCritical;
- // }
- // if (pSensorInfo->SettableThreshMask & BIT10)
- // {
- // pSensorInfo->LowerNonRecoverable = sfs->LowerNonRecoverable;
- // }
- // if (pSensorInfo->SettableThreshMask & BIT11)
- // {
- // pSensorInfo->UpperNonCritical = sfs->UpperNonCritical;
- // }
- // if (pSensorInfo->SettableThreshMask & BIT12)
- // {
- // pSensorInfo->UpperCritical = sfs->UpperCritical;
- // }
- // if (pSensorInfo->SettableThreshMask & BIT13)
- // {
- // pSensorInfo->UpperNonRecoverable = sfs->UpperNonRecoverable;
- // }
- // }
- //
- // pSensorInfo->EventFlags = 0;
- // pSensorInfo->EventFlags |= sfs->SensorInit & BIT6;
- // pSensorInfo->EventFlags |= (sfs->SensorInit & BIT5) << 2;
- // pSensorInfo->EventFlags |= sfs->SensorInit & BIT5;
- // pSensorInfo->AssertionEventEnablesByte1 = ipmitoh_u16(sfs->AssertionEventMask) & 0xFF;
- // pSensorInfo->AssertionEventEnablesByte2 = (ipmitoh_u16(sfs->AssertionEventMask) >> 8) & 0xFF;
- //
- // pSensorInfo->DeassertionEventEnablesByte1= ipmitoh_u16(sfs->DeAssertionEventMask) & 0xFF;
- //
- // pSensorInfo->DeassertionEventEnablesByte2= (ipmitoh_u16(sfs->DeAssertionEventMask) >> 8) & 0xFF;
- //
- // pSensorInfo->EventTypeCode = sfs->EventTypeCode;
- // pSensorInfo->SensorReadType = sfs->EventTypeCode;
- // pSensorInfo->InternalFlags = 0;
- // // pSensorInfo->InternalFlags |= BIT0; // Disable internal scanning by default
- //
- // // Check for a signed sensor
- // if (0x80 == (sfs->Units1 & 0xC0))
- // {
- // pSensorInfo->InternalFlags |= BIT1;
- // }
- // if (pBMCInfo->IpmiConfig.OPMASupport == 1)
- // {
- // pSensorInfo->SensorOwnerLun = sfs->OwnerLUN ;
- // OPMA_Config_T* OPMAconfig = &pBMCInfo->OPMAConfig;
- // int SensorIdx =0 ;
- //
- // for ( SensorIdx = 0 ; SensorIdx < MAX_SENSOR_NUMBERS ; SensorIdx++ )
- // {
- // if (!OPMAconfig->SensorOffsetInfo [SensorIdx] .valid) continue;
- // if ( ( OPMAconfig->SensorOffsetInfo [SensorIdx] .SensorNo == pSensorInfo->SensorNumber ) &&
- // ( OPMAconfig->SensorOffsetInfo [SensorIdx] .SensorLUN == pSensorInfo->SensorOwnerLun ) )
- // {
- // pSensorInfo->SenReadingOffset = OPMAconfig->SensorOffsetInfo [SensorIdx] .Offset;
- // break;
- // }
- // }
- // }
- // }
- // else if (sr->Type == COMPACT_SDR_REC)
- // {
- // scs = (_FAR_ CompactSensorRec_T*) sr;
- //
- // pSensorInfo->SensorOwnerLun = scs->OwnerLUN; /* Multi-LUN support */
- // pSensorInfo->SensorNumber = scs->SensorNum;
- // pSensorInfo->EventFlags = 0;
- // pSensorInfo->EventFlags |= scs->SensorInit & BIT6;
- // pSensorInfo->EventFlags |= (scs->SensorInit & BIT5) << 2;
- // pSensorInfo->EventFlags |= scs->SensorInit & BIT5;
- // pSensorInfo->AssertionEventEnablesByte1 = ipmitoh_u16(scs->AssertionEventMask) & 0xFF;
- // pSensorInfo->AssertionEventEnablesByte2 = (ipmitoh_u16(scs->AssertionEventMask) >> 8) & 0xFF;
- //
- // pSensorInfo->DeassertionEventEnablesByte1= ipmitoh_u16(scs->DeAssertionEventMask) & 0xFF;
- //
- // pSensorInfo->DeassertionEventEnablesByte2= (ipmitoh_u16(scs->DeAssertionEventMask) >> 8) & 0xFF;
- // pSensorInfo->SensorInit = scs->SensorInit;
- // pSensorInfo->SettableThreshMask = ipmitoh_u16(scs->DiscreteReadingMask);
- // pSensorInfo->PosHysteresis = scs->PositiveHysteris;
- // pSensorInfo->NegHysteresis = scs->NegativeHysterisis;
- // pSensorInfo->EventTypeCode = scs->EventTypeCode;
- // pSensorInfo->SensorReadType = scs->EventTypeCode;
- // pSensorInfo->SensorTypeCode = scs->SensorType;
- // pSensorInfo->SensorCaps = scs->SensorCaps;
- //
- // pSensorInfo->Units1 = scs->Units1;
- // pSensorInfo->Units2 = scs->Units2;
- // pSensorInfo->Units3 = scs->Units3;
- // pSensorInfo->InternalFlags = 0;
- // // pSensorInfo->InternalFlags |= BIT0; // Disable internal scanning by default
- //
- // // Check for a signed sensor
- // if (0x80 == (scs->Units1 & 0xC0))
- // {
- // pSensorInfo->InternalFlags |= BIT1;
- // }
- // if (pBMCInfo->IpmiConfig.OPMASupport == 1)
- // {
- // pSensorInfo->SensorOwnerLun = scs->OwnerLUN ;
- // BMCInfo_t *pBMCInfo = &g_BMCInfo[BMCInst];
- // OPMA_Config_T* OPMAconfig = &pBMCInfo->OPMAConfig;
- // int SensorIdx =0 ;
- //
- // for ( SensorIdx = 0 ; SensorIdx < MAX_SENSOR_NUMBERS ; SensorIdx++ )
- // {
- // if (!OPMAconfig->SensorOffsetInfo [SensorIdx] .valid) continue;
- // if ( ( OPMAconfig->SensorOffsetInfo [SensorIdx] .SensorNo == pSensorInfo->SensorNumber ) &&
- // ( OPMAconfig->SensorOffsetInfo [SensorIdx] .SensorLUN == pSensorInfo->SensorOwnerLun ) )
- // {
- // pSensorInfo->SenReadingOffset = OPMAconfig->SensorOffsetInfo [SensorIdx] .Offset;
- // break;
- // }
- // }
- // }
- //
- // pSensorInfo->OEMField = scs->OEMField ;
- // }
- // pSensorInfo->pPreMonitor = PreMonitorSensor;
- // pSensorInfo->pPostMonitor = PostMonitorSensor;
- }
- /*-----------------------------------------
- * GetDevSDRInfo
- *-----------------------------------------*/
- void
- SR_GetDevSDRInfo (_NEAR_ GetSDRInfoRes_T* GetSDRInfoRes,int BMCInst)
- {
- // GetSDRInfoRes->NumSensor = NUM_SENSORS(BMCInst);
- // GetSDRInfoRes->Flags = FL_STATIC_SENSOR + FL_NUM_LUN(0);
- // GetSDRInfoRes->TimeStamp = 0;
- // return;
- }
- /*---------------------------------------
- * GetDevSDRInfo
- *---------------------------------------*/
- int
- GetDevSDRInfo (_NEAR_ INT8U* pReq, INT8U ReqLen, _NEAR_ INT8U* pRes,_NEAR_ int BMCInst)
- {
- // _FAR_ SDRRecHdr_T* SDRRec;
- // BMCInfo_t *pBMCInfo = &g_BMCInfo[BMCInst];
- // _NEAR_ GetSDRInfoRes_T* pGetDevSDRInfoRes = (_NEAR_ GetSDRInfoRes_T*) pRes;
- // INT8U NumSensors = 0;
- //
- // OS_THREAD_MUTEX_ACQUIRE(&pBMCInfo->SDRConfig.SDRMutex, WAIT_INFINITE);
- // /* Count number of full and compact sensors */
- // SDRRec = SDR_GetFirstSDRRec (BMCInst);
- // while (0 != SDRRec)
- // {
- // if ((SDRRec->Type == FULL_SDR_REC) || (SDRRec->Type == COMPACT_SDR_REC)) { NumSensors++; }
- // /* Get the next record */
- // SDRRec = SDR_GetNextSDRRec (SDRRec,BMCInst);
- // }
- //
- // /* Fill in response data */
- // pGetDevSDRInfoRes->CompletionCode = CC_NORMAL;
- // pGetDevSDRInfoRes->NumSensor = NumSensors;
- // pGetDevSDRInfoRes->Flags = 0x01; /* BIT7 = 0 (static sensors), BIT0 = 1 (on LUN 0) */
- // pGetDevSDRInfoRes->TimeStamp = 0;
- // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->SDRConfig.SDRMutex);
- //
- // return sizeof (GetSDRInfoRes_T);
- }
- /*---------------------------------------
- * GetDevSDR
- *---------------------------------------*/
- int
- GetDevSDR (_NEAR_ INT8U* pReq, INT8U ReqLen, _NEAR_ INT8U* pRes,_NEAR_ int BMCInst)
- {
- // return GetSDR (pReq, ReqLen, pRes,BMCInst);
- }
- /*---------------------------------------
- * GetDevSDR
- *---------------------------------------*/
- int
- ReserveDevSDRRepository (_NEAR_ INT8U* pReq, INT8U ReqLen, _NEAR_ INT8U* pRes,_NEAR_ int BMCInst)
- {
- // return ReserveSDRRepository (pReq, ReqLen, pRes,BMCInst);
- }
- /*---------------------------------------
- * SetSensorType
- *---------------------------------------*/
- int
- SetSensorType (_NEAR_ INT8U* pReq, INT8U ReqLen, _NEAR_ INT8U* pRes,_NEAR_ int BMCInst)
- {
- // //pRes [0] = CC_INV_CMD;
- // //return sizeof (*pRes);
- // _NEAR_ SetSensorTypeReq_T * pSetSensorTypeReq=(_NEAR_ SetSensorTypeReq_T *)pReq;
- // _NEAR_ SetSensorTypeRes_T * pSetSensorTypeRes=(_NEAR_ SetSensorTypeRes_T *)pRes;
- // _FAR_ SensorSharedMem_T* pSenSharedMem;
- // _FAR_ BMCInfo_t* pBMCInfo = &g_BMCInfo[BMCInst];
- //
- //
- // /* Check for the reserved bytes should b zero */
- //
- // if ( 0 != (pSetSensorTypeReq->EventTypeCode & RESERVED_BITS_SETSENSORTYPE ) )
- // {
- // pSetSensorTypeRes->CompletionCode = CC_INV_DATA_FIELD;
- // return sizeof(*pRes);
- // }
- //
- // OS_THREAD_MUTEX_ACQUIRE(&g_BMCInfo[BMCInst].SensorSharedMemMutex, WAIT_INFINITE);
- // pSenSharedMem = (_FAR_ SensorSharedMem_T*)&pBMCInfo->SensorSharedMem; //m_hSensorSharedMem;
- //
- // if (!pSenSharedMem->SensorInfo [pSetSensorTypeReq->SensorNum].IsSensorPresent)
- // {
- // /* Release mutex for Sensor shared memory */
- // OS_THREAD_MUTEX_RELEASE(&g_BMCInfo[BMCInst].SensorSharedMemMutex);
- //
- // /* return sdr record not present completion code */
- // pSetSensorTypeRes->CompletionCode = CC_SDR_REC_NOT_PRESENT;
- // return sizeof (*pRes);
- // }
- //
- // pSenSharedMem->SensorInfo[pSetSensorTypeReq->SensorNum].SensorTypeCode=pSetSensorTypeReq->SensorType;
- // pSenSharedMem->SensorInfo[pSetSensorTypeReq->SensorNum].EventTypeCode=pSetSensorTypeReq->EventTypeCode;
- //
- // OS_THREAD_MUTEX_RELEASE(&g_BMCInfo[BMCInst].SensorSharedMemMutex);
- //
- // pSetSensorTypeRes->CompletionCode=CC_NORMAL;
- //
- // return sizeof(*pSetSensorTypeRes);
- }
- /*---------------------------------------
- * GetSensorType
- *---------------------------------------*/
- int
- GetSensorType (_NEAR_ INT8U* pReq, INT8U ReqLen, _NEAR_ INT8U* pRes,_NEAR_ int BMCInst)
- {
- // //pRes [0] = CC_INV_CMD;
- // // return sizeof (*pRes);
- //
- // _NEAR_ GetSensorTypeReq_T * pGetSensorTypeReq=(_NEAR_ GetSensorTypeReq_T *)pReq;
- // _NEAR_ GetSensorTypeRes_T * pGetSensorTypeRes=(_NEAR_ GetSensorTypeRes_T *)pRes;
- // _FAR_ SensorSharedMem_T* pSenSharedMem;
- // _FAR_ BMCInfo_t* pBMCInfo = &g_BMCInfo[BMCInst];
- // pSenSharedMem = (_FAR_ SensorSharedMem_T*)&pBMCInfo->SensorSharedMem; //m_hSensorSharedMem;
- //
- // OS_THREAD_MUTEX_ACQUIRE(&pBMCInfo->SensorSharedMemMutex, WAIT_INFINITE);
- //
- // if (!pSenSharedMem->SensorInfo [pGetSensorTypeReq->SensorNum].IsSensorPresent)
- // {
- // /* Release mutex for Sensor shared memory */
- // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->SensorSharedMemMutex);
- //
- // /* return sdr record not present completion code */
- // pGetSensorTypeRes->CompletionCode = CC_SDR_REC_NOT_PRESENT;
- // return sizeof (*pRes);
- // }
- //
- // pGetSensorTypeRes->CompletionCode=CC_NORMAL;
- // pGetSensorTypeRes->SensorType=pSenSharedMem->SensorInfo[pGetSensorTypeReq->SensorNum].SensorTypeCode;
- // pGetSensorTypeRes->EventTypeCode=pSenSharedMem->SensorInfo[pGetSensorTypeReq->SensorNum].EventTypeCode;
- //
- // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->SensorSharedMemMutex);
- //
- // return sizeof(*pGetSensorTypeRes);
- }
- /*---------------------------------------
- * ReArmSensor
- *---------------------------------------*/
- int
- ReArmSensor (_NEAR_ INT8U* pReq, INT8U ReqLen, _NEAR_ INT8U* pRes,_NEAR_ int BMCInst)
- {
- // _FAR_ MsgPkt_T Msg;
- // HQueue_T hSMHndlr_Q;
- // _NEAR_ ReArmSensorReq_T ReArmSensorReq;
- // _NEAR_ ReArmSensorReq_T* pReArmSensorReq = &ReArmSensorReq;
- // _NEAR_ ReArmSensorRes_T* pReArmSensorRes = (_NEAR_ ReArmSensorRes_T*) pRes;
- //
- // _fmemset (&ReArmSensorReq, 0, sizeof (ReArmSensorReq_T));
- // _fmemcpy (&ReArmSensorReq, pReq, ReqLen);
- // _FAR_ SensorSharedMem_T* pSenSharedMem;
- // _FAR_ BMCInfo_t* pBMCInfo = &g_BMCInfo[BMCInst];
- //
- // /* if request length is invalid */
- // if ((ReqLen < 2) || (ReqLen > sizeof (ReArmSensorReq_T)))
- // {
- // /* return request invalid length completion code */
- // pReArmSensorRes->CompletionCode = CC_REQ_INV_LEN;
- // return sizeof (*pRes);
- // }
- //
- // /* Check for the reserved bytes should b zero */
- //
- // if ( 0 != (pReArmSensorReq->ReArmAllEvents & RESERVED_BITS_REARMSENSOR_REARMALLEVENTS ) )
- // {
- // pReArmSensorRes->CompletionCode = CC_INV_DATA_FIELD;
- // return sizeof (*pRes);
- // }
- //
- // OS_THREAD_MUTEX_ACQUIRE(&pBMCInfo->SensorSharedMemMutex, WAIT_INFINITE);
- // pSenSharedMem = (_FAR_ SensorSharedMem_T*)&pBMCInfo->SensorSharedMem; //m_hSensorSharedMem;
- //
- // /* Check for the reserved bits */
- // if (pSenSharedMem->SensorInfo [pReArmSensorReq->SensorNum].SensorReadType == THRESHOLD_SENSOR_CLASS)
- // {
- // if ((pReArmSensorReq->ReArmAssertionEvents2 & RESERVED_BITS_REARMSENSOR_REARMASSEVT2_1) ||
- // (pReArmSensorReq->ReArmDeassertionEvents2 & RESERVED_BITS_REARMSENSOR_REARMDEASSEVT2_1))
- // {
- // pReArmSensorRes->CompletionCode = CC_INV_DATA_FIELD;
- // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->SensorSharedMemMutex);
- // return sizeof (*pRes);
- // }
- // }
- // else
- // {
- // if ((pReArmSensorReq->ReArmAssertionEvents2 & RESERVED_BITS_REARMSENSOR_REARMASSEVT2_2) ||
- // (pReArmSensorReq->ReArmDeassertionEvents2 & RESERVED_BITS_REARMSENSOR_REARMDEASSEVT2_2))
- // {
- // pReArmSensorRes->CompletionCode = CC_INV_DATA_FIELD;
- // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->SensorSharedMemMutex);
- // return sizeof (*pRes);
- // }
- // }
- //
- // if (pBMCInfo->IpmiConfig.OPMASupport == 1)
- // {
- // if (pSenSharedMem->GlobalSensorScanningEnable == FALSE)
- // {
- // pReArmSensorRes->CompletionCode = CC_PARAM_NOT_SUP_IN_CUR_STATE;
- // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->SensorSharedMemMutex);
- // return sizeof (*pRes);
- // }
- // }
- //
- // if (!pSenSharedMem->SensorInfo [pReArmSensorReq->SensorNum].IsSensorPresent)
- // {
- // /* return sdr record not present completion code */
- // pReArmSensorRes->CompletionCode = CC_SDR_REC_NOT_PRESENT;
- // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->SensorSharedMemMutex);
- // return sizeof (*pRes);
- // }
- //
- //
- // Msg.Param = PARAM_REARM_SENSOR;
- // Msg.Size = sizeof (ReArmSensorReq_T);
- // _fmemcpy(Msg.Data, &ReArmSensorReq, sizeof (ReArmSensorReq_T));
- //
- // /* Post to sensormonitor task Thread to rearm this sensor */
- // GetQueueHandle(SM_HNDLR_Q,&hSMHndlr_Q,BMCInst);
- // if ( -1 != hSMHndlr_Q )
- // {
- // PostMsg(&Msg, SM_HNDLR_Q,BMCInst);
- //
- // /* return normal completion code */
- // pReArmSensorRes->CompletionCode = CC_NORMAL;
- // }else
- // {
- // /* return normal completion code */
- // pReArmSensorRes->CompletionCode = 0xFF;
- // }
- // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->SensorSharedMemMutex);
- //
- // return (sizeof(ReArmSensorRes_T));
- }
- /*---------------------------------------
- * GetSensorEventStatus
- *---------------------------------------*/
- int
- GetSensorEventStatus (_NEAR_ INT8U* pReq, INT8U ReqLen, _NEAR_ INT8U* pRes,_NEAR_ int BMCInst)
- {
- // _NEAR_ GetSensorEventStatusReq_T* pSensorEventStatusReq = (_NEAR_ GetSensorEventStatusReq_T*) pReq;
- // _NEAR_ GetSensorEventStatusRes_T* pSensorEventStatusRes = (_NEAR_ GetSensorEventStatusRes_T*) pRes;
- // _FAR_ SensorSharedMem_T* pSenSharedMem;
- // _FAR_ BMCInfo_t* pBMCInfo = &g_BMCInfo[BMCInst];
- // pSenSharedMem = (_FAR_ SensorSharedMem_T*)&pBMCInfo->SensorSharedMem; //m_hSensorSharedMem;
- //
- // if(pBMCInfo->IpmiConfig.OPMASupport == 1)
- // {
- // if (pSenSharedMem->GlobalSensorScanningEnable == FALSE)
- // {
- // pSensorEventStatusRes->CompletionCode = CC_PARAM_NOT_SUP_IN_CUR_STATE;
- // return sizeof (*pRes);
- // }
- // }
- //
- // /* Acquire Shared memory */
- // OS_THREAD_MUTEX_ACQUIRE(&pBMCInfo->SensorSharedMemMutex, WAIT_INFINITE);
- //
- // if (!pSenSharedMem->SensorInfo [pSensorEventStatusReq->SensorNum].IsSensorPresent)
- // {
- // /* Release mutex for Sensor shared memory */
- // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->SensorSharedMemMutex);
- //
- // /* return sdr record not present completion code */
- // pSensorEventStatusRes->CompletionCode = CC_SDR_REC_NOT_PRESENT;
- // return sizeof (*pRes);
- // }
- //
- //
- // pSensorEventStatusRes->CompletionCode = CC_NORMAL;
- // pSensorEventStatusRes->Flags = (pSenSharedMem->SensorInfo [pSensorEventStatusReq->SensorNum].EventFlags & 0xe0);
- //
- // /* Set optional response bytes to zero if event messages are disabled for this sensor */
- // if (0 == ((pSenSharedMem->SensorInfo [pSensorEventStatusReq->SensorNum].EventFlags) & BIT7))
- // {
- // /* Release mutex for Sensor shared memory */
- // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->SensorSharedMemMutex);
- //
- // pSensorEventStatusRes->AssertionEvents1 = 0;
- // pSensorEventStatusRes->AssertionEvents2 = 0;
- // pSensorEventStatusRes->DeassertionEvents1 = 0;
- // pSensorEventStatusRes->DeassertionEvents2 = 0;
- // return sizeof (GetSensorEventStatusRes_T);
- // }
- //
- // if (0 == ((pSenSharedMem->SensorInfo [pSensorEventStatusReq->SensorNum].SensorCaps) & BIT6))
- // {
- // /* Get sensor event status history */
- // pSensorEventStatusRes->AssertionEvents1 =
- // (pSenSharedMem->SensorInfo [pSensorEventStatusReq->SensorNum].AssertionHistoryByte1 &
- // pSenSharedMem->SensorInfo [pSensorEventStatusReq->SensorNum].AssertionEventEnablesByte1);
- // pSensorEventStatusRes->AssertionEvents2 =
- // (pSenSharedMem->SensorInfo [pSensorEventStatusReq->SensorNum].AssertionHistoryByte2 &
- // pSenSharedMem->SensorInfo [pSensorEventStatusReq->SensorNum].AssertionEventEnablesByte2);
- // pSensorEventStatusRes->DeassertionEvents1 =
- // (pSenSharedMem->SensorInfo [pSensorEventStatusReq->SensorNum].DeassertionHistoryByte1 &
- // pSenSharedMem->SensorInfo [pSensorEventStatusReq->SensorNum].DeassertionEventEnablesByte1);
- // pSensorEventStatusRes->DeassertionEvents2 =
- // (pSenSharedMem->SensorInfo [pSensorEventStatusReq->SensorNum].DeassertionHistoryByte2 &
- // pSenSharedMem->SensorInfo [pSensorEventStatusReq->SensorNum].DeassertionEventEnablesByte2);
- // }
- // else
- // {
- // /* Get present sensor event status */
- // pSensorEventStatusRes->AssertionEvents1 =
- // (pSenSharedMem->SensorInfo [pSensorEventStatusReq->SensorNum].AssertionEventOccuredByte1 &
- // pSenSharedMem->SensorInfo [pSensorEventStatusReq->SensorNum].AssertionEventEnablesByte1);
- // pSensorEventStatusRes->AssertionEvents2 =
- // (pSenSharedMem->SensorInfo [pSensorEventStatusReq->SensorNum].AssertionEventOccuredByte2 &
- // pSenSharedMem->SensorInfo [pSensorEventStatusReq->SensorNum].AssertionEventEnablesByte2);
- // pSensorEventStatusRes->DeassertionEvents1 =
- // (pSenSharedMem->SensorInfo [pSensorEventStatusReq->SensorNum].DeassertionEventOccuredByte1 &
- // pSenSharedMem->SensorInfo [pSensorEventStatusReq->SensorNum].DeassertionEventEnablesByte1);
- // pSensorEventStatusRes->DeassertionEvents2 =
- // (pSenSharedMem->SensorInfo [pSensorEventStatusReq->SensorNum].DeassertionEventOccuredByte2 &
- // pSenSharedMem->SensorInfo [pSensorEventStatusReq->SensorNum].DeassertionEventEnablesByte2);
- // }
- // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->SensorSharedMemMutex);
- //
- // return sizeof (GetSensorEventStatusRes_T);
- }
- /*---------------------------------------
- * SetSensorHysterisis
- *---------------------------------------*/
- int
- SetSensorHysterisis (_NEAR_ INT8U* pReq, INT8U ReqLen, _NEAR_ INT8U* pRes,_NEAR_ int BMCInst)
- {
- // _NEAR_ SetSensorHysterisisReq_T* pSensorHysReq =
- // (_NEAR_ SetSensorHysterisisReq_T*) pReq;
- // _NEAR_ SetSensorHysterisisRes_T* pSensorHysRes =
- // (_NEAR_ SetSensorHysterisisRes_T*) pRes;
- // _FAR_ SensorSharedMem_T* pSenSharedMem;
- // _FAR_ BMCInfo_t* pBMCInfo = &g_BMCInfo[BMCInst];
- // pSenSharedMem = (_FAR_ SensorSharedMem_T*)&pBMCInfo->SensorSharedMem; //m_hSensorSharedMem;
- //
- // if (pBMCInfo->IpmiConfig.OPMASupport == 1)
- // {
- // if (pSenSharedMem->GlobalSensorScanningEnable == FALSE)
- // {
- // pSensorHysRes->CompletionCode = CC_PARAM_NOT_SUP_IN_CUR_STATE;
- // return sizeof (*pRes);
- // }
- // }
- //
- // /* Acquire Shared memory */
- // OS_THREAD_MUTEX_ACQUIRE(&pBMCInfo->SensorSharedMemMutex, WAIT_INFINITE);
- //
- // if (!pSenSharedMem->SensorInfo [pSensorHysReq->SensorNum].IsSensorPresent)
- // {
- // /* Release mutex for Sensor shared memory */
- // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->SensorSharedMemMutex);
- //
- // pSensorHysRes->CompletionCode = CC_SDR_REC_NOT_PRESENT;
- // return sizeof (*pRes);
- // }
- //
- // if (pSenSharedMem->SensorInfo [pSensorHysReq->SensorNum].SensorReadType != THRESHOLD_SENSOR_CLASS)
- // {
- // /* Release mutex for Sensor shared memory */
- // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->SensorSharedMemMutex);
- // pSensorHysRes->CompletionCode = CC_ILLEGAL_CMD_FOR_SENSOR_REC;
- // return sizeof (*pRes);
- // }
- //
- // if(BIT5 != (pSenSharedMem->SensorInfo[pSensorHysReq->SensorNum].SensorCaps & (BIT5 | BIT4)))
- // {
- // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->SensorSharedMemMutex);
- // //set operation is not allowed
- // *pRes = CC_INV_DATA_FIELD;
- // return sizeof(*pRes);
- // }
- //
- // /* Set the hysterisis values */
- // pSenSharedMem->SensorInfo [pSensorHysReq->SensorNum].PosHysteresis = pSensorHysReq->PositiveHysterisis;
- // pSenSharedMem->SensorInfo [pSensorHysReq->SensorNum].NegHysteresis = pSensorHysReq->NegativeHysterisis;
- //
- // /* Release mutex for Sensor shared memory */
- // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->SensorSharedMemMutex);
- //
- // pSensorHysRes->CompletionCode = CC_NORMAL;
- // return sizeof (SetSensorHysterisisRes_T);
- }
- /*---------------------------------------
- * GetSensorHysterisis
- *---------------------------------------*/
- int
- GetSensorHysterisis (_NEAR_ INT8U* pReq, INT8U ReqLen, _NEAR_ INT8U* pRes,_NEAR_ int BMCInst)
- {
- // _NEAR_ GetSensorHysterisisReq_T* pSensorHysReq =
- // (_NEAR_ GetSensorHysterisisReq_T*) pReq;
- // _NEAR_ GetSensorHysterisisRes_T* pSensorHysRes =
- // (_NEAR_ GetSensorHysterisisRes_T*) pRes;
- // _FAR_ SensorSharedMem_T* pSenSharedMem;
- // _FAR_ BMCInfo_t* pBMCInfo = &g_BMCInfo[BMCInst];
- // pSenSharedMem = (_FAR_ SensorSharedMem_T*)&pBMCInfo->SensorSharedMem; //m_hSensorSharedMem;
- //
- // if (pBMCInfo->IpmiConfig.OPMASupport == 1)
- // {
- // if (pSenSharedMem->GlobalSensorScanningEnable == FALSE)
- // {
- // pSensorHysRes->CompletionCode = CC_PARAM_NOT_SUP_IN_CUR_STATE;
- // return sizeof (*pRes);
- // }
- // }
- //
- // /* Acquire Shared memory */
- // OS_THREAD_MUTEX_ACQUIRE(&pBMCInfo->SensorSharedMemMutex, WAIT_INFINITE);
- //
- // if (!pSenSharedMem->SensorInfo [pSensorHysReq->SensorNum].IsSensorPresent)
- // {
- // /* Release mutex for Sensor shared memory */
- // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->SensorSharedMemMutex);
- //
- // pSensorHysRes->CompletionCode = CC_SDR_REC_NOT_PRESENT;
- // return sizeof (*pRes);
- // }
- //
- // if (pSenSharedMem->SensorInfo [pSensorHysReq->SensorNum].SensorReadType != THRESHOLD_SENSOR_CLASS)
- // {
- // /* Release mutex for Sensor shared memory */
- // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->SensorSharedMemMutex);
- // pSensorHysRes->CompletionCode = CC_ILLEGAL_CMD_FOR_SENSOR_REC;
- // return sizeof (*pRes);
- // }
- //
- // if(SENSOR_HYSTERESIS_ACCESS_BITS == (pSenSharedMem->SensorInfo[pSensorHysReq->SensorNum].SensorCaps & (BIT5 | BIT4)))
- // {
- // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->SensorSharedMemMutex);
- // //set operation is not allowed
- // *pRes = CC_INV_DATA_FIELD;
- // return sizeof(*pRes);
- // }
- //
- // /* Get the hysterisis values */
- // pSensorHysRes->PositiveHysterisis = pSenSharedMem->SensorInfo [pSensorHysReq->SensorNum].PosHysteresis;
- // pSensorHysRes->NegativeHysterisis = pSenSharedMem->SensorInfo [pSensorHysReq->SensorNum].NegHysteresis;
- //
- // /* Release mutex for Sensor shared memory */
- // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->SensorSharedMemMutex);
- //
- // pSensorHysRes->CompletionCode = CC_NORMAL;
- //
- // return sizeof (GetSensorHysterisisRes_T);
- }
- /*---------------------------------------
- * SetSensorThresholds
- *---------------------------------------*/
- int
- SetSensorThresholds (_NEAR_ INT8U* pReq, INT8U ReqLen, _NEAR_ INT8U* pRes,_NEAR_ int BMCInst)
- {
- // _NEAR_ SetSensorThresholdReq_T* pSensorThreshReq =
- // (_NEAR_ SetSensorThresholdReq_T*) pReq;
- // _NEAR_ SetSensorThresholdRes_T* pSensorThreshRes =
- // (_NEAR_ SetSensorThresholdRes_T*) pRes;
- // _FAR_ SensorSharedMem_T* pSenSharedMem;
- // _FAR_ BMCInfo_t* pBMCInfo = &g_BMCInfo[BMCInst];
- // pSenSharedMem = (_FAR_ SensorSharedMem_T*)&pBMCInfo->SensorSharedMem; //m_hSensorSharedMem;
- //
- // _NEAR_ INT8U SettableMask=0;
- //
- // /* Check for the reserved bytes should b zero */
- //
- // if ( 0 != (pSensorThreshReq->SetFlags & RESERVED_BITS_SETSENSORTHRESHOLDS ) )
- // {
- // pSensorThreshRes->CompletionCode = CC_INV_DATA_FIELD;
- // return sizeof (*pRes);
- // }
- //
- // if (pBMCInfo->IpmiConfig.OPMASupport == 1)
- // {
- // if (pSenSharedMem->GlobalSensorScanningEnable == FALSE)
- // {
- // pSensorThreshRes->CompletionCode = CC_PARAM_NOT_SUP_IN_CUR_STATE;
- // return sizeof (*pRes);
- // }
- // }
- //
- // /* Acquire Shared memory */
- // OS_THREAD_MUTEX_ACQUIRE(&pBMCInfo->SensorSharedMemMutex, WAIT_INFINITE);
- //
- // if (!pSenSharedMem->SensorInfo [pSensorThreshReq->SensorNum].IsSensorPresent)
- // {
- // /* Release mutex for Sensor shared memory */
- // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->SensorSharedMemMutex);
- //
- // pSensorThreshRes->CompletionCode = CC_SDR_REC_NOT_PRESENT;
- // return sizeof (*pRes);
- // }
- //
- //
- // if (pSenSharedMem->SensorInfo [pSensorThreshReq->SensorNum].SensorReadType != THRESHOLD_SENSOR_CLASS)
- // {
- // /* Release mutex for Sensor shared memory */
- // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->SensorSharedMemMutex);
- // pSensorThreshRes->CompletionCode = CC_ILLEGAL_CMD_FOR_SENSOR_REC;
- // return sizeof (*pRes);
- // }
- //
- // if(BIT3 != (pSenSharedMem->SensorInfo[pSensorThreshReq->SensorNum].SensorCaps & (BIT2 | BIT3)))
- // {
- // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->SensorSharedMemMutex);
- // //set operation is not allowed
- // *pRes = CC_INV_DATA_FIELD;
- // return sizeof(*pRes);
- // }
- //
- // pSensorThreshRes->CompletionCode = CC_NORMAL;
- // SettableMask=(INT8U)(pSenSharedMem->SensorInfo [pSensorThreshReq->SensorNum].SettableThreshMask >> 8);
- // /* Set the threshold values */
- // //if (pSenSharedMem->SensorInfo [pSensorThreshReq->SensorNum].SensorInit & BIT5)
- // if ( (pSenSharedMem->SensorInfo [pSensorThreshReq->SensorNum].SensorInit & BIT4 ) && (SettableMask | pSensorThreshReq->SetFlags ) == SettableMask) //<<Modified to support "set sensor enable>>
- // {
- // if (pSensorThreshReq->SetFlags & LWR_CRIT)
- // {
- // pSenSharedMem->SensorInfo [pSensorThreshReq->SensorNum].LowerCritical = pSensorThreshReq->LowerCritical;
- // }
- // if (pSensorThreshReq->SetFlags & LWR_NON_CRIT)
- // {
- // pSenSharedMem->SensorInfo [pSensorThreshReq->SensorNum].LowerNonCritical = pSensorThreshReq->LowerNonCritical;
- // }
- // if (pSensorThreshReq->SetFlags & LWR_NON_REC)
- // {
- // pSenSharedMem->SensorInfo [pSensorThreshReq->SensorNum].LowerNonRecoverable = pSensorThreshReq->LowerNonRecoverable;
- // }
- // if (pSensorThreshReq->SetFlags & UPR_CRIT)
- // {
- // pSenSharedMem->SensorInfo [pSensorThreshReq->SensorNum].UpperCritical = pSensorThreshReq->UpperCritical;
- // }
- // if (pSensorThreshReq->SetFlags & UPR_NON_CRIT)
- // {
- // pSenSharedMem->SensorInfo [pSensorThreshReq->SensorNum].UpperNonCritical = pSensorThreshReq->UpperNonCritical;
- // }
- // if (pSensorThreshReq->SetFlags & UPR_NON_REC)
- // {
- // pSenSharedMem->SensorInfo [pSensorThreshReq->SensorNum].UpperNonRecoverable = pSensorThreshReq->UpperNonRecoverable;
- // }
- //
- // if(pBMCInfo->IpmiConfig.RearmSetSensorThreshold == 1)
- // {
- // /* Since Changes in Threshold .We have to monitor the sensor again .*/
- // /* Already the Sensor reached the particular state . so we have to reset for generate the event according to the new Event mask */
- // if ( 0 ==(pSenSharedMem->SensorInfo[pSensorThreshReq->SensorNum].SensorCaps & BIT6))
- // {
- // /* Manual ReARM Sensor */
- // pSenSharedMem->SensorInfo[pSensorThreshReq->SensorNum].AssertionHistoryByte1=0;
- // pSenSharedMem->SensorInfo[pSensorThreshReq->SensorNum].AssertionHistoryByte2=0;
- // pSenSharedMem->SensorInfo[pSensorThreshReq->SensorNum].DeassertionHistoryByte1=0;
- // pSenSharedMem->SensorInfo[pSensorThreshReq->SensorNum].DeassertionHistoryByte2=0;
- // pSenSharedMem->SensorInfo[pSensorThreshReq->SensorNum].EventLevel=SENSOR_STATUS_NORMAL;
- // pSenSharedMem->SensorInfo[pSensorThreshReq->SensorNum].HealthLevel= SENSOR_STATUS_NORMAL;
- // }else
- // {
- // /* Auto ReARM Sensor */
- // pSenSharedMem->SensorInfo[pSensorThreshReq->SensorNum].EventLevel=SENSOR_STATUS_NORMAL;
- // pSenSharedMem->SensorInfo[pSensorThreshReq->SensorNum].HealthLevel = SENSOR_STATUS_NORMAL;
- // pSenSharedMem->SensorInfo[pSensorThreshReq->SensorNum].AssertionEventOccuredByte1 = 0;
- // pSenSharedMem->SensorInfo[pSensorThreshReq->SensorNum].AssertionEventOccuredByte2 = 0;
- // pSenSharedMem->SensorInfo[pSensorThreshReq->SensorNum].DeassertionEventOccuredByte1 = 0;
- // pSenSharedMem->SensorInfo[pSensorThreshReq->SensorNum].DeassertionEventOccuredByte2 = 0;
- // }
- // }
- //
- // pSensorThreshRes->CompletionCode = CC_NORMAL;
- // }else
- // {
- // pSensorThreshRes->CompletionCode = CC_ILLEGAL_CMD_FOR_SENSOR_REC;
- //
- // }
- // /* Release mutex for Sensor shared memory */
- // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->SensorSharedMemMutex);
- //
- // // To send notification to CIM
- // if(g_PDKCIMEventHandle[PDKCIMEVENT_NOTIFYSERVERUPDATETOCIM] != NULL)
- // {
- // uint8 CMD;
- // // Set bits for SDR event & Modify operation
- // CMD = 0x12;
- // ((int(*)(uint8,uint16))g_PDKCIMEventHandle[PDKCIMEVENT_NOTIFYSERVERUPDATETOCIM])(CMD, pSensorThreshReq->SensorNum);
- // }
- //
- // return sizeof (SetSensorThresholdRes_T);
- }
- /*---------------------------------------
- * GetSensorThresholds
- *---------------------------------------*/
- int
- GetSensorThresholds (_NEAR_ INT8U* pReq, INT8U ReqLen, _NEAR_ INT8U* pRes,_NEAR_ int BMCInst)
- {
- _NEAR_ GetSensorThresholdReq_T* pSensorThreshReq =
- (_NEAR_ GetSensorThresholdReq_T*) pReq;
- _NEAR_ GetSensorThresholdRes_T* pSensorThreshRes =
- (_NEAR_ GetSensorThresholdRes_T*) pRes;
- _FAR_ BMCInfo_t* pBMCInfo = &g_BMCInfo;//[BMCInst];
- INT16U LUNSensorNum;
- LUNSensorNum=pSensorThreshReq->SensorNum;
-
- pSensorThreshRes->CompletionCode=0x00;
- pSensorThreshRes->GetFlags=0x3f;
- pSensorThreshRes->LowerNonCritical=g_BMCInfo.SDRConfig.SDR[LUNSensorNum][0];
- pSensorThreshRes->LowerCritical=g_BMCInfo.SDRConfig.SDR[LUNSensorNum][1];
- pSensorThreshRes->LowerNonRecoverable=g_BMCInfo.SDRConfig.SDR[LUNSensorNum][2];
- pSensorThreshRes->UpperNonCritical=g_BMCInfo.SDRConfig.SDR[LUNSensorNum][3];
- pSensorThreshRes->UpperCritical=g_BMCInfo.SDRConfig.SDR[LUNSensorNum][4];
- pSensorThreshRes->UpperNonRecoverable=g_BMCInfo.SDRConfig.SDR[LUNSensorNum][5];
- SessionSequenceNumberCount=SessionSequenceNumberCount+1;
- return sizeof (GetSensorThresholdRes_T);
- }
- /*---------------------------------------
- * GetSensorReadingFactors
- *---------------------------------------*/
- int
- GetSensorReadingFactors (_NEAR_ INT8U* pReq, INT8U ReqLen, _NEAR_ INT8U* pRes,_NEAR_ int BMCInst)
- {
- // _NEAR_ GetSensorReadingFactorReq_T* pSensorFactorsReq =
- // (_NEAR_ GetSensorReadingFactorReq_T*) pReq;
- // _NEAR_ GetSensorReadingFactorRes_T* pSensorFactorsRes =
- // (_NEAR_ GetSensorReadingFactorRes_T*) pRes;
- // _FAR_ SensorSharedMem_T* pSenSharedMem;
- // _FAR_ BMCInfo_t* pBMCInfo = &g_BMCInfo[BMCInst];
- // pSenSharedMem = (_FAR_ SensorSharedMem_T*)&pBMCInfo->SensorSharedMem; //m_hSensorSharedMem;
- //
- // if (pBMCInfo->IpmiConfig.OPMASupport == 1)
- // {
- // if (pSenSharedMem->GlobalSensorScanningEnable == FALSE)
- // {
- // pSensorFactorsRes->CompletionCode = CC_PARAM_NOT_SUP_IN_CUR_STATE;
- // return sizeof (*pRes);
- // }
- // }
- //
- // /* Acquire Shared memory */
- // OS_THREAD_MUTEX_ACQUIRE(&pBMCInfo->SensorSharedMemMutex, WAIT_INFINITE);
- //
- // if (!pSenSharedMem->SensorInfo [pSensorFactorsReq->SensorNum].IsSensorPresent)
- // {
- // /* Release mutex for Sensor shared memory */
- // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->SensorSharedMemMutex);
- //
- // pSensorFactorsRes->CompletionCode = CC_SDR_REC_NOT_PRESENT;
- // return sizeof (*pRes);
- // }
- //
- // _fmemcpy (&(pSensorFactorsRes->M_LSB), &(pSenSharedMem->SensorInfo [pSensorFactorsReq->SensorNum].M_LSB),
- // sizeof (GetSensorReadingFactorRes_T) - (2 * sizeof (INT8U)));
- // pSensorFactorsRes->CompletionCode = CC_NORMAL;
- //
- // /* Release mutex for Sensor shared memory */
- // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->SensorSharedMemMutex);
- //
- // return sizeof (GetSensorReadingFactorRes_T);
- }
- /*---------------------------------------
- * SetSensorEventEnable
- *---------------------------------------*/
- int
- SetSensorEventEnable (_NEAR_ INT8U* pReq, INT8U ReqLen, _NEAR_ INT8U* pRes,_NEAR_ int BMCInst)
- {
- // _FAR_ SensorInfo_T* pSensorInfo;
- // INT8U LocalReq [6];
- // _NEAR_ SetSensorEventEnableReq_T* pSensorEvtEnReq;
- // _NEAR_ SetSensorEventEnableRes_T* pSensorEvtEnRes =
- // (_NEAR_ SetSensorEventEnableRes_T*) pRes;
- // INT16U AssertMask, DeassertMask;
- // INT16U ValidMask = htoipmi_u16(0x0FFF);
- // _FAR_ SensorSharedMem_T* pSenSharedMem;
- // _FAR_ BMCInfo_t* pBMCInfo = &g_BMCInfo[BMCInst];
- // pSenSharedMem = (_FAR_ SensorSharedMem_T*)&pBMCInfo->SensorSharedMem; //m_hSensorSharedMem;
- // INT16U LUNSensorNum;
- // INT16U *OwnerLUN = 0;
- //
- // if (pBMCInfo->IpmiConfig.OPMASupport == 1)
- // {
- // if (pSenSharedMem->GlobalSensorScanningEnable == FALSE)
- // {
- // pSensorEvtEnRes->CompletionCode = CC_PARAM_NOT_SUP_IN_CUR_STATE;
- // return sizeof (*pRes);
- // }
- // }
- //
- // AssertMask = DeassertMask = 0;
- //
- // memset (LocalReq, 0, sizeof (LocalReq));
- // memcpy (LocalReq, pReq, ReqLen);
- // pSensorEvtEnReq = (_NEAR_ SetSensorEventEnableReq_T*)LocalReq;
- //
- // if(g_corefeatures.more_than_256_sensors == ENABLED)
- // {
- //
- // OS_THREAD_TLS_GET(g_tls.OwnerLUN,OwnerLUN);
- // LUNSensorNum = ((*OwnerLUN & VALID_LUN) << 8 | pSensorEvtEnReq->SensorNum);
- // }
- // else
- // {
- // LUNSensorNum = pSensorEvtEnReq->SensorNum;
- // }
- //
- //
- //
- // /* Atleast two bytes are expected remaining bytes (3,4,5,6) are optional */
- // if ((ReqLen < sizeof(INT16U)) || (ReqLen > sizeof (SetSensorEventEnableReq_T)))
- // {
- // pSensorEvtEnRes->CompletionCode = CC_REQ_INV_LEN;
- // return sizeof (*pRes);
- // }
- //
- // /* Check for the reserved bytes should b zero */
- //
- // if ( 0 != (pSensorEvtEnReq->Flags & RESERVED_BITS_SETSENEVTEN_FLAGS ) )
- // {
- // pSensorEvtEnRes->CompletionCode = CC_INV_DATA_FIELD;
- // return sizeof (*pRes);
- // }
- //
- // if (ReqLen > sizeof(INT16U))
- // {
- // /* Check for the reserved bits */
- // if (pSenSharedMem->SensorInfo [LUNSensorNum].SensorReadType == THRESHOLD_SENSOR_CLASS)
- // {
- // if ((pSensorEvtEnReq->AssertionMask & ~ValidMask) ||
- // (pSensorEvtEnReq->DeAssertionMask & ~ValidMask))
- // {
- // pSensorEvtEnRes->CompletionCode = CC_INV_DATA_FIELD;
- // return sizeof (*pRes);
- // }
- // }
- // else
- // {
- // if ((pSensorEvtEnReq->AssertionMask & RESERVED_BITS_SETSENEVTEN_ASSERTIONMASK) ||
- // (pSensorEvtEnReq->DeAssertionMask & RESERVED_BITS_SETSENEVTEN_DEASSERTIONMASK))
- // {
- // pSensorEvtEnRes->CompletionCode = CC_INV_DATA_FIELD;
- // return sizeof (*pRes);
- // }
- // }
- // }
- //
- // /* Get the sensor Info for the sensor */
- // if(g_corefeatures.more_than_256_sensors == ENABLED)
- // {
- // pSensorInfo = GetSensorInfo (pSensorEvtEnReq->SensorNum, *OwnerLUN, BMCInst);
- // }
- // else
- // {
- // pSensorInfo = GetSensorInfo (pSensorEvtEnReq->SensorNum, 0x0, BMCInst);
- // }
- //
- // if (NULL == pSensorInfo)
- // {
- // pSensorEvtEnRes->CompletionCode = CC_SDR_REC_NOT_PRESENT;
- // return sizeof (*pRes);
- // }
- //
- // // If not threshold, adjust mask
- // if (pSensorInfo->EventTypeCode != 0x01)
- // {
- // ValidMask = htoipmi_u16(0x7FFF);
- // }
- //
- //
- // /* Acquire Shared memory */
- // OS_THREAD_MUTEX_ACQUIRE(&pBMCInfo->SensorSharedMemMutex, WAIT_INFINITE);
- //
- // if (!pSensorInfo->IsSensorPresent)
- // {
- // /* Release mutex for Sensor shared memory */
- // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->SensorSharedMemMutex);
- //
- // pSensorEvtEnRes->CompletionCode = CC_SDR_REC_NOT_PRESENT;
- // return sizeof (*pRes);
- // }
- //
- // /* Disable Events and scanning based on the flags */
- // if (0 == (pSensorEvtEnReq->Flags & EVENT_MSG_MASK))
- // {
- // /* DisableAllEventSensors () */
- // }
- //
- // if ((0 == (pSensorEvtEnReq->Flags & SCAN_MASK)) && (SCAN_MASK == (pSensorInfo->EventFlags & SCAN_MASK)))
- // {
- // // Check sensor accepts the ‘enable/disable scanning’
- // if(0 == (pSensorInfo->SensorInit & BIT6))
- // {
- // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->SensorSharedMemMutex);
- // pSensorEvtEnRes->CompletionCode = CC_INV_DATA_FIELD;
- // return sizeof (*pRes);
- // }
- // pSensorInfo->EventFlags |= BIT5; ///* Bit 5 - Unable to read */
- // }
- // else if((SCAN_MASK == (pSensorEvtEnReq->Flags & SCAN_MASK)) && (0 == (pSensorInfo->EventFlags & SCAN_MASK)))
- // {
- // // Check sensor accepts the ‘enable/disable scanning’
- // if(0 == (pSensorInfo->SensorInit & BIT6))
- // {
- // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->SensorSharedMemMutex);
- // pSensorEvtEnRes->CompletionCode = CC_INV_DATA_FIELD;
- // return sizeof (*pRes);
- // }
- // pSensorInfo->EventFlags &= ~BIT5; ///* Bit 5 - Unable to read */
- // }
- // pSensorInfo->EventFlags &= ~(EVENT_MSG_MASK | SCAN_MASK);
- // pSensorInfo->EventFlags |= (pSensorEvtEnReq->Flags & (EVENT_MSG_MASK | SCAN_MASK));
- //
- // AssertMask =
- // htoipmi_u16(((pSenSharedMem->SensorInfo [LUNSensorNum].AssertionEventEnablesByte2 << 8) |
- // (pSenSharedMem->SensorInfo [LUNSensorNum].AssertionEventEnablesByte1)) & ValidMask);
- //
- // DeassertMask =
- // htoipmi_u16(((pSenSharedMem->SensorInfo [LUNSensorNum].DeassertionEventEnablesByte2 << 8) |
- // (pSenSharedMem->SensorInfo [LUNSensorNum].DeassertionEventEnablesByte1)) & ValidMask);
- //
- // /* Enable disable assertion based on the flag */
- // if(ENABLE_DISABLE_EVENT_MASK == (pSensorEvtEnReq->Flags & ENABLE_DISABLE_EVENT_MASK))
- // {
- // // Flags [5:4] - 11b Reserved.
- // /* Release mutex for Sensor shared memory */
- // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->SensorSharedMemMutex);
- //
- // pSensorEvtEnRes->CompletionCode = CC_INV_DATA_FIELD;
- // return sizeof (*pRes);
- // }
- // else if (ENABLE_SELECTED_EVENT_MSG == (pSensorEvtEnReq->Flags & ENABLE_DISABLE_EVENT_MASK))
- // {
- // AssertMask |= ipmitoh_u16(pSensorEvtEnReq->AssertionMask);
- // DeassertMask |= ipmitoh_u16(pSensorEvtEnReq->DeAssertionMask);
- // }
- // else if (DISABLE_SELECTED_EVENT_MSG == (pSensorEvtEnReq->Flags & ENABLE_DISABLE_EVENT_MASK))
- // {
- // AssertMask &= ~ipmitoh_u16(pSensorEvtEnReq->AssertionMask);
- // DeassertMask &= ~ipmitoh_u16(pSensorEvtEnReq->DeAssertionMask);
- // }
- //
- // //For Threshold class sensors upper word bits are reserved
- // if(pSensorInfo->EventTypeCode == THRESHOLD_SENSOR_CLASS)
- // {
- // pSensorInfo->AssertionEventEnablesByte2 &= 0xF0;
- // pSensorInfo->AssertionEventEnablesByte2 |= (AssertMask >> 8);
- // }
- // else
- // {
- // pSensorInfo->AssertionEventEnablesByte2 = (AssertMask >> 8);
- // }
- // pSensorInfo->AssertionEventEnablesByte1 = (AssertMask) & 0xFF;
- //
- // //For Threshold class sensors upper word bits are reserved
- // if(pSensorInfo->EventTypeCode == THRESHOLD_SENSOR_CLASS)
- // {
- // pSensorInfo->DeassertionEventEnablesByte2 &= 0xF0;
- // pSensorInfo->DeassertionEventEnablesByte2 |= (DeassertMask >> 8);
- // }
- // else
- // {
- // pSensorInfo->DeassertionEventEnablesByte2 = (DeassertMask >> 8);
- // }
- //
- // pSensorInfo->DeassertionEventEnablesByte1 = (DeassertMask);
- //
- // // For threshold sensors, reset the threshold state machine for the sensor
- // // in order to pickup any newly enabled events.
- // if(pSensorInfo->EventTypeCode == THRESHOLD_SENSOR_CLASS)
- // {
- // pSensorInfo->EventLevel=SENSOR_STATUS_NORMAL;
- // pSensorInfo->HealthLevel = SENSOR_STATUS_NORMAL;
- // }
- //
- // pSensorEvtEnRes->CompletionCode = CC_NORMAL;
- //
- // /* Release mutex for Sensor shared memory */
- // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->SensorSharedMemMutex);
- //
- //
- // return sizeof (SetSensorEventEnableRes_T);
- }
- /*---------------------------------------
- * GetSensorEventEnable
- *---------------------------------------*/
- int
- GetSensorEventEnable (_NEAR_ INT8U* pReq, INT8U ReqLen, _NEAR_ INT8U* pRes,_NEAR_ int BMCInst)
- {
- // _NEAR_ GetSensorEventEnableReq_T* pSensorEvtEnReq =
- // (_NEAR_ GetSensorEventEnableReq_T*) pReq;
- // _NEAR_ GetSensorEventEnableRes_T* pSensorEvtEnRes =
- // (_NEAR_ GetSensorEventEnableRes_T*) pRes;
- // _FAR_ SensorSharedMem_T* pSenSharedMem;
- // _FAR_ BMCInfo_t* pBMCInfo = &g_BMCInfo[BMCInst];
- // pSenSharedMem = (_FAR_ SensorSharedMem_T*)&pBMCInfo->SensorSharedMem; //m_hSensorSharedMem;
- //
- // INT16U ValidMask = htoipmi_u16(0x0FFF);
- // if (pBMCInfo->IpmiConfig.OPMASupport == 1)
- // {
- // if (pSenSharedMem->GlobalSensorScanningEnable == FALSE)
- // {
- // pSensorEvtEnRes->CompletionCode = CC_PARAM_NOT_SUP_IN_CUR_STATE;
- // return sizeof (*pRes);
- // }
- // }
- //
- // /* Acquire Shared memory */
- // OS_THREAD_MUTEX_ACQUIRE(&pBMCInfo->SensorSharedMemMutex, WAIT_INFINITE);
- //
- // if (!pSenSharedMem->SensorInfo [pSensorEvtEnReq->SensorNum].IsSensorPresent)
- // {
- // /* Release mutex for Sensor shared memory */
- // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->SensorSharedMemMutex);
- //
- // pSensorEvtEnRes->CompletionCode = CC_SDR_REC_NOT_PRESENT;
- // return sizeof (*pRes);
- // }
- //
- // if (pSenSharedMem->SensorInfo [pSensorEvtEnReq->SensorNum].EventTypeCode != 0x01)
- // {
- // ValidMask = htoipmi_u16(0x7FFF);
- // }
- // /* Get the assertion enables */
- // pSensorEvtEnRes->AssertionMask =
- // htoipmi_u16(((pSenSharedMem->SensorInfo [pSensorEvtEnReq->SensorNum].AssertionEventEnablesByte2 << 8) |
- // (pSenSharedMem->SensorInfo [pSensorEvtEnReq->SensorNum].AssertionEventEnablesByte1)) & ValidMask);
- //
- // /* Get the deassertion enables */
- // pSensorEvtEnRes->DeAssertionMask =
- // htoipmi_u16(((pSenSharedMem->SensorInfo [pSensorEvtEnReq->SensorNum].DeassertionEventEnablesByte2 << 8) |
- // (pSenSharedMem->SensorInfo [pSensorEvtEnReq->SensorNum].DeassertionEventEnablesByte1)) & ValidMask);
- //
- // /* Set the flags */
- // pSensorEvtEnRes->Flags = (pSenSharedMem->SensorInfo [pSensorEvtEnReq->SensorNum].EventFlags & 0xc0);
- //
- // pSensorEvtEnRes->CompletionCode = CC_NORMAL;
- //
- // /* Release mutex for Sensor shared memory */
- // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->SensorSharedMemMutex);
- //
- // return sizeof (GetSensorEventEnableRes_T);
- }
- /**
- * @fn CheckForEntityPresence
- * @brief This function checks for the entity presence bit
- * or the entity presence sensor.
- * @param[in] SensorNum - Sensor number for reading.
- * @param[in] EventTypeCode - Event type code of the sdr.
- * @param[in] SensorType - Sensor type of the sdr.
- * @retval ENTITY_FOUND, if present,
- * ENTITY_NOT_FOUND, if not present,
- * NOT_FOUND_SCAN_DISABLED, if not able to find,
- * NOT_FOUND_SCAN_ENABLED, if Scanning bit enabled but failed.
- */
- static int
- CheckForEntityPresence (INT8U SensorNum, INT8U OwnerLUN, INT8U EventTypeCode, INT8U SensorType,int BMCInst)
- {
- // int RetVal = NOT_FOUND_SCAN_ENABLED;
- // _FAR_ SensorInfo_T* pSensorInfo;
- // int i;
- // _FAR_ BMCInfo_t* pBMCInfo = &g_BMCInfo[BMCInst];
- // _FAR_ SensorSharedMem_T* pSenSharedMem = (_FAR_ SensorSharedMem_T*)&pBMCInfo->SensorSharedMem;
- //
- // pSensorInfo = &(pSenSharedMem->SensorInfo[((OwnerLUN & VALID_LUN) << 8 | SensorNum)]);
- //
- // TDBG("Entered %s : Sensor Type : %x, SensorInit : %x, Reading : %x\n",
- // __func__, SensorType, pSensorInfo->SensorInit,
- // pSensorInfo->SensorReading);
- //
- // if( BIT0 == (BIT0 & pSensorInfo->SensorInit) )
- // {
- // // If Event/Reading type code is 0x08 then look for
- // // reading DEVICE_PRESENT to state the Entity Presence
- // if( GENERIC_EVENT_TYPE_DEV_PRESENCE == EventTypeCode )
- // {
- // if( DEVICE_PRESENT == pSensorInfo->SensorReading )
- // {
- // RetVal = ENTITY_FOUND;
- // }
- // else
- // {
- // RetVal = ENTITY_NOT_FOUND;
- // }
- // }
- // // If Event/Reading type code is 0x09 then look for
- // // reading DEVICE_ENABLED to state the Entity Enabled
- // else if( GENERIC_EVENT_TYPE_DEV_AVAILABLE == EventTypeCode )
- // {
- // if( DEVICE_ENABLED == pSensorInfo->SensorReading )
- // {
- // RetVal = ENTITY_FOUND;
- // }
- // else
- // {
- // RetVal = ENTITY_NOT_FOUND;
- // }
- // }
- // // If Event/Reading Type code is 0x6f then look for the
- // // special sensors like Processor, Memory etc.,
- // else if ( EVENT_TYPE_SENSOR_SPECIFIC == EventTypeCode )
- // {
- // for(i = 0; i < SENSOR_PRESENCE_COUNT; i++)
- // {
- // if( SensorType == sensor_presence[i][0] )
- // {
- // if( pSensorInfo->SensorReading == sensor_presence[i][1] )
- // RetVal = ENTITY_FOUND;
- // else
- // RetVal = ENTITY_NOT_FOUND;
- // }
- // }
- // }
- //
- // TDBG("Leaving : %s with %d\n", __func__, RetVal);
- // return RetVal;
- // }
- // TDBG("Leaving : %s with %d\n", __func__, NOT_FOUND_SCAN_DISABLED);
- // return NOT_FOUND_SCAN_DISABLED;
- }
- /**
- * @fn IsSensorPresence
- * @brief Check the presence bit for the entity or checks with
- * entity presence sensor to identify Entity presence
- * @param[in] EntityID - Entity id of the sensor.
- * @param[in] EntityIns - Entity instance of the sensor.
- * @param[in] SensorNum - Sensor number.
- * @retval 1, if present
- * 0, if not present
- * -1, if not able to find.
- */
- static int
- IsSensorPresence (INT8U EntityID, INT8U EntityIns, INT8U SensorNum, INT8U OwnerLUN, int BMCInst)
- {
- // _FAR_ SDRRecHdr_T* sr = NULL;
- // _FAR_ CommonSensorRec_T* scs = NULL;
- // _FAR_ BMCInfo_t* pBMCInfo = &g_BMCInfo[BMCInst];
- //
- // int RetVal, tmpRet = -1;
- //
- // TDBG("Entered : %s with EntityID : %x, SensorNum : %x, OwnerLUN : %x\n", __func__, EntityID, SensorNum, OwnerLUN);
- //
- // sr = SDR_GetFirstSDRRec (BMCInst);
- //
- // while (0 != sr)
- // {
- // // Populate sensor information for Threshold sensors
- // if (FULL_SDR_REC == sr->Type ||
- // COMPACT_SDR_REC == sr->Type)
- // {
- // /* Populate sensor information for full or Compact Record */
- // scs = (_FAR_ CommonSensorRec_T*) sr;
- // TDBG("COMPACT SDR REC SensorNum : %x, OwnerLUN : %x, EntityID : %x, EventTypeCode : %x\n",
- // scs->SensorNum, scs->OwnerLUN, scs->EntityID, scs->EventTypeCode);
- //
- // // Check for EntityId and EntityIns
- // if( (pBMCInfo->IpmiConfig.BMCSlaveAddr == scs->OwnerID) &&
- // (EntityID == scs->EntityID) &&
- // (EntityIns == scs->EntityIns) &&
- // ((SensorNum != scs->SensorNum) || (OwnerLUN != scs->OwnerLUN)) )
- // {
- // RetVal = CheckForEntityPresence (scs->SensorNum, scs->OwnerLUN, scs->EventTypeCode,
- // scs->SensorType,BMCInst);
- // if( NOT_FOUND_SCAN_DISABLED != RetVal &&
- // NOT_FOUND_SCAN_ENABLED != RetVal)
- // {
- // return RetVal;
- // }
- // else if( NOT_FOUND_SCAN_ENABLED == RetVal)
- // {
- // // An Entity is present if there is at least one active
- // // sensor for the Entity (and there is no explicit sensor saying
- // // the Entity is 'absent').
- // // A sensor is 'active' if scanning is enabled.
- // // We can return this value only after searching all the sensors.
- // tmpRet = 1;
- // }
- // }
- // }
- // /* Get the next record */
- // sr = SDR_GetNextSDRRec (sr,BMCInst);
- // }
- // TDBG("Leaving : %s with %d\n", __func__, tmpRet);
- // return tmpRet;
- }
- /**
- * @fn IsEntityAssociationPresence
- * @brief Check the EntityID and Entity instance to see if the entity is
- * a container entity in an entity-association. If so, check to
- * see if any of the contained entities are present, if so, assume
- * the container entity exists.
- * @param[in] EntityID - Entity id of the sensor.
- * @param[in] EntityIns - Entity instance of the sensor.
- * @retval 1, if present
- * 0, if not present
- * -1, if not able to find.
- */
- static int
- IsEntityAssociationPresence (INT8U EntityID, INT8U EntityIns)
- {
- // TDBG("Entered : %s\n", __func__);
- // // TODO: Entity Association record has to be handle later.
- // TDBG("Leaving : %s with -1\n", __func__);
- // return -1;
- }
- /**
- * @fn IsFRUPresence
- * @brief Check the entity to see if FRU device is present.
- * @param[in] EntityID - Entity id of the sensor.
- * @param[in] EntityIns - Entity instance of the sensor.
- * @retval 1, if present
- * 0, if not present
- * -1, if not able to find.
- */
- static int
- IsFRUPresence (INT8U EntityID, INT8U EntityIns,int BMCInst)
- {
- // _FAR_ SDRRecHdr_T* sr = NULL;
- // _FAR_ FRUDevLocatorRec_T* frudl;
- // FRUReadReq_T FRUReadReq;
- // INT8U FRUReadRes[64];
- //
- // TDBG("Entered : %s\n", __func__);
- //
- // sr = SDR_GetFirstSDRRec (BMCInst);
- // while (0 != sr)
- // {
- // // Check for FRU Device locator SDR Record
- // if (sr->Type == FRU_DEVICE_LOCATOR_SDR_REC)
- // {
- // frudl = (_FAR_ FRUDevLocatorRec_T*) sr;
- // TDBG("if Success : EntityID : %x, EntityIns : %x\n",
- // frudl->EntityID, frudl->EntityIns);
- // // If EntityID and EntityIns are equal try to read the fru data.
- // if(frudl->EntityID == EntityID &&
- // frudl->EntityIns == EntityIns)
- // {
- // FRUReadReq.FRUDeviceID=frudl->FRUIDSlaveAddr;
- // FRUReadReq.Offset=0x0;
- // FRUReadReq.CountToRead=sizeof(FRUCommonHeader_T);
- // ReadFRUData((INT8U *)&FRUReadReq, sizeof(FRUReadReq_T), FRUReadRes,BMCInst);
- // if (((FRUReadRes_T *)FRUReadRes)->CompletionCode == FRU_ACCESSIBLE)
- // {
- // TDBG("Leaving : %s with 1\n", __func__);
- // return 1;
- // }
- // else
- // {
- // TDBG("Leaving : %s with 0\n", __func__);
- // return 0;
- // }
- // }
- // }
- // sr = SDR_GetNextSDRRec (sr,BMCInst);
- // }
- // TDBG("Leaving : %s with -1\n", __func__);
- // return -1;
- }
- /**
- * @fn InitSensorScanningBit
- * @brief Initializes all the sensor's Scanning bit with respect
- * to the presence of the entity
- * @retval 0.
- */
- int InitSensorScanningBit(int BMCInst)
- {
- // _FAR_ SDRRecHdr_T* sr = NULL;
- // _FAR_ CommonSensorRec_T* scs = NULL;
- // int RetVal;
- // _FAR_ BMCInfo_t* pBMCInfo = &g_BMCInfo[BMCInst];
- // _FAR_ SensorSharedMem_T* pSenSharedMem = (_FAR_ SensorSharedMem_T*)&pBMCInfo->SensorSharedMem;
- //
- // TDBG("Entered : %s\n", __func__);
- // sr = SDR_GetFirstSDRRec (BMCInst);
- // INT16U LUNSensorNum;
- // while (0 != sr)
- // {
- // // Populater sensor information for Threshold sensors
- // if (FULL_SDR_REC == sr->Type ||
- // COMPACT_SDR_REC == sr->Type)
- // {
- // scs = (_FAR_ CommonSensorRec_T*) sr;
- //
- // if ((pBMCInfo->IpmiConfig.BMCSlaveAddr == scs->OwnerID))
- // {
- //// TDBG("Check for Entity Presence : SensorNum : %x, EntityId : %x, "
- //// "EntityIns : %x, SensorCaps : %x\n",
- //// scs->SensorNum, scs->EntityID, scs->EntityIns,
- //// (scs->SensorCaps & 0x80));
- // RetVal = 1;
- // if( BIT7 == (BIT7 & scs->SensorCaps) )
- // {
- // /* As per IPMI Spec Section 40.2
- // * Entity presence can be detected if any one of the following point is
- // * Satisfied,
- // * 1. If there is an active sensor that includes a presence bit,
- // * or the entity has an active Entity Presence sensor,
- // * use the sensor to determine the presence of the entity.
- // * 2. Check the SDRs to see if the entity is a container entity
- // * in an entity-association. If so, check to see if any of the
- // * contained entities are present, if so, assume the container
- // * entity exists. Note that this may need to be iterative.
- // * 3. The entity is present is there is a FRU device for the
- // * entity, and the FRU device is present.
- // */
- //
- // RetVal = IsSensorPresence(scs->EntityID, scs->EntityIns, scs->SensorNum, scs->OwnerLUN, BMCInst);
- // if( -1 == RetVal )
- // {
- // RetVal = IsEntityAssociationPresence(scs->EntityID, scs->EntityIns);
- // if( -1 == RetVal )
- // {
- // RetVal = IsFRUPresence(scs->EntityID, scs->EntityIns,BMCInst);
- // }
- // }
- // }
- // LUNSensorNum = ((scs->OwnerLUN & VALID_LUN) << 8 | scs->SensorNum);
- // /*
- // * [7] - 0b = All Event Messages disabled from this sensor
- // * [6] - 0b = sensor scanning disabled
- // * [5] - 1b = reading/state unavailable
- // */
- // if(1 == RetVal)
- // {
- // if((BIT0 | BIT1) == (pSenSharedMem->SensorInfo[LUNSensorNum].SensorInit & (BIT0 | BIT1)))
- // {
- // /* Enabling Sensor Scanning and Event Messages*/
- // pSenSharedMem->SensorInfo[LUNSensorNum].EventFlags = EVENT_AND_SCANNING_ENABLE;
- // }
- // else if(BIT1 == (pSenSharedMem->SensorInfo[LUNSensorNum].SensorInit & BIT1))
- // {
- // /* Enabling Event Messages */
- // pSenSharedMem->SensorInfo[LUNSensorNum].EventFlags = EVENT_MSG_MASK;
- // }
- // else if(BIT0 == (pSenSharedMem->SensorInfo[LUNSensorNum].SensorInit & BIT0))
- // {
- // /*Enabling Scanning*/
- // pSenSharedMem->SensorInfo[LUNSensorNum].EventFlags = SCAN_MASK;
- // }
- // if(0 == (pSenSharedMem->SensorInfo[LUNSensorNum].SensorInit & BIT0))
- // {
- // /* Reading Unavailable */
- // pSenSharedMem->SensorInfo[LUNSensorNum].EventFlags |= READING_UNAVAILABLE;
- // }
- // }
- // else
- // {
- // pSenSharedMem->SensorInfo[LUNSensorNum].EventFlags = READING_UNAVAILABLE;
- // if(BIT1 == (pSenSharedMem->SensorInfo[LUNSensorNum].SensorInit & BIT1))
- // {
- // /* Enabling Event Messages */
- // pSenSharedMem->SensorInfo[LUNSensorNum].EventFlags |= EVENT_MSG_MASK;
- // }
- // }
- //// TDBG("\nSensor Scanning Bit for sensor %x : %x\n", scs->SensorNum,
- //// pSenSharedMem->SensorInfo[scs->SensorNum].EventFlags);
- //
- // }
- // }
- // /* Get the next record */
- // sr = SDR_GetNextSDRRec (sr,BMCInst);
- // }
- // TDBG("Leaving : %s with 0\n", __func__);
- // return 0;
- }
- /* Compare two sensor values.
- * Returns -1 if val1 < val2
- * Returns 0 if val1 == val2
- * Returns 1 if val1 > val2
- */
- int
- CompareValues(BOOL isSigned, INT8U val1, INT8U val2)
- {
- // int retval = 0; // default to equal
- //
- // /* Do comparison based on isSigned flag */
- // if (FALSE == isSigned)
- // {
- // // Unsigned comparison
- // if (val1 < val2)
- // {
- // retval = -1;
- // }
- // else if (val1 > val2)
- // {
- // retval = 1;
- // }
- // }
- // else
- // {
- // // Signed comparison
- // INT8 sval1, sval2;
- //
- // sval1 = (INT8)val1;
- // sval2 = (INT8)val2;
- //
- // if (sval1 < sval2)
- // {
- // retval = -1;
- // }
- // else if (sval1 > sval2)
- // {
- // retval = 1;
- // }
- // }
- //
- // return retval;
- }
- /*-----------------------------------------
- * GetSensorReading
- *-----------------------------------------*/
- int
- GetSensorReading (_NEAR_ INT8U* pReq, INT8U ReqLen, _NEAR_ INT8U* pRes,_NEAR_ int BMCInst)
- {
- _NEAR_ GetSensorReadingReq_T* pSensorReadReq =
- (_NEAR_ GetSensorReadingReq_T*) pReq;
- _NEAR_ GetSensorReadingRes_T* pSensorReadRes =
- (_NEAR_ GetSensorReadingRes_T*) pRes;
- INT16U SensorReading;
- bool SensorIsSigned = FALSE;
- _FAR_ BMCInfo_t* pBMCInfo = &g_BMCInfo;
- uint8_t sensorNum;
- sensorNum=pSensorReadReq->SensorNum;
- pSensorReadRes->CompletionCode=0x00;
- pSensorReadRes->Flags=0xc0;
- pSensorReadRes->ComparisonStatus=0xc0;
- pSensorReadRes->OptionalStatus=0x00;
- pSensorReadRes->SensorReading=g_BMCInfo.sensorInfo[sensorNum].sensorReading;
- SessionSequenceNumberCount=SessionSequenceNumberCount+1;
- return sizeof (GetSensorReadingRes_T);
- }
- /*-----------------------------------------
- * SetSensorReading
- *-----------------------------------------*/
- int
- SetSensorReading (_NEAR_ INT8U* pReq, INT8U ReqLen, _NEAR_ INT8U* pRes,_NEAR_ int BMCInst)
- {
- // _NEAR_ SetSensorReadingReq_T* pSensorReadReq =
- // (_NEAR_ SetSensorReadingReq_T*) pReq;
- // _NEAR_ SetSensorReadingRes_T* pSensorReadRes =
- // (_NEAR_ SetSensorReadingRes_T*) pRes;
- // _FAR_ SensorSharedMem_T* pSenSharedMem;
- // _FAR_ BMCInfo_t* pBMCInfo = &g_BMCInfo[BMCInst];
- // pSenSharedMem = (_FAR_ SensorSharedMem_T*)&pBMCInfo->SensorSharedMem; //m_hSensorSharedMem;
- //
- // /* Check for the reserved bits */
- // if (pSenSharedMem->SensorInfo [pSensorReadReq->SensorNum].SensorReadType == THRESHOLD_SENSOR_CLASS)
- // {
- // if (((ReqLen>=LEN_FOR_ASSERT_DATA) && (pSensorReadReq->AssertionEventOccuredByte2 & RESERVED_BITS_SETSENRD_ASSEVTOCCBYTE_1)) ||
- // ((ReqLen>=LEN_FOR_DEASSERT_DATA) && (pSensorReadReq->DeAssertionEventOccuredByte2 & RESERVED_BITS_SETSENRD_DEASSEVTOCCBYTE_1)))
- // {
- // pSensorReadRes->CompletionCode = CC_INV_DATA_FIELD;
- // return sizeof (*pRes);
- // }
- // }
- // else
- // {
- // if (((ReqLen>=LEN_FOR_ASSERT_DATA) && (pSensorReadReq->AssertionEventOccuredByte2 & RESERVED_BITS_SETSENRD_ASSEVTOCCBYTE_2)) ||
- // ((ReqLen>=LEN_FOR_DEASSERT_DATA) && (pSensorReadReq->DeAssertionEventOccuredByte2 & RESERVED_BITS_SETSENRD_DEASSEVTOCCBYTE_2)))
- // {
- // pSensorReadRes->CompletionCode = CC_INV_DATA_FIELD;
- // return sizeof (*pRes);
- // }
- // }
- //
- // if (pBMCInfo->IpmiConfig.OPMASupport == 1)
- // {
- // if (pSenSharedMem->GlobalSensorScanningEnable == FALSE)
- // {
- // pSensorReadRes->CompletionCode = CC_PARAM_NOT_SUP_IN_CUR_STATE;
- // return sizeof (*pRes);
- // }
- // }
- //
- // /* Acquire Shared memory */
- // OS_THREAD_MUTEX_ACQUIRE(&pBMCInfo->SensorSharedMemMutex, WAIT_INFINITE);
- //
- // if (!pSenSharedMem->SensorInfo [pSensorReadReq->SensorNum].IsSensorPresent)
- // {
- // /* Release mutex for Sensor shared memory */
- // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->SensorSharedMemMutex);
- //
- // pSensorReadRes->CompletionCode = CC_SDR_REC_NOT_PRESENT;
- // return sizeof (*pRes);
- // }
- //
- // if (ReqLen < MIN_SET_SEN_READING_CMD_LEN)
- // {
- // /* Release mutex for Sensor shared memory */
- // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->SensorSharedMemMutex);
- //
- // pSensorReadRes->CompletionCode = CC_REQ_INV_LEN;
- // return sizeof (*pRes);
- // }
- //
- //
- // /* Check if the sensor is settable */
- // if (0 == GET_SETTABLE_SENSOR_BIT(pSenSharedMem->SensorInfo [pSensorReadReq->SensorNum].SensorInit))
- // {
- // /* Release mutex for Sensor shared memory */
- // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->SensorSharedMemMutex);
- //
- // pSensorReadRes->CompletionCode = CC_INVALID_ATTEMPT_TO_SET;
- // return sizeof (*pRes);
- // }
- //
- // pSenSharedMem->SensorInfo [pSensorReadReq->SensorNum].Operation = pSensorReadReq->Operation;
- //
- // /* Set Sensor Event Data based on the Operation byte */
- // switch (GET_EVENT_DATA_OP(pSensorReadReq->Operation))
- // {
- // case WRITE_NO_EVTDATA1:
- // pSensorReadReq->EvtData1 &= 0xF0;
- // /* Intentional Fall thru */
- // case WRITE_EVTDATA1:
- // if (LEN_FOR_EVT_DATA != ReqLen)
- // {
- // /* Release mutex for Sensor shared memory */
- // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->SensorSharedMemMutex);
- //
- // pSensorReadRes->CompletionCode = CC_REQ_INV_LEN;
- // return sizeof (*pRes);
- // }
- // /* Update EvtData fields */
- // pSenSharedMem->SensorInfo [pSensorReadReq->SensorNum].EvtData1 = pSensorReadReq->EvtData1;
- // pSenSharedMem->SensorInfo [pSensorReadReq->SensorNum].EvtData2 = pSensorReadReq->EvtData2;
- // pSenSharedMem->SensorInfo [pSensorReadReq->SensorNum].EvtData3 = pSensorReadReq->EvtData3;
- // break;
- // }
- //
- // /* Check Length for Assertion Set Opetation */
- // if (0 != GET_ASSERT_EVT_OP(pSensorReadReq->Operation))
- // {
- // if ((ReqLen < LEN_FOR_ASSERT_DATA) || (ReqLen > MAX_SET_SEN_READ_LEN))
- // {
- // /* Release mutex for Sensor shared memory */
- // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->SensorSharedMemMutex);
- //
- // pSensorReadRes->CompletionCode = CC_REQ_INV_LEN;
- // return sizeof (*pRes);
- // }
- // }
- //
- // /* Set Sensor Assertion Event based on the Operation byte */
- // switch (GET_ASSERT_EVT_OP(pSensorReadReq->Operation))
- // {
- // case CLEAR_ASSERT_BITS:
- // pSenSharedMem->SensorInfo [pSensorReadReq->SensorNum].AssertionEventOccuredByte1 &= pSensorReadReq->AssertionEventOccuredByte1;
- // pSenSharedMem->SensorInfo [pSensorReadReq->SensorNum].AssertionEventOccuredByte2 &= pSensorReadReq->AssertionEventOccuredByte2;
- // break;
- //
- // case SET_ASSERT_BITS:
- // pSenSharedMem->SensorInfo [pSensorReadReq->SensorNum].AssertionEventOccuredByte1 |= pSensorReadReq->AssertionEventOccuredByte1;
- // pSenSharedMem->SensorInfo [pSensorReadReq->SensorNum].AssertionEventOccuredByte2 |= pSensorReadReq->AssertionEventOccuredByte2;
- // break;
- //
- // case WRITE_ASSERT_BITS:
- // pSenSharedMem->SensorInfo [pSensorReadReq->SensorNum].AssertionEventOccuredByte1 |= pSensorReadReq->AssertionEventOccuredByte1;
- // pSenSharedMem->SensorInfo [pSensorReadReq->SensorNum].AssertionEventOccuredByte2 |= pSensorReadReq->AssertionEventOccuredByte2;
- // break;
- // }
- //
- //
- // /* Check Length for Assertion Set Opetation */
- // if (0 != GET_DEASSERT_EVT_OP(pSensorReadReq->Operation))
- // {
- // if ((ReqLen < LEN_FOR_DEASSERT_DATA) || (ReqLen > MAX_SET_SEN_READ_LEN))
- // {
- // /* Release mutex for Sensor shared memory */
- // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->SensorSharedMemMutex);
- //
- // pSensorReadRes->CompletionCode = CC_REQ_INV_LEN;
- // return sizeof (*pRes);
- // }
- // }
- //
- // /* Set Sensor DeAssertion Event based on the Operation byte */
- // switch (GET_DEASSERT_EVT_OP(pSensorReadReq->Operation))
- // {
- // case CLEAR_DEASSERT_BITS:
- // pSenSharedMem->SensorInfo [pSensorReadReq->SensorNum].DeassertionEventOccuredByte1 &= pSensorReadReq->DeAssertionEventOccuredByte1;
- // pSenSharedMem->SensorInfo [pSensorReadReq->SensorNum].DeassertionEventOccuredByte2 &= pSensorReadReq->DeAssertionEventOccuredByte2;
- // break;
- //
- // case SET_DEASSERT_BITS:
- // pSenSharedMem->SensorInfo [pSensorReadReq->SensorNum].DeassertionEventOccuredByte1 |= pSensorReadReq->DeAssertionEventOccuredByte1;
- // pSenSharedMem->SensorInfo [pSensorReadReq->SensorNum].DeassertionEventOccuredByte2 |= pSensorReadReq->DeAssertionEventOccuredByte2;
- // break;
- //
- // case WRITE_DEASSERT_BITS:
- // pSenSharedMem->SensorInfo [pSensorReadReq->SensorNum].DeassertionEventOccuredByte1 |= pSensorReadReq->DeAssertionEventOccuredByte1;
- // pSenSharedMem->SensorInfo [pSensorReadReq->SensorNum].DeassertionEventOccuredByte2 |= pSensorReadReq->DeAssertionEventOccuredByte2;
- // break;
- // }
- //
- //
- // /* Check Length for Set Sensor Reading Operation */
- // if (0 != GET_SETSENSOR_OP(pSensorReadReq->Operation))
- // {
- // if ((ReqLen < LEN_FOR_SETSENSOR_DATA) || (ReqLen > MAX_SET_SEN_READ_LEN))
- // {
- // /* Release mutex for Sensor shared memory */
- // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->SensorSharedMemMutex);
- //
- // pSensorReadRes->CompletionCode = CC_REQ_INV_LEN;
- // return sizeof (*pRes);
- // }
- //
- // /* Set new Sensor Reading */
- // pSenSharedMem->SensorInfo [pSensorReadReq->SensorNum].SensorReading = pSensorReadReq->SensorReading;
- //
- // }
- //
- // pSensorReadRes->CompletionCode = CC_NORMAL;
- //
- // /* Release mutex for Sensor shared memory */
- // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->SensorSharedMemMutex);
- //
- // return sizeof (SetSensorReadingRes_T);
- }
- /*-------------------------------------------
- * GetSensorSDR
- *-------------------------------------------*/
- _FAR_ SDRRecHdr_T*
- SR_GetSensorSDR (INT8U SensorNum, int BMCInst)
- {
- // _FAR_ SDRRecHdr_T* SDRRec;
- //
- // /* Search for the record containing the sensor */
- // SDRRec = SDR_GetFirstSDRRec (BMCInst);
- // while (0 != SDRRec)
- // {
- // switch (SDRRec->Type)
- // {
- // case FULL_SDR_REC :
- // if (((_FAR_ FullSensorRec_T*) SDRRec)->SensorNum == SensorNum)
- // {
- // return SDRRec;
- // }
- // break;
- //
- // case COMPACT_SDR_REC:
- // {
- // INT16U SharedRecs = ipmitoh_u16 (((_FAR_ CompactSensorRec_T*) SDRRec)->RecordSharing) &
- // SHARED_RECD_COUNT;
- // if ((SensorNum == ((_FAR_ CompactSensorRec_T*) SDRRec)->SensorNum ) ||
- // ((SensorNum >= (((_FAR_ CompactSensorRec_T*) SDRRec)->SensorNum )) &&
- // (SensorNum < (((_FAR_ CompactSensorRec_T*) SDRRec)->SensorNum + SharedRecs)))
- // )
- // {
- // return SDRRec;
- // }
- // }
- // break;
- //
- // default :
- // break;
- // }
- //
- // /* Get the next record */
- // SDRRec = SDR_GetNextSDRRec (SDRRec,BMCInst);
- // if (0 == SDRRec)
- // {
- // return 0;
- // }
- // }
- //
- // return 0;
- }
- /**
- * @brief Update global variables with number sensors.
- **/
- static void
- FindNumSensors (int BMCInst)
- {
- // _FAR_ SDRRecHdr_T* pSDRRec;
- // _FAR_ FullSensorRec_T* pFSR;
- // _FAR_ CompactSensorRec_T* pCSR;
- //
- // pFSR = 0;
- // pCSR = 0;
- //
- // /* Get First SDR Record */
- // pSDRRec = SDR_GetFirstSDRRec (BMCInst);
- // while (0 != pSDRRec)
- // {
- // switch (pSDRRec->Type)
- // {
- // case FULL_SDR_REC :
- //
- // pFSR = (_FAR_ FullSensorRec_T*) pSDRRec;
- // if (THRESHOLD_SENSOR_CLASS == pFSR->EventTypeCode)
- // {
- // g_BMCInfo[BMCInst].SenConfig.NumThreshSensors++;
- // }
- // else
- // {
- // g_BMCInfo[BMCInst].SenConfig.NumNonThreshSensors++;
- // }
- // break;
- //
- // case COMPACT_SDR_REC :
- //
- // pCSR = (_FAR_ CompactSensorRec_T*) pSDRRec;
- // if (THRESHOLD_SENSOR_CLASS == pCSR->EventTypeCode)
- // {
- // g_BMCInfo[BMCInst].SenConfig.NumThreshSensors += (ipmitoh_u16 (pCSR->RecordSharing) &
- // SHARED_RECD_COUNT);
- // }
- // else
- // {
- // g_BMCInfo[BMCInst].SenConfig.NumNonThreshSensors += (ipmitoh_u16 (pCSR->RecordSharing) &
- // SHARED_RECD_COUNT);
- // }
- // break;
- //
- // default:
- //
- // break;
- // }
- //
- // /* Get the next record */
- // pSDRRec = SDR_GetNextSDRRec (pSDRRec,BMCInst);
- //
- // }
- //
- //
- // IPMI_DBG_PRINT_1("Thereshold Sensors = %d\n",g_BMCInfo[BMCInst].SenConfig.NumThreshSensors);
- // IPMI_DBG_PRINT_1("Non Thershold Sensors = %d\n",g_BMCInfo[BMCInst].SenConfig.NumNonThreshSensors);
- //
- //
- // return;
- }
- int
- GetRecordIdsforDCMISensor (INT8U EntityID,INT8U SensorType, INT8U EntityInstance,
- INT8U StartingEntityInstance, INT16U* pBuf, INT8U* pTotalValidInstances,int BMCInst)
- {
- // int i, ValidInstances;
- // _FAR_ SensorSharedMem_T* pSenSharedMem;
- // _FAR_ BMCInfo_t* pBMCInfo = &g_BMCInfo[BMCInst];
- // pSenSharedMem = (_FAR_ SensorSharedMem_T*)&pBMCInfo->SensorSharedMem; //m_hSensorSharedMem;
- //
- // if (0 != EntityInstance)
- // {
- // *pTotalValidInstances = 0;
- // ValidInstances = 0;
- // /* Acquire Shared memory to populate sensor information */
- // //OS_ACQUIRE_MUTEX(m_hSensorSharedMemMutex, SHARED_MEM_TIMEOUT);
- // OS_THREAD_MUTEX_ACQUIRE(&g_BMCInfo[BMCInst].SensorSharedMemMutex, WAIT_INFINITE);
- //
- // for (i = 0; i < MAX_SENSOR_NUMBERS + 1; i++ )
- // {
- // if ((TRUE == pSenSharedMem->SensorInfo [i].IsDCMITempsensor) && (pSenSharedMem->SensorInfo[i].SDRRec->Type == FULL_SDR_REC) )
- // {
- // if(SensorType != pSenSharedMem->SensorInfo[i].SensorTypeCode)
- // {
- // /*Check the Sensor type*/
- // continue;
- // }
- //
- // 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))) ||
- // (((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))) ||
- // (((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))))
- // {
- // *pTotalValidInstances += 1;
- // if (EntityInstance == pSenSharedMem->SensorInfo [i].EntiryInstance)
- // {
- // pBuf [0] = pSenSharedMem->SensorInfo [i].RecordID;
- // ValidInstances = 1;
- // }
- // }
- // }
- // }
- // /* Release mutex for Sensor shared memory */
- // OS_THREAD_MUTEX_RELEASE(&g_BMCInfo[BMCInst].SensorSharedMemMutex);
- // return ValidInstances;
- // }
- // else
- // {
- // *pTotalValidInstances = 0;
- // ValidInstances = 0;
- // /* Acquire Shared memory to populate sensor information */
- // //OS_ACQUIRE_MUTEX(m_hSensorSharedMemMutex, SHARED_MEM_TIMEOUT);
- // OS_THREAD_MUTEX_ACQUIRE(&g_BMCInfo[BMCInst].SensorSharedMemMutex, WAIT_INFINITE);
- //
- // for (i = StartingEntityInstance; i < MAX_SENSOR_NUMBERS + 1; i++ )
- // {
- // if ((TRUE == pSenSharedMem->SensorInfo [i].IsDCMITempsensor) && (pSenSharedMem->SensorInfo[i].SDRRec->Type == FULL_SDR_REC) )
- // {
- // if(SensorType != pSenSharedMem->SensorInfo[i].SensorTypeCode)
- // {
- // /*Check the Sensor type*/
- // continue;
- // }
- //
- // 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))) ||
- // (((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))) ||
- // (((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))))
- // {
- // *pTotalValidInstances += 1;
- // if (ValidInstances < 8)
- // {
- // pBuf [ValidInstances] = pSenSharedMem->SensorInfo [i].RecordID;
- // ValidInstances += 1;
- // }
- // }
- // }
- // }
- // /* Release mutex for Sensor shared memory */
- // //OS_RELEASE_MUTEX(m_hSensorSharedMemMutex);
- // OS_THREAD_MUTEX_RELEASE(&g_BMCInfo[BMCInst].SensorSharedMemMutex);
- // return (ValidInstances > 8) ? 8: ValidInstances;
- // }
- }
- int GetDCMITempReading(INT8U EntityID,INT8U SensorType, INT8U EntityInstance,
- INT8U StartingEntityInstance, INT8U* pBuf, INT8U* pTotalValidInstances,int BMCInst)
- {
- // int i, ValidInstances,j = 0;
- // _FAR_ SensorSharedMem_T* pSenSharedMem;
- // _FAR_ BMCInfo_t* pBMCInfo = &g_BMCInfo[BMCInst];
- // pSenSharedMem = (_FAR_ SensorSharedMem_T*)&pBMCInfo->SensorSharedMem; //m_hSensorSharedMem;
- // _FAR_ SDRRecHdr_T* pSDRRec;
- // _FAR_ FullSensorRec_T* FullSDR;
- // float convreading = 0;
- // INT8U MinReading = 0, MaxReading = 0,Linear = 0;
- //
- // if (0 != EntityInstance)
- // {
- // *pTotalValidInstances = 0;
- // ValidInstances = 0;
- // OS_THREAD_MUTEX_ACQUIRE(&g_BMCInfo[BMCInst].SensorSharedMemMutex, WAIT_INFINITE);
- //
- // for (i = 0; i < MAX_SENSOR_NUMBERS + 1; i++ )
- // {
- // if ((TRUE == pSenSharedMem->SensorInfo [i].IsDCMITempsensor) && (pSenSharedMem->SensorInfo[i].SDRRec->Type == FULL_SDR_REC) )
- // {
- //
- // if(SensorType != pSenSharedMem->SensorInfo[i].SensorTypeCode)
- // {
- // /*Check the Sensor type*/
- // continue;
- // }
- //
- // 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))) ||
- // (((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))) ||
- // (((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))))
- // {
- // *pTotalValidInstances += 1;
- // if (EntityInstance == pSenSharedMem->SensorInfo [i].EntiryInstance)
- // {
- // if( !( pSenSharedMem->SensorInfo[i].EventFlags & 0x40) || (pSenSharedMem->SensorInfo[i].EventFlags & 0x20) )
- // {
- // printf("event flag is disabled\n");
- // pBuf[DCMI_TEMP_READING] = 0;
- // pBuf[DCMI_INST_NUMBER] = 0;
- // }
- // else
- // {
- // pSDRRec = GetSDRRec(pSenSharedMem->SensorInfo[i].SDRRec->ID,BMCInst);
- //
- // FullSDR = (_FAR_ FullSensorRec_T *)pSDRRec;
- // MinReading = FullSDR->MinReading;
- // MaxReading = FullSDR->MaxReading;
- // Linear = FullSDR->Linearization;
- //
- // 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,
- // pSenSharedMem->SensorInfo[i].B_LSB, pSenSharedMem->SensorInfo[i].M_MSB_Tolerance, pSenSharedMem->SensorInfo[i].B_MSB_Accuracy, pSenSharedMem->SensorInfo[i].RExp_BExp);
- //
- // pBuf [DCMI_TEMP_READING] = (INT8)convreading;
- // pBuf [DCMI_INST_NUMBER] = EntityInstance;
- // }
- // ValidInstances = 1;
- // }
- // }
- // }
- // }
- // /* Release mutex for Sensor shared memory */
- // OS_THREAD_MUTEX_RELEASE(&g_BMCInfo[BMCInst].SensorSharedMemMutex);
- // return ValidInstances;
- // }
- // else
- // {
- // *pTotalValidInstances = 0;
- // ValidInstances = 0;
- //
- // OS_THREAD_MUTEX_ACQUIRE(&g_BMCInfo[BMCInst].SensorSharedMemMutex, WAIT_INFINITE);
- //
- // for (i = StartingEntityInstance; i < MAX_SENSOR_NUMBERS + 1; i++ )
- // {
- // if ((TRUE == pSenSharedMem->SensorInfo [i].IsDCMITempsensor) && (pSenSharedMem->SensorInfo[i].SDRRec->Type == FULL_SDR_REC) )
- // {
- //
- // if(SensorType != pSenSharedMem->SensorInfo[i].SensorTypeCode)
- // {
- // /*Check the Sensor type*/
- // continue;
- // }
- //
- // 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))) ||
- // (((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))) ||
- // (((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))))
- // {
- // *pTotalValidInstances += 1;
- // if (ValidInstances < 8)
- // {
- // if( !( pSenSharedMem->SensorInfo[i].EventFlags & 0x40) || (pSenSharedMem->SensorInfo[i].EventFlags & 0x20) )
- // {
- // pBuf[DCMI_TEMP_READING + j] = 0;
- // pBuf[DCMI_INST_NUMBER + j] = 0;
- // j = j+2;
- // }
- // else
- // {
- // pSDRRec = GetSDRRec(pSenSharedMem->SensorInfo[i].SDRRec->ID,BMCInst);
- // FullSDR = (_FAR_ FullSensorRec_T *)pSDRRec;
- // MinReading = FullSDR->MinReading;
- // MaxReading = FullSDR->MaxReading;
- // Linear = FullSDR->Linearization;
- //
- // 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,
- // pSenSharedMem->SensorInfo[i].B_LSB, pSenSharedMem->SensorInfo[i].M_MSB_Tolerance, pSenSharedMem->SensorInfo[i].B_MSB_Accuracy, pSenSharedMem->SensorInfo[i].RExp_BExp);
- //
- // pBuf[ j++] = (INT8)convreading;
- // pBuf[ j++] = pSenSharedMem->SensorInfo[i].EntiryInstance;
- // TDBG("j value %d\n",j);
- // }
- // ValidInstances += 1;
- // }
- // }
- // }
- // }
- //
- // OS_THREAD_MUTEX_RELEASE(&g_BMCInfo[BMCInst].SensorSharedMemMutex);
- // return (ValidInstances > 8) ? 8: ValidInstances;
- //
- // }
- }
- #endif /* SENSOR_DEVICE */
|