This is the mail archive of the ecos-patches@sources.redhat.com mailing list for the eCos project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: MIPS Arch fix for hal_delay_us


There is a type-o it should be val2 for the second read, not val1
----- Original Message ----- 
From: "Tim Michals" <t.michals@attbi.com>
To: <ecos-patches@sources.redhat.com>
Sent: Wednesday, January 08, 2003 11:11 PM
Subject: MIPS Arch fix for hal_delay_us


> All,
> 
> In mips/arch/hal_misc.c function hal_delay_us uses counter/compare in the
> MIPS core.  If a HAL would like to use a different timer this causes an
> issue, due to how HAL_DELAY_US is defined.
> Several options that I could see:
> 1) replace the assembly with #define for reading the timer
> 2) hal_intr.h move the #define
> externC void hal_delay_us(int us);
> #define HAL_DELAY_US(n)          hal_delay_us(n)
> into the CYGHWR_HAL_CLOCK_CONTROL_DEFINED  and have the user supply the
> function and macro
> 
> Enclosed is a fix for 1) is this ok?  Is there another way?
> 
> Index: hal_misc.c
> ===================================================================
> RCS file: /cvs/ecos/ecos/packages/hal/mips/arch/current/src/hal_misc.c,v
> retrieving revision 1.29
> diff -u -5 -p -r1.29 hal_misc.c
> --- hal_misc.c 23 May 2002 23:03:22 -0000 1.29
> +++ hal_misc.c 9 Jan 2003 05:03:53 -0000
> @@ -374,14 +374,14 @@ hal_delay_us(int us)
> 
>          us -= us1;
> 
>          ticks = us1 * usticks;
> 
> -        asm volatile("mfc0 %0,$9;" : "=r"(val1));
> +  HAL_CLOCK_READ(&val1);
>          while (ticks > 0) {
>              do {
> -                asm volatile("mfc0 %0,$9;" : "=r"(val2));
> +                 HAL_CLOCK_READ(&val2);
>              } while (val1 == val2);
>              diff = val2 - val1;
>              if (diff < 0) diff += CYGNUM_HAL_RTC_PERIOD;
>              ticks -= diff;
>              val1 = val2;
> 


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]