Change more uses of tsleep() to digi_delay() and make the loop counts more

sane.
This commit is contained in:
Brian Somers 2002-04-10 12:03:36 +00:00
parent 13c3fcc238
commit 6e5b29b08e
3 changed files with 22 additions and 19 deletions

View File

@ -221,11 +221,11 @@ digi_bcopy(const void *vfrom, void *vto, size_t sz)
return (1);
}
static void
void
digi_delay(struct digi_softc *sc, const char *txt)
{
if (cold)
DELAY(5000);
DELAY(1000);
else
tsleep(sc, PUSER | PCATCH, txt, 5);
}
@ -314,7 +314,7 @@ digi_init(struct digi_softc *sc)
for (i = 0; ((sc->pcibus ? PCIPORT : inb(sc->port)) &
FEPMASK) != FEPRST; i++) {
if (i > 1000) {
if (i > 100) {
log(LOG_ERR, "digi%d: %s init reset failed\n",
sc->res.unit, sc->name);
return (EIO);
@ -370,7 +370,7 @@ digi_init(struct digi_softc *sc)
for (i = 0; ((sc->pcibus ? PCIPORT : inb(sc->port)) & FEPMASK)
== resp; i++) {
if (i > 1000) {
if (i > 100) {
log(LOG_ERR, "digi%d: BIOS start failed\n",
sc->res.unit);
return (EIO);
@ -381,7 +381,7 @@ digi_init(struct digi_softc *sc)
DLOG(DIGIDB_INIT, (sc->dev, "BIOS started after %d us\n", i));
for (i = 0; vW(ptr) != *(u_short *)"GD"; i++) {
if (i > 2000) {
if (i > 200) {
log(LOG_ERR, "digi%d: BIOS boot failed "
"(0x%02x != 0x%02x)\n",
sc->res.unit, vW(ptr), *(u_short *)"GD");
@ -421,7 +421,7 @@ digi_init(struct digi_softc *sc)
outb(sc->port, FEPCLR | FEPMEM);
for (i = 0; W(ptr); i++) {
if (i > 10) {
if (i > 100) {
log(LOG_ERR, "digi%d: FEP/OS move failed\n",
sc->res.unit);
sc->hidewin(sc);
@ -506,7 +506,7 @@ digi_init(struct digi_softc *sc)
/* Now wait 'till the FEP/OS has booted */
for (i = 0; vW(ptr) != *(u_short *)"OS"; i++) {
if (i > 2000) {
if (i > 200) {
log(LOG_ERR, "digi%d: FEP/OS start failed "
"(0x%02x != 0x%02x)\n",
sc->res.unit, vW(ptr), *(u_short *)"OS");

View File

@ -215,3 +215,4 @@ const char *digi_errortxt(int _id);
int digi_attach(struct digi_softc *);
int digi_detach(device_t _dev);
int digi_shutdown(device_t _dev);
void digi_delay(struct digi_softc *_sc, const char *_txt);

View File

@ -112,12 +112,14 @@ digi_isa_check(struct digi_softc *sc)
/* Invasive probe - reset the card */
outb(sc->port, FEPRST);
for (i = 1000; DELAY(1), i >= 0; i--)
for (i = 0; i < 100; i++) {
if ((inb(sc->port) & FEPMASK) == FEPRST)
break;
if (i == -1)
digi_delay(sc, "digirst");
}
if (i == 100)
return (NULL);
DLOG(DIGIDB_INIT, (sc->dev, "got reset after %d us\n", 1000 - i));
DLOG(DIGIDB_INIT, (sc->dev, "got reset after %d delays\n", i));
ident = inb(sc->port);
@ -373,18 +375,17 @@ digi_isa_attach(device_t dev)
reset |= FEPMEM;
outb(sc->port, reset);
for (i = 10; DELAY(1), i >= 0; i--) {
for (i = 0; i < 100; i++) {
if ((inb(sc->port) & FEPMASK) == reset)
break;
tsleep(sc, PUSER | PCATCH, "digirst0", hz / 5);
digi_delay(sc, "digirst1");
}
if (i == -1) {
if (i == 100) {
device_printf(dev, "1st reset failed\n");
sc->hidewin(sc);
goto failed;
}
DLOG(DIGIDB_INIT, (sc->dev, "got reset after %d us\n",
(10 - i) * (hz / 5)));
DLOG(DIGIDB_INIT, (sc->dev, "got reset after %d delays\n", i));
if (sc->model != PCXI) {
t = (sc->pmem >> 8) & 0xffe0;
@ -396,17 +397,18 @@ digi_isa_attach(device_t dev)
if (sc->model == PCXI || sc->model == PCXE) {
outb(sc->port, FEPRST | FEPMEM);
for (i = 10000; DELAY(1), i >= 0; i--)
for (i = 0; i < 100; i++) {
if ((inb(sc->port) & FEPMASK) != FEPRST)
break;
if (i == -1) {
digi_delay(sc, "digirst2");
}
if (i == 100) {
device_printf(dev, "2nd reset failed (0x%02x)\n",
inb(sc->port));
sc->hidewin(sc);
goto failed;
}
DLOG(DIGIDB_INIT, (sc->dev, "got memory after %d us\n",
10000 - i));
DLOG(DIGIDB_INIT, (sc->dev, "got memory after %d delays\n", i));
}
DLOG(DIGIDB_INIT, (sc->dev, "short memory test\n"));