diff --git a/src/arm/soc.c b/src/arm/soc.c index f5831e5..c76a876 100644 --- a/src/arm/soc.c +++ b/src/arm/soc.c @@ -909,9 +909,10 @@ struct system_on_chip* guess_soc_from_pci(struct system_on_chip* soc, struct cpu } pciToSoC; pciToSoC socFromPCI[] = { - {PCI_VENDOR_NVIDIA, PCI_DEVICE_TEGRA_X1, {SOC_TEGRA_X1, SOC_VENDOR_NVIDIA, 20, "Tegra X1", NULL} }, - // {PCI_VENDOR_NVIDIA, PCI_DEVICE_GH_200,{SOC_GH_200, SOC_VENDOR_NVIDIA, ?, "Grace Hopper", NULL} }, - {0x0000, 0x0000, {UNKNOWN, SOC_VENDOR_UNKNOWN, -1, "", NULL} } + {PCI_VENDOR_NVIDIA, PCI_DEVICE_TEGRA_X1, {SOC_TEGRA_X1, SOC_VENDOR_NVIDIA, 20, "Tegra X1", NULL} }, + // {PCI_VENDOR_NVIDIA, PCI_DEVICE_GH_200,{SOC_GH_200, SOC_VENDOR_NVIDIA, ?, "Grace Hopper", NULL} }, + {PCI_VENDOR_AMPERE, PCI_DEVICE_ALTRA, {SOC_AMPERE_ALTRA, SOC_VENDOR_AMPERE, 7, "Altra", NULL} }, // https://www.anandtech.com/show/15575/amperes-altra-80-core-n1-soc-for-hyperscalers-against-rome-and-xeon + {0x0000, 0x0000, {UNKNOWN, SOC_VENDOR_UNKNOWN, -1, "", NULL} } }; int index = 0; diff --git a/src/arm/socs.h b/src/arm/socs.h index aabfa51..640f061 100644 --- a/src/arm/socs.h +++ b/src/arm/socs.h @@ -380,6 +380,8 @@ enum { SOC_GOOGLE_TENSOR_G3, // NVIDIA, SOC_TEGRA_X1, + // ALTRA + SOC_AMPERE_ALTRA, // UNKNOWN SOC_MODEL_UNKNOWN }; @@ -396,6 +398,7 @@ inline static VENDOR get_soc_vendor_from_soc(SOC soc) { else if(soc >= SOC_ROCKCHIP_3288 && soc <= SOC_ROCKCHIP_3588) return SOC_VENDOR_ROCKCHIP; else if(soc >= SOC_GOOGLE_TENSOR && soc <= SOC_GOOGLE_TENSOR_G3) return SOC_VENDOR_GOOGLE; else if(soc >= SOC_TEGRA_X1 && soc <= SOC_TEGRA_X1) return SOC_VENDOR_NVIDIA; + else if(soc >= SOC_AMPERE_ALTRA && soc <= SOC_AMPERE_ALTRA) return SOC_VENDOR_AMPERE; return SOC_VENDOR_UNKNOWN; } diff --git a/src/common/ascii.h b/src/common/ascii.h index 7789c8f..e584f99 100644 --- a/src/common/ascii.h +++ b/src/common/ascii.h @@ -394,6 +394,25 @@ $C2## ## ## ## ## ## ## ## #: :# \ $C2## ## ## ## ## ## ## ## ####### \ $C2## ## ### ## ###### ## ## ## " +#define ASCII_AMPERE \ +"$C1 \ +$C1 \ +$C1 ## \ +$C1 #### \ +$C1 ### ## \ +$C1 ### ### \ +$C1 ### ### \ +$C1 ### ### \ +$C1 ## ### \ +$C1 ####### ### ### \ +$C1 ###### ## ###### ### \ +$C1 #### ### ######## \ +$C1 #### ### #### \ +$C1 ### ### #### \ +$C1 ## ### ### \ +$C1 \ +$C1 " + // --------------------- LONG LOGOS ------------------------- // #define ASCII_AMD_L \ "$C1 \ @@ -569,6 +588,7 @@ asciiL logo_sifive = { ASCII_SIFIVE, 48, 19, true, {C_BG_WHITE, C_BG_ asciiL logo_starfive = { ASCII_STARFIVE, 33, 17, false, {C_FG_WHITE}, {C_FG_WHITE, C_FG_BLUE} }; asciiL logo_sipeed = { ASCII_SIPEED, 41, 16, true, {C_BG_RED, C_BG_WHITE}, {C_FG_RED, C_FG_WHITE} }; asciiL logo_nvidia = { ASCII_NVIDIA, 45, 19, false, {C_FG_GREEN, C_FG_WHITE}, {C_FG_WHITE, C_FG_GREEN} }; +asciiL logo_ampere = { ASCII_AMPERE, 50, 17, false, {C_FG_RED}, {C_FG_WHITE, C_FG_RED} }; // Long variants | ----------------------------------------------------------------------------------------------------------------| asciiL logo_amd_l = { ASCII_AMD_L, 62, 19, true, {C_BG_WHITE, C_BG_GREEN}, {C_FG_WHITE, C_FG_GREEN} }; diff --git a/src/common/pci.c b/src/common/pci.c index c6931fb..620b04a 100644 --- a/src/common/pci.c +++ b/src/common/pci.c @@ -14,14 +14,6 @@ #define PCI_PATH "/sys/bus/pci/devices/" #define MAX_LENGTH_PCI_DIR_NAME 1024 -/* - * doc: https://wiki.osdev.org/PCI#Class_Codes - * https://pci-ids.ucw.cz/read/PC - */ -#define PCI_VENDOR_ID_AMD 0x1002 -#define CLASS_VGA_CONTROLLER 0x0300 -#define CLASS_3D_CONTROLLER 0x0302 - // Return a list of PCI devices containing only // the sysfs path struct pci_devices * get_pci_paths(void) { @@ -126,43 +118,6 @@ void populate_pci_devices(struct pci_devices * pci) { } } -// Right now, we are interested in PCI devices which -// vendor is NVIDIA (to be extended in the future). -// Should we also restrict to VGA controllers only? -bool pci_device_is_useful(struct pci_device* dev) { - return dev->vendor_id == PCI_VENDOR_NVIDIA; -} - -// Filter the input list in order to get only those PCI devices which -// we are interested in (decided by pci_device_is_useful) -// and return the filtered result. -struct pci_devices * filter_pci_devices(struct pci_devices * pci) { - int * devices_to_get = emalloc(sizeof(int) * pci->num_devices); - int dev_ptr = 0; - - for (int i=0; i < pci->num_devices; i++) { - if (pci_device_is_useful(pci->devices[i])) { - devices_to_get[dev_ptr] = i; - dev_ptr++; - } - } - - struct pci_devices * pci_filtered = emalloc(sizeof(struct pci_devices)); - pci_filtered->num_devices = dev_ptr; - - if (pci_filtered->num_devices == 0) { - pci_filtered->devices = NULL; - } - else { - pci_filtered->devices = emalloc(sizeof(struct pci_device) * pci_filtered->num_devices); - - for (int i=0; i < pci_filtered->num_devices; i++) - pci_filtered->devices[i] = pci->devices[devices_to_get[i]]; - } - - return pci_filtered; -} - // Return a list of PCI devices that could be used to infer the SoC. // The criteria to determine which devices are suitable for this task // is decided in filter_pci_devices. @@ -174,5 +129,5 @@ struct pci_devices * get_pci_devices(void) { populate_pci_devices(pci); - return filter_pci_devices(pci); + return pci; } diff --git a/src/common/pci.h b/src/common/pci.h index b7e36f3..eacfc3a 100644 --- a/src/common/pci.h +++ b/src/common/pci.h @@ -1,8 +1,11 @@ #ifndef __PCI__ #define __PCI__ -#define PCI_VENDOR_NVIDIA 0x10de +#define PCI_VENDOR_NVIDIA 0x10de +#define PCI_VENDOR_AMPERE 0x1def + #define PCI_DEVICE_TEGRA_X1 0x0faf +#define PCI_DEVICE_ALTRA 0xe100 struct pci_device { char * path; diff --git a/src/common/printer.c b/src/common/printer.c index 6973ea8..b52b837 100644 --- a/src/common/printer.c +++ b/src/common/printer.c @@ -389,6 +389,8 @@ void choose_ascii_art(struct ascii* art, struct color** cs, struct terminal* ter art->art = &logo_allwinner; else if(art->vendor == SOC_VENDOR_ROCKCHIP) art->art = &logo_rockchip; + else if(art->vendor == SOC_VENDOR_AMPERE) + art->art = &logo_ampere; else if(art->vendor == SOC_VENDOR_NVIDIA) art->art = choose_ascii_art_aux(&logo_nvidia_l, &logo_nvidia, term, lf); else { diff --git a/src/common/soc.c b/src/common/soc.c index 2211f50..3b15aed 100644 --- a/src/common/soc.c +++ b/src/common/soc.c @@ -21,6 +21,7 @@ static char* soc_trademark_string[] = { [SOC_VENDOR_ROCKCHIP] = "Rockchip ", [SOC_VENDOR_GOOGLE] = "Google ", [SOC_VENDOR_NVIDIA] = "NVIDIA ", + [SOC_VENDOR_AMPERE] = "Ampere ", // RISC-V [SOC_VENDOR_SIFIVE] = "SiFive ", [SOC_VENDOR_STARFIVE] = "StarFive ", diff --git a/src/common/soc.h b/src/common/soc.h index 2d4fcf7..92db36d 100644 --- a/src/common/soc.h +++ b/src/common/soc.h @@ -25,6 +25,7 @@ enum { SOC_VENDOR_ROCKCHIP, SOC_VENDOR_GOOGLE, SOC_VENDOR_NVIDIA, + SOC_VENDOR_AMPERE, // RISC-V SOC_VENDOR_SIFIVE, SOC_VENDOR_STARFIVE,