mirror of
https://github.com/yuzu-emu/unicorn
synced 2024-11-24 23:48:27 +00:00
pc: Add x86_topo_ids_from_apicid()
It's reverse of apicid_from_topo_ids() and will be used in follow up patches to fill in data structures for query-hotpluggable-cpus and for user friendly error reporting. Backports commit 9f3aab58539b4cc716e42e772be8116dc2e7d159 from qemu
This commit is contained in:
parent
bc8dbd862d
commit
95cced34fb
1 changed files with 15 additions and 0 deletions
|
@ -92,6 +92,21 @@ static inline unsigned apicid_pkg_offset(unsigned nr_cores, unsigned nr_threads)
|
||||||
apicid_core_width(nr_cores, nr_threads);
|
apicid_core_width(nr_cores, nr_threads);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Calculate thread/core/package IDs for a specific topology,
|
||||||
|
* based on APIC ID
|
||||||
|
*/
|
||||||
|
static inline void x86_topo_ids_from_apicid(apic_id_t apicid,
|
||||||
|
unsigned nr_cores,
|
||||||
|
unsigned nr_threads,
|
||||||
|
X86CPUTopoInfo *topo)
|
||||||
|
{
|
||||||
|
topo->smt_id = apicid &
|
||||||
|
~(0xFFFFFFFFUL << apicid_smt_width(nr_cores, nr_threads));
|
||||||
|
topo->core_id = (apicid >> apicid_core_offset(nr_cores, nr_threads)) &
|
||||||
|
~(0xFFFFFFFFUL << apicid_core_width(nr_cores, nr_threads));
|
||||||
|
topo->pkg_id = apicid >> apicid_pkg_offset(nr_cores, nr_threads);
|
||||||
|
}
|
||||||
|
|
||||||
/* Make APIC ID for the CPU based on Pkg_ID, Core_ID, SMT_ID
|
/* Make APIC ID for the CPU based on Pkg_ID, Core_ID, SMT_ID
|
||||||
*
|
*
|
||||||
* The caller must make sure core_id < nr_cores and smt_id < nr_threads.
|
* The caller must make sure core_id < nr_cores and smt_id < nr_threads.
|
||||||
|
|
Loading…
Reference in a new issue