diff --git a/sys/amd64/amd64/initcpu.c b/sys/amd64/amd64/initcpu.c index 9f13eb6f931..581fd631e88 100644 --- a/sys/amd64/amd64/initcpu.c +++ b/sys/amd64/amd64/initcpu.c @@ -83,10 +83,12 @@ u_int cpu_id = 0; /* Stepping ID */ u_int cpu_feature = 0; /* Feature flags */ u_int cpu_high = 0; /* Highest arg to CPUID */ u_int cpuid_cpuinfo = 0; /* HyperThreading Info / Brand Index / CLFUSH */ +u_int cpu_exthigh = 0; /* Highest arg to extended CPUID */ #ifdef CPU_ENABLE_SSE u_int cpu_fxsr = 0; /* SSE enabled */ #endif char cpu_vendor[20] = ""; /* CPU Origin code */ +char cpu_brand[48] = ""; /* Brand name */ #ifdef I486_CPU /* diff --git a/sys/amd64/amd64/locore.S b/sys/amd64/amd64/locore.S index b9efaf61324..58c008b6985 100644 --- a/sys/amd64/amd64/locore.S +++ b/sys/amd64/amd64/locore.S @@ -740,6 +740,30 @@ trycpuid: /* Use the `cpuid' instruction. */ /* Greater than Pentium...call it a Pentium Pro */ movl $CPU_686,R(cpu) 3: + /* Try to read extended CPUID information. */ + movl $0x80000000,%eax # cpuid 80000000 + cpuid + cmpl $0x80000000,%eax # is it a valid value? + jb 5f + movl %eax,R(cpu_exthigh) # highest extended capability + cmpl $0x80000004,%eax # does it have a brand name? + jb 5f + + /* Read the brand name. */ + leal R(cpu_brand),%edi + movl $0x80000002,%esi +4: + movl %esi,%eax + cpuid + movl %eax,(%edi) # Store next 16 characters + movl %ebx,4(%edi) # of brand name + movl %ecx,8(%edi) + movl %edx,12(%edi) + incl %esi # Advance to next set of 16 + addl $16,%edi + cmpl $0x80000004,%esi + jbe 4b +5: ret diff --git a/sys/amd64/amd64/locore.s b/sys/amd64/amd64/locore.s index b9efaf61324..58c008b6985 100644 --- a/sys/amd64/amd64/locore.s +++ b/sys/amd64/amd64/locore.s @@ -740,6 +740,30 @@ trycpuid: /* Use the `cpuid' instruction. */ /* Greater than Pentium...call it a Pentium Pro */ movl $CPU_686,R(cpu) 3: + /* Try to read extended CPUID information. */ + movl $0x80000000,%eax # cpuid 80000000 + cpuid + cmpl $0x80000000,%eax # is it a valid value? + jb 5f + movl %eax,R(cpu_exthigh) # highest extended capability + cmpl $0x80000004,%eax # does it have a brand name? + jb 5f + + /* Read the brand name. */ + leal R(cpu_brand),%edi + movl $0x80000002,%esi +4: + movl %esi,%eax + cpuid + movl %eax,(%edi) # Store next 16 characters + movl %ebx,4(%edi) # of brand name + movl %ecx,8(%edi) + movl %edx,12(%edi) + incl %esi # Advance to next set of 16 + addl $16,%edi + cmpl $0x80000004,%esi + jbe 4b +5: ret diff --git a/sys/amd64/include/md_var.h b/sys/amd64/include/md_var.h index 71c58c36744..1d0a03d4a9f 100644 --- a/sys/amd64/include/md_var.h +++ b/sys/amd64/include/md_var.h @@ -42,12 +42,14 @@ extern void (*bcopy_vector)(const void *from, void *to, size_t len); extern int busdma_swi_pending; extern int (*copyin_vector)(const void *udaddr, void *kaddr, size_t len); extern int (*copyout_vector)(const void *kaddr, void *udaddr, size_t len); +extern u_int cpu_exthigh; extern u_int cpu_feature; extern u_int cpu_high; extern u_int cpuid_cpuinfo; extern u_int cpu_id; extern u_int cpu_fxsr; extern char cpu_vendor[]; +extern char cpu_brand[]; extern u_int cyrix_did; extern uint16_t *elan_mmcr; extern char kstack[]; diff --git a/sys/i386/i386/initcpu.c b/sys/i386/i386/initcpu.c index 9f13eb6f931..581fd631e88 100644 --- a/sys/i386/i386/initcpu.c +++ b/sys/i386/i386/initcpu.c @@ -83,10 +83,12 @@ u_int cpu_id = 0; /* Stepping ID */ u_int cpu_feature = 0; /* Feature flags */ u_int cpu_high = 0; /* Highest arg to CPUID */ u_int cpuid_cpuinfo = 0; /* HyperThreading Info / Brand Index / CLFUSH */ +u_int cpu_exthigh = 0; /* Highest arg to extended CPUID */ #ifdef CPU_ENABLE_SSE u_int cpu_fxsr = 0; /* SSE enabled */ #endif char cpu_vendor[20] = ""; /* CPU Origin code */ +char cpu_brand[48] = ""; /* Brand name */ #ifdef I486_CPU /* diff --git a/sys/i386/i386/locore.s b/sys/i386/i386/locore.s index b9efaf61324..58c008b6985 100644 --- a/sys/i386/i386/locore.s +++ b/sys/i386/i386/locore.s @@ -740,6 +740,30 @@ trycpuid: /* Use the `cpuid' instruction. */ /* Greater than Pentium...call it a Pentium Pro */ movl $CPU_686,R(cpu) 3: + /* Try to read extended CPUID information. */ + movl $0x80000000,%eax # cpuid 80000000 + cpuid + cmpl $0x80000000,%eax # is it a valid value? + jb 5f + movl %eax,R(cpu_exthigh) # highest extended capability + cmpl $0x80000004,%eax # does it have a brand name? + jb 5f + + /* Read the brand name. */ + leal R(cpu_brand),%edi + movl $0x80000002,%esi +4: + movl %esi,%eax + cpuid + movl %eax,(%edi) # Store next 16 characters + movl %ebx,4(%edi) # of brand name + movl %ecx,8(%edi) + movl %edx,12(%edi) + incl %esi # Advance to next set of 16 + addl $16,%edi + cmpl $0x80000004,%esi + jbe 4b +5: ret diff --git a/sys/i386/include/md_var.h b/sys/i386/include/md_var.h index 71c58c36744..1d0a03d4a9f 100644 --- a/sys/i386/include/md_var.h +++ b/sys/i386/include/md_var.h @@ -42,12 +42,14 @@ extern void (*bcopy_vector)(const void *from, void *to, size_t len); extern int busdma_swi_pending; extern int (*copyin_vector)(const void *udaddr, void *kaddr, size_t len); extern int (*copyout_vector)(const void *kaddr, void *udaddr, size_t len); +extern u_int cpu_exthigh; extern u_int cpu_feature; extern u_int cpu_high; extern u_int cpuid_cpuinfo; extern u_int cpu_id; extern u_int cpu_fxsr; extern char cpu_vendor[]; +extern char cpu_brand[]; extern u_int cyrix_did; extern uint16_t *elan_mmcr; extern char kstack[];