[v0.88][ARM][BUGFIX] Fix some compilation issues

This commit is contained in:
Dr-Noob
2020-11-23 18:45:42 +01:00
parent eaa86522a4
commit bb05a4d577
5 changed files with 30 additions and 15 deletions

View File

@@ -534,7 +534,8 @@ void print_ascii(struct ascii* art) {
if(art->vendor == CPU_VENDOR_ARM)
print_ascii_arm(art, longest_attribute);
else {
printBug("Invalid CPU vendor: %d\n", art->vendor);
printWarn("Invalid CPU vendor: %d\n", art->vendor);
print_ascii_arm(art, longest_attribute);
}
}
@@ -581,7 +582,7 @@ bool print_cpufetch_arm(struct ascii* art, struct cpuInfo* cpu, struct colors* c
char* l2 = get_str_l2(ptr->cach);
char* l3 = get_str_l3(ptr->cach);
char* cpu_num = malloc(sizeof(char) * 6);
char* cpu_num = malloc(sizeof(char) * 9);
sprintf(cpu_num, "CPU %d:", i+1);
setAttribute(art, ATTRIBUTE_CPU_NUM, cpu_num);
setAttribute(art, ATTRIBUTE_UARCH, uarch);

View File

@@ -164,12 +164,14 @@ long parse_cpuinfo_field(char* buf, char* field_str, int field_base) {
}
// https://developer.arm.com/docs/ddi0595/h/aarch32-system-registers/midr
// https://static.docs.arm.com/ddi0595/h/SysReg_xml_v86A-2020-06.pdf
uint32_t get_midr_from_cpuinfo(uint32_t core) {
uint32_t get_midr_from_cpuinfo(uint32_t core, bool* success) {
int fd = open(_PATH_CPUINFO, O_RDONLY);
*success = true;
if(fd == -1) {
*success = false;
perror("open");
return UNKNOWN;
return 0;
}
//File exists, read it
@@ -191,8 +193,10 @@ uint32_t get_midr_from_cpuinfo(uint32_t core) {
tmp = strstr(tmp, CPUINFO_CPU_STRING);
}
if(tmp == NULL)
return UNKNOWN;
if(tmp == NULL) {
*success = false;
return 0;
}
uint32_t cpu_implementer;
uint32_t cpu_architecture;
@@ -204,30 +208,35 @@ uint32_t get_midr_from_cpuinfo(uint32_t core) {
if ((ret = parse_cpuinfo_field(tmp, CPUINFO_CPU_IMPLEMENTER_STR, 16)) < 0) {
printf("Failed parsing cpu_implementer\n");
*success = false;
return 0;
}
cpu_implementer = (uint32_t) ret;
if ((ret = parse_cpuinfo_field(tmp, CPUINFO_CPU_ARCHITECTURE_STR, 10)) < 0) {
printf("Failed parsing cpu_architecture\n");
*success = false;
return 0;
}
cpu_architecture = (uint32_t) 0xF; // Why?
if ((ret = parse_cpuinfo_field(tmp, CPUINFO_CPU_VARIANT_STR, 16)) < 0) {
printf("Failed parsing cpu_variant\n");
*success = false;
return 0;
}
cpu_variant = (uint32_t) ret;
if ((ret = parse_cpuinfo_field(tmp, CPUINFO_CPU_PART_STR, 16)) < 0) {
printf("Failed parsing cpu_part\n");
*success = false;
return 0;
}
cpu_part = (uint32_t) ret;
if ((ret = parse_cpuinfo_field(tmp, CPUINFO_CPU_REVISION_STR, 10)) < 0) {
printf("Failed parsing cpu_revision\n");
*success = false;
return 0;
}
cpu_revision = (uint32_t) ret;

View File

@@ -2,6 +2,7 @@
#define __UDEV__
#include <stdint.h>
#include <stdbool.h>
long get_max_freq_from_file(uint32_t core);
long get_min_freq_from_file(uint32_t core);
@@ -9,7 +10,7 @@ long get_min_freq_from_file(uint32_t core);
#ifdef ARCH_ARM
#define UNKNOWN -1
int get_ncores_from_cpuinfo();
uint32_t get_midr_from_cpuinfo(uint32_t core);
uint32_t get_midr_from_cpuinfo(uint32_t core, bool* success);
#endif
#endif