/* subr_prf.c 4.19 81/11/20 */
* In case console is off,
* panicstr contains argument to last
* 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");
* Uprintf prints to the current user's terminal,
* guarantees not to sleep (so can be called by interrupt routines)
* and does no watermark checking - (so no verbose messages).
while ((c
= *fmt
++) != '%') {
/* THIS CODE IS VAX DEPENDENT IN HANDLING %l? AND %c */
case 'u': /* what a joke */
printn((u_long
)*adx
, b
, touser
);
for (i
= 24; i
>= 0; i
-= 8)
printn((u_long
)b
, *s
++, touser
);
for (; (c
= *s
) > 32; s
++)
* Printn prints a number n in base b.
* We don't use recursion to avoid deep kernel stacks.
if (b
== 10 && (int)n
< 0) {
*cp
++ = "0123456789abcdef"[n
%b
];
* Panic is called on unresolvable fatal errors.
* It prints "panic: mesg", and then reboots.
* If we are called twice, then we avoid trying to
* sync the disks as this often leads to recursive panics.
int bootopt
= panicstr
? RB_AUTOBOOT
: RB_AUTOBOOT
|RB_NOSYNC
;
printf("panic: %s\n", s
);
* Warn that a system table is full.
printf("%s: table is full\n", tab
);
* Hard error is the preface to plaintive error messages
* about failing disk transfers.
printf("%s%d%c: hard error sn%d ", cp
,
dkunit(bp
), 'a'+(minor(bp
->b_dev
)&07), bp
->b_blkno
);
* Print a character on console or users terminal.
* If destination is console then the last MSGBUFS characters
* are saved in msgbuf for inspection later.
register struct tty
*tp
= u
.u_ttyp
;
if (tp
&& (tp
->t_state
&CARR_ON
)) {
(void) ttyoutput('\r', tp
);
if (c
!= '\0' && c
!= '\r' && c
!= 0177 && mfpr(MAPEN
)) {
if (msgbuf
.msg_magic
!= MSG_MAGIC
) {
msgbuf
.msg_magic
= MSG_MAGIC
;
if (msgbuf
.msg_bufx
< 0 || msgbuf
.msg_bufx
>= MSG_BSIZE
)
msgbuf
.msg_bufc
[msgbuf
.msg_bufx
++] = c
;