kernel/x86: Use call_single_cpu_sync in get_cpuid.
Sends a more targeted ICI than a broadcast.
This commit is contained in:
@@ -13,24 +13,29 @@
|
|||||||
|
|
||||||
#include <boot/kernel_args.h>
|
#include <boot/kernel_args.h>
|
||||||
#include <cpu.h>
|
#include <cpu.h>
|
||||||
|
#include <debug.h>
|
||||||
#include <kernel.h>
|
#include <kernel.h>
|
||||||
#include <smp.h>
|
#include <smp.h>
|
||||||
|
|
||||||
|
|
||||||
enum cpu_vendor sCPUVendor;
|
static enum cpu_vendor sCPUVendor;
|
||||||
uint32 sCPUModel;
|
static uint32 sCPUModel;
|
||||||
int64 sCPUClockSpeed;
|
static int64 sCPUClockSpeed;
|
||||||
|
|
||||||
|
|
||||||
static bool
|
struct get_cpuid_args {
|
||||||
get_cpuid_for(cpuid_info *info, uint32 currentCPU, uint32 eaxRegister,
|
int forCPU;
|
||||||
uint32 forCPU)
|
cpuid_info* info;
|
||||||
|
uint32 eaxRegister;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
static void
|
||||||
|
get_cpuid_for(void* arg, int currentCPU)
|
||||||
{
|
{
|
||||||
if (currentCPU != forCPU)
|
get_cpuid_args* args = (get_cpuid_args*)arg;
|
||||||
return false;
|
ASSERT(currentCPU == args->forCPU);
|
||||||
|
get_current_cpuid(args->info, args->eaxRegister, 0);
|
||||||
get_current_cpuid(info, eaxRegister, 0);
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -38,23 +43,17 @@ status_t
|
|||||||
get_cpuid(cpuid_info *info, uint32 eaxRegister, uint32 forCPU)
|
get_cpuid(cpuid_info *info, uint32 eaxRegister, uint32 forCPU)
|
||||||
{
|
{
|
||||||
uint32 numCPUs = (uint32)smp_get_num_cpus();
|
uint32 numCPUs = (uint32)smp_get_num_cpus();
|
||||||
cpu_status state;
|
|
||||||
|
|
||||||
if (forCPU >= numCPUs)
|
if (forCPU >= numCPUs)
|
||||||
return B_BAD_VALUE;
|
return B_BAD_VALUE;
|
||||||
|
|
||||||
// prevent us from being rescheduled
|
get_cpuid_args args;
|
||||||
state = disable_interrupts();
|
args.forCPU = forCPU;
|
||||||
|
args.info = info;
|
||||||
|
args.eaxRegister = eaxRegister;
|
||||||
|
|
||||||
// ToDo: as long as we only run on pentium-class systems, we can assume
|
// ToDo: as long as we only run on pentium-class systems, we can assume
|
||||||
// that the CPU supports cpuid.
|
// that the CPU supports cpuid.
|
||||||
|
call_single_cpu_sync(forCPU, get_cpuid_for, &args);
|
||||||
if (!get_cpuid_for(info, smp_get_current_cpu(), eaxRegister, forCPU)) {
|
|
||||||
smp_send_broadcast_ici(SMP_MSG_CALL_FUNCTION, (addr_t)info,
|
|
||||||
eaxRegister, forCPU, (void *)get_cpuid_for, SMP_MSG_FLAG_SYNC);
|
|
||||||
}
|
|
||||||
|
|
||||||
restore_interrupts(state);
|
|
||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user