Hi,
kataklinger wrote:I was thinking about implementing HT support and I realised that I don't need to scan ACPI table to find logical processors, I can look at CPUID flag (all physical processors must be the same in SMP, so if one support HT then all others must support it as well).
Some notes...
For most (decent) SMP motherboards the BIOS won't report faulty CPUs in the ACPI and/or MP specification tables so that an OS won't try to use these faulty CPUs.
If you don't use ACPI or MP specification tables you won't know how IRQs have been assigned to the I/O APIC/s, the addresses of the local APICs and I/O APICs, if you need to mess with an IMCR to disable the PIC chips, etc. If you assume that the BIOS hasn't changed the address of the local APIC (it'd be unusual if the BIOS did) then you could get it working in "PIC mode" though.
For dual core chips without hyper-threading, the "HT present" feature flag will be set (the "number of logical CPUs" reports the total number of logical CPUs in the chip rather than the number of logical CPUs per core).
There's no guarantee that APIC ID's are sane - for e.g. a system with 4 CPUs and hyperthreading could have APIC IDs that go 0/1, 4/5, 8/9, 12/13 rather than 0/1, 2/3, 4/5, 6/7.
If you don't care about trying to start faulty CPUs, you can send the INIT/SIPI/SIPI sequence as "broadcast to all except self" so that you don't need to know what the APIC IDs are to begin with. Once the other CPUs are running your code you can make them store their APIC IDs in memory somewhere.
kataklinger wrote:And now my question: how does BIOS/MP init. protocol assignes local APIC ID?
AFAIK, it doesn't. When the computer is turned on the CPUs do handshaking to determine their "fixed local APIC IDs". This is the ID you can read from CPUID, which can't be changed by software (unlike the version from the local APIC).
kataklinger wrote:
a. PP0 PP1 ....
. LP0 LP1 LP0 LP1 ....
. ID0 ID1 ID2 ID3 ....
APIC ID's inside of a single chip get APIC IDs in order, like you wrote above. For example, for a (made up) chip with 2 cores and 4 logical CPUs per core you'd get:
APIC ID 00: chip0, core0, logical0
APIC ID 01: chip0, core0, logical1
APIC ID 02: chip0, core0, logical2
APIC ID 03: chip0, core0, logical3
APIC ID 04: chip0, core1, logical0
APIC ID 05: chip0, core1, logical1
APIC ID 06: chip0, core1, logical2
APIC ID 07: chip0, core1, logical3
kataklinger wrote:This won't be final solution (final code will relay on ACPI), but for beginning.
IMHO it'd be better to it with ACPI and/or MP specification tables the first time, rather than doing it twice....
Cheers,
Brendan