blob: 8377cd013008200523538bb327a238183ffc7418 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
#include <console/console.h>
#include <cpu/cpu.h>
#include <cpu/x86/lapic.h>
#include <cpu/intel/hyperthreading.h>
#include <device/device.h>
#include <pc80/mc146818rtc.h>
#include <smp/spinlock.h>
#include <assert.h>
/* Return true if running thread does not have the smallest lapic ID
* within a CPU core.
*/
int intel_ht_sibling(void)
{
unsigned int core_ids, apic_ids, threads;
apic_ids = 1;
if (cpuid_eax(0) >= 1)
apic_ids = (cpuid_ebx(1) >> 16) & 0xff;
if (apic_ids < 1)
apic_ids = 1;
core_ids = 1;
if (cpuid_eax(0) >= 4)
core_ids += (cpuid_eax(4) >> 26) & 0x3f;
threads = (apic_ids / core_ids);
return !!(lapicid() & (threads-1));
}
|