[LinuxBIOS] Is there sched_clock equivalent in LB?
Lucas C. Villa Real
lucasvr at gobolinux.org
Thu Apr 27 13:09:43 CEST 2006
On 4/27/06, Eric Poulsen <eric at zyxod.com> wrote:
> Daniel Parthey wrote:
> >Eric Poulsen schrieb:
> >>I was going to hack LB a bit, and add a timestamp, just like you see in
> >>the newer Linux kernels, to look for potential bottlenecks specific to
> >>my MLB. The kernel printk uses sched_clock() to get the current time.
> >>Is there an equivalent call in LB? I've looked through the code base
> >>for files / code that has *clock* or *time* or something similar, but
> >>without much luck.
> >I suppose MLB means VIA EPIA ML Board?
> I had meant Main Logic Board, but I guess it works both ways.
> >On Intel compatible Pentium (or higher) boards like VIA EPIA, you could
> >read the Time Stamp Counter (TSC) CPU register which tells you the number
> >of cycles from the last machine reset. Use the "cpuid" assembler command
> >as a barrier (to prevent out-of-order command execution) in combination
> >with the "rdtsc" assembler command to read the time time stamp counter.
> >The linux kernel sourcecode contains examples for this.
> My Intel assembly is 15 years rusty -- I'd have better luck doing this
> on a PIC. My co-worker hacks Intel assembly -- I'll get him to help me.
I'm not yet started at LB development, but this sample code can
probably do the job for you, given that you're using GCC:
#define do_rdtsc(ticks) \
__asm__ volatile (".byte 0x0f, 0x31" : "=A" (ticks));
This instruction returns a 64-bit value in EDX:EAX. If you don't need
to use 64 bits, getting the lower 32 bits will require a change on
"=A" by "=a" and on uint64_t by uint32_t.
Hope that helps,
powered by /dev/dsp
More information about the coreboot