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 <cpu.h>
|
||||
#include <debug.h>
|
||||
#include <kernel.h>
|
||||
#include <smp.h>
|
||||
|
||||
|
||||
enum cpu_vendor sCPUVendor;
|
||||
uint32 sCPUModel;
|
||||
int64 sCPUClockSpeed;
|
||||
static enum cpu_vendor sCPUVendor;
|
||||
static uint32 sCPUModel;
|
||||
static int64 sCPUClockSpeed;
|
||||
|
||||
|
||||
static bool
|
||||
get_cpuid_for(cpuid_info *info, uint32 currentCPU, uint32 eaxRegister,
|
||||
uint32 forCPU)
|
||||
struct get_cpuid_args {
|
||||
int forCPU;
|
||||
cpuid_info* info;
|
||||
uint32 eaxRegister;
|
||||
};
|
||||
|
||||
|
||||
static void
|
||||
get_cpuid_for(void* arg, int currentCPU)
|
||||
{
|
||||
if (currentCPU != forCPU)
|
||||
return false;
|
||||
|
||||
get_current_cpuid(info, eaxRegister, 0);
|
||||
return true;
|
||||
get_cpuid_args* args = (get_cpuid_args*)arg;
|
||||
ASSERT(currentCPU == args->forCPU);
|
||||
get_current_cpuid(args->info, args->eaxRegister, 0);
|
||||
}
|
||||
|
||||
|
||||
@@ -38,23 +43,17 @@ status_t
|
||||
get_cpuid(cpuid_info *info, uint32 eaxRegister, uint32 forCPU)
|
||||
{
|
||||
uint32 numCPUs = (uint32)smp_get_num_cpus();
|
||||
cpu_status state;
|
||||
|
||||
if (forCPU >= numCPUs)
|
||||
return B_BAD_VALUE;
|
||||
|
||||
// prevent us from being rescheduled
|
||||
state = disable_interrupts();
|
||||
get_cpuid_args args;
|
||||
args.forCPU = forCPU;
|
||||
args.info = info;
|
||||
args.eaxRegister = eaxRegister;
|
||||
|
||||
// ToDo: as long as we only run on pentium-class systems, we can assume
|
||||
// that the CPU supports cpuid.
|
||||
|
||||
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);
|
||||
call_single_cpu_sync(forCPU, get_cpuid_for, &args);
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user