* Copyright (c) 1982, 1986 Regents of the University of California.
* All rights reserved. The Berkeley software License Agreement
* specifies the terms and conditions for redistribution.
* @(#)prf.c 7.6 (Berkeley) 8/27/88
* Scaled down version of C Library printf.
* Used to print diagnostic information directly on console tty.
* Since it is not interrupt driven, all system activities are
* suspended. Printf should not be used for chit-chat.
* One additional format: %b is supported to decode error registers.
* printf("reg=%b\n", regval, "<base><arg>*");
* Where <base> is the output base expressed as a control character,
* e.g. \10 gives octal; \20 gives hex. Each arg is a sequence of
* characters, the first of which gives the bit number to be inspected
* (origin 1), and the next characters (up to a control character, i.e.
* a character <= 32), give the name of the register. Thus
* printf("reg=%b\n", 3, "\10\2BITTWO\1BITONE\n");
while ((c
= *fmt
++) != '%') {
/* THIS CODE IS VAX DEPENDENT IN HANDLING %l? AND %c */
case 'u': /* what a joke */
for (i
= 24; i
>= 0; i
-= 8)
for (; (c
= *s
) > 32; s
++)
* Print a character on console.
* Try waiting for the console tty to come ready,
* otherwise give up after a reasonable time.
while((mfpr(TXCS
)&TXCS_RDY
) == 0)
while((mfpr(RXCS
)&RXCS_DONE
) == 0)
if (c
!= '\b' && c
!= '\177')