On 04.02.2008 16:45, ron minnich wrote:
we can provide a function, cycles, in the arch-dependent code. cycles returns whatever makes sense for the architecture.
Then this patch can be cleaned up.
What about this? (Varargs stuff still needs to get fixed.)
Regards, Carl-Daniel
Signed-off-by: Carl-Daniel Hailfinger c-d.hailfinger.devel.2006@gmx.net
Index: include/arch/x86/cpu.h =================================================================== --- include/arch/x86/cpu.h (Revision 571) +++ include/arch/x86/cpu.h (Arbeitskopie) @@ -196,4 +196,23 @@ __asm__ __volatile__("hlt" : : : "memory"); }
+/** + * Retrieve a 32-bit time stamp. The generic get_timestamp() offers no guarantee + * whatsoever about monotony, granularity, absence of wraparounds or linear + * relationship between the time stamp and real time. + * This implementation has wraparounds after 2^32 cycles of the TSC register + * and will usually have a linear dependency on real time. + * Qemu and Geode LX support the rdtsc instruction. + * If v3 ever is used on x86 architectures which don't support rdtsc, we have + * to provide an alternative. + * + * @return 32-bit truncated number of TSC cycles since poweron. + */ +u32 get_timestamp(void) +{ + u32 tstamp; + __asm__ __volatile__ ("rdtsc" : "=a" (tstamp) : : "edx"); + return tstamp; +} + #endif /* ARCH_X86_CPU_H */ Index: lib/console.c =================================================================== --- lib/console.c (Revision 571) +++ lib/console.c (Arbeitskopie) @@ -34,11 +34,16 @@ { va_list args; int i; + u32 tstamp;
if (msg_level > console_loglevel()) { return 0; }
+ tstamp = get_timestamp(); +#error vtxprintf expects varargs, need to fix up + vtxprintf(console_tx_byte, (void *)0, "[tstamp %d] ", tstamp); + va_start(args, fmt); i = vtxprintf(console_tx_byte, (void *)0, fmt, args); va_end(args);