Skip to content

Commit

Permalink
chipid: move vendor names to header (#97)
Browse files Browse the repository at this point in the history
  • Loading branch information
viktorxda authored Sep 26, 2023
1 parent e63193b commit 8794c20
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 13 deletions.
5 changes: 3 additions & 2 deletions example/ipcinfo.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include <ipchw.h>
#include <hal/common.h>

#include "chipid.h"
#include "tools.h"
#include "version.h"

Expand Down Expand Up @@ -99,9 +100,9 @@ static void print_serial() {
char serial[512];

const char *vendor = getchipvendor();
if (strstr(vendor, "HiSilicon") || strstr(vendor, "Goke"))
if (strstr(vendor, VENDOR_HISI) || strstr(vendor, VENDOR_GOKE))
hisi_ev300_get_die_id(serial, sizeof serial);
if (strstr(vendor, "SigmaStar"))
if (strstr(vendor, VENDOR_SSTAR))
sstar_get_die_id(serial, sizeof serial);

if (!serial)
Expand Down
19 changes: 8 additions & 11 deletions src/chipid.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@
#include "hal/common.h"
#include "tools.h"

#define VENDOR_HISI "HiSilicon"
#define VENDOR_GOKE "Goke"

int chip_generation;
char chip_name[128];
char nor_chip[128];
Expand All @@ -42,19 +39,19 @@ typedef struct {

static const manufacturers_t manufacturers[] = {
#if defined(mips) || defined(__mips__) || defined(__mips)
{"isvp", ingenic_detect_cpu, "Ingenic", setup_hal_ingenic},
{"ingenic", ingenic_detect_cpu, "Ingenic", setup_hal_ingenic},
{"isvp", ingenic_detect_cpu, VENDOR_INGENIC, setup_hal_ingenic},
{"ingenic", ingenic_detect_cpu, VENDOR_INGENIC, setup_hal_ingenic},
#endif
#ifdef __arm__
{"SStar", sstar_detect_cpu, "SigmaStar", sstar_setup_hal},
{"SStar", sstar_detect_cpu, VENDOR_SSTAR, sstar_setup_hal},
{"MStar", mstar_detect_cpu, NULL, sstar_setup_hal},
{"Novatek", novatek_detect_cpu, NULL, novatek_setup_hal},
{"Grain", gm_detect_cpu, "GrainMedia", gm_setup_hal},
{"FH", fh_detect_cpu, "Fullhan", fh_setup_hal},
{NULL /* Generic */, rockchip_detect_cpu, "Rockchip", rockchip_setup_hal},
{"Grain", gm_detect_cpu, VENDOR_GM, gm_setup_hal},
{"FH", fh_detect_cpu, VENDOR_FH, fh_setup_hal},
{NULL /* Generic */, rockchip_detect_cpu, VENDOR_ROCKCHIP, rockchip_setup_hal},
{"Xilinx", xilinx_detect_cpu, NULL, xilinx_setup_hal},
{"BCM", bcm_detect_cpu, "Broadcom", bcm_setup_hal},
{NULL, allwinner_detect_cpu, "Allwinner", allwinner_setup_hal}
{"BCM", bcm_detect_cpu, VENDOR_BCM, bcm_setup_hal},
{NULL, allwinner_detect_cpu, VENDOR_ALLWINNER, allwinner_setup_hal}
#endif
#if defined(__aarch64__) || defined(_M_ARM64)
{NULL, tegra_detect_cpu, "Nvidia", tegra_setup_hal},
Expand Down
10 changes: 10 additions & 0 deletions src/chipid.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,16 @@

#include <stdbool.h>

#define VENDOR_ALLWINNER "Allwinner"
#define VENDOR_BCM "Broadcom"
#define VENDOR_FH "Fullhan"
#define VENDOR_GM "GrainMedia"
#define VENDOR_GOKE "Goke"
#define VENDOR_HISI "HiSilicon"
#define VENDOR_INGENIC "Ingenic"
#define VENDOR_ROCKCHIP "Rockchip"
#define VENDOR_SSTAR "SigmaStar"

extern int chip_generation;
extern char chip_name[128];
extern char control[128];
Expand Down

0 comments on commit 8794c20

Please sign in to comment.