mirror of
https://github.com/Atmosphere-NX/Atmosphere.git
synced 2025-05-14 15:14:23 -04:00
kern: implement 64-virtual-core interface
This commit is contained in:
parent
3fd59b61bc
commit
28f9b534b6
8 changed files with 224 additions and 96 deletions
|
@ -22,7 +22,31 @@ namespace ams::kern::svc {
|
|||
namespace {
|
||||
|
||||
int32_t GetCurrentProcessorNumber() {
|
||||
return GetCurrentCoreId();
|
||||
/* Setup variables to track affinity information. */
|
||||
s32 current_phys_core;
|
||||
u64 v_affinity_mask = 0;
|
||||
|
||||
/* Forever try to get the affinity. */
|
||||
while (true) {
|
||||
/* Update affinity information if we've run out. */
|
||||
while (v_affinity_mask == 0) {
|
||||
current_phys_core = GetCurrentCoreId();
|
||||
v_affinity_mask = GetCurrentThread().GetVirtualAffinityMask();
|
||||
if ((v_affinity_mask & (1ul << current_phys_core)) != 0) {
|
||||
return current_phys_core;
|
||||
}
|
||||
}
|
||||
|
||||
/* Check the next virtual bit. */
|
||||
do {
|
||||
const s32 next_virt_core = static_cast<s32>(__builtin_ctzll(v_affinity_mask));
|
||||
if (current_phys_core == cpu::VirtualToPhysicalCoreMap[next_virt_core]) {
|
||||
return next_virt_core;
|
||||
}
|
||||
|
||||
v_affinity_mask &= ~(1ul << next_virt_core);
|
||||
} while (v_affinity_mask != 0);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue