1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134 |
- /*****************************************************************
- *****************************************************************
- *** **
- *** (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);
- //printf("---> pSensorInfo %p, reading: %#x\n", pSensorInfo, pSensorInfo->SensorReading);
- pSensorReadRes->Flags = pSensorInfo->EventFlags & 0xe0;
- if (0 != (pSensorInfo->EventFlags & BIT5))
- {
- //printf("---> log 1\n");
- 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)
- {
- //printf("---> log2\n");
- 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
- {
- //printf("---> log3\n");
- 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 */
|