Module Name:    src
Committed By:   msaitoh
Date:           Wed Oct 12 10:26:09 UTC 2022

Modified Files:
        src/sys/arch/x86/x86: cpu_topology.c

Log Message:
Use macros. No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.20 -r1.21 src/sys/arch/x86/x86/cpu_topology.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/x86/x86/cpu_topology.c
diff -u src/sys/arch/x86/x86/cpu_topology.c:1.20 src/sys/arch/x86/x86/cpu_topology.c:1.21
--- src/sys/arch/x86/x86/cpu_topology.c:1.20	Wed Oct 27 04:15:41 2021
+++ src/sys/arch/x86/x86/cpu_topology.c	Wed Oct 12 10:26:09 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: cpu_topology.c,v 1.20 2021/10/27 04:15:41 mrg Exp $	*/
+/*	$NetBSD: cpu_topology.c,v 1.21 2022/10/12 10:26:09 msaitoh Exp $	*/
 
 /*-
  * Copyright (c) 2009 Mindaugas Rasiukevicius <rmind at NetBSD org>,
@@ -36,7 +36,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: cpu_topology.c,v 1.20 2021/10/27 04:15:41 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cpu_topology.c,v 1.21 2022/10/12 10:26:09 msaitoh Exp $");
 
 #include "acpica.h"
 
@@ -143,11 +143,11 @@ x86_cpu_topology(struct cpu_info *ci)
 			break;
 		}
 
-		/* Number of Cores (NC) per package (ecx[7:0]). */
+		/* Number of Cores (NC) per package. */
 		x86_cpuid(0x80000008, descs);
-		core_max = (descs[2] & 0xff) + 1;
+		core_max = __SHIFTOUT(descs[2], CPUID_CAPEX_NC) + 1;
 		/* Amount of bits representing Core ID (ecx[15:12]). */
-		n = (descs[2] >> 12) & 0x0f;
+		n = __SHIFTOUT(descs[2], CPUID_CAPEX_ApicIdSize);
 		if (n != 0) {
 			/*
 			 * Extended Method.
@@ -188,7 +188,8 @@ x86_cpu_topology(struct cpu_info *ci)
 	/* Family 0x17 and above support SMT */
 	if (cpu_vendor == CPUVENDOR_AMD && cpu_family >= 0x17) { /* XXX */
 		x86_cpuid(0x8000001e, descs);
-		const u_int threads = ((descs[1] >> 8) & 0xff) + 1;
+		const u_int threads = __SHIFTOUT(descs[1],
+		    CPUID_AMD_PROCT_THREADS_PER_CORE) + 1;
 
 		KASSERT(smt_bits == 0);
 		smt_bits = ilog2(threads);

Reply via email to