x86: identify Hygon vendor

it's a Zen-based CPU: rely on AMD support code.

Change-Id: Ia980a42457575bf8d1130d813310a285bf137691
Reviewed-on: https://review.haiku-os.org/c/haiku/+/3217
Reviewed-by: Adrien Destugues <[email protected]>
This commit is contained in:
Jérôme Duval
2020-09-15 20:43:45 +00:00
parent 7c1bcc9cae
commit 357b9d3cbb
7 changed files with 17 additions and 7 deletions
+2 -1
View File
@@ -499,7 +499,8 @@ enum cpu_vendor {
B_CPU_VENDOR_VIA, B_CPU_VENDOR_VIA,
B_CPU_VENDOR_IBM, B_CPU_VENDOR_IBM,
B_CPU_VENDOR_MOTOROLA, B_CPU_VENDOR_MOTOROLA,
B_CPU_VENDOR_NEC B_CPU_VENDOR_NEC,
B_CPU_VENDOR_HYGON
}; };
typedef struct { typedef struct {
@@ -481,6 +481,7 @@ enum x86_vendors {
VENDOR_RISE, VENDOR_RISE,
VENDOR_TRANSMETA, VENDOR_TRANSMETA,
VENDOR_NSC, VENDOR_NSC,
VENDOR_HYGON,
VENDOR_NUM, VENDOR_NUM,
VENDOR_UNKNOWN, VENDOR_UNKNOWN,
+1 -1
View File
@@ -173,7 +173,7 @@ get_cpu_vendor_string(enum cpu_vendor cpuVendor)
// Should match vendors in OS.h // Should match vendors in OS.h
static const char* vendorStrings[] = { static const char* vendorStrings[] = {
NULL, "AMD", "Cyrix", "IDT", "Intel", "National Semiconductor", "Rise", NULL, "AMD", "Cyrix", "IDT", "Intel", "National Semiconductor", "Rise",
"Transmeta", "VIA", "IBM", "Motorola", "NEC" "Transmeta", "VIA", "IBM", "Motorola", "NEC", "Hygon"
}; };
if ((size_t)cpuVendor >= sizeof(vendorStrings) / sizeof(const char*)) if ((size_t)cpuVendor >= sizeof(vendorStrings) / sizeof(const char*))
+4 -3
View File
@@ -458,7 +458,7 @@ print_processor_signature(enum cpu_vendor vendor, cpuid_info *info)
"%1" B_PRIx32 "%1" B_PRIx32 "; ", info->eax_1.extended_family, "%1" B_PRIx32 "%1" B_PRIx32 "; ", info->eax_1.extended_family,
info->eax_1.extended_model, info->eax_1.family, info->eax_1.extended_model, info->eax_1.family,
info->eax_1.model, info->eax_1.stepping); info->eax_1.model, info->eax_1.stepping);
if (vendor == B_CPU_VENDOR_AMD) { if (vendor == B_CPU_VENDOR_AMD || vendor == B_CPU_VENDOR_HYGON) {
printf("Type %" B_PRIu32 ", family %" B_PRIu32 ", model %" B_PRIu32 printf("Type %" B_PRIu32 ", family %" B_PRIu32 ", model %" B_PRIu32
", stepping %" B_PRIu32 "\n", ", stepping %" B_PRIu32 "\n",
info->eax_1.type, info->eax_1.type,
@@ -596,14 +596,15 @@ dump_cpu(enum cpu_vendor vendor, uint32 model, int32 cpu)
/* Extended CPUID Information */ /* Extended CPUID Information */
if (maxExtendedFunction >= 1) { if (maxExtendedFunction >= 1) {
get_cpuid(&cpuInfo, 0x80000001, cpu); get_cpuid(&cpuInfo, 0x80000001, cpu);
if (vendor == B_CPU_VENDOR_INTEL || vendor == B_CPU_VENDOR_AMD) { if (vendor == B_CPU_VENDOR_INTEL || vendor == B_CPU_VENDOR_AMD
|| vendor == B_CPU_VENDOR_HYGON) {
// 0x80000001 EDX has overlap of 64,ED,SY/SE between amd and intel // 0x80000001 EDX has overlap of 64,ED,SY/SE between amd and intel
printf("\tExtended Features (0x80000001): 0x%08" B_PRIx32 "\n", printf("\tExtended Features (0x80000001): 0x%08" B_PRIx32 "\n",
cpuInfo.eax_1.features); cpuInfo.eax_1.features);
print_features(kAMDExtFeatures, cpuInfo.regs.edx); print_features(kAMDExtFeatures, cpuInfo.regs.edx);
} }
if (vendor == B_CPU_VENDOR_AMD) { if (vendor == B_CPU_VENDOR_AMD || vendor == B_CPU_VENDOR_HYGON) {
if (maxExtendedFunction >= 7) { if (maxExtendedFunction >= 7) {
get_cpuid(&cpuInfo, 0x80000007, cpu); get_cpuid(&cpuInfo, 0x80000007, cpu);
printf("\tExtended Features (0x80000007): 0x%08" B_PRIx32 "\n", printf("\tExtended Features (0x80000007): 0x%08" B_PRIx32 "\n",
+3 -1
View File
@@ -99,7 +99,9 @@ status_t
__x86_patch_errata_percpu(int currentCPU) __x86_patch_errata_percpu(int currentCPU)
{ {
const cpu_ent* cpu = get_cpu_struct(); const cpu_ent* cpu = get_cpu_struct();
if (cpu->arch.vendor == VENDOR_AMD) if (cpu->arch.vendor == VENDOR_AMD
|| cpu->arch.vendor == VENDOR_HYGON) {
return patch_errata_percpu_amd(currentCPU, cpu); return patch_errata_percpu_amd(currentCPU, cpu);
}
return B_OK; return B_OK;
} }
+3 -1
View File
@@ -60,6 +60,7 @@ static const struct cpu_vendor_info vendor_info[VENDOR_NUM] = {
{ "Rise", { "RiseRiseRise" } }, { "Rise", { "RiseRiseRise" } },
{ "Transmeta", { "GenuineTMx86", "TransmetaCPU" } }, { "Transmeta", { "GenuineTMx86", "TransmetaCPU" } },
{ "NSC", { "Geode by NSC" } }, { "NSC", { "Geode by NSC" } },
{ "Hygon", { "HygonGenuine" } },
}; };
#define K8_SMIONCMPHALT (1ULL << 27) #define K8_SMIONCMPHALT (1ULL << 27)
@@ -860,7 +861,8 @@ detect_cpu_topology(int currentCPU, cpu_ent* cpu, uint32 maxBasicLeaf,
status_t result = B_UNSUPPORTED; status_t result = B_UNSUPPORTED;
if (x86_check_feature(IA32_FEATURE_HTT, FEATURE_COMMON)) { if (x86_check_feature(IA32_FEATURE_HTT, FEATURE_COMMON)) {
if (cpu->arch.vendor == VENDOR_AMD) { if (cpu->arch.vendor == VENDOR_AMD
|| cpu->arch.vendor == VENDOR_HYGON) {
result = detect_amd_cpu_topology(maxBasicLeaf, maxExtendedLeaf); result = detect_amd_cpu_topology(maxBasicLeaf, maxExtendedLeaf);
if (result == B_OK) if (result == B_OK)
@@ -87,6 +87,9 @@ arch_system_info_init(struct kernel_args *args)
case VENDOR_TRANSMETA: case VENDOR_TRANSMETA:
sCPUVendor = B_CPU_VENDOR_TRANSMETA; sCPUVendor = B_CPU_VENDOR_TRANSMETA;
break; break;
case VENDOR_HYGON:
sCPUVendor = B_CPU_VENDOR_HYGON;
break;
default: default:
sCPUVendor = B_CPU_VENDOR_UNKNOWN; sCPUVendor = B_CPU_VENDOR_UNKNOWN;
break; break;