diff --git a/src/chipid.c b/src/chipid.c index 2d9bdf3..49af14a 100644 --- a/src/chipid.c +++ b/src/chipid.c @@ -107,7 +107,7 @@ static bool detect_and_set(const char *manufacturer, static bool hw_detect_system() { long uart_base = get_uart0_address(); switch (uart_base) { -#ifdef __arm__ +#if defined(__aarch64__) || defined(__arm__) // xm510 case 0x10030000: return detect_and_set("Xiongmai", xm_detect_cpu, setup_hal_xm, 0); @@ -132,6 +132,11 @@ static bool hw_detect_system() { case 0x20080000: return detect_and_set(VENDOR_HISI, hisi_detect_cpu, setup_hal_hisi, 0x20050000); +// hi3519DV500 + case 0x11040000: + return detect_and_set(VENDOR_HISI, hisi_detect_cpu, setup_hal_hisi, + 0x11020000); + #endif default: return generic_detect_cpu(); @@ -173,6 +178,8 @@ const char *getchipfamily() { return "hi3516cv300"; case HISI_V4A: return "hi3516cv500"; + case HISI_V4B: + return "hi3519dv500"; case HISI_V4: if (*chip_name == 'g') return "gk7205v200"; diff --git a/src/hal/hisi/hal_hisi.c b/src/hal/hisi/hal_hisi.c index 1d03e7a..3d48ef9 100644 --- a/src/hal/hisi/hal_hisi.c +++ b/src/hal/hisi/hal_hisi.c @@ -520,6 +520,11 @@ static uint32_t hisi_reg_temp(uint32_t read_addr, int temp_bitness, // Temperature sensor (T-Sensor) control register #define EV300_MISC_CTRL45 0x120280B4 +// T-Sensor temperature record register 0 +#define DV500_MISC_CTRL47 0x1102A008 +// Temperature sensor (T-Sensor) control register +#define DV500_MISC_CTRL45 0x1102A000 + static float hisi_get_temp() { float tempo; switch (chip_generation) { @@ -553,6 +558,12 @@ static float hisi_get_temp() { hisi_reg_temp(EV300_MISC_CTRL47, 10, EV300_MISC_CTRL45, 0xC3200000); tempo = ((tempo - 117) / 798) * 165 - 40; break; + case HISI_V4B: + // MISC_CTRL47 bit[9:0] + tempo = + hisi_reg_temp(DV500_MISC_CTRL47, 10, DV500_MISC_CTRL45, 0x60FA0000); + tempo = ((tempo - 136) / 793 * 165) - 40; + break; default: return NAN; } @@ -746,6 +757,10 @@ static const char *get_hisi_chip_id(uint32_t family_id, uint8_t scsysid0) { // A new chip that was received in the OpenIPC lab 2023.07.28 chip_generation = HISI_V4; return "7205V500"; +//3519DV500 + case 0x3519D500: + chip_generation = HISI_V4B; + return "3519DV500"; default: fprintf(stderr, "Got unexpected ID 0x%x for HiSilicon\n", family_id); return "unknown"; diff --git a/src/hal/hisi/hal_hisi.h b/src/hal/hisi/hal_hisi.h index 72d17a6..a678e57 100644 --- a/src/hal/hisi/hal_hisi.h +++ b/src/hal/hisi/hal_hisi.h @@ -16,6 +16,7 @@ #define HISI_V3 0x3516C300 #define HISI_V4 0x3516E300 #define HISI_V4A 0x3516C500 +#define HISI_V4B 0x3519D500 #define HISI_3536C 0x3536C100 #define HISI_3536D 0x3536D100 diff --git a/src/reginfo.c b/src/reginfo.c index 156a185..61e554d 100644 --- a/src/reginfo.c +++ b/src/reginfo.c @@ -2192,11 +2192,13 @@ static const muxctrl_reg_t **regs_by_chip() { else if (IS_16DV200) return DV200regs; break; + case HISI_V4B: + return CV500regs; case HISI_3536C: return RCV100regs; case HISI_3536D: return DV100regs; - case INFINITY6: + case INFINITY6: case INFINITY6B: return I6B_regs; case INFINITY6C: diff --git a/src/tools.c b/src/tools.c index 86d4deb..6db2aa3 100644 --- a/src/tools.c +++ b/src/tools.c @@ -276,17 +276,24 @@ void restore_printk() { bool get_pid_cmdline(pid_t godpid, char *cmdname) { char sname[1024]; - snprintf(sname, sizeof(sname), "/proc/%d/cmdline", godpid); FILE *fp = fopen(sname, "r"); + + +//////// /proc/10320000.usb30drd/ at 3519dv500 readed as /proc/10320000/ and call Segmentation fault +if (fp == NULL) { + +fprintf(stderr, "Failed to open file %s \n" , sname); + return; // Handle error appropriately +} + if (fp && fgets(sname, sizeof(sname), fp)) { if (cmdname) strcpy(cmdname, sname); - fclose(fp); +fp = NULL; // Set to NULL to avoid double close return true; } - fclose(fp); return false; } @@ -323,6 +330,8 @@ static unsigned long time_by_proc(const char *filename, char *shortname, } pid_t get_god_pid(char *shortname, size_t shortsz) { + + DIR *dir = opendir("/proc"); if (!dir) return -1; @@ -330,11 +339,11 @@ pid_t get_god_pid(char *shortname, size_t shortsz) { unsigned long max = 0; char sname[1024], prname[255], maxname[255] = {0}; pid_t godpid = -1, tmp; + struct dirent *entry; while ((entry = readdir(dir)) != NULL) { if (*entry->d_name && isdigit(entry->d_name[0])) { snprintf(sname, sizeof(sname), "/proc/%s/stat", entry->d_name); - tmp = strtol(entry->d_name, NULL, 10); if (get_pid_cmdline(tmp, NULL)) { unsigned long curres = time_by_proc(sname, prname, sizeof(prname));