code format
This commit is contained in:
@@ -36,38 +36,38 @@ TRIP_TEMP_RANGE = [40, 97]
|
|||||||
power = {'source': None, 'method': 'polling'}
|
power = {'source': None, 'method': 'polling'}
|
||||||
|
|
||||||
platform_info_bits = {
|
platform_info_bits = {
|
||||||
'maximum_non_turbo_ratio': [8, 15],
|
'maximum_non_turbo_ratio': [8, 15],
|
||||||
'maximum_efficiency_ratio': [40, 47],
|
'maximum_efficiency_ratio': [40, 47],
|
||||||
'minimum_operating_ratio': [48, 55],
|
'minimum_operating_ratio': [48, 55],
|
||||||
'feature_ppin_cap': [23, 23],
|
'feature_ppin_cap': [23, 23],
|
||||||
'feature_programmable_turbo_ratio': [28, 28],
|
'feature_programmable_turbo_ratio': [28, 28],
|
||||||
'feature_programmable_tdp_limit': [29, 29],
|
'feature_programmable_tdp_limit': [29, 29],
|
||||||
'number_of_additional_tdp_profiles': [33, 34],
|
'number_of_additional_tdp_profiles': [33, 34],
|
||||||
'feature_programmable_temperature_target': [30, 30],
|
'feature_programmable_temperature_target': [30, 30],
|
||||||
'feature_low_power_mode': [32, 32]
|
'feature_low_power_mode': [32, 32]
|
||||||
}
|
}
|
||||||
|
|
||||||
thermal_status_bits = {
|
thermal_status_bits = {
|
||||||
'thermal_limit_status': [0, 0],
|
'thermal_limit_status': [0, 0],
|
||||||
'thermal_limit_log': [1, 1],
|
'thermal_limit_log': [1, 1],
|
||||||
'prochot_or_forcepr_status': [2, 2],
|
'prochot_or_forcepr_status': [2, 2],
|
||||||
'prochot_or_forcepr_log': [3, 3],
|
'prochot_or_forcepr_log': [3, 3],
|
||||||
'crit_temp_status': [4, 4],
|
'crit_temp_status': [4, 4],
|
||||||
'crit_temp_log': [5, 5],
|
'crit_temp_log': [5, 5],
|
||||||
'thermal_threshold1_status': [6, 6],
|
'thermal_threshold1_status': [6, 6],
|
||||||
'thermal_threshold1_log': [7, 7],
|
'thermal_threshold1_log': [7, 7],
|
||||||
'thermal_threshold2_status': [8, 8],
|
'thermal_threshold2_status': [8, 8],
|
||||||
'thermal_threshold2_log': [9, 9],
|
'thermal_threshold2_log': [9, 9],
|
||||||
'power_limit_status': [10, 10],
|
'power_limit_status': [10, 10],
|
||||||
'power_limit_log': [11, 11],
|
'power_limit_log': [11, 11],
|
||||||
'current_limit_status': [12, 12],
|
'current_limit_status': [12, 12],
|
||||||
'current_limit_log': [13, 13],
|
'current_limit_log': [13, 13],
|
||||||
'cross_domain_limit_status': [14, 14],
|
'cross_domain_limit_status': [14, 14],
|
||||||
'cross_domain_limit_log': [15, 15],
|
'cross_domain_limit_log': [15, 15],
|
||||||
'cpu_temp': [16, 22],
|
'cpu_temp': [16, 22],
|
||||||
'temp_resolution': [27, 30],
|
'temp_resolution': [27, 30],
|
||||||
'reading_valid': [31, 31],
|
'reading_valid': [31, 31],
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
def writemsr(msr, val):
|
def writemsr(msr, val):
|
||||||
@@ -123,14 +123,17 @@ def readmsr(msr, from_bit=0, to_bit=63, cpu=None, flatten=False):
|
|||||||
else:
|
else:
|
||||||
raise e
|
raise e
|
||||||
|
|
||||||
|
|
||||||
def get_value_for_bits(val, from_bit=0, to_bit=63):
|
def get_value_for_bits(val, from_bit=0, to_bit=63):
|
||||||
mask = sum(2**x for x in range(from_bit, to_bit + 1))
|
mask = sum(2**x for x in range(from_bit, to_bit + 1))
|
||||||
return (val & mask) >> from_bit
|
return (val & mask) >> from_bit
|
||||||
|
|
||||||
|
|
||||||
def is_on_battery():
|
def is_on_battery():
|
||||||
with open(SYSFS_POWER_PATH) as f:
|
with open(SYSFS_POWER_PATH) as f:
|
||||||
return not bool(int(f.read()))
|
return not bool(int(f.read()))
|
||||||
|
|
||||||
|
|
||||||
def get_cpu_platform_info():
|
def get_cpu_platform_info():
|
||||||
features_msr_value = readmsr(0xce, cpu=0)
|
features_msr_value = readmsr(0xce, cpu=0)
|
||||||
cpu_platform_info = {}
|
cpu_platform_info = {}
|
||||||
@@ -302,8 +305,7 @@ def power_thread(config, regs, exit_event):
|
|||||||
thermal_status = get_reset_thermal_status()
|
thermal_status = get_reset_thermal_status()
|
||||||
for index, core_thermal_status in enumerate(thermal_status):
|
for index, core_thermal_status in enumerate(thermal_status):
|
||||||
for key, value in core_thermal_status.items():
|
for key, value in core_thermal_status.items():
|
||||||
print('[D] core {} thermal status: {} = {}'.format(
|
print('[D] core {} thermal status: {} = {}'.format(index, key.replace("_", " "), value))
|
||||||
index, key.replace("_", " "), value))
|
|
||||||
|
|
||||||
# switch back to sysfs polling
|
# switch back to sysfs polling
|
||||||
if power['method'] == 'polling':
|
if power['method'] == 'polling':
|
||||||
@@ -377,8 +379,7 @@ def main():
|
|||||||
platform_info = get_cpu_platform_info()
|
platform_info = get_cpu_platform_info()
|
||||||
if args.debug:
|
if args.debug:
|
||||||
for key, value in platform_info.items():
|
for key, value in platform_info.items():
|
||||||
print('[D] cpu platform info: {} = {}'.format(
|
print('[D] cpu platform info: {} = {}'.format(key.replace("_", " "), value))
|
||||||
key.replace("_", " "), value))
|
|
||||||
regs = calc_reg_values(platform_info, config)
|
regs = calc_reg_values(platform_info, config)
|
||||||
|
|
||||||
if not config.getboolean('GENERAL', 'Enabled'):
|
if not config.getboolean('GENERAL', 'Enabled'):
|
||||||
|
|||||||
Reference in New Issue
Block a user