Move delay() to locore, so we control code generation and can avoid

touching memory locations whose caching disposition can perturb timings.
This commit is contained in:
pk 1996-04-29 21:08:37 +00:00
parent b926918576
commit fa75ea39e1
2 changed files with 33 additions and 21 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: clock.c,v 1.39 1996/04/23 19:25:25 pk Exp $ */
/* $NetBSD: clock.c,v 1.40 1996/04/29 21:08:37 pk Exp $ */
/*
* Copyright (c) 1992, 1993
@ -200,7 +200,7 @@ void myetheraddr __P((u_char *));
int chiptotime __P((int, int, int, int, int, int));
void timetochip __P((struct chiptime *));
static int timerblurb = 10; /* Guess a value; used before clock is attached */
int timerblurb = 10; /* Guess a value; used before clock is attached */
/*
* old clock match routine
@ -260,10 +260,15 @@ oclockattach(parent, self, aux)
i7->clk_intr_reg = INTERSIL_INTER_CSECONDS; /* 1/100 sec */
intersil_enable(i7); /* enable clock */
delay(10000); /* Probe 1/100 sec delay */
intersil_disable(i7); /* disable clock */
ireg = intersil_clear(i7); /* clear interrupts */
intersil_disable(i7); /* disable clock */
if (ireg & INTERSIL_INTER_PENDING)
break;
if (timerblurb > 10) {
printf("oclock: calibration failing; clamped at %d\n",
timerblurb);
break;
}
}
#else
/*
@ -589,24 +594,6 @@ myetheraddr(cp)
cp[5] = idp->id_ether[5];
}
/*
* Delay: wait for about n microseconds to pass.
* (note: we want this to be a "leaf" routine, so we incur no
* unpredictable delays by taking register window overflow traps).
*/
void
delay(n)
register unsigned int n;
{
register int i;
volatile int dummy;
while (n-- > 0)
for (i = 0; i < timerblurb; i++)
dummy = i;
}
/*
* Set up the real-time and statistics clocks. Leave stathz 0 only if
* no alternative timer is available.
@ -734,6 +721,8 @@ forward:
if (rom_console_input && cnrom())
setsoftint();
}
return (1);
}

View File

@ -5670,6 +5670,29 @@ ENTRY(microtime)
retl
st %o3, [%o0+4]
/*
* delay(n): wait for about n microseconds to pass.
*/
ENTRY(delay)
sethi %hi(_timerblurb), %o1 ! load calibration factor
ld [%o1 + %lo(_timerblurb)], %o1 ! computed in clock.c
1:
mov %o1, %o2 ! while (n-- != 0) {
tst %o0 ! i = timerblurb;
be 3f !
sub %o0, 1, %o0
2:
tst %o2 ! while (i-- != 0)
bne 2b ! <do nothing>;
sub %o2, 1, %o2
ba,a 1b ! }
3:
retl
nop
#if defined(KGDB) || defined(DDB)
/*
* Write all windows (user or otherwise), except the current one.