diff --git a/bochs/cpu/apic.cc b/bochs/cpu/apic.cc index ec260a1e5..8b5d918c6 100644 --- a/bochs/cpu/apic.cc +++ b/bochs/cpu/apic.cc @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////// -// $Id: apic.cc,v 1.122 2009-02-19 23:19:10 sshwarts Exp $ +// $Id: apic.cc,v 1.123 2009-02-20 17:05:03 sshwarts Exp $ ///////////////////////////////////////////////////////////////////////// // // Copyright (c) 2002 Zwane Mwaikambo, Stanislav Shwartsman @@ -173,7 +173,7 @@ bx_local_apic_c::bx_local_apic_c(BX_CPU_C *mycpu) : base_addr(BX_LAPIC_BASE_ADDR), cpu(mycpu) { put("APIC?"); - id = APIC_UNKNOWN_ID; + apic_id = APIC_UNKNOWN_ID; // Register a non-active timer for use when the timer is started. timer_handle = bx_pc_system.register_timer_ticks(this, @@ -195,8 +195,7 @@ void bx_local_apic_c::init() { int i; - BX_INFO(("local apic in %s initializing", - (cpu && cpu->name) ? cpu->name : "?")); + BX_INFO(("local apic %d initializing", apic_id)); // default address for a local APIC, can be moved base_addr = BX_LAPIC_BASE_ADDR; @@ -236,22 +235,21 @@ void bx_local_apic_c::set_base(bx_phy_address newbase) mode = (newbase >> 10) & 3; newbase &= ~((bx_phy_address) 0xfff); base_addr = newbase; - if (id != APIC_UNKNOWN_ID) { + if (apic_id != APIC_UNKNOWN_ID) { BX_INFO(("allocate APIC id=%d (MMIO %s) to 0x" FMT_PHY_ADDRX, - id, (mode == BX_APIC_XAPIC_MODE) ? "enabled" : "disabled", newbase)); + apic_id, (mode == BX_APIC_XAPIC_MODE) ? "enabled" : "disabled", newbase)); } } void bx_local_apic_c::set_id(Bit32u new_id) { - id = new_id; - sprintf(cpu->name, "CPU apicid=%02x", id); + apic_id = new_id; - if(id < APIC_MAX_ID) { + if(apic_id < APIC_MAX_ID) { char buffer[16]; - sprintf(buffer, "APIC%x", id); + sprintf(buffer, "APIC%x", apic_id); put(buffer); - sprintf(buffer, "CPU%x", id); + sprintf(buffer, "CPU%x", apic_id); cpu->put(buffer); } else { BX_INFO(("naming convention for APICs requires id=0-%d only", APIC_MAX_ID)); @@ -361,7 +359,7 @@ void bx_local_apic_c::write_aligned(bx_phy_address addr, Bit32u value) { BX_ASSERT((addr & 0xf) == 0); unsigned apic_reg = addr & 0xff0; - BX_DEBUG(("%s: LAPIC write 0x%08x to register 0x%04x", cpu->name, value, apic_reg)); + BX_DEBUG(("LAPIC write 0x%08x to register 0x%04x", value, apic_reg)); switch(apic_reg) { case BX_LAPIC_TPR: // task priority set_tpr(value & 0xff); @@ -525,13 +523,13 @@ void bx_local_apic_c::write_spurious_interrupt_register(Bit32u value) void bx_local_apic_c::receive_EOI(Bit32u value) { - BX_DEBUG(("%s: Wrote 0x%x to EOI", cpu->name, value)); + BX_DEBUG(("Wrote 0x%x to EOI", value)); int vec = highest_priority_int(isr); if(vec < 0) { BX_DEBUG(("EOI written without any bit in ISR")); } else { if ((Bit32u) vec != spurious_vector) { - BX_DEBUG(("%s: local apic received EOI, hopefully for vector 0x%02x", cpu->name, vec)); + BX_DEBUG(("local apic received EOI, hopefully for vector 0x%02x", vec)); isr[vec] = 0; if(tmr[vec]) { apic_bus_broadcast_eoi(vec); @@ -555,10 +553,10 @@ Bit32u bx_local_apic_c::read_aligned(bx_phy_address addr) BX_ASSERT((addr & 0xf) == 0); Bit32u data = 0; // default value for unimplemented registers unsigned apic_reg = addr & 0xff0; - BX_DEBUG(("%s: LAPIC read from register 0x%04x", cpu->name, apic_reg)); + BX_DEBUG(("LAPIC read from register 0x%04x", apic_reg)); switch(apic_reg) { case BX_LAPIC_ID: // local APIC id - data = (id) << 24; break; + data = apic_id << 24; break; case BX_LAPIC_VERSION: // local APIC version data = BX_LAPIC_VERSION_ID; break; case BX_LAPIC_TPR: // task priority @@ -667,7 +665,7 @@ Bit32u bx_local_apic_c::read_aligned(bx_phy_address addr) BX_INFO(("APIC register %08x not implemented", apic_reg)); } - BX_DEBUG(("%s: read from APIC address 0x" FMT_PHY_ADDRX " = %08x", cpu->name, addr, data)); + BX_DEBUG(("read from APIC address 0x" FMT_PHY_ADDRX " = %08x", addr, data)); return data; } @@ -691,11 +689,11 @@ void bx_local_apic_c::service_local_apic(void) if (first_irr < 0) return; // no interrupts, leave INTR=0 int first_isr = highest_priority_int(isr); if (first_isr >= 0 && first_irr <= first_isr) { - BX_DEBUG(("local apic(%s): not delivering int 0x%02x because int 0x%02x is in service", cpu->name, first_irr, first_isr)); + BX_DEBUG(("lapic(%x): not delivering int 0x%02x because int 0x%02x is in service", apic_id, first_irr, first_isr)); return; } if(((Bit32u)(first_irr) & 0xf0) <= (task_priority & 0xf0)) { - BX_DEBUG(("local apic(%s): not delivering int 0x%02X because task_priority is 0x%02X", cpu->name, first_irr, task_priority)); + BX_DEBUG(("lapic(%x): not delivering int 0x%02X because task_priority is 0x%02X", apic_id, first_irr, task_priority)); return; } // interrupt has appeared in irr. Raise INTR. When the CPU @@ -743,7 +741,7 @@ bx_bool bx_local_apic_c::deliver(Bit8u vector, Bit8u delivery_mode, Bit8u trig_m void bx_local_apic_c::trigger_irq(Bit8u vector, unsigned trigger_mode, bx_bool bypass_irr_isr) { - BX_DEBUG(("Local apic on %s: trigger interrupt vector=0x%x", cpu->name, vector)); + BX_DEBUG(("trigger interrupt vector=0x%02x", vector)); if(vector > BX_LAPIC_LAST_VECTOR || vector < BX_LAPIC_FIRST_VECTOR) { shadow_error_status |= APIC_ERR_RX_ILLEGAL_VEC; @@ -770,7 +768,7 @@ service_vector: void bx_local_apic_c::untrigger_irq(Bit8u vector, unsigned trigger_mode) { - BX_DEBUG(("Local apic on %s: untrigger interrupt vector=0x%x", cpu->name, vector)); + BX_DEBUG(("untrigger interrupt vector=0x%02x", vector)); // hardware says "no more". clear the bit. If the CPU hasn't yet // acknowledged the interrupt, it will never be serviced. BX_ASSERT(irr[vector] == 1); @@ -782,13 +780,14 @@ Bit8u bx_local_apic_c::acknowledge_int(void) { // CPU calls this when it is ready to service one interrupt if(!INTR) - BX_PANIC(("%s: acknowledged an interrupt, but INTR=0", cpu->name)); + BX_PANIC(("APIC %d acknowledged an interrupt, but INTR=0", apic_id)); + BX_ASSERT(INTR); int vector = highest_priority_int(irr); if (vector < 0) goto spurious; if((vector & 0xf0) <= get_ppr()) goto spurious; BX_ASSERT(irr[vector] == 1); - BX_DEBUG(("%s: acknowledge_int returning vector 0x%x", cpu->name, vector)); + BX_DEBUG(("acknowledge_int() returning vector 0x%02x", vector)); irr[vector] = 0; isr[vector] = 1; if(bx_dbg.apic) { @@ -808,7 +807,7 @@ spurious: void bx_local_apic_c::print_status(void) { - BX_INFO(("%s local apic: status is {:", cpu->name)); + BX_INFO(("lapic %d: status is {:", apic_id)); for(int vec=0; vec %s", cpu->name, - address, ldr, match? "Match" : "Not a match")); + BX_DEBUG(("comparing MDA %02x to my LDR %02x -> %s", address, + ldr, match ? "Match" : "Not a match")); } else if (dest_format == 0) { // cluster model @@ -903,7 +902,7 @@ void bx_local_apic_c::periodic_smf(void *this_ptr) void bx_local_apic_c::periodic(void) { if(!timer_active) { - BX_ERROR(("%s: bx_local_apic_c::periodic called, timer_active==0", cpu->name)); + BX_ERROR(("bx_local_apic_c::periodic called, timer_active==0")); return; } @@ -916,12 +915,12 @@ void bx_local_apic_c::periodic(void) trigger_irq(timervec & 0xff, APIC_EDGE_TRIGGERED); } else { - BX_DEBUG(("%s: local apic timer LVT masked", cpu->name)); + BX_DEBUG(("local apic timer LVT masked")); } // Reload timer values. timer_current = timer_initial; ticksInitial = bx_pc_system.time_ticks(); // Take a reading. - BX_DEBUG(("%s: local apic timer(periodic) triggered int, reset counter to 0x%08x", cpu->name, timer_current)); + BX_DEBUG(("local apic timer(periodic) triggered int, reset counter to 0x%08x", timer_current)); } else { // one-shot mode @@ -931,10 +930,10 @@ void bx_local_apic_c::periodic(void) trigger_irq(timervec & 0xff, APIC_EDGE_TRIGGERED); } else { - BX_DEBUG(("%s: local apic timer LVT masked", cpu->name)); + BX_DEBUG(("local apic timer LVT masked")); } timer_active = 0; - BX_DEBUG(("%s: local apic timer(one-shot) triggered int", cpu->name)); + BX_DEBUG(("local apic timer(one-shot) triggered int")); bx_pc_system.deactivate_timer(timer_handle); } } @@ -945,8 +944,8 @@ void bx_local_apic_c::set_divide_configuration(Bit32u value) // move bit 3 down to bit 0. value = ((value & 8) >> 1) | (value & 3); BX_ASSERT(value >= 0 && value <= 7); - timer_divide_factor = (value==7)? 1 : (2 << value); - BX_INFO(("%s: set timer divide factor to %d", cpu->name, timer_divide_factor)); + timer_divide_factor = (value==7) ? 1 : (2 << value); + BX_INFO(("set timer divide factor to %d", timer_divide_factor)); } void bx_local_apic_c::set_initial_timer_count(Bit32u value) @@ -983,7 +982,7 @@ void bx_local_apic_c::register_state(bx_param_c *parent) bx_list_c *lapic = new bx_list_c(parent, "local_apic", 25); BXRS_HEX_PARAM_SIMPLE(lapic, base_addr); - BXRS_HEX_PARAM_SIMPLE(lapic, id); + BXRS_HEX_PARAM_SIMPLE(lapic, apic_id); BXRS_HEX_PARAM_SIMPLE(lapic, mode); BXRS_HEX_PARAM_SIMPLE(lapic, spurious_vector); BXRS_PARAM_BOOL(lapic, software_enabled, software_enabled); diff --git a/bochs/cpu/apic.h b/bochs/cpu/apic.h index eb9f93b5a..9f11ed708 100644 --- a/bochs/cpu/apic.h +++ b/bochs/cpu/apic.h @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////// -// $Id: apic.h,v 1.45 2009-02-20 16:01:30 sshwarts Exp $ +// $Id: apic.h,v 1.46 2009-02-20 17:05:03 sshwarts Exp $ ///////////////////////////////////////////////////////////////////////// // // Copyright (c) 2002 Zwane Mwaikambo, Stanislav Shwartsman @@ -48,7 +48,7 @@ class BOCHSAPI bx_local_apic_c : public logfunctions { bx_phy_address base_addr; - Bit32u id; + Bit32u apic_id; unsigned mode; bx_bool software_enabled; @@ -126,7 +126,7 @@ public: 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 id; } + 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); void write(bx_phy_address addr, void *data, unsigned len); diff --git a/bochs/cpu/cpu.cc b/bochs/cpu/cpu.cc index a1a4f08ec..dde149978 100644 --- a/bochs/cpu/cpu.cc +++ b/bochs/cpu/cpu.cc @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////// -// $Id: cpu.cc,v 1.270 2009-02-17 19:20:46 sshwarts Exp $ +// $Id: cpu.cc,v 1.271 2009-02-20 17:05:03 sshwarts Exp $ ///////////////////////////////////////////////////////////////////////// // // Copyright (C) 2001 MandrakeSoft S.A. @@ -845,10 +845,10 @@ void BX_CPU_C::deliver_SIPI(unsigned vector) RIP = 0; load_seg_reg(&BX_CPU_THIS_PTR sregs[BX_SEG_REG_CS], vector*0x100); BX_CPU_THIS_PTR disable_INIT = 0; // enable INIT pin back - BX_INFO(("%s started up at %04X:%08X by APIC", - BX_CPU_THIS_PTR name, vector*0x100, EIP)); + BX_INFO(("CPU %d started up at %04X:%08X by APIC", + BX_CPU_THIS_PTR bx_cpuid, vector*0x100, EIP)); } else { - BX_INFO(("%s started up by APIC, but was not halted at the time", BX_CPU_THIS_PTR name)); + BX_INFO(("CPU %d started up by APIC, but was not halted at the time", BX_CPU_THIS_PTR bx_cpuid)); } } diff --git a/bochs/cpu/cpu.h b/bochs/cpu/cpu.h index e69b11228..c01f30bb7 100644 --- a/bochs/cpu/cpu.h +++ b/bochs/cpu/cpu.h @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////// -// $Id: cpu.h,v 1.575 2009-02-20 08:12:51 sshwarts Exp $ +// $Id: cpu.h,v 1.576 2009-02-20 17:05:03 sshwarts Exp $ ///////////////////////////////////////////////////////////////////////// // // Copyright (C) 2001 MandrakeSoft S.A. @@ -771,8 +771,6 @@ class BOCHSAPI BX_CPU_C : public logfunctions { public: // for now... - char name[64]; - unsigned bx_cpuid; // cpuid diff --git a/bochs/cpu/init.cc b/bochs/cpu/init.cc index ac0cd2fac..4f596d507 100644 --- a/bochs/cpu/init.cc +++ b/bochs/cpu/init.cc @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////// -// $Id: init.cc,v 1.201 2009-02-18 22:38:58 sshwarts Exp $ +// $Id: init.cc,v 1.202 2009-02-20 17:05:03 sshwarts Exp $ ///////////////////////////////////////////////////////////////////////// // // Copyright (C) 2001 MandrakeSoft S.A. @@ -159,10 +159,6 @@ void BX_CPU_C::initialize(void) BX_CPU_THIS_PTR lapic.init(); #endif - // in SMP mode, the prefix of the CPU will be changed to [CPUn] in - // bx_local_apic_c::set_id as soon as the apic ID is assigned. - sprintf(name, "CPU %d", BX_CPU_ID); - #if BX_CONFIGURE_MSRS for (unsigned n=0; n < BX_MSR_MAX_INDEX; n++) { BX_CPU_THIS_PTR msrs[n] = 0; diff --git a/bochs/logio.cc b/bochs/logio.cc index 31d404b70..8cb1bd957 100644 --- a/bochs/logio.cc +++ b/bochs/logio.cc @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////// -// $Id: logio.cc,v 1.71 2009-01-10 11:30:20 vruppert Exp $ +// $Id: logio.cc,v 1.72 2009-02-20 17:05:03 sshwarts Exp $ ///////////////////////////////////////////////////////////////////////// // // Copyright (C) 2001 MandrakeSoft S.A. @@ -299,36 +299,34 @@ logfunctions::logfunctions(iofunc_t *iofunc) logfunctions::~logfunctions() { - this->logio->remove_logfn(this); + logio->remove_logfn(this); if (prefix) free(prefix); } void logfunctions::setio(iofunc_t *i) { // add pointer to iofunction object to use - this->logio = i; + logio = i; // give iofunction a pointer to me i->add_logfn(this); } void logfunctions::put(const char *p) { - char * tmpbuf=strdup("[ ]"); // if we ever have more than 32 chars, - // we need to rethink this + char *tmpbuf=strdup("[ ]"); // if we ever have more than 32 chars, + // we need to rethink this if (tmpbuf == NULL) - { - return; // allocation not successful - } + return; // allocation not successful - if (this->prefix != NULL) + if (prefix != NULL) { - free(this->prefix); // free previously allocated memory + free(prefix); // free previously allocated memory prefix = NULL; } size_t len=strlen(p); - for(size_t i=1;ilogio != NULL); + assert(logio != NULL); if(!onoff[LOGLEV_INFO]) return; va_start(ap, fmt); - this->logio->out(LOGLEV_INFO, this->prefix, fmt, ap); + logio->out(LOGLEV_INFO, prefix, fmt, ap); if (onoff[LOGLEV_INFO] == ACT_ASK) - ask(LOGLEV_INFO, this->prefix, fmt, ap); + ask(LOGLEV_INFO, prefix, fmt, ap); if (onoff[LOGLEV_INFO] == ACT_FATAL) - fatal(this->prefix, fmt, ap, 1); + fatal(prefix, fmt, ap, 1); va_end(ap); } @@ -365,17 +362,16 @@ void logfunctions::error(const char *fmt, ...) { va_list ap; - assert(this != NULL); - assert(this->logio != NULL); + assert(logio != NULL); if(!onoff[LOGLEV_ERROR]) return; va_start(ap, fmt); - this->logio->out(LOGLEV_ERROR, this->prefix, fmt, ap); + logio->out(LOGLEV_ERROR, prefix, fmt, ap); if (onoff[LOGLEV_ERROR] == ACT_ASK) - ask(LOGLEV_ERROR, this->prefix, fmt, ap); + ask(LOGLEV_ERROR, prefix, fmt, ap); if (onoff[LOGLEV_ERROR] == ACT_FATAL) - fatal(this->prefix, fmt, ap, 1); + fatal(prefix, fmt, ap, 1); va_end(ap); } @@ -383,24 +379,23 @@ void logfunctions::panic(const char *fmt, ...) { va_list ap; - assert(this != NULL); - assert(this->logio != NULL); + assert(logio != NULL); // Special case for panics since they are so important. Always print // the panic to the log, no matter what the log action says. //if(!onoff[LOGLEV_PANIC]) return; va_start(ap, fmt); - this->logio->out(LOGLEV_PANIC, this->prefix, fmt, ap); + logio->out(LOGLEV_PANIC, prefix, fmt, ap); // This fixes a funny bug on linuxppc where va_list is no pointer but a struct va_end(ap); va_start(ap, fmt); if (onoff[LOGLEV_PANIC] == ACT_ASK) - ask(LOGLEV_PANIC, this->prefix, fmt, ap); + ask(LOGLEV_PANIC, prefix, fmt, ap); if (onoff[LOGLEV_PANIC] == ACT_FATAL) - fatal(this->prefix, fmt, ap, 1); + fatal(prefix, fmt, ap, 1); va_end(ap); } @@ -408,24 +403,23 @@ void logfunctions::pass(const char *fmt, ...) { va_list ap; - assert(this != NULL); - assert(this->logio != NULL); + assert(logio != NULL); // Special case for panics since they are so important. Always print // the panic to the log, no matter what the log action says. //if(!onoff[LOGLEV_PASS]) return; va_start(ap, fmt); - this->logio->out(LOGLEV_PASS, this->prefix, fmt, ap); + logio->out(LOGLEV_PASS, prefix, fmt, ap); // This fixes a funny bug on linuxppc where va_list is no pointer but a struct va_end(ap); va_start(ap, fmt); if (onoff[LOGLEV_PASS] == ACT_ASK) - ask(LOGLEV_PASS, this->prefix, fmt, ap); + ask(LOGLEV_PASS, prefix, fmt, ap); if (onoff[LOGLEV_PASS] == ACT_FATAL) - fatal(this->prefix, fmt, ap, 101); + fatal(prefix, fmt, ap, 101); va_end(ap); } @@ -433,17 +427,16 @@ void logfunctions::ldebug(const char *fmt, ...) { va_list ap; - assert(this != NULL); - assert(this->logio != NULL); + assert(logio != NULL); if(!onoff[LOGLEV_DEBUG]) return; va_start(ap, fmt); - this->logio->out(LOGLEV_DEBUG, this->prefix, fmt, ap); + logio->out(LOGLEV_DEBUG, prefix, fmt, ap); if (onoff[LOGLEV_DEBUG] == ACT_ASK) - ask(LOGLEV_DEBUG, this->prefix, fmt, ap); + ask(LOGLEV_DEBUG, prefix, fmt, ap); if (onoff[LOGLEV_DEBUG] == ACT_FATAL) - fatal(this->prefix, fmt, ap, 1); + fatal(prefix, fmt, ap, 1); va_end(ap); }