12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811 |
- /*****************************************************************
- *****************************************************************
- *** **
- *** (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.SDRConfig.SDRRAM) + g_BMCInfo.SDRConfig.SDRRAM->Size)
- #define MAX_SDR_LEN 25
- #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_ALLOC_UNIT_SIZE 0x10
- #define SDR_MAX_RECORD_SIZE 0x80
- #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.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.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.SDRConfig.UpdatingSDR )
- {
- pResSDRRepRes->CompletionCode = CC_SDR_REP_IN_UPDATE_MODE;
- return sizeof (pResSDRRepRes->CompletionCode);
- }
-
- pResSDRRepRes->ReservationID = SDR_ReserveSDRRepository ();
- g_BMCInfo.SDRConfig.PartAddbytes = 0;
- pResSDRRepRes->CompletionCode = CC_NORMAL;
- 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 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.SDRConfig.UpdatingSDR ))
- {
- pSDRRec = GetSDRRec (pGetSDRReq->RecID);
- }
- else
- {
- pSDRRec = SDR_GetSDRRec ( pGetSDRReq->RecID, pGetSDRReq->ReservationID );
- }
- if (0 == pSDRRec)
- {
- pGetSDRRes->CompletionCode = g_BMCInfo.SDRConfig.SDRError;
- return sizeof (uint8_t);
- }
- SDRLen = pSDRRec->Len+sizeof(SDRRecHdr_T);
- if((0xFF == pGetSDRReq->Size) && (SDRLen >= pGetSDRReq->Offset))
- {
- pGetSDRReq->Size = SDRLen - pGetSDRReq->Offset;
- }
- /* Check for Max Request Bytes */
- if ((pGetSDRReq->Size > MAX_SDR_LEN) || (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.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.SDRConfig.TrackPOffset =0;
- g_BMCInfo.SDRConfig.TrackRecID =pPartialAddReq->RecID;
- }
- else if((g_BMCInfo.SDRConfig.TrackPOffset) != pPartialAddReq->Offset || g_BMCInfo.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.SDRConfig.SDRError;
- return sizeof (pPartialAddRes->CompletionCode);
- }
- pPartialAddRes->CompletionCode = CC_NORMAL;
- pPartialAddRes->RecID = RecID;
- g_BMCInfo.SDRConfig.TrackPOffset +=Size;
- g_BMCInfo.SDRConfig.TrackRecID =RecID; //We are updating the available or alloted Record ID
-
- 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.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.SDRConfig.UpdatingSDR = TRUE;
- g_BMCInfo.SDRConfig.UpdatingChannel = 0;//*curchannel & 0xF;
- pEnterSDRUpdateModeRes->CompletionCode = CC_NORMAL;
- 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.SDRConfig.UpdatingSDR = FALSE;
- pExitSDRUpdateModeRes->CompletionCode = CC_NORMAL;
-
- 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.SDRConfig.SDRError = CC_SDR_REC_NOT_PRESENT;
- 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.SDRConfig.SDRError = CC_SDR_REC_NOT_PRESENT;
- 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.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.SDRConfig.ReservationID)
- {
- g_BMCInfo.SDRConfig.ReservationID = 1;
- }else
- {
- g_BMCInfo.SDRConfig.ReservationID++;
- }
- g_BMCInfo.SDRConfig.TrackPOffset =0;
- return g_BMCInfo.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.SDRConfig.ReservationID == ReservationID) && (0x00 != ReservationID) &&
- (FALSE == g_BMCInfo.SDRConfig.UpdatingSDR)) || ((TRUE == g_BMCInfo.SDRConfig.UpdatingSDR) &&
- (0x00 == ReservationID))))
- {
- if( TRUE == g_BMCInfo.SDRConfig.UpdatingSDR )
- {
- g_BMCInfo.SDRConfig.SDRError = CC_SDR_REP_IN_UPDATE_MODE;
- }else /* Reservation ID doesn't match, return invalid reservation ID */
- {
- g_BMCInfo.SDRConfig.SDRError = CC_INV_RESERVATION_ID;
- }
- 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 */
|