[SeaBIOS] [QEMU RFC PATCH 4/7] i386: create apic_id_for_cpu() function

Eduardo Habkost ehabkost at redhat.com
Tue Jul 10 22:22:19 CEST 2012


Currently we need a way to calculate the Initial APIC ID using only the
CPU index, as the CPU hotplug interface doesn't have a method to send
the correct APIC ID to the ACPI hotplug code at hotplug-time.

Signed-off-by: Eduardo Habkost <ehabkost at redhat.com>
---
 target-i386/cpu.c |    2 +-
 target-i386/cpu.h |   17 +++++++++++++++++
 2 files changed, 18 insertions(+), 1 deletion(-)

diff --git a/target-i386/cpu.c b/target-i386/cpu.c
index b257241..c54619a 100644
--- a/target-i386/cpu.c
+++ b/target-i386/cpu.c
@@ -1770,7 +1770,7 @@ static void x86_cpu_initfn(Object *obj)
                         x86_cpuid_get_tsc_freq,
                         x86_cpuid_set_tsc_freq, NULL, NULL, NULL);
 
-    env->cpuid_apic_id = env->cpu_index;
+    env->cpuid_apic_id = apic_id_for_cpu(env->cpu_index);
 
     /* init various static tables used in TCG mode */
     if (tcg_enabled() && !inited) {
diff --git a/target-i386/cpu.h b/target-i386/cpu.h
index 6924c7f..e983c10 100644
--- a/target-i386/cpu.h
+++ b/target-i386/cpu.h
@@ -908,6 +908,23 @@ void cpu_clear_apic_feature(CPUX86State *env);
 void host_cpuid(uint32_t function, uint32_t count,
                 uint32_t *eax, uint32_t *ebx, uint32_t *ecx, uint32_t *edx);
 
+
+/* Calculate initial APIC ID for a specific CPU index
+ *
+ * Currently we need to be able to calculate the APIC ID from the CPU index
+ * only, as the QEMU<->Seabios(ACPI) interface for CPU hotplug isn't able
+ * to let the ACPI CPU hotplug code to retrivew the APIC ID at hotplug
+ * time.
+ */
+static inline uint8_t apic_id_for_cpu(int cpu_index)
+{
+    /* right now APIC ID == CPU index. this will eventually change to use
+     * the CPU topology configuration properly
+     */
+    return cpu_index;
+}
+
+
 /* helper.c */
 int cpu_x86_handle_mmu_fault(CPUX86State *env, target_ulong addr,
                              int is_write, int mmu_idx);
-- 
1.7.10.4




More information about the SeaBIOS mailing list