[U-Boot] [PATCH v1 (WIP) 08/16] [Timer]Create new userland timer API
Simon Glass
sjg at chromium.org
Wed Jun 29 06:31:17 CEST 2011
Hi Graeme,
What a mammoth effort and what a fantastic clean up.
I'm a bit unsure of this patch which seems to have two prototypes for
the since functions:
On Tue, Jun 28, 2011 at 4:41 AM, Graeme Russ <graeme.russ at gmail.com> wrote:
>
> Signed-off-by: Graeme Russ <graeme.russ at gmail.com>
> ---
> include/common.h | 36 ++++++++++++++++++++----------------
> lib/time.c | 26 ++++++++++++++++++++++++++
> 2 files changed, 46 insertions(+), 16 deletions(-)
>
> diff --git a/include/common.h b/include/common.h
> index 340e585..9735d47 100644
> --- a/include/common.h
> +++ b/include/common.h
> @@ -584,11 +584,29 @@ void timer_interrupt (struct pt_regs *);
> void external_interrupt (struct pt_regs *);
> void irq_install_handler(int, interrupt_handler_t *, void *);
> void irq_free_handler (int);
> -void reset_timer (void);
> -ulong get_timer (ulong base);
> void enable_interrupts (void);
> int disable_interrupts (void);
>
> +/*
> + * Timer API
> + */
> +void reset_timer (void);
> +ulong get_timer (ulong base);
> +u64 get_ticks(void);
> +void wait_ticks(unsigned long);
> +void __udelay(unsigned long);
> +ulong usec2ticks(unsigned long usec);
> +ulong ticks2usec(unsigned long ticks);
> +int init_timebase(void);
> +
> +/* lib/time.c */
> +void udelay(unsigned long);
> +
> +u32 time_now_ms(void);
> +u32 time_since_ms(u32 from, u32 to);
> +u32 time_max_since_ms(u32 from, u32 to);
Here they have two parameters
> +u32 time_resolution_ms(void);
> +
> /* $(CPU)/.../commproc.c */
> int dpram_init (void);
> uint dpram_base(void);
> @@ -616,17 +634,6 @@ void flush_cache (unsigned long, unsigned long);
> void flush_dcache_range(unsigned long start, unsigned long stop);
> void invalidate_dcache_range(unsigned long start, unsigned long stop);
>
> -
> -/* arch/$(ARCH)/lib/ticks.S */
> -unsigned long long get_ticks(void);
> -void wait_ticks (unsigned long);
> -
> -/* arch/$(ARCH)/lib/time.c */
> -void __udelay (unsigned long);
> -ulong usec2ticks (unsigned long usec);
> -ulong ticks2usec (unsigned long ticks);
> -int init_timebase (void);
> -
> /* lib/gunzip.c */
> int gunzip(void *, int, unsigned char *, unsigned long *);
> int zunzip(void *dst, int dstlen, unsigned char *src, unsigned long *lenp,
> @@ -644,9 +651,6 @@ void qsort(void *base, size_t nmemb, size_t size,
> int(*compar)(const void *, const void *));
> int strcmp_compar(const void *, const void *);
>
> -/* lib/time.c */
> -void udelay (unsigned long);
> -
> /* lib/vsprintf.c */
> ulong simple_strtoul(const char *cp,char **endp,unsigned int base);
> int strict_strtoul(const char *cp, unsigned int base, unsigned long *res);
> diff --git a/lib/time.c b/lib/time.c
> index a309c26..1563507 100644
> --- a/lib/time.c
> +++ b/lib/time.c
> @@ -41,3 +41,29 @@ void udelay(unsigned long usec)
> usec -= kv;
> } while(usec);
> }
> +
> +u32 time_since_ms(u32 from)
and here only one (which is what I expect).
Can you please explain what I am missing?
Thanks,
Simon
> +{
> + u32 delta = time_now_ms() - from;
> +
> + /* round down */
> + if (delta < time_ms_resolution())
> + return 0;
> +
> + return delta - time_resolution_ms();
> +}
> +
> +u32 time_max_since_ms(u32 from)
> +{
> + u32 delta = time_now_ms() - from;
> +
> + return delta + time_resolution_ms();
> +}
> +
> +__attribute__((weak))
> +u32 time_resolution_ms(void) {return 1;}
> +
> +u32 time_now_ms(void)
> +{
> + return get_timer(0);
> +}
> --
> 1.7.5.2.317.g391b14
>
> _______________________________________________
> U-Boot mailing list
> U-Boot at lists.denx.de
> http://lists.denx.de/mailman/listinfo/u-boot
>
More information about the U-Boot
mailing list