New delay(), more carefully coded:
- Use explicit assembly; don't want the compiler optimizing things too much here. - Subtract 2 for each iteration of the loop, rather than 3. The loop consists of only 2 instructions (even the C version compiled to a loop of 2 instructions). The latter change has squashed a fairly annoying timing bug in the mii_bitbang module as used by the `ex' driver on my AlphaStation 500. XXX delay() should maybe be rewritten again, to use the rpcc instruction.
This commit is contained in:
parent
fafcf62fd6
commit
0aa48d5c55
@ -1,4 +1,4 @@
|
|||||||
/* $NetBSD: machdep.c,v 1.185 1999/11/30 19:31:56 thorpej Exp $ */
|
/* $NetBSD: machdep.c,v 1.186 1999/12/03 07:29:57 thorpej Exp $ */
|
||||||
|
|
||||||
/*-
|
/*-
|
||||||
* Copyright (c) 1998, 1999 The NetBSD Foundation, Inc.
|
* Copyright (c) 1998, 1999 The NetBSD Foundation, Inc.
|
||||||
@ -79,7 +79,7 @@
|
|||||||
|
|
||||||
#include <sys/cdefs.h> /* RCS ID & Copyright macro defns */
|
#include <sys/cdefs.h> /* RCS ID & Copyright macro defns */
|
||||||
|
|
||||||
__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.185 1999/11/30 19:31:56 thorpej Exp $");
|
__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.186 1999/12/03 07:29:57 thorpej Exp $");
|
||||||
|
|
||||||
#include <sys/param.h>
|
#include <sys/param.h>
|
||||||
#include <sys/systm.h>
|
#include <sys/systm.h>
|
||||||
@ -2014,8 +2014,16 @@ delay(n)
|
|||||||
{
|
{
|
||||||
long N = cycles_per_usec * (n);
|
long N = cycles_per_usec * (n);
|
||||||
|
|
||||||
while (N > 0) /* XXX */
|
/*
|
||||||
N -= 3; /* XXX */
|
* XXX Should be written to use RPCC?
|
||||||
|
*/
|
||||||
|
|
||||||
|
__asm __volatile(
|
||||||
|
"# The 2 corresponds to the insn count\n"
|
||||||
|
"1: subq %2, %1, %0 \n"
|
||||||
|
" bgt %0, 1b"
|
||||||
|
: "=r" (N)
|
||||||
|
: "i" (2), "0" (N));
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(COMPAT_OSF1) || 1 /* XXX */
|
#if defined(COMPAT_OSF1) || 1 /* XXX */
|
||||||
|
Loading…
Reference in New Issue
Block a user