2424#ifndef HW_I386_TOPOLOGY_H
2525#define HW_I386_TOPOLOGY_H
2626
27- /* This file implements the APIC-ID-based CPU topology enumeration logic,
27+ /*
28+ * This file implements the APIC-ID-based CPU topology enumeration logic,
2829 * documented at the following document:
2930 * Intel® 64 Architecture Processor Topology Enumeration
3031 * http://software.intel.com/en-us/articles/intel-64-architecture-processor-topology-enumeration/
4142
4243#include "qemu/bitops.h"
4344
44- /* APIC IDs can be 32-bit, but beware: APIC IDs > 255 require x2APIC support
45+ /*
46+ * APIC IDs can be 32-bit, but beware: APIC IDs > 255 require x2APIC support
4547 */
4648typedef uint32_t apic_id_t ;
4749
@@ -58,24 +60,21 @@ typedef struct X86CPUTopoInfo {
5860 unsigned threads_per_core ;
5961} X86CPUTopoInfo ;
6062
61- /* Return the bit width needed for 'count' IDs
62- */
63+ /* Return the bit width needed for 'count' IDs */
6364static unsigned apicid_bitwidth_for_count (unsigned count )
6465{
6566 g_assert (count >= 1 );
6667 count -= 1 ;
6768 return count ? 32 - clz32 (count ) : 0 ;
6869}
6970
70- /* Bit width of the SMT_ID (thread ID) field on the APIC ID
71- */
71+ /* Bit width of the SMT_ID (thread ID) field on the APIC ID */
7272static inline unsigned apicid_smt_width (X86CPUTopoInfo * topo_info )
7373{
7474 return apicid_bitwidth_for_count (topo_info -> threads_per_core );
7575}
7676
77- /* Bit width of the Core_ID field
78- */
77+ /* Bit width of the Core_ID field */
7978static inline unsigned apicid_core_width (X86CPUTopoInfo * topo_info )
8079{
8180 return apicid_bitwidth_for_count (topo_info -> cores_per_die );
@@ -87,8 +86,7 @@ static inline unsigned apicid_die_width(X86CPUTopoInfo *topo_info)
8786 return apicid_bitwidth_for_count (topo_info -> dies_per_pkg );
8887}
8988
90- /* Bit offset of the Core_ID field
91- */
89+ /* Bit offset of the Core_ID field */
9290static inline unsigned apicid_core_offset (X86CPUTopoInfo * topo_info )
9391{
9492 return apicid_smt_width (topo_info );
@@ -100,14 +98,14 @@ static inline unsigned apicid_die_offset(X86CPUTopoInfo *topo_info)
10098 return apicid_core_offset (topo_info ) + apicid_core_width (topo_info );
10199}
102100
103- /* Bit offset of the Pkg_ID (socket ID) field
104- */
101+ /* Bit offset of the Pkg_ID (socket ID) field */
105102static inline unsigned apicid_pkg_offset (X86CPUTopoInfo * topo_info )
106103{
107104 return apicid_die_offset (topo_info ) + apicid_die_width (topo_info );
108105}
109106
110- /* Make APIC ID for the CPU based on Pkg_ID, Core_ID, SMT_ID
107+ /*
108+ * Make APIC ID for the CPU based on Pkg_ID, Core_ID, SMT_ID
111109 *
112110 * The caller must make sure core_id < nr_cores and smt_id < nr_threads.
113111 */
@@ -120,7 +118,8 @@ static inline apic_id_t x86_apicid_from_topo_ids(X86CPUTopoInfo *topo_info,
120118 topo_ids -> smt_id ;
121119}
122120
123- /* Calculate thread/core/package IDs for a specific topology,
121+ /*
122+ * Calculate thread/core/package IDs for a specific topology,
124123 * based on (contiguous) CPU index
125124 */
126125static inline void x86_topo_ids_from_idx (X86CPUTopoInfo * topo_info ,
@@ -137,7 +136,8 @@ static inline void x86_topo_ids_from_idx(X86CPUTopoInfo *topo_info,
137136 topo_ids -> smt_id = cpu_index % nr_threads ;
138137}
139138
140- /* Calculate thread/core/package IDs for a specific topology,
139+ /*
140+ * Calculate thread/core/package IDs for a specific topology,
141141 * based on APIC ID
142142 */
143143static inline void x86_topo_ids_from_apicid (apic_id_t apicid ,
@@ -155,7 +155,8 @@ static inline void x86_topo_ids_from_apicid(apic_id_t apicid,
155155 topo_ids -> pkg_id = apicid >> apicid_pkg_offset (topo_info );
156156}
157157
158- /* Make APIC ID for the CPU 'cpu_index'
158+ /*
159+ * Make APIC ID for the CPU 'cpu_index'
159160 *
160161 * 'cpu_index' is a sequential, contiguous ID for the CPU.
161162 */
0 commit comments