> I have ported Linux 2.6 to PowerPC 440. Could you tell me
> how it is possible to access the timebase register (TBU, TBL)
> from user space (in Linux) because I want to measure the time
> of an application that runs in Linux?

I just grabbed this code from the kernel (you can put the macro
expansions into the function if you like):

typedef unsigned long long u64;

#define mftbl() ({unsigned long rval; \
 asm volatile("mftbl %0" : "=r" (rval)); rval;})
#define mftbu() ({unsigned long rval; \
 asm volatile("mftbu %0" : "=r" (rval)); rval;})

static inline u64 get_tb(void)
{
        unsigned int tbhi, tblo, tbhi2;
        do {
                tbhi = get_tbu();
                tblo = get_tbl();
                tbhi2 = get_tbu();
        } while (tbhi != tbhi2);
        return ((u64)tbhi << 32) | tblo;
}

The timebase frequency is available in text form from
/proc/cpuinfo and in binary (as a 4-byte bigendian
integer)from /proc/device-tree/...

grep timebase /proc/cpuinfo

find /proc/device-tree -name timebase-frequency -print \
 -exec od -td -An '{}' \;

Clive
_______________________________________________
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

Reply via email to