diff --git a/bochs/cpu/apic.cc b/bochs/cpu/apic.cc index 8b5d918c6..fe4812bac 100644 --- a/bochs/cpu/apic.cc +++ b/bochs/cpu/apic.cc @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////// -// $Id: apic.cc,v 1.123 2009-02-20 17:05:03 sshwarts Exp $ +// $Id: apic.cc,v 1.124 2009-02-20 17:26:01 sshwarts Exp $ ///////////////////////////////////////////////////////////////////////// // // Copyright (c) 2002 Zwane Mwaikambo, Stanislav Shwartsman @@ -31,8 +31,6 @@ #define BX_CPU_APIC(i) (&(BX_CPU(i)->lapic)) -#define APIC_UNKNOWN_ID 0xff - #define APIC_BROADCAST_PHYSICAL_DESTINATION_MODE (APIC_MAX_ID) #define BX_LAPIC_FIRST_VECTOR 0x10 @@ -169,11 +167,17 @@ void apic_bus_broadcast_smi(void) //////////////////////////////////// -bx_local_apic_c::bx_local_apic_c(BX_CPU_C *mycpu) +bx_local_apic_c::bx_local_apic_c(BX_CPU_C *mycpu, unsigned id) : base_addr(BX_LAPIC_BASE_ADDR), cpu(mycpu) { - put("APIC?"); - apic_id = APIC_UNKNOWN_ID; + apic_id = id; + BX_ASSERT(apic_id < APIC_MAX_ID); + + char buffer[16]; + sprintf(buffer, "APIC%x", apic_id); + put(buffer); + + BX_INFO(("80%d86", BX_CPU_LEVEL)); // Register a non-active timer for use when the timer is started. timer_handle = bx_pc_system.register_timer_ticks(this, @@ -186,12 +190,6 @@ bx_local_apic_c::bx_local_apic_c(BX_CPU_C *mycpu) } void bx_local_apic_c::reset(unsigned type) -{ - /* same as INIT but also sets arbitration ID and APIC ID */ - init(); -} - -void bx_local_apic_c::init() { int i; @@ -235,27 +233,8 @@ void bx_local_apic_c::set_base(bx_phy_address newbase) mode = (newbase >> 10) & 3; newbase &= ~((bx_phy_address) 0xfff); base_addr = newbase; - if (apic_id != APIC_UNKNOWN_ID) { - BX_INFO(("allocate APIC id=%d (MMIO %s) to 0x" FMT_PHY_ADDRX, - apic_id, (mode == BX_APIC_XAPIC_MODE) ? "enabled" : "disabled", newbase)); - } -} - -void bx_local_apic_c::set_id(Bit32u new_id) -{ - apic_id = new_id; - - if(apic_id < APIC_MAX_ID) { - char buffer[16]; - sprintf(buffer, "APIC%x", apic_id); - put(buffer); - sprintf(buffer, "CPU%x", apic_id); - cpu->put(buffer); - } else { - BX_INFO(("naming convention for APICs requires id=0-%d only", APIC_MAX_ID)); - } - - BX_INFO(("80%d86", BX_CPU_LEVEL)); + BX_INFO(("allocate APIC id=%d (MMIO %s) to 0x" FMT_PHY_ADDRX, + apic_id, (mode == BX_APIC_XAPIC_MODE) ? "enabled" : "disabled", newbase)); } bx_bool bx_local_apic_c::is_selected(bx_phy_address addr) diff --git a/bochs/cpu/apic.h b/bochs/cpu/apic.h index 9f11ed708..d6c70970c 100644 --- a/bochs/cpu/apic.h +++ b/bochs/cpu/apic.h @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////// -// $Id: apic.h,v 1.46 2009-02-20 17:05:03 sshwarts Exp $ +// $Id: apic.h,v 1.47 2009-02-20 17:26:01 sshwarts Exp $ ///////////////////////////////////////////////////////////////////////// // // Copyright (c) 2002 Zwane Mwaikambo, Stanislav Shwartsman @@ -119,13 +119,11 @@ class BOCHSAPI bx_local_apic_c : public logfunctions public: bx_bool INTR; - bx_local_apic_c(BX_CPU_C *cpu); + bx_local_apic_c(BX_CPU_C *cpu, unsigned id); ~bx_local_apic_c() { } void reset(unsigned type); - void init(void); bx_phy_address get_base(void) const { return base_addr; } void set_base(bx_phy_address newbase); - void set_id(Bit32u newid); Bit32u get_id() const { return apic_id; } bx_bool is_selected(bx_phy_address addr); void read(bx_phy_address addr, void *data, unsigned len); diff --git a/bochs/cpu/init.cc b/bochs/cpu/init.cc index 4f596d507..29c6f0ea3 100644 --- a/bochs/cpu/init.cc +++ b/bochs/cpu/init.cc @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////// -// $Id: init.cc,v 1.202 2009-02-20 17:05:03 sshwarts Exp $ +// $Id: init.cc,v 1.203 2009-02-20 17:26:01 sshwarts Exp $ ///////////////////////////////////////////////////////////////////////// // // Copyright (C) 2001 MandrakeSoft S.A. @@ -38,13 +38,15 @@ BX_CPU_C::BX_CPU_C(unsigned id): bx_cpuid(id) #if BX_SUPPORT_APIC - ,lapic (this) + ,lapic (this, id) #endif { // in case of SMF, you cannot reference any member data // in the constructor because the only access to it is via // global variables which aren't initialized quite yet. - put("CPU"); + char buffer[16]; + sprintf(buffer, "CPU%x", bx_cpuid); + put(buffer); } #if BX_WITH_WX @@ -149,16 +151,11 @@ static Bit64s cpu_param_handler(bx_param_c *param, int set, Bit64s val) #endif +// BX_CPU_C constructor void BX_CPU_C::initialize(void) { - // BX_CPU_C constructor BX_CPU_THIS_PTR set_INTR (0); -#if BX_SUPPORT_APIC - BX_CPU_THIS_PTR lapic.set_id(BX_CPU_ID); - BX_CPU_THIS_PTR lapic.init(); -#endif - #if BX_CONFIGURE_MSRS for (unsigned n=0; n < BX_MSR_MAX_INDEX; n++) { BX_CPU_THIS_PTR msrs[n] = 0; @@ -922,7 +919,7 @@ void BX_CPU_C::reset(unsigned source) #if BX_SUPPORT_APIC /* APIC Address, APIC enabled and BSP is default, we'll fill in the rest later */ BX_CPU_THIS_PTR msr.apicbase = BX_LAPIC_BASE_ADDR; - BX_CPU_THIS_PTR lapic.init(); + BX_CPU_THIS_PTR lapic.reset(source); BX_CPU_THIS_PTR msr.apicbase |= 0x900; BX_CPU_THIS_PTR lapic.set_base(BX_CPU_THIS_PTR msr.apicbase); #endif