|
|
1.1 ! root 1: /* ! 2: * @(#)spinning.c 1.1 86/02/03 Copyright (c) 1985 by Sun Microsystems, Inc. ! 3: */ ! 4: #include <sys/types.h> ! 5: #include <sys/inode.h> ! 6: #include "saio.h" ! 7: #include <machine/sunromvec.h> ! 8: ! 9: char msg_spinup[] = "\n\007Waiting for disk to spin up...\n\n\ ! 10: Please start it, if necessary, -OR- press any key to quit.\n\n"; ! 11: char msg_noctlr[] = "No controller at mbio %x\n"; ! 12: ! 13: /* ! 14: * Returns 0 if disk is apparently not spinning, after waiting awhile. ! 15: * Returns 1 if disk is already spinning on entry to this routine. ! 16: * Returns 2 if disk starts spinning sometime after entry to this routine. ! 17: * Returns <0 if (*isready)() returns a negative result at any time. ! 18: * ! 19: * If on initial entry, after a suitable delay, the disk is not spinning, ! 20: * we produce a message to remind the user to turn on the disk. ! 21: */ ! 22: int ! 23: isspinning(isready, addr, data) ! 24: int (*isready)(); ! 25: char *addr; ! 26: int data; ! 27: { ! 28: register int r; ! 29: long t; ! 30: ! 31: /* ! 32: * Wait for disk to spin up, if necessary. ! 33: */ ! 34: r = (*isready)(addr, data); ! 35: if (r < 0) ! 36: return r; /* Error */ ! 37: if (r) ! 38: return 1; /* Already spinning */ ! 39: DELAY(1000000); /* RTZ can take a long time */ ! 40: r = (*isready)(addr, data); ! 41: if (r < 0) ! 42: return r; ! 43: if (r) ! 44: return 2; /* Spun up while we waited */ ! 45: while ((*romp->v_mayget)() != -1) /* clear typeahead */ ! 46: ; ! 47: printf(msg_spinup); ! 48: t = (3*60*1000) + *romp->v_nmiclock; /* quitting time in 3 minutes */ ! 49: ! 50: for (;;) { ! 51: r = (*isready)(addr, data); /* Test disk */ ! 52: if (r < 0) ! 53: return r; ! 54: if (r) ! 55: return 2; ! 56: if ((*romp->v_mayget)() != -1) /* Test keyboard */ ! 57: return 0; ! 58: if (*romp->v_nmiclock > t) { /* Test timer */ ! 59: printf("Giving up...\n"); ! 60: return 0; ! 61: } ! 62: } /* Loop */ ! 63: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.