home *** CD-ROM | disk | FTP | other *** search
- /**
- *
- * Name KBQUEUE -- Return total and remaining capacity of
- * BIOS keyboard queue
- *
- * Synopsis avail = kbqueue (ptotal);
- *
- * int avail Number of available spaces in
- * type-ahead queue.
- *
- * int *ptotal Pointer to variable to receive
- * total capacity of queue.
- *
- * Description This function reports the total capacity of the of the
- * BIOS type-ahead buffer and the number of unfilled spaces
- * available in it.
- *
- * If the returned value ("avail") is to be used, then
- * KBQUEUE should probably be called with interrupts
- * turned off (via UTINTOFF). That will prevent further
- * keystrokes or other processes from changing the number
- * of available spaces. Once the value is used,
- * interrupts may be turned back on via UTINTON.
- *
- * KBQUEUE assumes that the BIOS type-ahead buffer is at
- * the standard location of 0x40:0x1e. It will probably
- * malfunction otherwise.
- *
- * Returns avail Number of available spaces in
- * type-ahead queue.
- * *ptotal Pointer to variable to receive
- * total size of queue.
- *
- * Version 6.00 (C)Copyright Blaise Computing Inc. 1987,1989
- *
- *
- **/
-
-
- #include <bkeybrd.h>
- #include <butil.h>
-
-
- int kbqueue (ptotal)
- int *ptotal;
- {
- unsigned int bufhead;
- unsigned int buftail;
- int avail, wason;
-
- *ptotal = KB_BUFACSIZE;
-
- bufhead = utpeekw (KB_BUFHEADADDR);
- buftail = utpeekw (KB_BUFTAILADDR);
-
- wason = utintoff ();
-
- if (bufhead > buftail)
- avail = (bufhead - buftail);
-
- else
- avail = (bufhead + KB_BUFSIZE - buftail);
-
- if (wason)
- utinton ();
-
- return ((avail >> 1) - 1);
- }