Browse Source

add get_timer to get accurate delay.

Change-Id: I99dbd6b3c84394744ca19759e7b7b8fcc6a180e7
Signed-off-by: QiaoChong <qiaochong@loongson.cn>
master
QiaoChong 5 years ago
parent
commit
7c2be0e59d
  1. 16
      pmon/arch/mips/mips_machdep.c
  2. 1
      sys/arch/mips/include/cpu.h

16
pmon/arch/mips/mips_machdep.c

@ -268,6 +268,22 @@ void delay1(int microseconds)
}; };
} }
unsigned int get_timer(unsigned int base)
{
unsigned int clkperms;
static unsigned int high, low;
unsigned int now;
clkperms = tgt_pipefreq() / 2 /1000;
now = CPU_GetCOUNT();
if (!base)
high = 0;
else
high += (now < low);
low = now;
return (high*0x100000000ULL+low)/clkperms - base;
}
u_int __res_randomid(void); u_int __res_randomid(void);
u_int u_int
__res_randomid() __res_randomid()

1
sys/arch/mips/include/cpu.h

@ -460,6 +460,7 @@ void flushicache __P((void *, size_t));
void flushdcache __P((void *, size_t)); void flushdcache __P((void *, size_t));
void syncicache __P((void *, size_t)); void syncicache __P((void *, size_t));
void delay __P((int)); void delay __P((int));
unsigned int get_timer(unsigned int base);
int CPU_ConfigCache __P((void)); int CPU_ConfigCache __P((void));
void CPU_SetWIRED __P((int)); void CPU_SetWIRED __P((int));

Loading…
Cancel
Save