123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824 |
- /*****************************************************************
- *****************************************************************
- *** **
- *** (C)Copyright 2005-2006, American Megatrends Inc. **
- *** **
- *** All Rights Reserved. **
- *** **
- *** 6145-F, Northbelt Parkway, Norcross, **
- *** **
- *** Georgia - 30071, USA. Phone-(770)-246-8600. **
- *** **
- *****************************************************************
- ******************************************************************
- *
- * SDR.c
- * SDR functions.
- *
- * Author: Govind Kothandapani <govindk@ami.com>
- *
- ******************************************************************/
- //#include "main.h"
- #include "com_IPMI_SDRRecord.h"
- #include "SDR.h"
- #include "SDRRecord.h"
- #include <string.h>
- #include "Support.h"
- #include "SDRFunc.h"
- #include "main.h"
- /**
- * NVRAM Handles
- **/
- #define NVRH_USERCONFIG 0
- #define NVRH_CHCONFIG 0
- #define NVRH_SDR 0
- /* Reserved bit macro definitions */
- #define RESERVED_BITS_PARTIALADDSDR 0xF0 //(BIT7 | BIT6 | BIT5 | BIT4)
- #if SDR_DEVICE == 1
- #define SUPPORT_MULTI_CONTROLLER 1
- /*** Local Definitions ***/
- #define SDR_FIRST_FREE_BYTE() ((( uint8_t*)g_BMCInfo.IpmiConfig.SDRConfig.SDRRAM) + g_BMCInfo.IpmiConfig.SDRConfig.SDRRAM->Size)
- #define MAX_SDR_LEN 255
- #define MAX_RES_LEN 128
- #define SDR_VERSION 0x51
- #define CMD_RUN_INITIALIZATION_AGENT 0x2C
- #define MANAGEMENT_DEV_LOC_REC 0x12
- #define PARTIAL_ADD_SDR_SUPPORT 0x04
- #define RESERVE_SDR_SUPPORT 0x02
- #define GET_SDR_REPOSITORY_ALLOC_SUPPORT 0x01
- #define NON_MODAL_SUPPORT 0x20
- #define NO_SUPPORT 0x00
- #define DELETE_SDR_SUPPORT 0x08
- #define MAX_OEM_REC_LEN 64
- #define SDR_ERASE_COMPLETED 0x01
- #define SDR_INIT_COMPLETED 0x01
- #define ENABLE_SELECTED_EVENT_MSG 0x10
- #define DISABLE_SELECTED_EVENT_MSG 0x20
- #define OEM_SDR_NM_REC 0x0D
- /**
- * @brief Size of SDR Record
- **/
- #define SDR_SIZE(SDRRecHdr) (sizeof (SDRRecHdr_T) + (SDRRecHdr)->Len)
- /**
- * @brief Size the SDR Record occupies in the memory
- **/
- #define SDR_SIZE_IN_MEM(SDRRecHdr) \
- (((SDR_SIZE(SDRRecHdr) & 0x0f) == 0) ? SDR_SIZE(SDRRecHdr) : \
- (SDR_SIZE(SDRRecHdr) & 0xf0) + 0x10)
- /*** Prototype Declarations ***/
- static uint8_t PreCheckSDRUpdateModeCmd ( uint8_t* pRes);
- static uint16_t SDR_ReserveSDRRepository (void);
- static SDRRecHdr_T* GetLastSDRRec (void);
- //static void UpdateRepositoryInfo (void);
- static SDRRecHdr_T* SDR_GetSDRRec (uint16_t RecID, uint16_t ReservationID);
- //static void SDRInitAgent (void);
- //static uint8_t ValidateSDRSize (uint8_t SDRType, uint8_t Size);
- //const uint8_t SDRSize [][2] = {
- //// { SDR Type, Maximum Length },
- // { FULL_SDR_REC, 64 },
- // { COMPACT_SDR_REC, 48 },
- // { EVENT_ONLY_SDR_REC, 33 },
- // { ENTITY_ASSOCIATION_SDR_REC, 16 },
- // { DEV_REL_ENTITY_ASSOCIATION_SDR_REC, 32 },
- // { GENERIC_DEVICE_LOCATOR_SDR_REC, 32 },
- // { FRU_DEVICE_LOCATOR_SDR_REC, 32 },
- // { MGMT_CTRL_DEV_LOCATOR_SDR_REC, 32 },
- // { MGMT_CTRL_CONFIRMATION_SDR_REC, 32 },
- // { BMC_MSG_CHANNEL_INFO_REC, 16 },
- // };
- static uint16_t SDR_AddSDRRec ( SDRRecHdr_T* pSDRRecHdr);
- static uint16_t SDR_PartialAddSDR ( uint8_t* SDRData, uint8_t Offset, uint8_t Size,uint8_t IsLast, uint16_t ReservationID);
- #define CLEAR_SDR_INITIATE_ERASE 0xAA
- #define CLEAR_SDR_GET_STATUS 0x00
- static int SDR_ClearSDRRepository (uint16_t ReservationID, uint8_t InitOrStatus);
- //static uint16_t SDR_DeleteSDR (uint16_t ReservationID, uint16_t RecID);
- /*---------------------------------------
- * GetSDRRepositoryInfo
- *---------------------------------------*/
- int
- GetSDRRepositoryInfo ( uint8_t* pReq, uint8_t ReqLen, uint8_t* pRes)
- {
- SDRRepositoryInfo_T* pSDRRepInfoRes =
- ( SDRRepositoryInfo_T*) pRes;
- memcpy (pSDRRepInfoRes, &g_BMCInfo.IpmiConfig.SDRConfig.RepositoryInfo, sizeof (SDRRepositoryInfo_T));
- pSDRRepInfoRes->CompletionCode = CC_NORMAL;
-
- return sizeof (SDRRepositoryInfo_T);
- }
- /*---------------------------------------
- * GetSDRRepositoryAllocInfo
- *---------------------------------------*/
- int
- GetSDRRepositoryAllocInfo ( uint8_t* pReq, uint8_t ReqLen, uint8_t* pRes)
- {
- SDRRepositoryAllocInfo_T* pSDRRepAllocInfoRes =
- ( SDRRepositoryAllocInfo_T*) pRes;
- memcpy (pSDRRepAllocInfoRes, &g_BMCInfo.IpmiConfig.SDRConfig.RepositoryAllocInfo,
- sizeof (SDRRepositoryAllocInfo_T));
- pSDRRepAllocInfoRes->CompletionCode = CC_NORMAL;
-
- return sizeof (SDRRepositoryAllocInfo_T);
- }
- /*---------------------------------------
- * ReserveSDRRepository
- *---------------------------------------*/
- int
- ReserveSDRRepository ( uint8_t* pReq, uint8_t ReqLen, uint8_t* pRes)
- {
-
- ReserveSDRRepositoryRes_T* pResSDRRepRes =
- ( ReserveSDRRepositoryRes_T*) pRes;
- /* Shouldnt allow to reserve when the SDR is in update mode */
- if( TRUE == g_BMCInfo.IpmiConfig.SDRConfig.UpdatingSDR )
- {
- pResSDRRepRes->CompletionCode = CC_SDR_REP_IN_UPDATE_MODE;
- return sizeof (pResSDRRepRes->CompletionCode);
- }
-
- pResSDRRepRes->ReservationID = SDR_ReserveSDRRepository ();
- g_BMCInfo.IpmiConfig.SDRConfig.PartAddbytes = 0;
- pResSDRRepRes->CompletionCode = CC_NORMAL;
- FlushIPMIToFlash();
- return sizeof (ReserveSDRRepositoryRes_T);
- }
- /*---------------------------------------
- * GetSDR
- *---------------------------------------*/
- int GetSDR ( uint8_t* pReq, uint8_t ReqLen, uint8_t* pRes)
- {
- SDRRecHdr_T* pSDRRec;
- GetSDRReq_T* pGetSDRReq = ( GetSDRReq_T*) pReq;
- GetSDRRes_T* pGetSDRRes = ( GetSDRRes_T*) pRes;
- uint8_t *curchannel;
-
- uint8_t SDRLen = 0;
- if (TRUE != PreCheckSDRUpdateModeCmd (pRes))
- {
- return sizeof (uint8_t); /* error code set in func */
- }
- /* If the Offset is Not zero then its A partial get.. / if SDR is in update mode
- then check for the reservation id */
- if ((pGetSDRReq->Offset == 0) && (FALSE == g_BMCInfo.IpmiConfig.SDRConfig.UpdatingSDR ))
- {
- pSDRRec = GetSDRRec (pGetSDRReq->RecID);
- }
- else
- {
- pSDRRec = SDR_GetSDRRec ( pGetSDRReq->RecID, pGetSDRReq->ReservationID );
- }
- if (0 == pSDRRec)
- {
- pGetSDRRes->CompletionCode = g_BMCInfo.IpmiConfig.SDRConfig.SDRError;
- return sizeof (uint8_t);
- }
- SDRLen = pSDRRec->Len+sizeof(SDRRecHdr_T);
- if((0xFF == pGetSDRReq->Size) && (SDRLen >= pGetSDRReq->Offset))
- {
- pGetSDRReq->Size = SDRLen - pGetSDRReq->Offset;
- }
- curchannel = pthread_getspecific(g_tls.CurChannel);
- /* Check for Max Request Bytes */
- if (((pGetSDRReq->Size > MAX_SDR_LEN) &&
- (( g_BMCInfo.IpmiConfig.PrimaryIPMBSupport == 0x01 && PRIMARY_IPMB_CHANNEL == (*curchannel & 0xF))
- || (g_BMCInfo.IpmiConfig.SecondaryIPMBSupport == 0x01 && SECONDARY_IPMB_CHANNEL == (*curchannel & 0xF))))
- || (pGetSDRReq->Size > SDRLen) || (pGetSDRReq->Offset > SDRLen)
- || (pGetSDRReq->Size > (SDRLen-pGetSDRReq->Offset)))
- {
- pGetSDRRes->CompletionCode = CC_CANNOT_RETURN_REQ_BYTES;
- return sizeof (uint8_t);
- }
- /* Copy the response */
- pGetSDRRes->CompletionCode = CC_NORMAL;
- pGetSDRRes->NextRecID = SDR_GetNextSDRId (pSDRRec->ID);
- memcpy (pGetSDRRes + 1,
- (( uint8_t*) pSDRRec) + pGetSDRReq->Offset,
- pGetSDRReq->Size);
- return sizeof (GetSDRRes_T) + pGetSDRReq->Size;
- }
- /*---------------------------------------
- * AddSDR
- *---------------------------------------*/
- int
- AddSDR ( uint8_t* pReq, uint8_t ReqLen, uint8_t* pRes)
- {
- uint16_t RecID;
- SDRRecHdr_T* pSDRRec = ( SDRRecHdr_T*) pReq;
- AddSDRRes_T* pAddSDRRes = ( AddSDRRes_T*) pRes;
-
- /*Check the Minimum length of the SDR record*/
- if(ReqLen < sizeof(SDRRecHdr_T))
- {
- *pRes = CC_REQ_INV_LEN;
- return sizeof(uint8_t);
- }
- /*Check the SDR length*/
- if((ReqLen - sizeof(SDRRecHdr_T)) != pSDRRec->Len)
- {
- *pRes = CC_REQ_INV_LEN;
- return sizeof(uint8_t);
- }
- if (TRUE != PreCheckSDRUpdateModeCmd (pRes))
- {
- return sizeof (uint8_t); /* error code set in func */
- }
- RecID = SDR_AddSDRRec (pSDRRec);
- if (INVALID_RECORD_ID == RecID)
- {
- pAddSDRRes->CompletionCode = g_BMCInfo.IpmiConfig.SDRConfig.SDRError;
- return sizeof (pAddSDRRes->CompletionCode);
- }
- pAddSDRRes->CompletionCode = CC_NORMAL;
- pAddSDRRes->RecID = RecID;
-
- return sizeof (AddSDRRes_T);
- }
- /*---------------------------------------
- * PartialAddSDR
- *---------------------------------------*/
- int
- PartialAddSDR ( uint8_t* pReq, uint8_t ReqLen, uint8_t* pRes)
- {
- uint8_t Size;
- uint16_t RecID;
- PartialAddSDRReq_T* pPartialAddReq = ( PartialAddSDRReq_T*) pReq;
- PartialAddSDRRes_T* pPartialAddRes = ( PartialAddSDRRes_T*) pRes;
-
- if( ReqLen < sizeof(PartialAddSDRReq_T))
- {
- pPartialAddRes->CompletionCode = CC_REQ_INV_LEN;
- return sizeof (pPartialAddRes->CompletionCode);
- }
- /* Check for the reserved bytes should b zero */
- if ( 0 != (pPartialAddReq->Progress & RESERVED_BITS_PARTIALADDSDR ) )
- {
- pPartialAddRes->CompletionCode = CC_INV_DATA_FIELD;
- return sizeof(uint8_t);
- }
- if (TRUE != PreCheckSDRUpdateModeCmd (pRes))
- {
- return sizeof (uint8_t); /* error code set in func */
- }
- Size = ReqLen - sizeof (PartialAddSDRReq_T);
- if(0 == pPartialAddReq->Offset )
- {
- g_BMCInfo.IpmiConfig.SDRConfig.TrackPOffset =0;
- g_BMCInfo.IpmiConfig.SDRConfig.TrackRecID =pPartialAddReq->RecID;
- }
- else if((g_BMCInfo.IpmiConfig.SDRConfig.TrackPOffset) != pPartialAddReq->Offset || g_BMCInfo.IpmiConfig.SDRConfig.TrackRecID != pPartialAddReq->RecID)
- {
- pPartialAddRes->CompletionCode = CC_INV_DATA_FIELD;
- return sizeof (pPartialAddRes->CompletionCode);
- }
- RecID = SDR_PartialAddSDR (( uint8_t*)(pPartialAddReq + 1),
- pPartialAddReq->Offset,
- Size,
- pPartialAddReq->Progress & 0xf,
- pPartialAddReq->ReservationID);
- if (RecID == INVALID_RECORD_ID)
- {
- pPartialAddRes->CompletionCode = g_BMCInfo.IpmiConfig.SDRConfig.SDRError;
- FlushIPMIToFlash();
- return sizeof (pPartialAddRes->CompletionCode);
- }
- pPartialAddRes->CompletionCode = CC_NORMAL;
- pPartialAddRes->RecID = RecID;
- g_BMCInfo.IpmiConfig.SDRConfig.TrackPOffset +=Size;
- g_BMCInfo.IpmiConfig.SDRConfig.TrackRecID =RecID; //We are updating the available or alloted Record ID
-
- FlushIPMIToFlash();
- return sizeof (PartialAddSDRRes_T);
- }
- /*---------------------------------------
- * DeleteSDR
- *---------------------------------------*/
- int
- DeleteSDR ( uint8_t* pReq, uint8_t ReqLen, uint8_t* pRes)
- {
- printf("DeleteSDR not implement\r\n");
- // BMCInfo_t* pBMCInfo = &g_BMCInfo[BMCInst];
- // DeleteSDRReq_T* pDeleteSDRReq = ( DeleteSDRReq_T*)pReq;
- // DeleteSDRRes_T* pDeleteSDRRes = ( DeleteSDRRes_T*)pRes;
- // uint16_t RecID;
- // OS_THREAD_MUTEX_ACQUIRE(&pBMCInfo->SDRConfig.SDRMutex, WAIT_INFINITE);
- // if (TRUE != PreCheckSDRUpdateModeCmd (pRes,BMCInst))
- // {
- // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->SDRConfig.SDRMutex);
- // return sizeof (uint8_t); /* error code set in func */
- // }
- // RecID=SDR_DeleteSDR ( pDeleteSDRReq->ReservationID, pDeleteSDRReq->RecID,BMCInst);
- // if(RecID == INVALID_RECORD_ID )
- // {
- // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->SDRConfig.SDRMutex);
- // pDeleteSDRRes->CompletionCode = g_BMCInfo[BMCInst].SDRConfig.SDRError;
- // return sizeof (pDeleteSDRRes->CompletionCode);
- // }
- // pDeleteSDRRes->CompletionCode = CC_NORMAL;
- // pDeleteSDRRes->RecID = RecID;
- // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->SDRConfig.SDRMutex);
- // // To send notification to CIM
- // if(g_PDKCIMEventHandle[PDKCIMEVENT_NOTIFYSERVERUPDATETOCIM] != NULL)
- // {
- // uint8 CMD;
- // // Set bits for SDR Event & Delete operation
- // CMD = 0x13;
- // ((int(*)(uint8, uint16))g_PDKCIMEventHandle[PDKCIMEVENT_NOTIFYSERVERUPDATETOCIM])(CMD, RecID);
- //
- // }
- return sizeof (DeleteSDRRes_T);
- }
- /*---------------------------------------
- * ClearSDRRepository
- *---------------------------------------*/
- int
- ClearSDRRepository ( uint8_t* pReq, uint8_t ReqLen, uint8_t* pRes)
- {
- int status;
- ClearSDRReq_T* pClrSDRReq = ( ClearSDRReq_T*) pReq;
- ClearSDRRes_T* pClrSDRRes = ( ClearSDRRes_T*) pRes;
-
- if (TRUE != PreCheckSDRUpdateModeCmd (pRes))
- {
- return sizeof (uint8_t); /* error code set in func */
- }
- if(pClrSDRReq->CLR[0] != 'C' || pClrSDRReq->CLR[1] != 'L' || pClrSDRReq->CLR[2] != 'R' )
- {
- pClrSDRRes->CompletionCode= CC_PASSWORD_TEST_FAILED;
- return sizeof(uint8_t);
- }
- status = SDR_ClearSDRRepository (pClrSDRReq->ReservationID,pClrSDRReq->InitOrStatus);
- if (0 != status)
- {
- pClrSDRRes->CompletionCode = g_BMCInfo.IpmiConfig.SDRConfig.SDRError;
- return sizeof (pClrSDRRes->CompletionCode);
- }
- pClrSDRRes->CompletionCode = CC_NORMAL;
- pClrSDRRes->EraseProgress = SDR_ERASE_COMPLETED;
-
- return sizeof (ClearSDRRes_T);
- }
- /*---------------------------------------
- * GetSDRRepositoryTime
- *---------------------------------------*/
- int
- GetSDRRepositoryTime ( uint8_t* pReq, uint8_t ReqLen, uint8_t* pRes)
- {
- //TODO
- uint32_t SDRTime = 0;
- GetSDRRepositoryTimeRes_T* pGetSDRTimeRes =
- ( GetSDRRepositoryTimeRes_T*) pRes;
-
- /* Get the time */
- // SDRTime = GetSelTimeStamp ();
- pGetSDRTimeRes->CompletionCode = CC_NORMAL;
- pGetSDRTimeRes->Time = SDRTime;
- return sizeof (GetSDRRepositoryTimeRes_T);
- }
- /*--------------------------------------
- * * SetSDRRepositoryTime
- * * -------------------------------------*/
- int
- SetSDRRepositoryTime ( uint8_t* pReq, uint8_t ReqLen, uint8_t* pRes)
- {
- //TODO
- SetSDRRepositoryTimeReq_T* pSetSDRTimeReq = ( SetSDRRepositoryTimeReq_T*) pReq;
-
- pSetSDRTimeReq->Time = (pSetSDRTimeReq->Time);
- //SET_SYSTEM_TIME_STAMP (&pSetSDRTimeReq->Time);
- /* Resetting the SELTimeUTCOffset to default value */
- // pBMCInfo->GenConfig.SELTimeUTCOffset = UNSPECIFIED_UTC_OFFSET;
- /*Write to NVRAM*/
- // FlushIPMI((uint8_t*)&pBMCInfo->GenConfig,(uint8_t*)&pBMCInfo->GenConfig,pBMCInfo->IPMIConfLoc.GenConfigAddr,
- // sizeof(GENConfig_T));
- pRes [0] = CC_NORMAL;
- return sizeof (*pRes);
- }
- /*---------------------------------------
- * EnterSDRUpdateMode
- *---------------------------------------*/
- int
- EnterSDRUpdateMode ( uint8_t* pReq, uint8_t ReqLen, uint8_t* pRes)
- {
- EnterSDRUpdateModeRes_T* pEnterSDRUpdateModeRes =
- ( EnterSDRUpdateModeRes_T*) pRes;
-
-
- g_BMCInfo.IpmiConfig.SDRConfig.UpdatingSDR = TRUE;
- g_BMCInfo.IpmiConfig.SDRConfig.UpdatingChannel = 0;//*curchannel & 0xF;
- pEnterSDRUpdateModeRes->CompletionCode = CC_NORMAL;
- FlushIPMIToFlash();
- return sizeof (EnterSDRUpdateModeRes_T);
- }
- /*------------------------------------------
- * ExitSDRUpdateMode
- *------------------------------------------*/
- int
- ExitSDRUpdateMode ( uint8_t* pReq, uint8_t ReqLen, uint8_t* pRes)
- {
- ExitSDRUpdateModeRes_T* pExitSDRUpdateModeRes =
- ( ExitSDRUpdateModeRes_T*) pRes;
-
- if (TRUE != PreCheckSDRUpdateModeCmd (pRes))
- {
- return sizeof (uint8_t); /* error code set in func */
- }
- g_BMCInfo.IpmiConfig.SDRConfig.UpdatingSDR = FALSE;
- pExitSDRUpdateModeRes->CompletionCode = CC_NORMAL;
-
- FlushIPMIToFlash();
- return sizeof (ExitSDRUpdateModeRes_T);
- }
- /*-------------------------------------------------
- * RunInitializationAgent
- *--------------------------------------------------*/
- int
- RunInitializationAgent ( uint8_t* pReq, uint8_t ReqLen, uint8_t* pRes)
- {
- printf("RunInitializationAgent not implement\r\n");
- // RunInitAgentRes_T* pRunInitAgentRes =
- // ( RunInitAgentRes_T*) pRes;
- // BMCInfo_t *pBMCInfo = &g_BMCInfo[BMCInst];
- // /* Reserved bit Checking */
- // if((pReq[0] & 0xFE) != 0x00)
- // {
- // pRes [0] = CC_INV_DATA_FIELD;
- // return sizeof (*pRes);
- // }
- // OS_THREAD_MUTEX_ACQUIRE(&pBMCInfo->SDRConfig.SDRMutex, WAIT_INFINITE);
- // if (0 != pReq[0])
- // {
- // InitSDR (BMCInst);
- // SDRInitAgent (BMCInst);
- // // The sensor monitor loop has been made 0 for
- // // initializing the sensor scanning bit.
- // pBMCInfo->SenConfig.SensorMonitorLoopCount = 0;
- // }
- // pRunInitAgentRes->CompletionCode = CC_NORMAL;
- // pRunInitAgentRes->Status = SDR_INIT_COMPLETED;
- // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->SDRConfig.SDRMutex);
- return sizeof (RunInitAgentRes_T);
- }
- /*-----------------------------------------
- * GetSDRRec
- *-----------------------------------------*/
- SDRRecHdr_T*
- GetSDRRec (uint16_t RecID)
- {
- SDRRecHdr_T* pSDRRec;
- /* If ID == 0x0000 return first record */
- if (0 == RecID)
- {
- pSDRRec = SDR_GetFirstSDRRec ();
- if (0== pSDRRec) /* is SDR empty? */
- {
- g_BMCInfo.IpmiConfig.SDRConfig.SDRError = CC_SDR_REC_NOT_PRESENT;
- FlushIPMIToFlash();
- return 0;
- }
- return pSDRRec;
- }
- /* If ID == 0xFFFF return the last record */
- if (0xFFFF == RecID)
- {
- return GetLastSDRRec ();
- }
- pSDRRec = SDR_GetFirstSDRRec ();
- while (TRUE)
- {
- if (0== pSDRRec)
- {
- g_BMCInfo.IpmiConfig.SDRConfig.SDRError = CC_SDR_REC_NOT_PRESENT;
- FlushIPMIToFlash();
- return 0;
- }
- if (pSDRRec->ID == RecID)
- {
- return pSDRRec;
- }
- pSDRRec = SDR_GetNextSDRRec (pSDRRec);
- }
- }
- /*-----------------------------------------------------
- * InitSDR
- *-----------------------------------------------------*/
- int InitSDR ()
- {
- // uint8_t* pSDRRec;
- // SDRRecHdr_T* pSDRRecord;
- // int i; /* Multi-LUN support index will have more than 256 sensors*/
- // uint8_t OEM_Recdata[MAX_OEM_REC_LEN];
- // BMCInfo_t* pBMCInfo = &g_BMCInfo;
- // pBMCInfo->SDRConfig.SDRRAM = ( SDRRepository_T*) GetSDRSELNVRAddr(NVRH_SDR, BMCInst);
- // pSDRRec = GetSDRSELNVRAddr (NVRH_SDR + sizeof(SDRRepository_T), BMCInst);
- // pBMCInfo->SDRConfig.SDRRAM->NumRecords = 0;
- // pBMCInfo->SDRConfig.LatestRecordID =0;
- // pBMCInfo->SDRConfig.SDRRAM->Size = 16; /* SDR Repository Header */
- //#if (0x01 == MARK_FOR_DELETION_SUPPORT)
- // pBMCInfo->SDRConfig.NumMarkedRecords= 0;
- //#endif
- // if (pBMCInfo->SDRConfig.RepositoryInfo.OpSupport & OVERFLOW_FLAG)
- // {
- // pBMCInfo->SDRConfig.RepositoryInfo.OpSupport &= ~OVERFLOW_FLAG;
- // }
- // printf ("Init SDR\n");
- // while (TRUE)
- // {
- //#if (0x01 == MARK_FOR_DELETION_SUPPORT)
- // if ((0x5A == (( E2ROMHdr_T*)pSDRRec)->Valid)
- // || (0x01 == (( E2ROMHdr_T*)pSDRRec)->Valid) )
- // {
- // //count the records marked for deletion.
- // if (0x01 == (( E2ROMHdr_T*)pSDRRec)->Valid)
- // {
- // pBMCInfo->SDRConfig.NumMarkedRecords++;
- // }
- // else
- // {
- // pBMCInfo->SDRConfig.SDRRAM->NumRecords ++;
- // }
- //#else
- // if (0x5A == (( E2ROMHdr_T*)pSDRRec)->Valid)
- // {
- // pBMCInfo->SDRConfig.SDRRAM->NumRecords ++;
- //#endif
- // pBMCInfo->SDRConfig.LatestRecordID = ((SDRRecHdr_T *)((( E2ROMHdr_T*)pSDRRec)+1))->ID;
- // pBMCInfo->SDRConfig.SDRRAM->Size += (( E2ROMHdr_T*)pSDRRec)->Len;
- // pSDRRec += (( E2ROMHdr_T*)pSDRRec)->Len;
- // }
- // /* if No more Records */
- // else
- // {
- // break;
- // }
- // }
- // /* Check if SDR (valid record count) Empty */
- // if (0 == pBMCInfo->SDRConfig.SDRRAM->NumRecords)
- // {
- //#if IPM_DEVICE == 1
- // pBMCInfo->Msghndlr.SelfTestByte |= GST_SDR_EMPTY;
- //#endif
- // printf ("SDR EMPTY \n");
- // }
- // /* Update the SDR Erase Time Stamp */
- // pBMCInfo->SDRConfig.RepositoryInfo.EraseTimeStamp = pBMCInfo->GenConfig.SDREraseTime ;
- // /* Update the repository information */
- // UpdateRepositoryInfo (BMCInst);
- // pSDRRecord = SDR_GetFirstSDRRec (BMCInst);
- // for (i=0; i < pBMCInfo->SDRConfig.SDRRAM->NumRecords && pSDRRecord != NULL; i++)
- // {
- // if ((OEM_SDRFRU_REC == pSDRRecord->Type)||(OEM_SDRNM_REC == pSDRRecord->Type))
- // {
- // uint8_t Rec_len;
- // Rec_len=pSDRRecord->Len ;
- // memcpy(OEM_Recdata , pSDRRecord ,sizeof(SDRRecHdr_T)+Rec_len);
- // if(g_PDKHandle[PDK_PROCESSOEMRECORD] != NULL)
- // {
- // ((void(*)(uint8_t *,int))g_PDKHandle[PDK_PROCESSOEMRECORD]) ((uint8_t*)&OEM_Recdata,BMCInst);
- // }
- // }
- // if(g_corefeatures.node_manager == ENABLED)
- // {
- // if(OEM_SDRNM_REC == pSDRRecord->Type)
- // {
- // OEM_NMRec_T* sonm;
- // sonm =(OEM_NMRec_T*) ( (UINT8*)pSDRRecord );
- // if(sonm->RecordSubType == OEM_SDR_NM_REC)
- // pBMCInfo->NMConfig.NMDevSlaveAddress = sonm->NMDevSlaveAddress;
- // }
- // }
- // if(g_PDKHandle[PDK_PROCESSSENSORDATARECORD] != NULL)
- // {
- // ((void(*)(uint8_t *,int))g_PDKHandle[PDK_PROCESSSENSORDATARECORD]) ((uint8_t*)pSDRRecord,BMCInst);
- // }
- // pSDRRecord = SDR_GetNextSDRRec (pSDRRecord,BMCInst);
- // }
- //
- // if(g_PDKHandle[PDK_AFTERSDRINIT] != NULL)
- // {
- // ((void(*)(uint8_t))g_PDKHandle[PDK_AFTERSDRINIT]) (BMCInst);
- // }
-
- return 0;
- }
- /*----------------------------------------------------------*
- * SDR_GetNextSDRId
- *----------------------------------------------------------*/
- uint16_t
- SDR_GetNextSDRId (uint16_t RecID)
- {
- SDRRecHdr_T* pSDRRec;
- pSDRRec = GetSDRRec(RecID);
- if (0 == pSDRRec)
- {
- return INVALID_RECORD_ID;
- }
- pSDRRec = SDR_GetNextSDRRec (pSDRRec);
- if (0 == pSDRRec)
- {
- /* return last record ID (0xFFFF) */
- return 0xFFFF;
- }
- else
- {
- return pSDRRec->ID;
- }
- }
- /*--------------------------------------------------
- * SDR_GetFirstSDRRec
- *--------------------------------------------------*/
- SDRRecHdr_T*
- SDR_GetFirstSDRRec ()
- {
- return ReadSDRRepository (NULL);
- }
- /*--------------------------------------------------
- * SDR_GetNextSDRRec
- *-------------------------------------------------*/
- SDRRecHdr_T*
- SDR_GetNextSDRRec ( SDRRecHdr_T* pSDRRec)
- {
- return ReadSDRRepository (pSDRRec);
- }
- /*--------------------------------------------------
- * ReadSDRRepository
- *-------------------------------------------------*/
- SDRRecHdr_T*
- ReadSDRRepository ( SDRRecHdr_T* pSDRRec)
- {
- E2ROMHdr_T* InternalHdr;
- // uint8_t SDRSize=0;
- if (pSDRRec == 0)
- {
- InternalHdr = ( E2ROMHdr_T*)(g_BMCInfo.pSDR + sizeof(SDRRepository_T));
- }
- else
- {
-
- InternalHdr = ( E2ROMHdr_T*)(( uint8_t*)pSDRRec + SDR_SIZE (pSDRRec));
-
- /* is address >= First free byte ? */
- if (( uint8_t*) InternalHdr >= ( uint8_t*)SDR_FIRST_FREE_BYTE() )
- {
- /* No more records to read */
- //log("No more records to read\r\n");
- return 0;
- }
- //log("Reading the next record of %x \r\n", pSDRRec->ID);
- }
- /* is SDR Empty ?*/
- if (g_BMCInfo.IpmiConfig.SDRConfig.SDRRAM->NumRecords == 0)
- {
- return 0;
- }
- #if (0x01 == MARK_FOR_DELETION_SUPPORT)
- /* Fetch a Valid SDR */
- while (TRUE)
- {
- if( InternalHdr->Valid == 0x5a )
- {
- printf("Returning Valid record ID %x \n", (( SDRRecHdr_T*)(InternalHdr+1))->ID );
- return (( SDRRecHdr_T*)(InternalHdr+1));
- }
- InternalHdr = ( E2ROMHdr_T*) (((uint8_t*)InternalHdr) + InternalHdr->Len);
- /* is address >= First free byte ? */
- if (( uint8_t*) InternalHdr >= ( uint8_t*)SDR_FIRST_FREE_BYTE(BMCInst) )
- {
- log("No more valid records found \n");
- return 0;
- }
- }
- #else
- return (( SDRRecHdr_T*)(InternalHdr+1));
- #endif
- }
- /*--------------------------------------------------
- * WriteSDRRepository
- *-------------------------------------------------*/
- void
- WriteSDRRepository ( SDRRecHdr_T* pSDRRec, uint8_t Offset, uint8_t Size,uint8_t SdrSize)
- {
- //TODO:
- printf("WriteSDRRepository not implement\r\n");
- // E2ROMHdr_T* InternalHdr = ( E2ROMHdr_T *)SDR_FIRST_FREE_BYTE(BMCInst);
- // uint8_t* WriteAddr;
- // /* Update Validity and Length */
- // if ( Offset < sizeof(SDRRecHdr_T ) && ((Offset + Size) >= sizeof(SDRRecHdr_T)) )
- // {
- // InternalHdr->Valid = 0x5A;
- // InternalHdr->Len = SdrSize;
- // }
- // WriteAddr = ( uint8_t*)(InternalHdr+1);
- // memset((WriteAddr + Offset),0,SdrSize);
- // _fmemcpy ((WriteAddr + Offset), pSDRRec, Size);
- return ;
- }
- /**
- * @brief Check the SDR update mode.
- * @param pRes - Response.
- * @return TRUE/FALSE
- **/
- static uint8_t
- PreCheckSDRUpdateModeCmd ( uint8_t* pRes)
- {
- //TODO: when update SDR return FALSE.
- return TRUE;
- }
- /**
- * @brief Reserve the SDR Repository.
- * @return Reservation ID.
- **/
- static uint16_t
- SDR_ReserveSDRRepository ()
- {
- if (0xffff == g_BMCInfo.IpmiConfig.SDRConfig.ReservationID)
- {
- g_BMCInfo.IpmiConfig.SDRConfig.ReservationID = 1;
- }else
- {
- g_BMCInfo.IpmiConfig.SDRConfig.ReservationID++;
- }
- g_BMCInfo.IpmiConfig.SDRConfig.TrackPOffset =0;
- FlushIPMIToFlash();
- return g_BMCInfo.IpmiConfig.SDRConfig.ReservationID;
- }
- /**
- * @brief Get an SDR record.
- * @param RecID - SDR record ID.
- * @param ReservationID - SDR Reservation ID.
- * @return SDR record.
- **/
- static SDRRecHdr_T*
- SDR_GetSDRRec (uint16_t RecID, uint16_t ReservationID)
- {
- /* Bail out with error, if both the conditions are False (Reservation not valid)
- 1. Reservation ID matches, not equal to 0x00 & SDR is not in Update mode /
- 2. SDR is in Update mode & Reservation ID equals to 0x00
- */
- if ( !(((g_BMCInfo.IpmiConfig.SDRConfig.ReservationID == ReservationID) && (0x00 != ReservationID) &&
- (FALSE == g_BMCInfo.IpmiConfig.SDRConfig.UpdatingSDR)) || ((TRUE == g_BMCInfo.IpmiConfig.SDRConfig.UpdatingSDR) &&
- (0x00 == ReservationID))))
- {
- if( TRUE == g_BMCInfo.IpmiConfig.SDRConfig.UpdatingSDR )
- {
- g_BMCInfo.IpmiConfig.SDRConfig.SDRError = CC_SDR_REP_IN_UPDATE_MODE;
- }else /* Reservation ID doesn't match, return invalid reservation ID */
- {
- g_BMCInfo.IpmiConfig.SDRConfig.SDRError = CC_INV_RESERVATION_ID;
- }
- FlushIPMIToFlash();
- return 0;
- }
- return GetSDRRec (RecID);
- }
- //static uint8_t
- //ValidateSDRSize (uint8_t SDRType, uint8_t Size)
- //{
- // //TODO:
- // printf("ValidateSDRSize not implement\r\n");
- // int i;
- // IPMI_DBG_PRINT_2("ValidateSDR Type : 0x%X, Size : 0x%X\n", SDRType, Size);
- // if ((SDRType == OEM_SDRFRU_REC)||(SDRType == OEM_SDRNM_REC))
- // return TRUE;
- // for (i = 0; i < sizeof (SDRSize)/ 2; i++)
- // {
- // if ((SDRSize[i][0] == SDRType) && (SDRSize[i][1] >= Size))
- // {
- // return TRUE;
- // }
- // }
- // return FALSE;
- // return TRUE;
- //}
- /**
- * @brief Add an SDR record.
- * @param pSDRRec - SDR record.
- * @return Record ID.
- **/
- static uint16_t
- SDR_AddSDRRec ( SDRRecHdr_T* pSDRRec)
- {
- //TODO
- printf("SDR_AddSDRRec not implement\r\n");
- // uint16_t SDRSize;
- // uint8_t AllocSize;
- // int nRet;
- // if (FALSE == ValidateSDRSize(pSDRRec->Type, pSDRRec->Len + sizeof (SDRRecHdr_T)))
- // {
- // g_BMCInfo[BMCInst].SDRConfig.SDRError = CC_REQ_INV_LEN;
- // return INVALID_RECORD_ID;
- // }
- //
- // AllocSize = SDR_SIZE (pSDRRec) + sizeof(E2ROMHdr_T);
- // if(0 != (AllocSize % SDR_ALLOC_UNIT_SIZE))
- // {
- // SDRSize = AllocSize + (SDR_ALLOC_UNIT_SIZE -(AllocSize % SDR_ALLOC_UNIT_SIZE));
- // }
- // else
- // {
- // SDRSize = AllocSize;
- // }
- // if (SDRSize > htoipmi_u16 (g_BMCInfo[BMCInst].SDRConfig.RepositoryInfo.FreeSpace))
- // {
- // g_BMCInfo[BMCInst].SDRConfig.RepositoryInfo.OpSupport |= OVERFLOW_FLAG;
- // g_BMCInfo[BMCInst].SDRConfig.SDRError = CC_OUT_OF_SPACE;
- // return INVALID_RECORD_ID;
- // }
- // /* Update the record ID */
- // pSDRRec->ID = g_BMCInfo[BMCInst].SDRConfig.LatestRecordID + 1;
- // /* Add this record to the end of the repository */
- // WriteSDRRepository (pSDRRec, 0, SDR_SIZE (pSDRRec),SDRSize,BMCInst);
- // /* Flush the sdr */
- // FlushSDR (SDR_FIRST_FREE_BYTE(BMCInst), SDRSize, nRet,BMCInst);
- //#if IPM_DEVICE == 1
- // if (-1 == nRet)
- // {
- // g_BMCInfo[BMCInst].Msghndlr.SelfTestByte |= GST_CANNOT_ACCESS_SDR;
- // }
- // else
- // {
- // g_BMCInfo[BMCInst].Msghndlr.SelfTestByte &= ~GST_CANNOT_ACCESS_SDR;
- // }
- //#endif
- // /* Update the fields in SDR Repository */
- // g_BMCInfo[BMCInst].SDRConfig.SDRRAM->NumRecords++;
- // g_BMCInfo[BMCInst].SDRConfig.LatestRecordID++;
- //#if IPM_DEVICE == 1
- // if (g_BMCInfo[BMCInst].Msghndlr.SelfTestByte & GST_SDR_EMPTY)
- // {
- // g_BMCInfo[BMCInst].Msghndlr.SelfTestByte &= ~GST_SDR_EMPTY;
- // }
- //#endif
- //
- // g_BMCInfo[BMCInst].SDRConfig.SDRRAM->Size += SDRSize;
- // g_BMCInfo[BMCInst].SDRConfig.SDRRAM->AddTimeStamp = GetSelTimeStamp(BMCInst);
- // g_BMCInfo[BMCInst].SDRConfig.RepositoryInfo.AddTimeStamp = GetSelTimeStamp(BMCInst);
- // /* Update the repository info */
- // UpdateRepositoryInfo (BMCInst);
- // /* Invalidate Reservation ID if any */
- // SDR_ReserveSDRRepository (BMCInst);
- // return pSDRRec->ID;
- return 0;
- }
- /**
- * @brief Add partial SDR record.
- * @param SDRData - SDR Data.
- * @param Offset - SDR offset.
- * @param Size - Size of the data.
- * @param IsLast - Is this a last record?
- * @param ReservationID - SDR reservation id.
- * @return the record id.
- **/
- static uint16_t
- SDR_PartialAddSDR ( uint8_t* SDRData, uint8_t Offset, uint8_t Size,
- uint8_t IsLast, uint16_t ReservationID)
- {
- //TODO
- printf("SDR_PartialAddSDR not implement\r\n");
- // uint16_t RecID;
- // SDRRecHdr_T* pSDRRecInNVR;
- // uint8_t SdrSize=0;
- // int nRet;
- //
- // /* Bail out with error, if both the conditions are False (Reservation not valid)
- // 1. Reservation ID matches, not equal to 0x00 & SDR is not in Update mode /
- // 2. SDR is in Update mode & Reservation ID equals to 0x00
- // */
- // if ( !(((g_BMCInfo[BMCInst].SDRConfig.ReservationID == ReservationID) && (0x00 != ReservationID) && (FALSE == g_BMCInfo[BMCInst].SDRConfig.UpdatingSDR)) ||
- // ((TRUE == g_BMCInfo[BMCInst].SDRConfig.UpdatingSDR) && (0x00 == ReservationID))))
- // {
- // if( TRUE == g_BMCInfo[BMCInst].SDRConfig.UpdatingSDR )
- // {
- // g_BMCInfo[BMCInst].SDRConfig.SDRError = CC_SDR_REP_IN_UPDATE_MODE;
- // }else //Reservation ID doesn't match, return invalid reservation ID.
- // {
- // g_BMCInfo[BMCInst].SDRConfig.SDRError = CC_INV_RESERVATION_ID;
- // }
- // g_BMCInfo[BMCInst].SDRConfig.PartAddbytes=0;
- // return INVALID_RECORD_ID;
- // }
- // pSDRRecInNVR = ( SDRRecHdr_T*) (SDR_FIRST_FREE_BYTE(BMCInst) +
- // sizeof (E2ROMHdr_T));
- // RecID = g_BMCInfo[BMCInst].SDRConfig.LatestRecordID + 1;
- // /* If the header is received completely, validate the size */
- // if ((Offset + Size) >= sizeof(SDRRecHdr_T))
- // {
- // if ( Offset < sizeof(SDRRecHdr_T ))
- // {
- // SDRRecHdr_T SDRHdr;
- //
- // memcpy((uint8_t*)&SDRHdr, (uint8_t*)pSDRRecInNVR, Offset );
- // memcpy(((uint8_t*)&SDRHdr) + Offset, SDRData, sizeof(SDRRecHdr_T) - Offset);
- //
- // (( SDRRecHdr_T*) pSDRRecInNVR)->ID = SDRHdr.ID = RecID;
- // memcpy( SDRData, ((uint8_t*)&SDRHdr) + Offset, sizeof(SDRRecHdr_T) - Offset );
- //
- // if (FALSE == ValidateSDRSize(SDRHdr.Type, SDRHdr.Len + sizeof (SDRRecHdr_T)))
- // {
- // g_BMCInfo[BMCInst].SDRConfig.SDRError = CC_REQ_INV_LEN;
- // return INVALID_RECORD_ID;
- // }
- // SdrSize = SDRHdr.Len + sizeof (SDRRecHdr_T) + sizeof (E2ROMHdr_T);
- // if(0 != (SdrSize % SDR_ALLOC_UNIT_SIZE))
- // {
- // SdrSize += (SDR_ALLOC_UNIT_SIZE - (SdrSize % SDR_ALLOC_UNIT_SIZE));
- // }
- // if (SdrSize > ipmitoh_u16 (g_BMCInfo[BMCInst].SDRConfig.RepositoryInfo.FreeSpace))
- // {
- // g_BMCInfo[BMCInst].SDRConfig.RepositoryInfo.OpSupport |= OVERFLOW_FLAG;
- // g_BMCInfo[BMCInst].SDRConfig.SDRError = CC_OUT_OF_SPACE;
- // return INVALID_RECORD_ID;
- // }
- // g_BMCInfo[BMCInst].SDRConfig.PartAddbytes = SdrSize;
- // if ((Offset + Size) > (SDRHdr.Len + sizeof (SDRRecHdr_T)))
- // {
- // g_BMCInfo[BMCInst].SDRConfig.SDRError = CC_INV_DATA_FIELD;
- // return INVALID_RECORD_ID;
- // }
- // }
- // else if ((Offset + Size) > (pSDRRecInNVR->Len + sizeof (SDRRecHdr_T)))
- // {
- // g_BMCInfo[BMCInst].SDRConfig.SDRError = CC_INV_DATA_FIELD;
- // return INVALID_RECORD_ID;
- // }
- // }
- // if ((IsLast == 1) && ((Offset + Size) != (pSDRRecInNVR->Len + sizeof (SDRRecHdr_T))))
- // {
- // g_BMCInfo[BMCInst].SDRConfig.SDRError = CC_INCOMPLETE_WRITTEN_BYTES;
- // return INVALID_RECORD_ID;
- // }
- // WriteSDRRepository (( SDRRecHdr_T*)SDRData, Offset, Size,SdrSize,BMCInst);
- //
- // /* If this is the last data update the data fields and flush. */
- // if (IsLast == 1)
- // {
- // /* Flush the sdr */
- // FlushSDR (SDR_FIRST_FREE_BYTE(BMCInst), g_BMCInfo[BMCInst].SDRConfig.PartAddbytes, nRet,BMCInst);
- //#if IPM_DEVICE == 1
- // if (-1 == nRet)
- // {
- // g_BMCInfo[BMCInst].Msghndlr.SelfTestByte |= GST_CANNOT_ACCESS_SDR;
- // }
- // else
- // {
- // g_BMCInfo[BMCInst].Msghndlr.SelfTestByte &= ~GST_CANNOT_ACCESS_SDR;
- // }
- //#endif
- // /* Update the fields in SDR Repository */
- // g_BMCInfo[BMCInst].SDRConfig.SDRRAM->NumRecords ++;
- // g_BMCInfo[BMCInst].SDRConfig.LatestRecordID++;
- // g_BMCInfo[BMCInst].SDRConfig.TrackPOffset=0;
- //#if IPM_DEVICE == 1
- // if (g_BMCInfo[BMCInst].Msghndlr.SelfTestByte & GST_SDR_EMPTY)
- // {
- // g_BMCInfo[BMCInst].Msghndlr.SelfTestByte &= ~GST_SDR_EMPTY;
- // }
- //#endif
- // g_BMCInfo[BMCInst].SDRConfig.SDRRAM->Size += g_BMCInfo[BMCInst].SDRConfig.PartAddbytes;
- // g_BMCInfo[BMCInst].SDRConfig.SDRRAM->AddTimeStamp = GetSelTimeStamp(BMCInst);
- // g_BMCInfo[BMCInst].SDRConfig.RepositoryInfo.AddTimeStamp = GetSelTimeStamp(BMCInst);
- //
- // /* Update the repository info */
- // UpdateRepositoryInfo (BMCInst);
- // g_BMCInfo[BMCInst].SDRConfig.PartAddbytes =0;
- // /* Invalidate Reservation ID if any */
- // SDR_ReserveSDRRepository (BMCInst);
- // // To send notification to CIM
- // if(g_PDKCIMEventHandle[PDKCIMEVENT_NOTIFYSERVERUPDATETOCIM] != NULL)
- // {
- // uint8 CMD;
- // // Set bits for SDR Event & Add operation
- // CMD = 0x11;
- // ((int(*)(uint8, uint16))g_PDKCIMEventHandle[PDKCIMEVENT_NOTIFYSERVERUPDATETOCIM])(CMD, RecID);
- // }
- // }
- // return RecID;
-
- return 0;
- }
- ///**
- // * @brief Delete the SDR.
- // * @param ReservationID - SDR reservation id.
- // * @param RecordID - SDR Record ID, which needs to be deleted
- // * @return 0 if success, -1 if error.
- //**/
- //static uint16_t
- //SDR_DeleteSDR (uint16_t ReservationID, uint16_t RecID)
- //{
- // //TODO:
- // printf("SDR_DeleteSDR not implement\r\n");
- // //#define MARK_FOR_DELETION
- // SDRRecHdr_T* pSDRRec = NULL;
- // int nRet;
- // BMCInfo_t *pBMCInfo = &g_BMCInfo[BMCInst];
- //#if (0x01 == MARK_FOR_DELETION_SUPPORT)
- // E2ROMHdr_T* pRec = NULL;
- //#else
- // uint8_t* pDestLocation = NULL;
- // uint8_t* pSrcData = NULL;
- // uint8_t* pFreeBytes= NULL;
- // uint8_t deleteSDR_Size;
- // uint16_t size;
- //#endif
- // /* Bail out with error, if both the conditions are False (Reservation not valid)
- // 1. Reservation ID matches, not equal to 0x00 & SDR is not in Update mode /
- // 2. SDR is in Update mode & Reservation ID equals to 0x00
- // */
- // if ( !(((g_BMCInfo[BMCInst].SDRConfig.ReservationID == ReservationID) && (0x00 != ReservationID) && (FALSE == g_BMCInfo[BMCInst].SDRConfig.UpdatingSDR)) ||
- // ((TRUE == g_BMCInfo[BMCInst].SDRConfig.UpdatingSDR) && (0x00 == ReservationID))))
- // {
- // if( TRUE == g_BMCInfo[BMCInst].SDRConfig.UpdatingSDR )
- // {
- // g_BMCInfo[BMCInst].SDRConfig.SDRError = CC_SDR_REP_IN_UPDATE_MODE;
- // }else /* Reservation ID doesn't match, return invalid reservation ID */
- // {
- // g_BMCInfo[BMCInst].SDRConfig.SDRError = CC_INV_RESERVATION_ID;
- // }
- // return INVALID_RECORD_ID;
- // }
- // while(TRUE)
- // {
- // pSDRRec = ReadSDRRepository(pSDRRec,BMCInst);
- // if (pSDRRec == 0)
- // {
- // g_BMCInfo[BMCInst].SDRConfig.SDRError = CC_SDR_REC_NOT_PRESENT;
- // return INVALID_RECORD_ID;
- // }
- // if (pSDRRec->ID == RecID)
- // {
- //#if (0x01 == MARK_FOR_DELETION_SUPPORT)
- // pRec = ((E2ROMHdr_T *) pSDRRec) -1;
- // pRec->Valid = 0x01; /* Mark this record for deletion */
- // FlushSDR((uint8_t *)pRec, sizeof(pRec->Valid), nRet,BMCInst);
- //#if IPM_DEVICE == 1
- // if (-1 == nRet)
- // {
- // g_BMCInfo[BMCInst].Msghndlr.SelfTestByte |= GST_CANNOT_ACCESS_SDR;
- // }
- // else
- // {
- // g_BMCInfo[BMCInst].Msghndlr.SelfTestByte &= ~GST_CANNOT_ACCESS_SDR;
- // }
- //#endif
- // g_BMCInfo[BMCInst].SDRConfig.SDRRAM->NumRecords--;
- // g_BMCInfo[BMCInst].SDRConfig.NumMarkedRecords++;
- //#else
- // /* Delete SDR - delete the current SDR, and rearrange the subsequent SDR's */
- // pDestLocation = (uint8_t*)(((E2ROMHdr_T *) pSDRRec) -1);
- // deleteSDR_Size = (((E2ROMHdr_T *) pSDRRec) -1)->Len;
- // pSrcData = pDestLocation + deleteSDR_Size;
- // pFreeBytes = (uint8_t*)SDR_FIRST_FREE_BYTE(BMCInst);
- // size = ( uint8_t*) pFreeBytes - ( uint8_t*)pDestLocation;
- // _fmemcpy (pDestLocation, pSrcData, size-deleteSDR_Size);
- // _fmemset ((pFreeBytes - deleteSDR_Size), '\0', deleteSDR_Size );
- // g_BMCInfo[BMCInst].SDRConfig.SDRRAM->Size -= deleteSDR_Size;
- // FlushSDR(pDestLocation, size, nRet,BMCInst);
- //#if IPM_DEVICE == 1
- // if (-1 == nRet)
- // {
- // g_BMCInfo[BMCInst].Msghndlr.SelfTestByte |= GST_CANNOT_ACCESS_SDR;
- // }
- // else
- // {
- // g_BMCInfo[BMCInst].Msghndlr.SelfTestByte &= ~GST_CANNOT_ACCESS_SDR;
- // }
- //#endif
- // g_BMCInfo[BMCInst].SDRConfig.SDRRAM->NumRecords--;
- //#endif
- // /* Update the SDR Erase Timestamp */
- // g_BMCInfo[BMCInst].SDRConfig.SDRRAM->EraseTimeStamp = GetSelTimeStamp (BMCInst);
- // g_BMCInfo[BMCInst].SDRConfig.RepositoryInfo.EraseTimeStamp = GetSelTimeStamp(BMCInst);
- // /* Store the SDR Ease Time Stamp in NVR */
- // pBMCInfo->GenConfig.SDREraseTime = g_BMCInfo[BMCInst].SDRConfig.RepositoryInfo.EraseTimeStamp;
- // FlushIPMI((uint8_t*)&pBMCInfo->GenConfig,(uint8_t*)&pBMCInfo->GenConfig,pBMCInfo->IPMIConfLoc.GenConfigAddr,
- // sizeof(GENConfig_T),BMCInst);
- // /* Update the repository info */
- // UpdateRepositoryInfo (BMCInst);
- // /* Invalidate Reservation ID if any */
- // SDR_ReserveSDRRepository (BMCInst);
- // return RecID;
- // }
- // }
- //return 0;
- //}
- /**
- * @brief Clear the SDR repository.
- * @param ReservationID - SDR reservation id.
- * @param InitOrStatus - Initiate erase or get status flag
- * @return 0 if success, -1 if error.
- **/
- static int
- SDR_ClearSDRRepository (uint16_t ReservationID, uint8_t InitOrStatus)
- {
- //TODO:
- printf("SDR_ClearSDRRepository not implement\r\n");
- // int nRet;
- // BMCInfo_t* pBMCInfo = &g_BMCInfo[BMCInst];
- // /* Bail out with error, if both the conditions are False (Reservation not valid)
- // 1. Reservation ID matches, not equal to 0x00 & SDR is not in Update mode /
- // 2. SDR is in Update mode & Reservation ID equals to 0x00
- // */
- // if ( !(((g_BMCInfo[BMCInst].SDRConfig.ReservationID == ReservationID) && (0x00 != ReservationID) && (FALSE == g_BMCInfo[BMCInst].SDRConfig.UpdatingSDR)) ||
- // ((TRUE == g_BMCInfo[BMCInst].SDRConfig.UpdatingSDR) && (0x00 == ReservationID))))
- // {
- // if( TRUE == g_BMCInfo[BMCInst].SDRConfig.UpdatingSDR )
- // {
- // g_BMCInfo[BMCInst].SDRConfig.SDRError = CC_SDR_REP_IN_UPDATE_MODE;
- // }else //Reservation ID doesn't match, return invalid reservation ID.
- // {
- // g_BMCInfo[BMCInst].SDRConfig.SDRError = CC_INV_RESERVATION_ID;
- // }
- // return -1;
- // }
- // // AAh = initiate erase, 00h = get erasure status.
- // if (InitOrStatus != CLEAR_SDR_INITIATE_ERASE &&
- // InitOrStatus != CLEAR_SDR_GET_STATUS)
- // {
- // g_BMCInfo[BMCInst].SDRConfig.SDRError = CC_INV_DATA_FIELD;
- // return -1;
- // }
- // else if (InitOrStatus == CLEAR_SDR_GET_STATUS)
- // {
- // return 0;
- // }
- // _fmemset ((( uint8_t*)g_BMCInfo[BMCInst].SDRConfig.SDRRAM + 16), 0xFF,(pBMCInfo->IpmiConfig.SDRAllocationSize * 1024) - 16 );
- // /* Flush the NVRAM */
- // FlushSDR (g_BMCInfo[BMCInst].SDRConfig.SDRRAM, (pBMCInfo->IpmiConfig.SDRAllocationSize * 1024), nRet,BMCInst);
- //#if IPM_DEVICE == 1
- // if (-1 == nRet)
- // {
- // g_BMCInfo[BMCInst].Msghndlr.SelfTestByte |= GST_CANNOT_ACCESS_SDR;
- // }
- // else
- // {
- // g_BMCInfo[BMCInst].Msghndlr.SelfTestByte &= ~GST_CANNOT_ACCESS_SDR;
- // }
- //#endif
- // /* Clear the fields of the SDR */
- // g_BMCInfo[BMCInst].SDRConfig.SDRRAM->NumRecords = 0;
- // g_BMCInfo[BMCInst].SDRConfig.LatestRecordID =0;
- //#if (0x01 == MARK_FOR_DELETION_SUPPORT)
- // g_BMCInfo[BMCInst].SDRConfig.NumMarkedRecords=0;
- //#endif
- // if (g_BMCInfo[BMCInst].SDRConfig.RepositoryInfo.OpSupport & OVERFLOW_FLAG)
- // {
- // g_BMCInfo[BMCInst].SDRConfig.RepositoryInfo.OpSupport &= ~OVERFLOW_FLAG;
- // }
- //#if IPM_DEVICE == 1
- // g_BMCInfo[BMCInst].Msghndlr.SelfTestByte |= GST_SDR_EMPTY;
- //#endif
- // g_BMCInfo[BMCInst].SDRConfig.SDRRAM->Size = 16;
- // g_BMCInfo[BMCInst].SDRConfig.SDRRAM->EraseTimeStamp = GetSelTimeStamp (BMCInst);
- // g_BMCInfo[BMCInst].SDRConfig.RepositoryInfo.EraseTimeStamp = GetSelTimeStamp(BMCInst);
- // /* Store the SDR Ease Time Stamp in NVR */
- // pBMCInfo->GenConfig.SDREraseTime = g_BMCInfo[BMCInst].SDRConfig.RepositoryInfo.EraseTimeStamp;
- // FlushIPMI((uint8_t*)&pBMCInfo->GenConfig,(uint8_t*)&pBMCInfo->GenConfig,pBMCInfo->IPMIConfLoc.GenConfigAddr,
- // sizeof(GENConfig_T),BMCInst);
- // /* Update the Repository Info */
- // UpdateRepositoryInfo (BMCInst);
- // /* Invalidate Reservation ID if any */
- // SDR_ReserveSDRRepository (BMCInst);
- return 0;
- }
- /**
- * @brief Get the last SDR record.
- * @return the last SDR record.
- **/
- static SDRRecHdr_T*
- GetLastSDRRec ()
- {
- SDRRecHdr_T* pSDRRec;
- pSDRRec = SDR_GetFirstSDRRec ();
- while (TRUE)
- {
- SDRRecHdr_T* pCurSDRRec;
- /* Save this record and get the next record */
- pCurSDRRec = pSDRRec;
- pSDRRec = SDR_GetNextSDRRec (pSDRRec);
- /* If we have reached past the last return the last record */
- if (0 == pSDRRec)
- {
- return pCurSDRRec;
- }
- }
- }
- ///**
- // * @brief Update SDR repository information.
- //**/
- //static void
- //UpdateRepositoryInfo ()
- //{
- // //TODO:
- // printf("UpdateRepositoryInfo not implement\r\n");
- // BMCInfo_t* pBMCInfo = &g_BMCInfo[BMCInst];
- // /* Update the version */
- // g_BMCInfo[BMCInst].SDRConfig.RepositoryInfo.Version = SDR_VERSION;
- // /* Update the record count */
- // g_BMCInfo[BMCInst].SDRConfig.RepositoryInfo.RecCt = htoipmi_u16 (g_BMCInfo[BMCInst].SDRConfig.SDRRAM->NumRecords);
- // /* Update the free space available */
- // g_BMCInfo[BMCInst].SDRConfig.RepositoryInfo.FreeSpace = htoipmi_u16 (((pBMCInfo->IpmiConfig.SDRAllocationSize * 1024) - g_BMCInfo[BMCInst].SDRConfig.SDRRAM->Size));
- // /* Update the the operation support */
- // g_BMCInfo[BMCInst].SDRConfig.RepositoryInfo.OpSupport=NO_SUPPORT;
- // if(g_PDKCmdsHandle[PDKCMDS_PDKISCOMMANDENABLED]!= NULL)
- // {
- // if(((int(*)(uint8_t,uint8_t*,uint8_t,int))g_PDKCmdsHandle[PDKCMDS_PDKISCOMMANDENABLED])(NETFN_STORAGE,NULL,CMD_RESERVE_SDR_REPOSITORY,BMCInst) == 0)
- // {
- // g_BMCInfo[BMCInst].SDRConfig.RepositoryInfo.OpSupport|=RESERVE_SDR_SUPPORT;
- // }
- // if(((int(*)(uint8_t,uint8_t*,uint8_t,int))g_PDKCmdsHandle[PDKCMDS_PDKISCOMMANDENABLED])(NETFN_STORAGE,NULL,CMD_GET_SDR_REPOSITORY_ALLOCATION_INFO,BMCInst) == 0)
- // {
- // g_BMCInfo[BMCInst].SDRConfig.RepositoryInfo.OpSupport|=NON_MODAL_SUPPORT+GET_SDR_REPOSITORY_ALLOC_SUPPORT;
- // }
- // if(((int(*)(uint8_t,uint8_t*,uint8_t,int))g_PDKCmdsHandle[PDKCMDS_PDKISCOMMANDENABLED])(NETFN_STORAGE,NULL,CMD_PARTIAL_ADD_SDR,BMCInst) == 0)
- // {
- // g_BMCInfo[BMCInst].SDRConfig.RepositoryInfo.OpSupport|=PARTIAL_ADD_SDR_SUPPORT;
- // }
- // if(((int(*)(uint8_t,uint8_t*,uint8_t,int))g_PDKCmdsHandle[PDKCMDS_PDKISCOMMANDENABLED])(NETFN_STORAGE,NULL,CMD_DELETE_SDR,BMCInst) == 0)
- // {
- // g_BMCInfo[BMCInst].SDRConfig.RepositoryInfo.OpSupport|=DELETE_SDR_SUPPORT;
- // }
- // }
- // /* Update the repository allocation information */
- // g_BMCInfo[BMCInst].SDRConfig.RepositoryAllocInfo.NumAllocUnits = htoipmi_u16 (((pBMCInfo->IpmiConfig.SDRAllocationSize * 1024) - 16) / SDR_ALLOC_UNIT_SIZE); /* Because 16 bytes are reserved for header info */
- // g_BMCInfo[BMCInst].SDRConfig.RepositoryAllocInfo.AllocUnitSize = htoipmi_u16 (SDR_ALLOC_UNIT_SIZE);
- // g_BMCInfo[BMCInst].SDRConfig.RepositoryAllocInfo.NumFreeAllocUnits = htoipmi_u16 (ipmitoh_u16 (g_BMCInfo[BMCInst].SDRConfig.RepositoryInfo.FreeSpace) /
- // SDR_ALLOC_UNIT_SIZE);
- // g_BMCInfo[BMCInst].SDRConfig.RepositoryAllocInfo.LargestFreeBlock = htoipmi_u16 (ipmitoh_u16 (g_BMCInfo[BMCInst].SDRConfig.RepositoryInfo.FreeSpace) /
- // SDR_ALLOC_UNIT_SIZE);
- // g_BMCInfo[BMCInst].SDRConfig.RepositoryAllocInfo.MaxRecSize = SDR_MAX_RECORD_SIZE / SDR_ALLOC_UNIT_SIZE;
- //}
- ///**
- // * @brief SDR initialization agent.
- //**/
- //static void
- //SDRInitAgent ()
- //{
- // //TODO:
- // printf("SDRInitAgent not implement\r\n");
- // uint8_t i,Count =0;
- // uint8_t CmdRes [MAX_RES_LEN];
- // SDRRecHdr_T* pSDRRec;
- // HQueue_T IfcQ;
- // BMCInfo_t* pBMCInfo = &g_BMCInfo[BMCInst];
- // if(g_PDKHandle[PDK_BEFOREINITAGENT] != NULL)
- // {
- // if(-1 == ((int(*)(int))g_PDKHandle[PDK_BEFOREINITAGENT]) (BMCInst))
- // {
- // return;
- // }
- // }
- //#if SET_EVENT_RECEIVER == 1
- // /* Turn off Event Generation */
- // {
- // SetEvtRcvReq_T SetEvtRcvReq = { 0xFF, 0 };
- // SetEventReceiver (( uint8_t*)&SetEvtRcvReq,
- // sizeof (SetEvtRcvReq_T), CmdRes,BMCInst);
- // }
- //#endif
- // /* Get the MMC Controller addresses*/
- // pSDRRec = SDR_GetFirstSDRRec (BMCInst);
- // if(0 != GetQueueHandle(LAN_IFC_Q,&IfcQ,BMCInst))
- // {
- // IPMI_WARNING("Error in getting LanIfcQ Handle \n");
- // }
- // for (i=0; i < pBMCInfo->SDRConfig.SDRRAM->NumRecords && pSDRRec != NULL; i++)
- // {
- // if(MANAGEMENT_DEV_LOC_REC == pSDRRec->Type)
- // {
- // MgmtCtrlrDevLocator_T* pMgmtDevLocRec = ( MgmtCtrlrDevLocator_T*)pSDRRec;
- // if(pBMCInfo->IpmiConfig.BMCSlaveAddr != pMgmtDevLocRec->DevSlaveAddr )
- // {
- // pBMCInfo->MgmtTbl[Count].OWNERID=pMgmtDevLocRec->DevSlaveAddr;
- // pBMCInfo->MgmtTbl[Count++].PowerNotification=pMgmtDevLocRec->PowerStateNotification;
- // }
- // }
- // pSDRRec = SDR_GetNextSDRRec (pSDRRec,BMCInst);
- // }
- // pBMCInfo->MgmtTbl[Count].OWNERID= 0xff;
- //#if SUPPORT_MULTI_CONTROLLER == 1
- // /* Sending the Set Event Reciver Disable Command to all MMC in IPMB BUS */
- // if(pBMCInfo->IpmiConfig.PrimaryIPMBSupport == 0x01)
- // {
- // for(i=0; i<Count; i++)
- // {
- // MsgPkt_T Req;
- // memset(&Req,0,sizeof(MsgPkt_T));
- // IPMIMsgHdr_T* pIPMIMsgHdr = (IPMIMsgHdr_T*)Req.Data;
- // SetEvtRcvReq_T* SetEvtRcvReq = ( SetEvtRcvReq_T*) &Req.Data[sizeof(IPMIMsgHdr_T)];
- // pIPMIMsgHdr->ResAddr =pBMCInfo->MgmtTbl[i].OWNERID;
- // pIPMIMsgHdr->NetFnLUN = (NETFN_SENSOR<< 2) | BMC_LUN_00;
- // pIPMIMsgHdr->ChkSum = ~(pIPMIMsgHdr->ResAddr + pIPMIMsgHdr->NetFnLUN) + 1;
- // pIPMIMsgHdr->ReqAddr = pBMCInfo->IpmiConfig.BMCSlaveAddr;
- // pBMCInfo->SDRConfig.IPMB_Seqnum++;
- // if (pBMCInfo->SDRConfig.IPMB_Seqnum >= 0x3F) { pBMCInfo->SDRConfig.IPMB_Seqnum = 0xFF; }
- // pIPMIMsgHdr->RqSeqLUN = pBMCInfo->SDRConfig.IPMB_Seqnum<< 2; /* Request Seq Num */
- // pIPMIMsgHdr->RqSeqLUN |= BMC_LUN_00; /* LUN =00 */
- // pIPMIMsgHdr->Cmd = CMD_SET_EVENT_RECEIVER;
- // SetEvtRcvReq->RcvSlaveAddr =0xFF ;
- // SetEvtRcvReq->RcvLUN =BMC_LUN_00;
- // Req.Param=BRIDGING_REQUEST;
- // Req.Channel=PRIMARY_IPMB_CHANNEL;
- // Req.Data [sizeof (IPMIMsgHdr_T) + sizeof(SetEvtRcvReq_T)] =
- // CalculateCheckSum2 (Req.Data, sizeof (IPMIMsgHdr_T) + sizeof(SetEvtRcvReq_T));
- // Req.Size = sizeof(IPMIMsgHdr_T) + sizeof(SetEvtRcvReq_T) +1 ; //Plus 1 for Check sum
- // /* Post Msg to IPMB task to send the set event receiver */
- // if ( -1 != IfcQ )
- // {
- // if(0 != PostMsg(&Req, IPMB_PRIMARY_IFC_Q,BMCInst))
- // {
- // IPMI_WARNING ("SDR.c : Error posting message to IPMBIfc_Q\n");
- // }
- // pBMCInfo->MgmtTbl[i].Status =TRUE;
- // }
- // }
- // }
- //#endif
- //#if SUPPORT_MULTI_CONTROLLER == 1
- // /* Sending the Run Initalization Command to all MMC in IPMB BUS */
- // if(pBMCInfo->IpmiConfig.PrimaryIPMBSupport == 0x01)
- // {
- // for(i=0; i<Count; i++)
- // {
- // MsgPkt_T Req;
- // memset(&Req,0,sizeof(MsgPkt_T));
- // IPMIMsgHdr_T* pIPMIMsgHdr = (IPMIMsgHdr_T*)Req.Data;
- // pIPMIMsgHdr->ResAddr =pBMCInfo->MgmtTbl[i].OWNERID;
- // pIPMIMsgHdr->NetFnLUN = (NETFN_STORAGE<< 2) | BMC_LUN_00;
- // /* Get Device ID */
- // // pIPMIMsgHdr->NetFnLUN = (NETFN_APP<< 2) | BMC_LUN_00;
- // pIPMIMsgHdr->ChkSum = ~(pIPMIMsgHdr->ResAddr + pIPMIMsgHdr->NetFnLUN) + 1;
- // pIPMIMsgHdr->ReqAddr = pBMCInfo->IpmiConfig.BMCSlaveAddr;
- // Req.Channel=PRIMARY_IPMB_CHANNEL;
- // g_BMCInfo[BMCInst].SDRConfig.IPMB_Seqnum++;
- // if (g_BMCInfo[BMCInst].SDRConfig.IPMB_Seqnum >= 0x3F) { g_BMCInfo[BMCInst].SDRConfig.IPMB_Seqnum = 0xFF; }
- // pIPMIMsgHdr->RqSeqLUN = g_BMCInfo[BMCInst].SDRConfig.IPMB_Seqnum<< 2; /* Request Seq Num */
- // pIPMIMsgHdr->RqSeqLUN |= BMC_LUN_00; /* LUN =00 */
- // Req.Param=BRIDGING_REQUEST;
- // pIPMIMsgHdr->Cmd = CMD_RUN_INITIALIZATION_AGENT;
- // Req.Data[sizeof(IPMIMsgHdr_T)]=0x1;
- // Req.Data [sizeof (IPMIMsgHdr_T) + 1] =
- // CalculateCheckSum2 (Req.Data, sizeof (IPMIMsgHdr_T) +1);
- // Req.Size = sizeof(IPMIMsgHdr_T) + 2; //Plus 2 for req data's
- // if ( -1 !=IfcQ )
- // {
- // if(0 != PostMsg(&Req, IPMB_PRIMARY_IFC_Q,BMCInst))
- // {
- // IPMI_WARNING ("SDR.c : Error posting message to IPMBIfc_Q\n");
- // }
- // pBMCInfo->MgmtTbl[i].Status =TRUE;
- // }
- // }
- // }
- //#endif
- // pSDRRec = SDR_GetFirstSDRRec (BMCInst);
- // for (i=0; i < pBMCInfo->SDRConfig.SDRRAM->NumRecords && pSDRRec != NULL; i++)
- // {
- // if (FULL_SDR_REC == pSDRRec->Type)
- // {
- // /* For all records of type 01h */
- // FullSensorRec_T* pFullRec = ( FullSensorRec_T*)pSDRRec;
- // uint16_t ValidMask = htoipmi_u16(0x0FFF);
- // // If not a threshold sensor, then 15 event bits are used.
- // if (pFullRec->EventTypeCode != 0x01)
- // {
- // ValidMask = htoipmi_u16(0x7FFF);
- // }
- // /* Disable Event & Scanning messages, if Disable is supported */
- // if (0x03 != (pFullRec->SensorCaps & 0x03))
- // {
- // SetSensorEventEnableReq_T SetSEReq;
- // // disable all events for sensor
- // SetSEReq.SensorNum = pFullRec->SensorNum;
- // SetSEReq.Flags = DISABLE_SELECTED_EVENT_MSG; // Event Disabled
- // SetSEReq.AssertionMask = ValidMask;
- // SetSEReq.DeAssertionMask = ValidMask;
- // SetSensorEventEnable (( uint8_t*)&SetSEReq,
- // sizeof (SetSensorEventEnableReq_T), CmdRes,BMCInst);
- // }
- // /* Set Sensor Type */
- //#if SET_SENSOR_TYPE != UNIMPLEMENTED
- // if (pFullRec->SensorInit & BIT2)
- // {
- // /* Set Sensor Type */
- // SetSensorTypeReq_T SetSensorTypeReq;
- // SetSensorTypeReq.SensorNum = pFullRec->SensorNum;
- // SetSensorTypeReq.SensorType = pFullRec->SensorType;
- // SetSensorTypeReq.EventTypeCode = pFullRec->EventTypeCode;
- // SetSensorType (( uint8_t*)&SetSensorTypeReq, sizeof(SetSensorTypeReq), CmdRes,BMCInst);
- // }
- //#endif
- // /* Set Sensor Thresholds */
- // {
- // SetSensorThresholdReq_T SetThresholdReq;
- // SetThresholdReq.SensorNum = pFullRec->SensorNum;
- // SetThresholdReq.SetFlags = ((pFullRec->DiscreteReadingMask >> 8) & 0x3F);
- // if (pFullRec->SensorInit & BIT4)
- // {
- // SetThresholdReq.LowerNonCritical = pFullRec->LowerNonCritical;
- // SetThresholdReq.LowerCritical = pFullRec->LowerCritical;
- // SetThresholdReq.LowerNonRecoverable = pFullRec->LowerNonRecoverable;
- // SetThresholdReq.UpperNonCritical = pFullRec->UpperNonCritical;
- // SetThresholdReq.UpperCritical = pFullRec->UpperCritical;
- // SetThresholdReq.UpperNonRecoverable = pFullRec->UpperNonRecoverable;
- // SetSensorThresholds (( uint8_t*)&SetThresholdReq,
- // sizeof (SetSensorThresholdReq_T), CmdRes,BMCInst);
- // }
- // }
- // /* Set Sensor Hysteresis */
- // {
- // SetSensorHysterisisReq_T SetHysteresisReq;
- // SetHysteresisReq.SensorNum = pFullRec->SensorNum;
- // SetHysteresisReq.Reserved = 0;
- // if (pFullRec->SensorInit & BIT3) //Added for DR#31091
- // {
- // SetHysteresisReq.PositiveHysterisis = pFullRec->PositiveHysterisis;
- // SetHysteresisReq.NegativeHysterisis = pFullRec->NegativeHysterisis;
- // SetSensorHysterisis (( uint8_t*)&SetHysteresisReq,
- // sizeof (SetSensorHysterisisReq_T), CmdRes,BMCInst);
- // }
- // }
- // /* Enable Event & Scanning messages, if Disabled */
- // if (0x03 != (pFullRec->SensorCaps & 0x03))
- // {
- // SetSensorEventEnableReq_T SetSEReq;
- // SetSEReq.SensorNum = pFullRec->SensorNum;
- // SetSEReq.Flags = (pFullRec->SensorInit & BIT6) | ((pFullRec->SensorInit & BIT5) << 2) | ENABLE_SELECTED_EVENT_MSG; // Event Enabled
- // SetSEReq.AssertionMask = (pFullRec->AssertionEventMask & ValidMask);
- // SetSEReq.DeAssertionMask = (pFullRec->DeAssertionEventMask & ValidMask);
- // SetSensorEventEnable (( uint8_t*)&SetSEReq,
- // sizeof (SetSensorEventEnableReq_T), CmdRes,BMCInst);
- // }
- // }
- // if (pSDRRec->Type == COMPACT_SDR_REC)
- // {
- // CompactSensorRec_T* pCompactRec = ( CompactSensorRec_T*)pSDRRec;
- // uint16_t ValidMask = htoipmi_u16(0x0FFF);
- // // If not a threshold sensor, then 15 event bits are used.
- // if (pCompactRec->EventTypeCode != 0x01)
- // {
- // ValidMask = htoipmi_u16(0x7FFF);
- // }
- // /* Disable Event & Scanning messages, if Disable is supported */
- // if (0x03 != (pCompactRec->SensorCaps & 0x03))
- // {
- // SetSensorEventEnableReq_T SetSEReq;
- // SetSEReq.SensorNum = pCompactRec->SensorNum;
- // SetSEReq.Flags = DISABLE_SELECTED_EVENT_MSG; // Event Disabled
- // SetSEReq.AssertionMask = ValidMask;
- // SetSEReq.DeAssertionMask = ValidMask;
- // SetSensorEventEnable (( uint8_t*)&SetSEReq,
- // sizeof (SetSensorEventEnableReq_T), CmdRes,BMCInst);
- // }
- // /* Set Sensor Type */
- //#if SET_SENSOR_TYPE != UNIMPLEMENTED
- // if (pCompactRec->SensorInit & BIT2)
- // {
- // /* Set Sensor Type */
- // SetSensorTypeReq_T SetSensorTypeReq;
- // SetSensorTypeReq.SensorNum = pCompactRec->SensorNum;
- // SetSensorTypeReq.SensorType = pCompactRec->SensorType;
- // SetSensorTypeReq.EventTypeCode = pCompactRec->EventTypeCode;
- // SetSensorType (( uint8_t*)&SetSensorTypeReq, sizeof(SetSensorTypeReq), CmdRes,BMCInst);
- // }
- //#endif
- // /* Set Sensor Hysteresis */
- // {
- // SetSensorHysterisisReq_T SetHysteresisReq;
- // SetHysteresisReq.SensorNum = pCompactRec->SensorNum;
- // SetHysteresisReq.Reserved = 0;
- // SetHysteresisReq.PositiveHysterisis = pCompactRec->PositiveHysteris;
- // SetHysteresisReq.NegativeHysterisis = pCompactRec->NegativeHysterisis;
- // SetSensorHysterisis (( uint8_t*)&SetHysteresisReq,
- // sizeof (SetSensorHysterisisReq_T), CmdRes,BMCInst);
- // }
- // /* Enable Event & Scanning messages, if Disabled */
- // if (0x03 != (pCompactRec->SensorCaps & 0x03))
- // {
- // SetSensorEventEnableReq_T SetSEReq;
- // SetSEReq.SensorNum = pCompactRec->SensorNum;
- // SetSEReq.Flags = (pCompactRec->SensorInit & BIT6) | ((pCompactRec->SensorInit & BIT5) << 2) |ENABLE_SELECTED_EVENT_MSG ; // Event Enabled
- // SetSEReq.AssertionMask = (pCompactRec->AssertionEventMask & ValidMask);
- // SetSEReq.DeAssertionMask = (pCompactRec->DeAssertionEventMask & ValidMask);
- // SetSensorEventEnable (( uint8_t*)&SetSEReq,
- // sizeof (SetSensorEventEnableReq_T), CmdRes,BMCInst);
- // }
- // }
- // pSDRRec = SDR_GetNextSDRRec (pSDRRec,BMCInst);
- // }
- //#if SET_EVENT_RECEIVER == 0
- // /* Enable Event Generation */
- // {
- // SetEvtRcvReq_T SetEvtRcvReq = { 0x20, 0 };
- // SetEventReceiver (( uint8_t*)&SetEvtRcvReq,
- // sizeof (SetEvtRcvReq_T), CmdRes,BMCInst);
- // }
- //#endif
- //#if SUPPORT_MULTI_CONTROLLER == 1
- // /* Sending the Set Event Reciver enable Command to all MMC in IPMB BUS */
- // for(i=0;i<Count;i++)
- // {
- // MsgPkt_T Req;
- // IPMIMsgHdr_T* pIPMIMsgHdr = (IPMIMsgHdr_T*)Req.Data;
- // SetEvtRcvReq_T* SetEvtRcvReq = ( SetEvtRcvReq_T*) &Req.Data[sizeof(IPMIMsgHdr_T)];
- // pIPMIMsgHdr->ResAddr =pBMCInfo->MgmtTbl[i].OWNERID;
- // pIPMIMsgHdr->NetFnLUN = (NETFN_SENSOR<< 2) | BMC_LUN_00;
- // pIPMIMsgHdr->ChkSum = ~(pIPMIMsgHdr->ResAddr + pIPMIMsgHdr->NetFnLUN) + 1;
- // pIPMIMsgHdr->ReqAddr = pBMCInfo->IpmiConfig.BMCSlaveAddr;
- // Req.Channel=PRIMARY_IPMB_CHANNEL;
- // g_BMCInfo[BMCInst].SDRConfig.IPMB_Seqnum++;
- // if (g_BMCInfo[BMCInst].SDRConfig.IPMB_Seqnum >= 0x3F) { g_BMCInfo[BMCInst].SDRConfig.IPMB_Seqnum = 0xFF; }
- // pIPMIMsgHdr->RqSeqLUN = g_BMCInfo[BMCInst].SDRConfig.IPMB_Seqnum<< 2; /* Request Seq Num */
- // pIPMIMsgHdr->RqSeqLUN |= BMC_LUN_00; /* LUN =00 */
- // pIPMIMsgHdr->Cmd = CMD_SET_EVENT_RECEIVER;
- // SetEvtRcvReq->RcvSlaveAddr = pBMCInfo->IpmiConfig.BMCSlaveAddr;
- // SetEvtRcvReq->RcvLUN =BMC_LUN_00;
- // Req.Param=BRIDGING_REQUEST;
- // Req.Data [sizeof (IPMIMsgHdr_T) + sizeof(SetEvtRcvReq_T)] =
- // CalculateCheckSum2 (Req.Data, sizeof (IPMIMsgHdr_T) + sizeof(SetEvtRcvReq_T));
- // Req.Size = sizeof(IPMIMsgHdr_T) + sizeof(SetEvtRcvReq_T)+1; // plus 1 for checksum
- // /* Post Msg to IPMB task to send the set event receiver */
- // if ( -1 != IfcQ )
- // {
- // if(0 != PostMsg(&Req, IPMB_PRIMARY_IFC_Q,BMCInst))
- // {
- // IPMI_WARNING ("SDR.c : Error posting message to IPMBIfc_Q\n");
- // }
- // pBMCInfo->MgmtTbl[i].Status =TRUE;
- // }
- // //PDK_SMCDelay(pBMCInfo->MgmtTbl[i].OWNERID);
- // //PDK_SMCDelay(0x40);
- // //sleep(3);
- // }
- //#endif
- // if(g_PDKHandle[PDK_AFTERINITAGENT] != NULL)
- // {
- // ((int(*)(uint8_t,int))g_PDKHandle[PDK_AFTERINITAGENT]) (CmdRes[0],BMCInst);
- // }
- // return;
- //}
- #endif /* SDR_DEVICE */
|