[ECOS] delay_us()

Jonathan Larmour jifl@eCosCentric.com
Tue Mar 25 12:22:00 GMT 2003


Motoya Kurotsu wrote:
> Hi all;
> 
> I would like to ask you how to think about the following issue.
> 
> The delay_us() take cares the large number of delay without kernel, 
> calling hal_delay_us() -- at least in mips architecture -- but not do so 
> with kernel. I think that it should not vary how to take care the large number 
> of delay depending on the use of kernel. Considering that some ethernet 
> drivers actually use this function with the value of several seconds, 

That's unfortunate, but I see it's true, or at least I see 100ms max for 
most now anyway, which is still quite a lot. However the CF driver and the 
82559 driver go up to 500ms and 2 *seconds* respectively. Do you have any 
other fixed examples of ethernet drivers and specific HAL platforms this 
has problems right now with?

> I think that delay_us() should take care of the large number of delay 
> as well with the kernel.

Hmm... really the drivers shouldn't be using such large values, and should 
instead loop with smaller values, i.e. for (i=0;i<10;i++) HAL_DELAY_US(10000);

> Please tell me how you think ahout it?

Not sure about adding a dependency on a 64-bit type in hal common code.

I think I'd try and fix the problem by adding loops where required, and 
then impose an API limit on this by also adding an assertion in hal_if.c's 
delay_us() to barf if some maximum value is exceeded, perhaps 100000 us, 
i.e. 100ms.

> The attachment is just an example to clarify the overflow issue.
> 
> 3/17/03
> Motoya Kurotsu
> Allied Telesis K.K.
> 
> --- hal_if.c.orig	Mon Mar 17 15:08:38 2003
> +++ hal_if.c	Mon Mar 17 15:39:38 2003
> @@ -125,10 +125,10 @@
>  #ifdef CYGPKG_KERNEL
>      {
>          cyg_int32 start, elapsed;
> -        cyg_int32 usec_ticks, slice;
> +        cyg_int64 usec_ticks, slice;
>  
>          // How many ticks total we should wait for.
> -        usec_ticks = usecs*CYGNUM_KERNEL_COUNTERS_RTC_PERIOD;
> +        usec_ticks = (cyg_int64)usecs*CYGNUM_KERNEL_COUNTERS_RTC_PERIOD;
>          usec_ticks /= CYGNUM_HAL_RTC_NUMERATOR/CYGNUM_HAL_RTC_DENOMINATOR/1000;
>  
>          do {
> 


-- 
eCosCentric    http://www.eCosCentric.com/    The eCos and RedBoot experts
--[ "You can complain because roses have thorns, or you ]--
--[  can rejoice because thorns have roses." -Lincoln   ]-- Opinions==mine


-- 
Before posting, please read the FAQ: http://sources.redhat.com/fom/ecos
and search the list archive: http://sources.redhat.com/ml/ecos-discuss



More information about the Ecos-discuss mailing list