diff --git a/src/system/kernel/arch/x86/arch_timer.cpp b/src/system/kernel/arch/x86/arch_timer.cpp index 2248afa4fd..b533f5738f 100644 --- a/src/system/kernel/arch/x86/arch_timer.cpp +++ b/src/system/kernel/arch/x86/arch_timer.cpp @@ -27,11 +27,12 @@ //#define TRACE_TIMER #ifdef TRACE_TIMER -# define TRACE(x) dprintf x +# define TRACE(x...) dprintf("arch_timer: " x) #else -# define TRACE(x) ; +# define TRACE(x...) ; #endif + extern timer_info gPITTimer; extern timer_info gAPICTimer; extern timer_info gHPETTimer; @@ -48,7 +49,7 @@ static timer_info *sTimer = NULL; void arch_timer_set_hardware_timer(bigtime_t timeout) { - TRACE(("arch_timer_set_hardware_timer: timeout %lld\n", timeout)); + TRACE("arch_timer_set_hardware_timer: timeout %" B_PRIdBIGTIME "\n", timeout); sTimer->set_hardware_timer(timeout); } @@ -56,7 +57,7 @@ arch_timer_set_hardware_timer(bigtime_t timeout) void arch_timer_clear_hardware_timer(void) { - TRACE(("arch_timer_clear_hardware_timer\n")); + TRACE("arch_timer_clear_hardware_timer\n"); sTimer->clear_hardware_timer(); } @@ -65,10 +66,10 @@ static void sort_timers(timer_info *timers[], int numTimers) { timer_info *tempPtr; - int max = 0; + int max = 0; int i = 0; int j = 0; - + for (i = 0; i < numTimers - 1; i++) { max = i; for (j = i + 1; j < numTimers; j++) { @@ -78,10 +79,10 @@ sort_timers(timer_info *timers[], int numTimers) if (max != i) { tempPtr = timers[max]; timers[max] = timers[i]; - timers[i] = tempPtr; + timers[i] = tempPtr; } } - + #if 0 for (i = 0; i < numTimers; i++) dprintf(" %s: priority %d\n", timers[i]->name, timers[i]->get_priority()); @@ -97,7 +98,7 @@ arch_init_timer(kernel_args *args) timer_info *timer = NULL; cpu_status state = disable_interrupts(); - + for (int i = 0; (timer = sTimers[i]) != NULL; i++) { if (timer->init(args) == B_OK) break; diff --git a/src/system/kernel/arch/x86/timers/x86_apic.cpp b/src/system/kernel/arch/x86/timers/x86_apic.cpp index 568cd65244..c8c2351acb 100644 --- a/src/system/kernel/arch/x86/timers/x86_apic.cpp +++ b/src/system/kernel/arch/x86/timers/x86_apic.cpp @@ -18,6 +18,14 @@ #include "apic_timer.h" +//#define TRACE_APIC +#ifdef TRACE_APIC +# define TRACE(x...) dprintf("apic: " x) +#else +# define TRACE(x...) ; +#endif + + /* Method Prototypes */ static int apic_timer_get_priority(); static status_t apic_timer_set_hardware_timer(bigtime_t relativeTimeout); @@ -70,8 +78,9 @@ apic_timer_set_hardware_timer(bigtime_t relativeTimeout) config = apic_lvt_timer() & ~APIC_LVT_MASKED; // unmask the timer apic_set_lvt_timer(config); - //TRACE_TIMER(("arch_smp_set_apic_timer: config 0x%lx, timeout %Ld, tics/sec %lu, tics %lu\n", - // config, relativeTimeout, sApicTicsPerSec, ticks)); + TRACE("arch_smp_set_apic_timer: config 0x%" B_PRIx32 ", timeout %" B_PRIdBIGTIME + ", tics/sec %" B_PRIu32 ", tics %" B_PRId32 "\n", config, relativeTimeout, + sApicTicsPerSec, ticks); apic_set_lvt_initial_timer_count(ticks); // start it up diff --git a/src/system/kernel/arch/x86/timers/x86_hpet.cpp b/src/system/kernel/arch/x86/timers/x86_hpet.cpp index 07e64dfcca..6f7e347966 100644 --- a/src/system/kernel/arch/x86/timers/x86_hpet.cpp +++ b/src/system/kernel/arch/x86/timers/x86_hpet.cpp @@ -20,13 +20,14 @@ //#define TRACE_HPET #ifdef TRACE_HPET - #define TRACE(x) dprintf x +# define TRACE(x...) dprintf("hpet: " x) #else - #define TRACE(x) ; +# define TRACE(x...) ; #endif #define TEST_HPET + static struct hpet_regs *sHPETRegs; static volatile struct hpet_timer *sTimer; static uint64 sHPETPeriod; @@ -234,9 +235,9 @@ hpet_init(struct kernel_args *args) sHPETPeriod = HPET_GET_PERIOD(sHPETRegs); - TRACE(("hpet_init: HPET is at %p.\n\tVendor ID: %llx, rev: %llx, period: %" B_PRId64 "\n", + TRACE("hpet_init: HPET is at %p.\n\tVendor ID: %llx, rev: %llx, period: %" B_PRId64 "\n", sHPETRegs, HPET_GET_VENDOR_ID(sHPETRegs), HPET_GET_REVID(sHPETRegs), - sHPETPeriod)); + sHPETPeriod); status_t status = hpet_set_enabled(false); if (status != B_OK) @@ -248,11 +249,11 @@ hpet_init(struct kernel_args *args) uint32 numTimers = HPET_GET_NUM_TIMERS(sHPETRegs) + 1; - TRACE(("hpet_init: HPET supports %" B_PRIu32 " timers, and is %s bits wide.\n", - numTimers, HPET_IS_64BIT(sHPETRegs) ? "64" : "32")); + TRACE("hpet_init: HPET supports %" B_PRIu32 " timers, and is %s bits wide.\n", + numTimers, HPET_IS_64BIT(sHPETRegs) ? "64" : "32"); - TRACE(("hpet_init: configuration: 0x%" B_PRIx64 ", timer_interrupts: 0x%" B_PRIx64 "\n", - sHPETRegs->config, sHPETRegs->interrupt_status)); + TRACE("hpet_init: configuration: 0x%" B_PRIx64 ", timer_interrupts: 0x%" B_PRIx64 "\n", + sHPETRegs->config, sHPETRegs->interrupt_status); if (numTimers < 3) { dprintf("hpet_init: HPET does not have at least 3 timers. Skipping.\n"); diff --git a/src/system/kernel/arch/x86/timers/x86_pit.cpp b/src/system/kernel/arch/x86/timers/x86_pit.cpp index a9007d124a..622798ddf0 100644 --- a/src/system/kernel/arch/x86/timers/x86_pit.cpp +++ b/src/system/kernel/arch/x86/timers/x86_pit.cpp @@ -15,6 +15,15 @@ #include "pit.h" + +//#define TRACE_PIT +#ifdef TRACE_PIT +# define TRACE(x...) dprintf("pit: " x) +#else +# define TRACE(x...) ; +#endif + + static bool sPITTimerInitialized = false; struct timer_info gPITTimer = { @@ -73,13 +82,15 @@ static status_t pit_init(struct kernel_args *args) { if (sPITTimerInitialized) { + TRACE("timer is already initialized"); return B_OK; } - + install_io_interrupt_handler(0, &pit_timer_interrupt, NULL, 0); - pit_clear_hardware_timer(); + pit_clear_hardware_timer(); sPITTimerInitialized = true; + TRACE("timer initialized"); return B_OK; } diff --git a/src/system/kernel/timer.cpp b/src/system/kernel/timer.cpp index 28284f4ae1..dfb1193a78 100644 --- a/src/system/kernel/timer.cpp +++ b/src/system/kernel/timer.cpp @@ -250,8 +250,8 @@ timer_interrupt() per_cpu_timer_data& cpuData = sPerCPU[smp_get_current_cpu()]; int32 rc = B_HANDLED_INTERRUPT; - TRACE(("timer_interrupt: time %lld, cpu %ld\n", system_time(), - smp_get_current_cpu())); + TRACE(("timer_interrupt: time %" B_PRIdBIGTIME ", cpu %" B_PRId32 "\n", + system_time(), smp_get_current_cpu())); spinlock = &cpuData.lock;