Re: [RFC] new timeofday core subsystem (v.A1)

From: Martin Waitz
Date: Wed Dec 08 2004 - 15:28:55 EST


hoi :)

On Tue, Dec 07, 2004 at 05:56:38PM -0800, john stultz wrote:
> +struct timesource_t {

usually only typedefs end with _t

> + char* name;
> + int priority;
> + enum {
> + TIMESOURCE_FUNCTION,
> + TIMESOURCE_MMIO_32,
> + TIMESOURCE_MMIO_64
> + } type;
> + cycle_t (*read_fnct)(void);
> + void* ptr;

This could be made __iomem if it is intended to point to an IO memory region.
Hmm, but then there is no ioread64, so I guess I'm wrong.

> + cycle_t mask;
> + u32 mult;
> + u32 shift;
> +};

> +static inline nsec_t cyc2ns(struct timesource_t* ts, cycle_t cycles, cycle_t* rem)
> +{
> + u64 ret;
> + ret = (u64)cycles;
> + ret *= ts->mult;
> + ret >>= ts->shift;
> + if (rem) /* XXX we still need to do remainder math */
> + *rem = (cycle_t)0;
> + return (nsec_t)ret;
> +}

well, the math is simple:
if (rem) *rem = ret & (1 << ts->shift -1);
ret >>= ts->shift;


--
Martin Waitz

Attachment: signature.asc
Description: Digital signature