1 /*++ 2 3 Copyright (c) 2010 - 2014, Intel Corporation. All rights reserved.<BR> 4 5 6 This program and the accompanying materials are licensed and made available under 7 8 the terms and conditions of the BSD License that accompanies this distribution. 9 10 The full text of the license may be found at 11 12 http://opensource.org/licenses/bsd-license.php. 13 14 15 16 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, 17 18 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. 19 20 21 22 23 24 Module Name: 25 26 CmosTable.h 27 28 Abstract: 29 30 --*/ 31 32 #include <Base.h> 33 #include <Library/IoLib.h> 34 #include <Library/PlatformCmosLib.h> 35 #include "CmosMap.h" 36 #include <PchAccess.h> 37 #include "PlatformBaseAddresses.h" 38 39 #define DEFAULT_VALUE 0 40 #define DEFAULT_ATTRIBUTES 0 41 #define EXCLUDE_FROM_CHECKSUM CMOS_ATTRIBUTE_EXCLUDE_FROM_CHECKSUM 42 43 #define CMOS_DEBUG_PRINT_LEVEL_DEFAULT_VALUE 0x46 // EFI_D_WARN|EFI_D_INFO|EFI_D_LOAD 44 #define CMOS_DEBUG_PRINT_LEVEL_3_DEFAULT_VALUE 0x80 // EFI_D_ERROR 45 46 // 47 // Add the CMOS entry below 48 // 49 CMOS_ENTRY mCmosTable[] = { 50 { CPU_HT_POLICY, CPU_HT_POLICY_ENABLED, EXCLUDE_FROM_CHECKSUM }, 51 { TPM_POLICY, TPM_POLICY_ENABLED, DEFAULT_ATTRIBUTES }, 52 { CMOS_LCDPANELTYPE_REG, DEFAULT_VALUE, DEFAULT_ATTRIBUTES }, 53 { CMOS_LCDPANELSCALING_REG, DEFAULT_VALUE, DEFAULT_ATTRIBUTES }, 54 { CMOS_IGDBOOTTYPE_REG, DEFAULT_VALUE, DEFAULT_ATTRIBUTES }, 55 { CMOS_BACKLIGHT_REG, DEFAULT_VALUE, DEFAULT_ATTRIBUTES }, 56 { CMOS_LFP_PANEL_COLOR_DEPTH_REG, DEFAULT_VALUE, DEFAULT_ATTRIBUTES }, 57 { CMOS_EDP_ACTIVE_LFP_CONFIG_REG, DEFAULT_VALUE, DEFAULT_ATTRIBUTES }, 58 { CMOS_PRIMARY_DISPLAY_REG, DEFAULT_VALUE, DEFAULT_ATTRIBUTES }, 59 { CMOS_IGD_DISPLAY_PIPE_B_REG, DEFAULT_VALUE, DEFAULT_ATTRIBUTES }, 60 { CMOS_SDVOPANELTYPE_REG, DEFAULT_VALUE, DEFAULT_ATTRIBUTES }, 61 { CMOS_PLATFORM_RESET_OS, DEFAULT_VALUE, DEFAULT_ATTRIBUTES }, 62 { CMOS_CPU_BSP_SELECT, DEFAULT_VALUE, DEFAULT_ATTRIBUTES }, 63 { CMOS_CPU_RATIO_OFFSET, DEFAULT_VALUE, DEFAULT_ATTRIBUTES }, 64 { CMOS_ICH_PORT80_OFFSET, DEFAULT_VALUE, DEFAULT_ATTRIBUTES }, 65 { CMOS_MAXRATIO_CONFIG_REG, DEFAULT_VALUE, DEFAULT_ATTRIBUTES }, 66 { RTC_ADDRESS_CENTURY, RTC_ADDRESS_CENTURY_DEFAULT, CMOS_ATTRIBUTE_EXCLUDE_FROM_CHECKSUM }, 67 { CMOS_POST_CODE_BREAK_REG, DEFAULT_VALUE, EXCLUDE_FROM_CHECKSUM }, 68 { CMOS_POST_CODE_BREAK_1_REG, DEFAULT_VALUE, EXCLUDE_FROM_CHECKSUM }, 69 { CMOS_POST_CODE_BREAK_2_REG, DEFAULT_VALUE, EXCLUDE_FROM_CHECKSUM }, 70 { CMOS_POST_CODE_BREAK_3_REG, DEFAULT_VALUE, EXCLUDE_FROM_CHECKSUM }, 71 { CMOS_DEBUG_PRINT_LEVEL_REG, CMOS_DEBUG_PRINT_LEVEL_DEFAULT_VALUE, EXCLUDE_FROM_CHECKSUM }, 72 { CMOS_DEBUG_PRINT_LEVEL_1_REG, DEFAULT_VALUE, EXCLUDE_FROM_CHECKSUM }, 73 { CMOS_DEBUG_PRINT_LEVEL_2_REG, DEFAULT_VALUE, EXCLUDE_FROM_CHECKSUM }, 74 { CMOS_DEBUG_PRINT_LEVEL_3_REG, CMOS_DEBUG_PRINT_LEVEL_3_DEFAULT_VALUE, EXCLUDE_FROM_CHECKSUM }, 75 }; 76 77 /** 78 Funtion to return platform CMOS entry. GetPlatformCmosEntry(OUT CMOS_ENTRY ** CmosEntry,OUT UINTN * CmosEntryCount)79 80 @param [out] CmosEntry Platform CMOS entry. 81 82 @param [out] CmosEntryCount Number of platform CMOS entry. 83 84 @return Status. 85 **/ 86 RETURN_STATUS 87 EFIAPI 88 GetPlatformCmosEntry ( 89 OUT CMOS_ENTRY **CmosEntry, 90 OUT UINTN *CmosEntryCount 91 ) 92 { 93 *CmosEntry = mCmosTable; 94 *CmosEntryCount = sizeof(mCmosTable)/sizeof(mCmosTable[0]); 95 return RETURN_SUCCESS; 96 } CheckCmosBatteryStatus(VOID)97 98 /** 99 Function to check if Battery lost or CMOS cleared. 100 101 @reval TRUE Battery is always present. 102 @reval FALSE CMOS is cleared. 103 **/ 104 BOOLEAN 105 EFIAPI 106 CheckCmosBatteryStatus ( 107 VOID 108 ) 109 { 110 // 111 // Check if the CMOS battery is present 112 // Checks RTC_PWR_STS bit in the GEN_PMCON_1 register 113 // 114 115 if ((MmioRead8 (PMC_BASE_ADDRESS + R_PCH_PMC_GEN_PMCON_1) & B_PCH_PMC_GEN_PMCON_RTC_PWR_STS) == 0) { 116 return TRUE; 117 } else { 118 return FALSE; 119 } 120 } 121