123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130 |
- /*****************************************************************
- *****************************************************************
- *** **
- *** (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>
- ******************************************************************/
- #include "MsgHndlr.h"
- #include "sensor_tbl.h"
- #include "com_IPMI_Sensor.h"
- #include "Support.h"
- #include "Sensor.h"
- #include "SDRFunc.h"
- #include "SensorEvent.h"
- #include <string.h>
- #include "main.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() (g_BMCInfo.SenConfig.NumThreshSensors + g_BMCInfo.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 */
- uint8_t M_LSB;
- uint8_t M_MSB_Tolerance;
- uint8_t B_LSB;
- uint8_t B_MSB_Accuracy;
- uint8_t Accuracy_MSB_Exp;
- uint8_t RExp_BExp;
- uint8_t PositiveHysterisis;
- uint8_t NegativeHysterisis;
- uint8_t LowerNonCritical;
- uint8_t LowerCritical;
- uint8_t LowerNonRecoverable;
- uint8_t UpperNonCritical;
- uint8_t UpperCritical;
- uint8_t UpperNonRecoverable;
- uint8_t EventFlags;
- uint16_t AssertionMask;
- uint16_t DeAssertionMask;
- uint8_t EventTypeCode;
- uint16_t ReadWriteThreshMask;
- uint8_t SensorInit;
- uint8_t SensorNum;
- } SR_SensorInfo_T;
- /*** Global Variables ***/
- // uint8_t g_NumThreshSensors;
- // uint8_t g_NumNonThreshSensors;
- // uint8_t g_FRUInfo[MAX_PDK_FRU_SUPPORTED];
- //FRUInfo_T *m_FRUInfo[MAX_PDK_FRU_SUPPORTED];
- //uint8_t m_total_frus=0;
- //Sensor-Type Sensor-specific-offset
- static const uint8_t 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 (void);
- /*---------------------------------------
- * InitSensor
- *---------------------------------------*/
- int
- InitSensorInfo ()
- {
- SensorInfo_T* pSensorInfo;
- SensorSharedMem_T* pSMSharedMem;
- SDRRecHdr_T* pSDRRec;
- int i;
-
- pSMSharedMem = ( SensorSharedMem_T*)&g_BMCInfo.SensorSharedMem;
- /* Update Sensor Properties & Get SDR & initialize sensors */
- for (i = 0; i < g_BMCInfo.SenConfig.ValidSensorCnt; i++)
- {
- pSensorInfo = (SensorInfo_T*)&pSMSharedMem->SensorInfo [i];
-
- g_BMCInfo.SenConfig.ValidSensorList[i] = sensor_tbl[i].sensor_number;
-
- pSensorInfo->SensorNumber = sensor_tbl[i].sensor_number;
- pSensorInfo->SensorReading = 0;
- pSensorInfo->SensorMonitorInterval = sensor_tbl[i].monitor_interval;
- pSensorInfo->SensorState = sensor_tbl[i].monitor_state;
- pSensorInfo->PowerOnDelay = sensor_tbl[i].poweron_delay;
- pSensorInfo->SysResetDelay = sensor_tbl[i].reset_delay;
-
- pSDRRec = SR_FindSDR(pSensorInfo->SensorNumber);
-
- SR_LoadSDRDefaults(pSDRRec, pSensorInfo);
-
- pSensorInfo->SDRRec = (SDRRecHdr_T*)pSDRRec;
- }
- return 0;
- }
- /*---------------------------------------
- * InitSensor
- *---------------------------------------*/
- int
- InitSensorDev ()
- {
- int i;
- sensor_tbl_t* pSensorDev = NULL;
- for(i=0;i<g_BMCInfo.SenConfig.ValidSensorCnt;i++)
- {
- pSensorDev = (sensor_tbl_t*)getSensorDev(g_BMCInfo.SenConfig.ValidSensorList[i]);
- pSensorDev->device_init();
- }
- return 0;
- }
- /*-----------------------------------------
- * SR_FindSDR
- *-----------------------------------------*/
- SDRRecHdr_T* SR_FindSDR (uint8_t SensorNum)
- {
- SDRRecHdr_T* sr = SDR_GetFirstSDRRec ();
- FullSensorRec_T* sfs = NULL;
- CompactSensorRec_T* scs = NULL;
-
- while(sr != 0)
- {
- if (sr->Type == FULL_SDR_REC)
- {
- sfs = (FullSensorRec_T*) sr;
- if (sfs->SensorNum == SensorNum) { return sr; }
- }
- else if (sr->Type == COMPACT_SDR_REC)
- {
- scs = (CompactSensorRec_T*) sr;
- if (scs->SensorNum == SensorNum) { return sr; }
- }
- /* Get the next record */
- sr = SDR_GetNextSDRRec (sr);
- }
- 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, SensorInfo_T* pSensorInfo)
- {
- FullSensorRec_T* sfs;
- CompactSensorRec_T* scs;
- // Populater sensor information for Threshold sensors
- if (sr->Type == FULL_SDR_REC)
- {
- sfs = ( 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->RecordID = sfs->hdr.ID;
- pSensorInfo->PosHysteresis = sfs->PositiveHysterisis;
- pSensorInfo->NegHysteresis = sfs->NegativeHysterisis;
- pSensorInfo->SensorInit = sfs->SensorInit;
- pSensorInfo->SettableThreshMask = (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 = (sfs->AssertionEventMask) & 0xFF;
- pSensorInfo->AssertionEventEnablesByte2 = ((sfs->AssertionEventMask) >> 8) & 0xFF;
- pSensorInfo->DeassertionEventEnablesByte1= (sfs->DeAssertionEventMask) & 0xFF;
- pSensorInfo->DeassertionEventEnablesByte2= ((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;
- }
- }
- else if (sr->Type == COMPACT_SDR_REC)
- {
- scs = ( 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 = (scs->AssertionEventMask) & 0xFF;
- pSensorInfo->AssertionEventEnablesByte2 = ((scs->AssertionEventMask) >> 8) & 0xFF;
- pSensorInfo->DeassertionEventEnablesByte1= (scs->DeAssertionEventMask) & 0xFF;
- pSensorInfo->DeassertionEventEnablesByte2= ((scs->DeAssertionEventMask) >> 8) & 0xFF;
- pSensorInfo->SensorInit = scs->SensorInit;
- pSensorInfo->SettableThreshMask = (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->OEMField = scs->OEMField ;
- pSensorInfo->InternalFlags = 0;
- // pSensorInfo->InternalFlags |= BIT0; // Disable internal scanning by default
- // Check for a signed sensor
- if (0x80 == (scs->Units1 & 0xC0))
- {
- pSensorInfo->InternalFlags |= BIT1;
- }
- }
- }
- /*---------------------------------------
- * GetDevSDRInfo
- *---------------------------------------*/
- int
- GetDevSDRInfo ( uint8_t* pReq, uint8_t ReqLen, uint8_t* pRes)
- {
- GetSDRInfoRes_T* pGetDevSDRInfoRes = (GetSDRInfoRes_T*) pRes;
- /* Fill in response data */
- pGetDevSDRInfoRes->CompletionCode = CC_NORMAL;
- pGetDevSDRInfoRes->NumSensor = g_BMCInfo.SenConfig.ValidSensorCnt;
- pGetDevSDRInfoRes->Flags = 0x01; /* BIT7 = 0 (static sensors), BIT0 = 1 (on LUN 0) */
- pGetDevSDRInfoRes->TimeStamp = 0;
- return sizeof (GetSDRInfoRes_T);
- }
- /*---------------------------------------
- * GetDevSDR
- *---------------------------------------*/
- int
- GetDevSDR ( uint8_t* pReq, uint8_t ReqLen, uint8_t* pRes)
- {
- return GetSDR (pReq, ReqLen, pRes);
- }
- /*---------------------------------------
- * GetDevSDR
- *---------------------------------------*/
- int
- ReserveDevSDRRepository ( uint8_t* pReq, uint8_t ReqLen, uint8_t* pRes)
- {
- return ReserveSDRRepository (pReq, ReqLen, pRes);
- }
- /*---------------------------------------
- * SetSensorType
- *---------------------------------------*/
- int
- SetSensorType ( uint8_t* pReq, uint8_t ReqLen, uint8_t* pRes)
- {
- printf("SetSensorType not implement\r\n");
- // //pRes [0] = CC_INV_CMD;
- // //return sizeof (*pRes);
- // SetSensorTypeReq_T * pSetSensorTypeReq=( SetSensorTypeReq_T *)pReq;
- // SetSensorTypeRes_T * pSetSensorTypeRes=( SetSensorTypeRes_T *)pRes;
- // SensorSharedMem_T* pSenSharedMem;
- // 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 = ( SensorSharedMem_T*)&g_BMCInfo.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);
- return 0;
- }
- /*---------------------------------------
- * GetSensorType
- *---------------------------------------*/
- int
- GetSensorType ( uint8_t* pReq, uint8_t ReqLen, uint8_t* pRes)
- {
- //pRes [0] = CC_INV_CMD;
- // return sizeof (*pRes);
- GetSensorTypeReq_T * pGetSensorTypeReq=( GetSensorTypeReq_T *)pReq;
- GetSensorTypeRes_T * pGetSensorTypeRes=( GetSensorTypeRes_T *)pRes;
- SensorInfo_T* pSensorInfo = NULL;
- pSensorInfo = getSensorInfo(pGetSensorTypeReq->SensorNum);
- pGetSensorTypeRes->CompletionCode=CC_NORMAL;
- pGetSensorTypeRes->SensorType=pSensorInfo->SensorTypeCode;
- pGetSensorTypeRes->EventTypeCode=pSensorInfo->EventTypeCode;
- return sizeof(*pGetSensorTypeRes);
- }
- /*---------------------------------------
- * ReArmSensor
- *---------------------------------------*/
- int
- ReArmSensor ( uint8_t* pReq, uint8_t ReqLen, uint8_t* pRes)
- {
- printf("ReArmSensor not implement\r\n");
- // MsgPkt_T Msg;
- // HQueue_T hSMHndlr_Q;
- // ReArmSensorReq_T ReArmSensorReq;
- // ReArmSensorReq_T* pReArmSensorReq = &ReArmSensorReq;
- // ReArmSensorRes_T* pReArmSensorRes = ( ReArmSensorRes_T*) pRes;
- // _fmemset (&ReArmSensorReq, 0, sizeof (ReArmSensorReq_T));
- // _fmemcpy (&ReArmSensorReq, pReq, ReqLen);
- // SensorSharedMem_T* pSenSharedMem;
- // 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(&g_BMCInfo.SensorSharedMemMutex, WAIT_INFINITE);
- // pSenSharedMem = ( SensorSharedMem_T*)&g_BMCInfo.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(&g_BMCInfo.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(&g_BMCInfo.SensorSharedMemMutex);
- // return sizeof (*pRes);
- // }
- // }
- // if (g_BMCInfo.IpmiConfig.OPMASupport == 1)
- // {
- // if (pSenSharedMem->GlobalSensorScanningEnable == FALSE)
- // {
- // pReArmSensorRes->CompletionCode = CC_PARAM_NOT_SUP_IN_CUR_STATE;
- // OS_THREAD_MUTEX_RELEASE(&g_BMCInfo.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(&g_BMCInfo.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(&g_BMCInfo.SensorSharedMemMutex);
- // return (sizeof(ReArmSensorRes_T));
- return 1;
- }
- /*---------------------------------------
- * GetSensorEventStatus
- *---------------------------------------*/
- int
- GetSensorEventStatus ( uint8_t* pReq, uint8_t ReqLen, uint8_t* pRes)
- {
- GetSensorEventStatusReq_T* pSensorEventStatusReq = ( GetSensorEventStatusReq_T*) pReq;
- GetSensorEventStatusRes_T* pSensorEventStatusRes = ( GetSensorEventStatusRes_T*) pRes;
- SensorInfo_T* pSensorInfo = getSensorInfo(pSensorEventStatusReq->SensorNum);
- pSensorEventStatusRes->CompletionCode = CC_NORMAL;
- pSensorEventStatusRes->Flags = (pSensorInfo->EventFlags & 0xe0);
- /* Set optional response bytes to zero if event messages are disabled for this sensor */
- if (0 == ((pSensorInfo->EventFlags) & BIT7))
- {
- pSensorEventStatusRes->AssertionEvents1 = 0;
- pSensorEventStatusRes->AssertionEvents2 = 0;
- pSensorEventStatusRes->DeassertionEvents1 = 0;
- pSensorEventStatusRes->DeassertionEvents2 = 0;
- return sizeof (GetSensorEventStatusRes_T);
- }
- if (0 == ((pSensorInfo->SensorCaps) & BIT6))
- {
- /* Get sensor event status history */
- pSensorEventStatusRes->AssertionEvents1 = (pSensorInfo->AssertionHistoryByte1 & pSensorInfo->AssertionEventEnablesByte1);
- pSensorEventStatusRes->AssertionEvents2 = (pSensorInfo->AssertionHistoryByte2 & pSensorInfo->AssertionEventEnablesByte2);
- pSensorEventStatusRes->DeassertionEvents1 = (pSensorInfo->DeassertionHistoryByte1 & pSensorInfo->DeassertionEventEnablesByte1);
- pSensorEventStatusRes->DeassertionEvents2 = (pSensorInfo->DeassertionHistoryByte2 & pSensorInfo->DeassertionEventEnablesByte2);
- }
- else
- {
- /* Get present sensor event status */
- pSensorEventStatusRes->AssertionEvents1 = (pSensorInfo->AssertionEventOccuredByte1 & pSensorInfo->AssertionEventEnablesByte1);
- pSensorEventStatusRes->AssertionEvents2 = (pSensorInfo->AssertionEventOccuredByte2 & pSensorInfo->AssertionEventEnablesByte2);
- pSensorEventStatusRes->DeassertionEvents1 = (pSensorInfo->DeassertionEventOccuredByte1 & pSensorInfo->DeassertionEventEnablesByte1);
- pSensorEventStatusRes->DeassertionEvents2 =(pSensorInfo->DeassertionEventOccuredByte2 & pSensorInfo->DeassertionEventEnablesByte2);
- }
- return sizeof (GetSensorEventStatusRes_T);
- }
- /*---------------------------------------
- * SetSensorHysterisis
- *---------------------------------------*/
- int
- SetSensorHysterisis ( uint8_t* pReq, uint8_t ReqLen, uint8_t* pRes)
- {
- // SetSensorHysterisisReq_T* pSensorHysReq =
- // ( SetSensorHysterisisReq_T*) pReq;
- SetSensorHysterisisRes_T* pSensorHysRes =
- ( SetSensorHysterisisRes_T*) pRes;
- printf("SetSensorHysterisis not implement\r\n");
- // SensorSharedMem_T* pSenSharedMem;
- // BMCInfo_t* pBMCInfo = &g_BMCInfo[BMCInst];
- // pSenSharedMem = ( SensorSharedMem_T*)&g_BMCInfo.SensorSharedMem; //m_hSensorSharedMem;
- // if (g_BMCInfo.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(&g_BMCInfo.SensorSharedMemMutex, WAIT_INFINITE);
- // if (!pSenSharedMem->SensorInfo [pSensorHysReq->SensorNum].IsSensorPresent)
- // {
- // /* Release mutex for Sensor shared memory */
- // OS_THREAD_MUTEX_RELEASE(&g_BMCInfo.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(&g_BMCInfo.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(&g_BMCInfo.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(&g_BMCInfo.SensorSharedMemMutex);
- pSensorHysRes->CompletionCode = CC_NORMAL;
- return sizeof (SetSensorHysterisisRes_T);
- }
- /*---------------------------------------
- * GetSensorHysterisis
- *---------------------------------------*/
- int
- GetSensorHysterisis ( uint8_t* pReq, uint8_t ReqLen, uint8_t* pRes)
- {
- GetSensorHysterisisReq_T* pSensorHysReq =
- ( GetSensorHysterisisReq_T*) pReq;
- GetSensorHysterisisRes_T* pSensorHysRes =
- ( GetSensorHysterisisRes_T*) pRes;
- SensorInfo_T* pSensorInfo = getSensorInfo(pSensorHysReq->SensorNum);
- if (pSensorInfo->SensorReadType != THRESHOLD_SENSOR_CLASS)
- {
- pSensorHysRes->CompletionCode = CC_ILLEGAL_CMD_FOR_SENSOR_REC;
- return sizeof (*pRes);
- }
- if(SENSOR_HYSTERESIS_ACCESS_BITS == (pSensorInfo->SensorCaps & (BIT5 | BIT4)))
- {
- //set operation is not allowed
- *pRes = CC_INV_DATA_FIELD;
- return sizeof(*pRes);
- }
- /* Get the hysterisis values */
- pSensorHysRes->PositiveHysterisis = pSensorInfo->PosHysteresis;
- pSensorHysRes->NegativeHysterisis = pSensorInfo->NegHysteresis;
- pSensorHysRes->CompletionCode = CC_NORMAL;
- return sizeof (GetSensorHysterisisRes_T);
- }
- /*---------------------------------------
- * SetSensorThresholds
- *---------------------------------------*/
- int
- SetSensorThresholds ( uint8_t* pReq, uint8_t ReqLen, uint8_t* pRes)
- {
- SetSensorThresholdReq_T* pSensorThreshReq =
- ( SetSensorThresholdReq_T*) pReq;
- SetSensorThresholdRes_T* pSensorThreshRes =
- ( SetSensorThresholdRes_T*) pRes;
- uint8_t SettableMask=0;
- SensorInfo_T* pSensorInfo = getSensorInfo(pSensorThreshReq->SensorNum);
- SDRRecHdr_T* pSDRRec = SR_FindSDR(pSensorThreshReq->SensorNum);
- FullSensorRec_T* sfs = NULL;
- //CompactSensorRec_T* scs = NULL;
-
- if(pSDRRec->Type == FULL_SDR_REC)
- {
- sfs = (FullSensorRec_T*)pSDRRec;
- }
- /* 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 (pSensorInfo->SensorReadType != THRESHOLD_SENSOR_CLASS)
- {
- pSensorThreshRes->CompletionCode = CC_ILLEGAL_CMD_FOR_SENSOR_REC;
- return sizeof (*pRes);
- }
- if(BIT3 != (pSensorInfo->SensorCaps & (BIT2 | BIT3)))
- {
- //set operation is not allowed
- *pRes = CC_INV_DATA_FIELD;
- return sizeof(*pRes);
- }
- pSensorThreshRes->CompletionCode = CC_NORMAL;
- SettableMask=(uint8_t)(pSensorInfo->SettableThreshMask >> 8);
- /* Set the threshold values */
- //if (pSenSharedMem->SensorInfo [pSensorThreshReq->SensorNum].SensorInit & BIT5)
- if ( (pSensorInfo->SensorInit & BIT4 ) && (SettableMask | pSensorThreshReq->SetFlags ) == SettableMask) //<<Modified to support "set sensor enable>>
- {
- if (pSensorThreshReq->SetFlags & LWR_CRIT)
- {
- pSensorInfo->LowerCritical = pSensorThreshReq->LowerCritical;
- if(sfs != NULL) {sfs->LowerCritical = pSensorThreshReq->LowerCritical;}
- }
- if (pSensorThreshReq->SetFlags & LWR_NON_CRIT)
- {
- pSensorInfo->LowerNonCritical = pSensorThreshReq->LowerNonCritical;
- if(sfs != NULL) {sfs->LowerNonCritical = pSensorThreshReq->LowerNonCritical;}
- }
- if (pSensorThreshReq->SetFlags & LWR_NON_REC)
- {
- pSensorInfo->LowerNonRecoverable = pSensorThreshReq->LowerNonRecoverable;
- if(sfs != NULL) {sfs->LowerNonRecoverable = pSensorThreshReq->LowerNonRecoverable;}
- }
- if (pSensorThreshReq->SetFlags & UPR_CRIT)
- {
- pSensorInfo->UpperCritical = pSensorThreshReq->UpperCritical;
- if(sfs != NULL) {sfs->UpperCritical = pSensorThreshReq->UpperCritical;}
- }
- if (pSensorThreshReq->SetFlags & UPR_NON_CRIT)
- {
- pSensorInfo->UpperNonCritical = pSensorThreshReq->UpperNonCritical;
- if(sfs != NULL) {sfs->UpperNonCritical = pSensorThreshReq->UpperNonCritical;}
- }
- if (pSensorThreshReq->SetFlags & UPR_NON_REC)
- {
- pSensorInfo->UpperNonRecoverable = pSensorThreshReq->UpperNonRecoverable;
- if(sfs != NULL) {sfs->UpperNonRecoverable = pSensorThreshReq->UpperNonRecoverable;}
- }
- if(g_BMCInfo.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 ==(pSensorInfo->SensorCaps & BIT6))
- {
- /* Manual ReARM Sensor */
- pSensorInfo->AssertionHistoryByte1=0;
- pSensorInfo->AssertionHistoryByte2=0;
- pSensorInfo->DeassertionHistoryByte1=0;
- pSensorInfo->DeassertionHistoryByte2=0;
- pSensorInfo->EventLevel=SENSOR_STATUS_NORMAL;
- pSensorInfo->HealthLevel= SENSOR_STATUS_NORMAL;
- }else
- {
- /* Auto ReARM Sensor */
- pSensorInfo->EventLevel=SENSOR_STATUS_NORMAL;
- pSensorInfo->HealthLevel = SENSOR_STATUS_NORMAL;
- pSensorInfo->AssertionEventOccuredByte1 = 0;
- pSensorInfo->AssertionEventOccuredByte2 = 0;
- pSensorInfo->DeassertionEventOccuredByte1 = 0;
- pSensorInfo->DeassertionEventOccuredByte2 = 0;
- }
- }
- pSensorThreshRes->CompletionCode = CC_NORMAL;
- UpdateFlash();
- }
- else
- {
- pSensorThreshRes->CompletionCode = CC_ILLEGAL_CMD_FOR_SENSOR_REC;
- }
- return sizeof (SetSensorThresholdRes_T);
- }
- /*---------------------------------------
- * GetSensorThresholds
- *---------------------------------------*/
- int
- GetSensorThresholds ( uint8_t* pReq, uint8_t ReqLen, uint8_t* pRes)
- {
- GetSensorThresholdReq_T* pSensorThreshReq =
- ( GetSensorThresholdReq_T*) pReq;
- GetSensorThresholdRes_T* pSensorThreshRes =
- ( GetSensorThresholdRes_T*) pRes;
- SensorInfo_T* pSensorInfo = getSensorInfo(pSensorThreshReq->SensorNum);
-
- if (pSensorInfo->SensorReadType != THRESHOLD_SENSOR_CLASS)
- {
- pSensorThreshRes->CompletionCode = CC_ILLEGAL_CMD_FOR_SENSOR_REC;
- return sizeof (*pRes);
- }
-
- memset (pSensorThreshRes, 0, sizeof (GetSensorThresholdRes_T));
-
- if(SENSOR_THRESOLD_ACCESS_BITS != (pSensorInfo->SensorCaps & (BIT2 | BIT3)))
- {
- pSensorThreshRes->GetFlags = pSensorInfo->SettableThreshMask & 0xFF;
-
- /* Get the Threshold values according to readable threshold flag */
- if( pSensorThreshRes->GetFlags & BIT0 )
- pSensorThreshRes->LowerNonCritical = pSensorInfo->LowerNonCritical;
- if( pSensorThreshRes->GetFlags & BIT1 )
- pSensorThreshRes->LowerCritical = pSensorInfo->LowerCritical;
- if( pSensorThreshRes->GetFlags & BIT2 )
- pSensorThreshRes->LowerNonRecoverable = pSensorInfo->LowerNonRecoverable;
- if( pSensorThreshRes->GetFlags & BIT3 )
- pSensorThreshRes->UpperNonCritical = pSensorInfo->UpperNonCritical;
- if( pSensorThreshRes->GetFlags & BIT4 )
- pSensorThreshRes->UpperCritical = pSensorInfo->UpperCritical;
- if( pSensorThreshRes->GetFlags & BIT5 )
- pSensorThreshRes->UpperNonRecoverable = pSensorInfo->UpperNonRecoverable;
- }
-
- pSensorThreshRes->CompletionCode = CC_NORMAL;
- return sizeof (GetSensorThresholdRes_T);
- }
- /*---------------------------------------
- * GetSensorReadingFactors
- *---------------------------------------*/
- int
- GetSensorReadingFactors ( uint8_t* pReq, uint8_t ReqLen, uint8_t* pRes)
- {
- GetSensorReadingFactorReq_T* pSensorFactorsReq =
- ( GetSensorReadingFactorReq_T*) pReq;
- GetSensorReadingFactorRes_T* pSensorFactorsRes =
- ( GetSensorReadingFactorRes_T*) pRes;
- SensorInfo_T* pSensorInfo = getSensorInfo(pSensorFactorsReq->SensorNum);
-
- memcpy (&(pSensorFactorsRes->M_LSB), &(pSensorInfo->M_LSB),
- sizeof (GetSensorReadingFactorRes_T) - (2 * sizeof (uint8_t)));
- pSensorFactorsRes->CompletionCode = CC_NORMAL;
- return sizeof (GetSensorReadingFactorRes_T);
- }
- /*---------------------------------------
- * SetSensorEventEnable
- *---------------------------------------*/
- int
- SetSensorEventEnable ( uint8_t* pReq, uint8_t ReqLen, uint8_t* pRes)
- {
- // SensorInfo_T* pSensorInfo;
- // uint8_t LocalReq [6];
- // SetSensorEventEnableReq_T* pSensorEvtEnReq;
- // SetSensorEventEnableRes_T* pSensorEvtEnRes =
- // ( SetSensorEventEnableRes_T*) pRes;
- printf("SetSensorEventEnable not implement\r\n");
- // uint16_t AssertMask, DeassertMask;
- // uint16_t ValidMask = htoipmi_u16(0x0FFF);
- // SensorSharedMem_T* pSenSharedMem;
- // BMCInfo_t* pBMCInfo = &g_BMCInfo[BMCInst];
- // pSenSharedMem = ( SensorSharedMem_T*)&g_BMCInfo.SensorSharedMem; //m_hSensorSharedMem;
- // uint16_t LUNSensorNum;
- // uint16_t *OwnerLUN = 0;
- // if (g_BMCInfo.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 = ( 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(uint16_t)) || (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(uint16_t))
- // {
- // /* 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(&g_BMCInfo.SensorSharedMemMutex, WAIT_INFINITE);
- // if (!pSensorInfo->IsSensorPresent)
- // {
- // /* Release mutex for Sensor shared memory */
- // OS_THREAD_MUTEX_RELEASE(&g_BMCInfo.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(&g_BMCInfo.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(&g_BMCInfo.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(&g_BMCInfo.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(&g_BMCInfo.SensorSharedMemMutex);
- return sizeof (SetSensorEventEnableRes_T);
- }
- /*---------------------------------------
- * GetSensorEventEnable
- *---------------------------------------*/
- int
- GetSensorEventEnable ( uint8_t* pReq, uint8_t ReqLen, uint8_t* pRes)
- {
- GetSensorEventEnableReq_T* pSensorEvtEnReq =
- ( GetSensorEventEnableReq_T*) pReq;
- GetSensorEventEnableRes_T* pSensorEvtEnRes =
- ( GetSensorEventEnableRes_T*) pRes;
- SensorInfo_T* pSensorInfo = getSensorInfo(pSensorEvtEnReq->SensorNum);
- uint16_t ValidMask = (0x0FFF);
-
- if (pSensorInfo->EventTypeCode != 0x01)
- {
- ValidMask = (0x7FFF);
- }
- /* Get the assertion enables */
- pSensorEvtEnRes->AssertionMask =
- (((pSensorInfo->AssertionEventEnablesByte2 << 8) | (pSensorInfo->AssertionEventEnablesByte1)) & ValidMask);
- /* Get the deassertion enables */
- pSensorEvtEnRes->DeAssertionMask =
- (((pSensorInfo->DeassertionEventEnablesByte2 << 8) | (pSensorInfo->DeassertionEventEnablesByte1)) & ValidMask);
- /* Set the flags */
- pSensorEvtEnRes->Flags = (pSensorInfo->EventFlags & 0xc0);
- pSensorEvtEnRes->CompletionCode = CC_NORMAL;
- 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 (uint8_t SensorNum, uint8_t OwnerLUN, uint8_t EventTypeCode, uint8_t SensorType)
- {
- int RetVal = NOT_FOUND_SCAN_ENABLED;
- SensorInfo_T* pSensorInfo;
- int i;
-
-
- pSensorInfo = getSensorInfo(SensorNum);
- 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;
- }
- }
- }
- return RetVal;
- }
- 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 (uint8_t EntityID, uint8_t EntityIns, uint8_t SensorNum, uint8_t OwnerLUN)
- {
- SDRRecHdr_T* sr = NULL;
- CommonSensorRec_T* scs = NULL;
-
- int RetVal, tmpRet = -1;
- sr = SDR_GetFirstSDRRec ();
- 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 = ( CommonSensorRec_T*) sr;
- // Check for EntityId and EntityIns
- if((EntityID == scs->EntityID) && (EntityIns == scs->EntityIns) &&
- ((SensorNum != scs->SensorNum) || (OwnerLUN != scs->OwnerLUN)) )
- {
- RetVal = CheckForEntityPresence (scs->SensorNum, scs->OwnerLUN, scs->EventTypeCode,
- scs->SensorType);
- 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);
- }
- 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 (uint8_t EntityID, uint8_t EntityIns)
- {
- //TODO
- 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 (uint8_t EntityID, uint8_t EntityIns)
- {
- printf("IsFRUPresence not implement\r\n");
- // SDRRecHdr_T* sr = NULL;
- // FRUDevLocatorRec_T* frudl;
- // FRUReadReq_T FRUReadReq;
- // uint8_t FRUReadRes[64];
- // sr = SDR_GetFirstSDRRec (BMCInst);
- // while (0 != sr)
- // {
- // // Check for FRU Device locator SDR Record
- // if (sr->Type == FRU_DEVICE_LOCATOR_SDR_REC)
- // {
- // frudl = ( FRUDevLocatorRec_T*) sr;
- // 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((uint8_t *)&FRUReadReq, sizeof(FRUReadReq_T), FRUReadRes);
- // if (((FRUReadRes_T *)FRUReadRes)->CompletionCode == FRU_ACCESSIBLE)
- // {
- // return 1;
- // }
- // else
- // {
- // return 0;
- // }
- // }
- // }
- // sr = SDR_GetNextSDRRec (sr);
- // }
- return -1;
- }
- /**
- * @fn InitSensorScanningBit
- * @brief Initializes all the sensor's Scanning bit with respect
- * to the presence of the entity
- * @retval 0.
- */
- int InitSensorScanningBit()
- {
- SDRRecHdr_T* sr = NULL;
- CommonSensorRec_T* scs = NULL;
- int RetVal;
-
-
- SensorInfo_T* pSensorInfo = NULL;
- uint16_t LUNSensorNum;
- sr = SDR_GetFirstSDRRec ();
-
- while (0 != sr)
- {
- // Populater sensor information for Threshold sensors
- if (FULL_SDR_REC == sr->Type || COMPACT_SDR_REC == sr->Type)
- {
- scs = ( CommonSensorRec_T*) sr;
-
- 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);
- if( -1 == RetVal )
- {
- RetVal = IsEntityAssociationPresence(scs->EntityID, scs->EntityIns);
- if( -1 == RetVal )
- {
- RetVal = IsFRUPresence(scs->EntityID, scs->EntityIns);
- }
- }
- }
- LUNSensorNum = (scs->SensorNum);
- /*
- * [7] - 0b = All Event Messages disabled from this sensor
- * [6] - 0b = sensor scanning disabled
- * [5] - 1b = reading/state unavailable
- */
- if(1 == RetVal)
- {
- pSensorInfo = getSensorInfo(LUNSensorNum);
- if((BIT0 | BIT1) == (pSensorInfo->SensorInit & (BIT0 | BIT1)))
- {
- /* Enabling Sensor Scanning and Event Messages*/
- pSensorInfo->EventFlags = EVENT_AND_SCANNING_ENABLE;
- }
- else if(BIT1 == (pSensorInfo->SensorInit & BIT1))
- {
- /* Enabling Event Messages */
- pSensorInfo->EventFlags = EVENT_MSG_MASK;
- }
- else if(BIT0 == (pSensorInfo->SensorInit & BIT0))
- {
- /*Enabling Scanning*/
- pSensorInfo->EventFlags = SCAN_MASK;
- }
- if(0 == (pSensorInfo->SensorInit & BIT0))
- {
- /* Reading Unavailable */
- pSensorInfo->EventFlags |= READING_UNAVAILABLE;
- }
- }
- else
- {
- pSensorInfo->EventFlags = READING_UNAVAILABLE;
- if(BIT1 == (pSensorInfo->SensorInit & BIT1))
- {
- /* Enabling Event Messages */
- pSensorInfo->EventFlags |= EVENT_MSG_MASK;
- }
- }
- }
- /* Get the next record */
- sr = SDR_GetNextSDRRec (sr);
- }
- printf("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(uint8_t isSigned, uint8_t val1, uint8_t val2)
- {
- int retval = 0; // default to equal
- // Signed comparison
- int8_t sval1, sval2;
- /* Do comparison based on isSigned flag */
- if (FALSE == isSigned)
- {
- // Unsigned comparison
- if (val1 < val2)
- {
- retval = -1;
- }
- else if (val1 > val2)
- {
- retval = 1;
- }
- }
- else
- {
- sval1 = (int8_t)val1;
- sval2 = (int8_t)val2;
- if (sval1 < sval2)
- {
- retval = -1;
- }
- else if (sval1 > sval2)
- {
- retval = 1;
- }
- }
- return retval;
- }
- /*-----------------------------------------
- * GetSensorReading
- *-----------------------------------------*/
- int
- GetSensorReading ( uint8_t* pReq, uint8_t ReqLen, uint8_t* pRes)
- {
- GetSensorReadingReq_T* pSensorReadReq =
- ( GetSensorReadingReq_T*) pReq;
- GetSensorReadingRes_T* pSensorReadRes =
- ( GetSensorReadingRes_T*) pRes;
- uint16_t SensorReading;
- uint8_t SensorIsSigned = FALSE;
-
- SensorInfo_T * pSensorInfo = NULL;
- pSensorInfo = getSensorInfo(pSensorReadReq->SensorNum);
- pSensorReadRes->Flags = pSensorInfo->EventFlags & 0xe0;
- if (0 != (pSensorInfo->EventFlags & BIT5))
- {
- pSensorReadRes->SensorReading = 0;
- pSensorReadRes->CompletionCode = CC_NORMAL;
- pSensorReadRes->ComparisonStatus = (((uint8_t) (pSensorReadRes->SensorReading & 0x00FF)) & ((uint8_t) (pSensorInfo->SettableThreshMask & 0x00FF)) );
- pSensorReadRes->OptionalStatus = (((uint8_t) (pSensorReadRes->SensorReading >> 8)) & ((uint8_t)(pSensorInfo->SettableThreshMask >> 8)) );
- // For Discrete sensor, [7] - reserved. Returned as 1b. Ignore on read.
- pSensorReadRes->OptionalStatus |= 0x80;
-
- return sizeof (GetSensorReadingRes_T);
- }
- pSensorReadRes->CompletionCode = CC_NORMAL;
- SensorReading = pSensorInfo->SensorReading;
- pSensorReadRes->SensorReading = 0;
- SensorIsSigned = (0 != (pSensorInfo->Units1 & 0xC0)) ? TRUE : FALSE;
- if (THRESHOLD_SENSOR_CLASS == pSensorInfo->EventTypeCode)
- {
- pSensorReadRes->SensorReading = (SensorReading & 0x00FF); //notice
- pSensorReadRes->ComparisonStatus = 0x00;
- if((pSensorInfo->DeassertionEventEnablesByte2 & BIT6) == BIT6 )
- {
- if (CompareValues(SensorIsSigned, pSensorReadRes->SensorReading,
- pSensorInfo->UpperNonRecoverable) >= 0)
- {
- pSensorReadRes->ComparisonStatus |= BIT5;
- }
- }
- if((pSensorInfo->DeassertionEventEnablesByte2 & BIT5) == BIT5 )
- {
- if (CompareValues(SensorIsSigned, pSensorReadRes->SensorReading,
- pSensorInfo->UpperCritical) >= 0)
- {
- pSensorReadRes->ComparisonStatus |= BIT4;
- }
- }
- if((pSensorInfo->DeassertionEventEnablesByte2 & BIT4) == BIT4 )
- {
- if (CompareValues(SensorIsSigned, pSensorReadRes->SensorReading,
- pSensorInfo->UpperNonCritical) >= 0)
- {
- pSensorReadRes->ComparisonStatus |= BIT3;
- }
- }
- if((pSensorInfo->AssertionEventEnablesByte2 & BIT6) == BIT6 )
- {
- if (CompareValues(SensorIsSigned, pSensorReadRes->SensorReading,
- pSensorInfo->LowerNonRecoverable) <= 0)
- {
- pSensorReadRes->ComparisonStatus |= BIT2;
- }
- }
- if((pSensorInfo->AssertionEventEnablesByte2 & BIT5) == BIT5 )
- {
- if (CompareValues(SensorIsSigned, pSensorReadRes->SensorReading,
- pSensorInfo->LowerCritical) <= 0)
- {
- pSensorReadRes->ComparisonStatus |= BIT1;
- }
- }
- if((pSensorInfo->AssertionEventEnablesByte2 & BIT4) == BIT4 )
- {
- if (CompareValues(SensorIsSigned, pSensorReadRes->SensorReading,
- pSensorInfo->LowerNonCritical) <= 0)
- {
- pSensorReadRes->ComparisonStatus |= BIT0;
- }
- }
- pSensorReadRes->ComparisonStatus &=
- ((pSensorInfo->SettableThreshMask >> 8) & 0xFF);
- pSensorReadRes->OptionalStatus = 0;
- // For Threshold sensor, [7:6] - reserved. Returned as 1b. Ignore on read.
- pSensorReadRes->ComparisonStatus |= 0xC0;
- }
- else
- {
- pSensorReadRes->ComparisonStatus = (((uint8_t) (SensorReading & 0x00FF)) & ((uint8_t) (pSensorInfo->SettableThreshMask & 0x00FF)) );
- pSensorReadRes->OptionalStatus = (((uint8_t) (SensorReading >> 8)) & ((uint8_t)(pSensorInfo->SettableThreshMask >> 8)) );
- // For Discrete sensor, [7] - reserved. Returned as 1b. Ignore on read.
- pSensorReadRes->OptionalStatus |= 0x80;
- }
- return sizeof (GetSensorReadingRes_T);
- }
- /*-----------------------------------------
- * SetSensorReading
- *-----------------------------------------*/
- int
- SetSensorReading ( uint8_t* pReq, uint8_t ReqLen, uint8_t* pRes)
- {
- printf("SetSensorReading not implement\r\n");
- // SetSensorReadingReq_T* pSensorReadReq =
- // ( SetSensorReadingReq_T*) pReq;
- // SetSensorReadingRes_T* pSensorReadRes =
- // ( SetSensorReadingRes_T*) pRes;
- // SensorSharedMem_T* pSenSharedMem;
- // BMCInfo_t* pBMCInfo = &g_BMCInfo[BMCInst];
- // pSenSharedMem = ( SensorSharedMem_T*)&g_BMCInfo.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 (g_BMCInfo.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(&g_BMCInfo.SensorSharedMemMutex, WAIT_INFINITE);
- // if (!pSenSharedMem->SensorInfo [pSensorReadReq->SensorNum].IsSensorPresent)
- // {
- // /* Release mutex for Sensor shared memory */
- // OS_THREAD_MUTEX_RELEASE(&g_BMCInfo.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(&g_BMCInfo.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(&g_BMCInfo.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(&g_BMCInfo.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(&g_BMCInfo.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(&g_BMCInfo.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(&g_BMCInfo.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(&g_BMCInfo.SensorSharedMemMutex);
- // return sizeof (SetSensorReadingRes_T);
- return 0;
- }
- /*-------------------------------------------
- * GetSensorSDR
- *-------------------------------------------*/
- SDRRecHdr_T*
- SR_GetSensorSDR (uint8_t SensorNum)
- {
- SDRRecHdr_T* SDRRec;
- /* Search for the record containing the sensor */
- SDRRec = SDR_GetFirstSDRRec ();
- while (0 != SDRRec)
- {
- switch (SDRRec->Type)
- {
- case FULL_SDR_REC :
- if ((( FullSensorRec_T*) SDRRec)->SensorNum == SensorNum)
- {
- return SDRRec;
- }
- break;
- case COMPACT_SDR_REC:
- {
- uint16_t SharedRecs = ((( CompactSensorRec_T*) SDRRec)->RecordSharing) &
- SHARED_RECD_COUNT;
- if ((SensorNum == (( CompactSensorRec_T*) SDRRec)->SensorNum ) ||
- ((SensorNum >= ((( CompactSensorRec_T*) SDRRec)->SensorNum )) &&
- (SensorNum < ((( CompactSensorRec_T*) SDRRec)->SensorNum + SharedRecs)))
- )
- {
- return SDRRec;
- }
- }
- break;
- default :
- break;
- }
- /* Get the next record */
- SDRRec = SDR_GetNextSDRRec (SDRRec);
- if (0 == SDRRec)
- {
- return 0;
- }
- }
- return 0;
- }
- ///**
- // * @brief Update global variables with number sensors.
- //**/
- //static void
- //FindNumSensors ()
- //{
- // SDRRecHdr_T* pSDRRec;
- // FullSensorRec_T* pFSR;
- // CompactSensorRec_T* pCSR;
- // pFSR = 0;
- // pCSR = 0;
- // /* Get First SDR Record */
- // pSDRRec = SDR_GetFirstSDRRec ();
- // while (0 != pSDRRec)
- // {
- // switch (pSDRRec->Type)
- // {
- // case FULL_SDR_REC :
- // pFSR = ( FullSensorRec_T*) pSDRRec;
- // if (THRESHOLD_SENSOR_CLASS == pFSR->EventTypeCode)
- // {
- // g_BMCInfo.SenConfig.NumThreshSensors++;
- // }
- // else
- // {
- // g_BMCInfo.SenConfig.NumNonThreshSensors++;
- // }
- // break;
- // case COMPACT_SDR_REC :
- // pCSR = ( CompactSensorRec_T*) pSDRRec;
- // if (THRESHOLD_SENSOR_CLASS == pCSR->EventTypeCode)
- // {
- // g_BMCInfo.SenConfig.NumThreshSensors += ( (pCSR->RecordSharing) & SHARED_RECD_COUNT);
- // }
- // else
- // {
- // g_BMCInfo.SenConfig.NumNonThreshSensors += ( (pCSR->RecordSharing) & SHARED_RECD_COUNT);
- // }
- // break;
- // default:
- // break;
- // }
- // /* Get the next record */
- // pSDRRec = SDR_GetNextSDRRec (pSDRRec);
- // }
- // printf("Thereshold Sensors = %d\n",g_BMCInfo.SenConfig.NumThreshSensors);
- // printf("Non Thershold Sensors = %d\n",g_BMCInfo.SenConfig.NumNonThreshSensors);
- // return;
- //}
- int
- GetRecordIdsforDCMISensor (uint8_t EntityID,uint8_t SensorType, uint8_t EntityInstance,
- uint8_t StartingEntityInstance, uint16_t* pBuf, uint8_t* pTotalValidInstances)
- {
- printf("GetRecordIdsforDCMISensor not implement\r\n");
- // int i, ValidInstances;
- // SensorSharedMem_T* pSenSharedMem;
- // BMCInfo_t* pBMCInfo = &g_BMCInfo[BMCInst];
- // pSenSharedMem = ( SensorSharedMem_T*)&g_BMCInfo.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;
- // }
- return 0;
- }
- int GetDCMITempReading(uint8_t EntityID,uint8_t SensorType, uint8_t EntityInstance,
- uint8_t StartingEntityInstance, uint8_t* pBuf, uint8_t* pTotalValidInstances)
- {
- printf("GetDCMITempReading not implement\r\n");
- // int i, ValidInstances,j = 0;
- // SensorSharedMem_T* pSenSharedMem;
- // BMCInfo_t* pBMCInfo = &g_BMCInfo[BMCInst];
- // pSenSharedMem = ( SensorSharedMem_T*)&g_BMCInfo.SensorSharedMem; //m_hSensorSharedMem;
- // SDRRecHdr_T* pSDRRec;
- // FullSensorRec_T* FullSDR;
- // float convreading = 0;
- // uint8_t 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 = ( 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_t)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 = ( 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_t)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;
- // }
- return 0;
- }
- #endif /* SENSOR_DEVICE */
|