Reputation: 535
I want to program the IO-APIC & Local-APIC in my loader code, the code runs after BIOS.
I've read the i82093AA datasheet, and found that the register base is defined by PIIX3's APICBASE register. How can I read the "PIIX3 APICBASE" register?
As I know IO-APIC register base is 0xFEC00000 by default, but the BIOS may change it. So I want to find a way to get the base correctly.
Upvotes: 2
Views: 1596
Reputation: 6413
If you're working with a built-in APIC, everything is actually very simple. All you need to do is to read a model-specific register which contains the APICBASE
. Here is a basic list of MSRs.
To read a MSR, use the rdmsr
instruction (privileged).
mov ecx, 0x1B ; ECX=register address
xor eax, eax ; value of unimplemented bits in MSR will turn undefined when moved to
xor edx, edx ; EDX:EAX, so I set everything to 0
rdmsr
; EDX:EAX now contains APICBASE
When speaking about the PIIX3 external APIC, from PIIX3 documentation:
APICBASE—APIC BASE ADDRESS RELOCATION REGISTER (Function 0)
Address Offset: 80h
Default Value: 00h
Attribute: Read/WriteThis register provides the modifier for the APIC base address. APIC is mapped in the memory space at the locations
0xFEC0xy00
and0xFEC0xy10
(x=0-F
,y=0/4/8/C
). The value ofy
is defined by bits [1,0] and the value ofx
is defined by bits [5:2]. Thus, the relocation register provides 1-Kbyte address granularity (i.e., potentially up to 64 IOAPICs can be uniformly addresses in the memory space). The default value of 00h provides mapping of the IOAPIC unit at the addresses0xFEC00000
and0xFEC00010
.
A look on a driver actually interfacing PCI for this kind of data may be helpful.
Many of sources I've come through on internet used fixed 0xFEC00000
and didn't care about possibility of it being different. But as PIIX3 documentation says, 0xFEC00000
is guaranteed default value and you don't have to think about it further.
Upvotes: 3