NVRAccess.h 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  1. /*****************************************************************
  2. *****************************************************************
  3. *** **
  4. *** (C)Copyright 2005-2006, American Megatrends Inc. **
  5. *** **
  6. *** All Rights Reserved. **
  7. *** **
  8. *** 6145-F, Northbelt Parkway, Norcross, **
  9. *** **
  10. *** Georgia - 30071, USA. Phone-(770)-246-8600. **
  11. *** **
  12. *****************************************************************
  13. *****************************************************************
  14. ******************************************************************
  15. *
  16. * nvram.h
  17. * NVRAM Functions
  18. *
  19. * Author: Govind Kothandapani <govindk@ami.com>
  20. * Basavaraj Astekar <basavaraja@ami.com>
  21. * Ravinder Reddy <bakkar@ami.com>
  22. ******************************************************************/
  23. #ifndef NVRAM_H
  24. #define NVRAM_H
  25. #include "Types.h"
  26. #include "IPMI_Main.h"
  27. #include "NVRData.h"
  28. //#include "PDKPARAccess.h"
  29. #include "SharedMem.h"
  30. #include "IPMI_OPMA.h"
  31. #include "IPMI_AMISmtp.h"
  32. #define conf_path "/conf/BMC"
  33. #define SEL_DIR "SEL"
  34. #define IPMI_CONFIGS_FILE(Instance,filename) \
  35. sprintf(filename,"%s%s%d/%s",CONFIG_SPX_FEATURE_PREFIX_IPMICONFIG_FILE_LOCATION_SUPPORT,"/BMC",Instance,"IPMIConfig.dat")
  36. #define IPMI_CONFIGS_DIRECTORY(Instance,filename) \
  37. sprintf(filename,"%s%s%d/",CONFIG_SPX_FEATURE_PREFIX_IPMICONFIG_FILE_LOCATION_SUPPORT,"/BMC",Instance)
  38. #define SENSORTHRESH_FILE(Instance,filename) \
  39. sprintf(filename,"%s%d/%s",NV_DIR_PATH,Instance,"SensorThresholds.dat");
  40. #define SEL_RECLAIM_DIR(Instance,dirname) \
  41. sprintf(dirname,"%s%d/%s",conf_path,Instance,SEL_DIR);
  42. #define SEL_RECLAIM_INFO(Instance,filename) \
  43. sprintf(filename,"%s%d/%s",conf_path,Instance,"selinfo.dat");
  44. #define SEL_RECLAIM_INFO_INI(Instance,filename) \
  45. sprintf(filename,"%s%d/%s",conf_path,Instance,"selreclaiminfo.ini");
  46. #define MAX_SIZE 256
  47. #define WRITE_NVR 1
  48. #define READ_NVR 2
  49. #define FLUSH_PMC 1
  50. #define FLUSH_SDR 2
  51. #define FLUSH_SEL 3
  52. #define FLUSH_FRU 4
  53. #define FLUSH_TO_SEL_REPO 0xF0
  54. #define FLUSH_SEL_REC 1
  55. #define FLUSH_SEL_TIMESTAMP 2
  56. #define FLUSH_LAST_RECID 3
  57. #define FLUSH_BMC_PROC_EVT_ID 4
  58. #define FLUSH_CIRCULAR_SEL_FLAG 5
  59. #define FLUSH_CLEAR_SEL 6
  60. #define FLUSH_ERASE_TIMESTAMP 7
  61. #define FLUSH_SW_PROC_EVT_ID 8
  62. extern int FlushStarted;
  63. /**
  64. *@fn GetSDRSELNVRAddr
  65. *@brief Get SDR & SEL address from RAM
  66. *@param NVRHanle Handler for NVRAM
  67. *@param BMCInst - BMC Instance
  68. */
  69. extern INT8U* GetSDRSELNVRAddr(INT32U NVRHandle, int BMCInst);
  70. /**
  71. * @macro GetNVRUsrCfgAddr
  72. * @brief Gets NVR UsrCfg address from RAM
  73. * @param NVRHandle - Handle for NVRAM
  74. **/
  75. extern INT8U* GetNVRUsrCfgAddr(INT32U NVRHandle, int BMCInst) ;
  76. /**
  77. * @fn VerifyChksum
  78. * @brief Verify checksum of a block
  79. * @param Addr - Start address of block
  80. * @param Size - Size of block
  81. **/
  82. extern int VerifyChksum ( _FAR_ INT32U* Addr , INT16U Size );
  83. /**
  84. * @fn VerifyChksum
  85. * @brief Calculates checksum of a block
  86. * @param Addr - Start address of block
  87. * @param Size - Size of block
  88. **/
  89. extern void CalChksum( _FAR_ INT32U* Offset, INT16U Size);
  90. /**
  91. * @fn ReadWriteNVR
  92. * @brief Reads/Writes the Non volatile informations to/from file
  93. * @param FileName - File to Write or Read from.
  94. * @param pData - Pointer to data.
  95. * @param Offset - Offset in the file to Write of Read from.
  96. * @param Size - Size of data to read/write.
  97. * @param Flag - Flag to perform write or read operation.
  98. **/
  99. extern int ReadWriteNVR (char *FileName, INT8U* pData, INT32U Offset, INT16U Size, INT8U Falg);
  100. /*
  101. *@fn FlushIPMI
  102. *@brief Writes IPMI configurations to NVRAM
  103. *@param RAMAddr - Address in RAM to be flushed to NVRAM
  104. *@param Offset-
  105. *@param Size -
  106. *@param BMCInst - BMC Instance
  107. */
  108. extern int FlushIPMI(INT8U *RAMStartAddr,INT8U* RAMAddr,INT32U Offset,INT16U Size,int BMCInst);
  109. /*
  110. *@fn FlushChConfigs
  111. *@brief Flushes Channel Configurations to IPMIConfig.dat file
  112. *@param RAMAddr - Address in RAM to be flushed to NVRAM
  113. *@param ChNum - Channel Number
  114. *@param BMCInst - BMC Instance
  115. */
  116. extern int FlushChConfigs(INT8U* RAMAddr,int ChNum,int BMCInst);
  117. /*
  118. *@fn PostSELToFlush
  119. *@brief Writes SEL entries in background
  120. *@param Params - Parameter for SEL flushing entries
  121. *@param seldata- seldata required for the parameter
  122. *@param BMCInst - BMC Instance
  123. */
  124. extern int PostSELToFlush(INT8U Params,void *seldata,int BMCInst);
  125. /**
  126. *@fn GetChType
  127. *@brief Retrieves the Corresponding Channel Type
  128. *@param BMCInst - BMC Instance
  129. *@param ChNum - Channel Number
  130. */
  131. extern int GetChType(int BMCInst,int ChNum);
  132. /**
  133. *@macro FlushSDR
  134. *@brief Wirtes the SDR entries to NVRAM
  135. **/
  136. #define FlushSDR(RAMAddr, Size, Ret, BMCInst) \
  137. do { \
  138. if(g_PDKHandle[PDKWRITESDR] != NULL) \
  139. { \
  140. Ret = ((int(*)(INT8U*,INT32U,INT16U,int))g_PDKHandle[PDKWRITESDR]) ((INT8U*)RAMAddr,(INT8U*)RAMAddr - (INT8U*)GetSDRSELNVRAddr(NVRH_SDR, BMCInst),Size, BMCInst); \
  141. } \
  142. else \
  143. { \
  144. IPMI_WARNING("Unable to FlushSDR to NVRAM \n"); \
  145. Ret = 0; \
  146. } \
  147. }while(0);
  148. /**
  149. *@macro FlushSEL
  150. *@brief Wirtes the SEL entries to NVRAM
  151. **/
  152. #define FlushSEL(RAMAddr, Size, Ret, BMCInst) \
  153. do { \
  154. if(g_PDKHandle[PDKWRITESEL] != NULL) \
  155. { \
  156. Ret = ((int(*)(INT8U*,INT32U,INT16U,int))g_PDKHandle[PDKWRITESEL]) ((INT8U*)RAMAddr, (INT8U*)RAMAddr - (INT8U*)GetSDRSELNVRAddr((pBMCInfo->IpmiConfig.SDRAllocationSize * 1024), BMCInst),Size, BMCInst); \
  157. } \
  158. else \
  159. { \
  160. IPMI_WARNING("Unable to FlushSEL to NVRAM \n"); \
  161. Ret = 0; \
  162. } \
  163. }while(0);
  164. #endif /* NVRAM_H */