[v0.94][x86] Consider missing frequency file in x86_64 as a bug if no hypervisor is present. Took this idea from issue #37. Add if hypervisor is present to debug mode to prevent more confusions in the future

This commit is contained in:
Dr-Noob
2020-12-29 00:09:01 +01:00
parent 56a1da3428
commit 797c708f2d
4 changed files with 54 additions and 16 deletions

View File

@@ -28,11 +28,21 @@ char* read_file(char* path, int* len) {
return buf;
}
long get_freq_from_file(char* path) {
long get_freq_from_file(char* path, bool hv_present) {
int filelen;
char* buf;
if((buf = read_file(path, &filelen)) == NULL) {
printWarn("Could not open '%s'", path);
#ifdef ARCH_X86
if(hv_present) {
printWarn("Could not open '%s'", path);
}
else {
perror("open");
printBug("Could not open '%s'", path);
}
#elif ARCH_ARM
printWarn("Could not open '%s'", path);
#endif
return UNKNOWN_FREQ;
}
@@ -59,14 +69,14 @@ long get_freq_from_file(char* path) {
return ret/1000;
}
long get_max_freq_from_file(uint32_t core) {
long get_max_freq_from_file(uint32_t core, bool hv_present) {
char path[_PATH_FREQUENCY_MAX_LEN];
sprintf(path, "%s%s/cpu%d%s%s", _PATH_SYS_SYSTEM, _PATH_SYS_CPU, core, _PATH_FREQUENCY, _PATH_FREQUENCY_MAX);
return get_freq_from_file(path);
return get_freq_from_file(path, hv_present);
}
long get_min_freq_from_file(uint32_t core) {
long get_min_freq_from_file(uint32_t core, bool hv_present) {
char path[_PATH_FREQUENCY_MAX_LEN];
sprintf(path, "%s%s/cpu%d%s%s", _PATH_SYS_SYSTEM, _PATH_SYS_CPU, core, _PATH_FREQUENCY, _PATH_FREQUENCY_MIN);
return get_freq_from_file(path);
return get_freq_from_file(path, hv_present);
}

View File

@@ -10,6 +10,8 @@
#include <fcntl.h>
#include <errno.h>
#include "cpu.h"
#define _PATH_SYS_SYSTEM "/sys/devices/system"
#define _PATH_SYS_CPU "/cpu"
#define _PATH_FREQUENCY "/cpufreq"
@@ -20,7 +22,7 @@
#define DEFAULT_FILE_SIZE 4096
char* read_file(char* path, int* len);
long get_max_freq_from_file(uint32_t core);
long get_min_freq_from_file(uint32_t core);
long get_max_freq_from_file(uint32_t core, bool hv_present);
long get_min_freq_from_file(uint32_t core, bool hv_present);
#endif