2 Copyright © 1995-2011, The AROS Development Team. All rights reserved.
6 #include <exec/memory.h>
7 #include <proto/exec.h>
9 #include "kernel_base.h"
10 #include "kernel_debug.h"
11 #include "kernel_intern.h"
16 /* Initialize APIC by probing */
17 struct APICData
*core_APIC_Probe(void)
19 struct APICData
*data
;
21 /* Only i386 needs detection. On x86-64 APIC is always present. */
25 asm volatile("cpuid":"+a"(arg
),"=d"(res
)::"%ebx", "%ecx");
27 if (!(res
& (1 << 9)))
30 D(bug("[APIC] Detected by CPUID instruction\n"));
33 /* Assuming uniprocessor IBM PC compatible */
34 data
= AllocMem(sizeof(struct APICData
) + sizeof(struct CPUData
), MEMF_CLEAR
);
38 data
->lapicBase
= core_APIC_GetBase();
40 data
->flags
= APF_8259
;
41 data
->cores
[0].lapicID
= core_APIC_GetID(data
->lapicBase
);
43 /* Just initialize to default state */
44 core_APIC_Init(data
, 0);
48 UBYTE
core_APIC_GetNumber(struct APICData
*data
)
50 UBYTE __APICLogicalID
;
55 /* No APIC data -> uniprocessor system */
59 __APICLogicalID
= core_APIC_GetID(data
->lapicBase
);
61 for (__APICNo
= 0; __APICNo
< data
->count
; __APICNo
++)
63 if (data
->cores
[__APICNo
].lapicID
== __APICLogicalID
)