Re: [U-Boot] [PATCH v1 (WIP) 08/16] [Timer]Create new userland timer API
Dear Graeme Russ, In message 1309261269-4363-9-git-send-email-graeme.r...@gmail.com you wrote: Signed-off-by: Graeme Russ graeme.r...@gmail.com Please define userland in U-Boot context ? +u32 time_now_ms(void); +u32 time_since_ms(u32 from, u32 to); +u32 time_max_since_ms(u32 from, u32 to); +u32 time_resolution_ms(void); I'm unhappy about these. Sorry, but I don't want to have that. See previous message(s). Best regards, Wolfgang Denk -- DENX Software Engineering GmbH, MD: Wolfgang Denk Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: w...@denx.de I am not now, nor have I ever been, a member of the demigodic party. -- Dennis Ritchie ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH v1 (WIP) 08/16] [Timer]Create new userland timer API
Hi Wolfgang, On 12/07/11 08:05, Wolfgang Denk wrote: Dear Graeme Russ, In message 1309261269-4363-9-git-send-email-graeme.r...@gmail.com you wrote: Signed-off-by: Graeme Russ graeme.r...@gmail.com Please define userland in U-Boot context ? Used outside of /arch (i.e. in board or driver code). Anything in arch/ binds the architecture specific implementation to lib/ +u32 time_now_ms(void); +u32 time_since_ms(u32 from, u32 to); +u32 time_max_since_ms(u32 from, u32 to); +u32 time_resolution_ms(void); I'm unhappy about these. Sorry, but I don't want to have that. See previous message(s). Will do Thanks, Graeme ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH v1 (WIP) 08/16] [Timer]Create new userland timer API
Signed-off-by: Graeme Russ graeme.r...@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); intdisable_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); +u32 time_resolution_ms(void); + /* $(CPU)/.../commproc.c */ intdpram_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); -intinit_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) +{ + 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@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH v1 (WIP) 08/16] [Timer]Create new userland timer API
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.r...@gmail.com wrote: Signed-off-by: Graeme Russ graeme.r...@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@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH v1 (WIP) 08/16] [Timer]Create new userland timer API
Hi Simon, On Wed, Jun 29, 2011 at 2:31 PM, Simon Glass s...@chromium.org wrote: 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: [snip] +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 [snip] + +u32 time_since_ms(u32 from) and here only one (which is what I expect). Can you please explain what I am missing? The fact I haven't tried to build it yet ;) I'll add that to the list of fixes for v2 - Thanks Regards, Graeme ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH v1 (WIP) 08/16] [Timer]Create new userland timer API
Hi Graeme, On Tue, Jun 28, 2011 at 9:36 PM, Graeme Russ graeme.r...@gmail.com wrote: Hi Simon, Can you please explain what I am missing? The fact I haven't tried to build it yet ;) Oh, OK. That explains the mystery :-) I haven't built it yet either but it certainly looks good. Regards, Simon I'll add that to the list of fixes for v2 - Thanks Regards, Graeme ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot