panic() cleanup.
this change
- makes panic() variadic, doing full printf() formatting -
no more NO_NUM, and no more separate printf() statements
needed to print extra info (or something in hex) before panicing
- unifies panic() - same panic() name and usage for everyone -
vm, kernel and rest have different names/syntax currently
in order to implement their own luxuries, but no longer
- throws out the 1st argument, to make source less noisy.
the panic() in syslib retrieves the server name from the kernel
so it should be clear enough who is panicing; e.g.
panic("sigaction failed: %d", errno);
looks like:
at_wini(73130): panic: sigaction failed: 0
syslib:panic.c: stacktrace: 0x74dc 0x2025 0x100a
- throws out report() - printf() is more convenient and powerful
- harmonizes/fixes the use of panic() - there were a few places
that used printf-style formatting (didn't work) and newlines
(messes up the formatting) in panic()
- throws out a few per-server panic() functions
- cleans up a tie-in of tty with panic()
merging printf() and panic() statements to be done incrementally.
This commit is contained in:
@@ -103,7 +103,6 @@ SRCS= \
|
||||
env_prefix.c \
|
||||
fkey_ctl.c \
|
||||
tsc_util.c \
|
||||
report.c \
|
||||
read_tsc.S \
|
||||
read_tsc_64.c \
|
||||
ser_putc.c \
|
||||
@@ -111,6 +110,7 @@ SRCS= \
|
||||
sys_hz.c \
|
||||
timing.c \
|
||||
profile_extern.c \
|
||||
profile.c
|
||||
profile.c \
|
||||
vprintf.c
|
||||
|
||||
.include <minix.lib.mk>
|
||||
|
||||
@@ -68,7 +68,7 @@ void *alloc_contig(size_t len, int flags, phys_bytes *phys)
|
||||
|
||||
/* Get physical address, if requested. */
|
||||
if(phys != NULL && sys_umap_data_fb(SELF, buf, len, phys) != OK)
|
||||
panic("alloc_contig.c", "sys_umap_data_fb failed", NO_NUM);
|
||||
panic("sys_umap_data_fb failed");
|
||||
|
||||
return (void *) buf;
|
||||
}
|
||||
|
||||
@@ -9,6 +9,5 @@
|
||||
#include <minix/sysutil.h>
|
||||
|
||||
void __bad_assertion(const char *mess) {
|
||||
printf("%s", mess);
|
||||
panic(NULL, NULL, NO_NUM);
|
||||
panic("%s", mess);
|
||||
}
|
||||
|
||||
@@ -79,7 +79,7 @@ int fl;
|
||||
/* Tell the kernel to stop processing */
|
||||
r= senda(NULL, 0);
|
||||
if (r != OK)
|
||||
panic(__FILE__, "asynsend: senda failed", r);
|
||||
panic("asynsend: senda failed: %d", r);
|
||||
|
||||
dst_ind= 0;
|
||||
for (src_ind= first_slot; src_ind<next_slot; src_ind++)
|
||||
@@ -112,7 +112,7 @@ int fl;
|
||||
first_slot= 0;
|
||||
next_slot= dst_ind;
|
||||
if (next_slot >= ASYN_NR)
|
||||
panic(__FILE__, "asynsend: msgtable full", NO_NUM);
|
||||
panic("asynsend: msgtable full");
|
||||
}
|
||||
|
||||
fl |= AMF_VALID;
|
||||
|
||||
@@ -14,6 +14,6 @@ char *key; /* environment variable whose value is bogus */
|
||||
printf("WARNING: env_get_param() failed in env_panic(): %d\n", s);
|
||||
}
|
||||
printf("Bad environment setting: '%s = %s'\n", key, value);
|
||||
panic("","", NO_NUM);
|
||||
panic("");
|
||||
}
|
||||
|
||||
|
||||
@@ -3,189 +3,19 @@
|
||||
*/
|
||||
#define nil 0
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
#include <stddef.h>
|
||||
#include <limits.h>
|
||||
|
||||
#define isdigit(c) ((unsigned) ((c) - '0') < (unsigned) 10)
|
||||
|
||||
#if !__STDC__
|
||||
/* Classic C stuff, ignore. */
|
||||
void kputc();
|
||||
int printf(fmt) char *fmt;
|
||||
#else
|
||||
|
||||
/* Printf() uses kputc() to print characters. */
|
||||
void kputc(int c);
|
||||
|
||||
#define count_kputc(c) do { charcount++; kputc(c); } while(0)
|
||||
|
||||
int printf(const char *fmt, ...)
|
||||
#endif
|
||||
{
|
||||
int c, charcount = 0;
|
||||
enum { LEFT, RIGHT } adjust;
|
||||
enum { LONG, INT } intsize;
|
||||
int fill;
|
||||
int width, max, len, base;
|
||||
static char X2C_tab[]= "0123456789ABCDEF";
|
||||
static char x2c_tab[]= "0123456789abcdef";
|
||||
char *x2c;
|
||||
char *p;
|
||||
long i;
|
||||
unsigned long u;
|
||||
char temp[8 * sizeof(long) / 3 + 2];
|
||||
int n;
|
||||
va_list ap;
|
||||
|
||||
va_list argp;
|
||||
va_start(ap, fmt);
|
||||
n = vprintf(fmt, ap);
|
||||
va_end(ap);
|
||||
|
||||
va_start(argp, fmt);
|
||||
|
||||
while ((c= *fmt++) != 0) {
|
||||
if (c != '%') {
|
||||
/* Ordinary character. */
|
||||
count_kputc(c);
|
||||
continue;
|
||||
}
|
||||
|
||||
/* Format specifier of the form:
|
||||
* %[adjust][fill][width][.max]keys
|
||||
*/
|
||||
c= *fmt++;
|
||||
|
||||
adjust= RIGHT;
|
||||
if (c == '-') {
|
||||
adjust= LEFT;
|
||||
c= *fmt++;
|
||||
}
|
||||
|
||||
fill= ' ';
|
||||
if (c == '0') {
|
||||
fill= '0';
|
||||
c= *fmt++;
|
||||
}
|
||||
|
||||
width= 0;
|
||||
if (c == '*') {
|
||||
/* Width is specified as an argument, e.g. %*d. */
|
||||
width= va_arg(argp, int);
|
||||
c= *fmt++;
|
||||
} else
|
||||
if (isdigit(c)) {
|
||||
/* A number tells the width, e.g. %10d. */
|
||||
do {
|
||||
width= width * 10 + (c - '0');
|
||||
} while (isdigit(c= *fmt++));
|
||||
}
|
||||
|
||||
max= INT_MAX;
|
||||
if (c == '.') {
|
||||
/* Max field length coming up. */
|
||||
if ((c= *fmt++) == '*') {
|
||||
max= va_arg(argp, int);
|
||||
c= *fmt++;
|
||||
} else
|
||||
if (isdigit(c)) {
|
||||
max= 0;
|
||||
do {
|
||||
max= max * 10 + (c - '0');
|
||||
} while (isdigit(c= *fmt++));
|
||||
}
|
||||
}
|
||||
|
||||
/* Set a few flags to the default. */
|
||||
x2c= x2c_tab;
|
||||
i= 0;
|
||||
base= 10;
|
||||
intsize= INT;
|
||||
if (c == 'l' || c == 'L') {
|
||||
/* "Long" key, e.g. %ld. */
|
||||
intsize= LONG;
|
||||
c= *fmt++;
|
||||
}
|
||||
if (c == 0) break;
|
||||
|
||||
switch (c) {
|
||||
/* Decimal. */
|
||||
case 'd':
|
||||
i= intsize == LONG ? va_arg(argp, long)
|
||||
: va_arg(argp, int);
|
||||
u= i < 0 ? -i : i;
|
||||
goto int2ascii;
|
||||
|
||||
/* Octal. */
|
||||
case 'o':
|
||||
base= 010;
|
||||
goto getint;
|
||||
|
||||
/* Pointer, interpret as %X or %lX. */
|
||||
case 'p':
|
||||
if (sizeof(char *) > sizeof(int)) intsize= LONG;
|
||||
|
||||
/* Hexadecimal. %X prints upper case A-F, not %lx. */
|
||||
case 'X':
|
||||
x2c= X2C_tab;
|
||||
case 'x':
|
||||
base= 0x10;
|
||||
goto getint;
|
||||
|
||||
/* Unsigned decimal. */
|
||||
case 'u':
|
||||
getint:
|
||||
u= intsize == LONG ? va_arg(argp, unsigned long)
|
||||
: va_arg(argp, unsigned int);
|
||||
int2ascii:
|
||||
p= temp + sizeof(temp)-1;
|
||||
*p= 0;
|
||||
do {
|
||||
*--p= x2c[(ptrdiff_t) (u % base)];
|
||||
} while ((u /= base) > 0);
|
||||
goto string_length;
|
||||
|
||||
/* A character. */
|
||||
case 'c':
|
||||
p= temp;
|
||||
*p= va_arg(argp, int);
|
||||
len= 1;
|
||||
goto string_print;
|
||||
|
||||
/* Simply a percent. */
|
||||
case '%':
|
||||
p= temp;
|
||||
*p= '%';
|
||||
len= 1;
|
||||
goto string_print;
|
||||
|
||||
/* A string. The other cases will join in here. */
|
||||
case 's':
|
||||
p= va_arg(argp, char *);
|
||||
|
||||
string_length:
|
||||
for (len= 0; p[len] != 0 && len < max; len++) {}
|
||||
|
||||
string_print:
|
||||
width -= len;
|
||||
if (i < 0) width--;
|
||||
if (fill == '0' && i < 0) count_kputc('-');
|
||||
if (adjust == RIGHT) {
|
||||
while (width > 0) { count_kputc(fill); width--; }
|
||||
}
|
||||
if (fill == ' ' && i < 0) count_kputc('-');
|
||||
while (len > 0) { count_kputc((unsigned char) *p++); len--; }
|
||||
while (width > 0) { count_kputc(fill); width--; }
|
||||
break;
|
||||
|
||||
/* Unrecognized format key, echo it back. */
|
||||
default:
|
||||
count_kputc('%');
|
||||
count_kputc(c);
|
||||
}
|
||||
}
|
||||
|
||||
/* Mark the end with a null (should be something else, like -1). */
|
||||
kputc(0);
|
||||
va_end(argp);
|
||||
return charcount;
|
||||
return n;
|
||||
}
|
||||
|
||||
/*
|
||||
* $PchId: kprintf.c,v 1.5 1996/04/11 06:59:05 philip Exp $
|
||||
*/
|
||||
|
||||
@@ -1,19 +1,15 @@
|
||||
#include <stdlib.h>
|
||||
#include <signal.h>
|
||||
#include <unistd.h>
|
||||
#include <stdarg.h>
|
||||
#include <minix/sysutil.h>
|
||||
|
||||
#include "syslib.h"
|
||||
|
||||
int panicing= 0;
|
||||
|
||||
/*===========================================================================*
|
||||
* panic *
|
||||
* panic *
|
||||
*===========================================================================*/
|
||||
PUBLIC void panic(who, mess, num)
|
||||
char *who; /* server identification */
|
||||
char *mess; /* message format string */
|
||||
int num; /* number to go with format string */
|
||||
PUBLIC void panic(const char *fmt, ...)
|
||||
{
|
||||
/* Something awful has happened. Panics are caused when an internal
|
||||
* inconsistency is detected, e.g., a programming error or illegal
|
||||
@@ -23,24 +19,29 @@ int num; /* number to go with format string */
|
||||
endpoint_t me = NONE;
|
||||
char name[20];
|
||||
void (*suicide)(void);
|
||||
static int panicing= 0;
|
||||
va_list args;
|
||||
|
||||
if(panicing) return;
|
||||
panicing= 1;
|
||||
|
||||
if(sys_whoami(&me, name, sizeof(name)) == OK && me != NONE)
|
||||
printf("%s(%d): ", name, me);
|
||||
printf("%s(%d): panic: ", name, me);
|
||||
else
|
||||
printf("(sys_whoami failed): ");
|
||||
printf("(sys_whoami failed): panic: ");
|
||||
|
||||
if(fmt) {
|
||||
va_start(args, fmt);
|
||||
vprintf(fmt, args);
|
||||
va_end(fmt);
|
||||
} else {
|
||||
printf("no message\n");
|
||||
}
|
||||
printf("\n");
|
||||
|
||||
printf("syslib:panic.c: stacktrace: ");
|
||||
util_stacktrace();
|
||||
|
||||
if (NULL != who && NULL != mess) {
|
||||
if (num != NO_NUM) {
|
||||
printf("Panic in %s: %s: %d\n", who, mess, num);
|
||||
} else {
|
||||
printf("Panic in %s: %s\n", who, mess);
|
||||
}
|
||||
}
|
||||
|
||||
/* Try exit */
|
||||
_exit(1);
|
||||
|
||||
|
||||
@@ -22,10 +22,10 @@ int port;
|
||||
|
||||
r= sendrec(pci_procnr, &m);
|
||||
if (r != 0)
|
||||
panic("syslib/" __FILE__, "pci_attr_r16: can't talk to PCI", r);
|
||||
panic("pci_attr_r16: can't talk to PCI: %d", r);
|
||||
|
||||
if (m.m_type != 0)
|
||||
panic("syslib/" __FILE__, "pci_attr_r16: got bad reply from PCI", m.m_type);
|
||||
panic("pci_attr_r16: got bad reply from PCI: %d", m.m_type);
|
||||
|
||||
return m.m2_l1;
|
||||
}
|
||||
|
||||
@@ -22,10 +22,10 @@ int port;
|
||||
|
||||
r= sendrec(pci_procnr, &m);
|
||||
if (r != 0)
|
||||
panic("syslib/" __FILE__, "pci_attr_r32: can't talk to PCI", r);
|
||||
panic("pci_attr_r32: can't talk to PCI: %d", r);
|
||||
|
||||
if (m.m_type != 0)
|
||||
panic("syslib/" __FILE__, "pci_attr_r32: got bad reply from PCI", m.m_type);
|
||||
panic("pci_attr_r32: got bad reply from PCI: %d", m.m_type);
|
||||
|
||||
return m.m2_l1;
|
||||
}
|
||||
|
||||
@@ -22,10 +22,10 @@ int port;
|
||||
|
||||
r= sendrec(pci_procnr, &m);
|
||||
if (r != 0)
|
||||
panic("syslib/" __FILE__, "pci_attr_r8: can't talk to PCI", r);
|
||||
panic("pci_attr_r8: can't talk to PCI: %d", r);
|
||||
|
||||
if (m.m_type != 0)
|
||||
panic("syslib/" __FILE__, "pci_attr_r8: got bad reply from PCI", m.m_type);
|
||||
panic("pci_attr_r8: got bad reply from PCI: %d", m.m_type);
|
||||
|
||||
return m.m2_l1;
|
||||
}
|
||||
|
||||
@@ -24,9 +24,9 @@ u16_t value;
|
||||
|
||||
r= sendrec(pci_procnr, &m);
|
||||
if (r != 0)
|
||||
panic("syslib/" __FILE__, "pci_attr_w16: can't talk to PCI", r);
|
||||
panic("pci_attr_w16: can't talk to PCI: %d", r);
|
||||
|
||||
if (m.m_type != 0)
|
||||
panic("syslib/" __FILE__, "pci_attr_w16: got bad reply from PCI", m.m_type);
|
||||
panic("pci_attr_w16: got bad reply from PCI: %d", m.m_type);
|
||||
}
|
||||
|
||||
|
||||
@@ -24,9 +24,9 @@ u32_t value;
|
||||
|
||||
r= sendrec(pci_procnr, &m);
|
||||
if (r != 0)
|
||||
panic("syslib/" __FILE__, "pci_attr_w32: can't talk to PCI", r);
|
||||
panic("pci_attr_w32: can't talk to PCI: %d", r);
|
||||
|
||||
if (m.m_type != 0)
|
||||
panic("syslib/" __FILE__, "pci_attr_w32: got bad reply from PCI", m.m_type);
|
||||
panic("pci_attr_w32: got bad reply from PCI: %d", m.m_type);
|
||||
}
|
||||
|
||||
|
||||
@@ -24,9 +24,9 @@ u8_t value;
|
||||
|
||||
r= sendrec(pci_procnr, &m);
|
||||
if (r != 0)
|
||||
panic("syslib/" __FILE__, "pci_attr_w8: can't talk to PCI", r);
|
||||
panic("pci_attr_w8: can't talk to PCI: %d", r);
|
||||
|
||||
if (m.m_type != 0)
|
||||
panic("syslib/" __FILE__, "pci_attr_w8: got bad reply from PCI", m.m_type);
|
||||
panic("pci_attr_w8: got bad reply from PCI: %d", m.m_type);
|
||||
}
|
||||
|
||||
|
||||
@@ -24,9 +24,7 @@ endpoint_t proc_ep;
|
||||
r= ds_retrieve_label_num("pci", &u32);
|
||||
if (r != 0)
|
||||
{
|
||||
panic("syslib/" __FILE__,
|
||||
"pci_del_acl: _pm_findproc failed for 'pci'",
|
||||
r);
|
||||
panic("pci_del_acl: _pm_findproc failed for 'pci': %d", r);
|
||||
}
|
||||
pci_procnr = u32;
|
||||
}
|
||||
@@ -37,7 +35,7 @@ endpoint_t proc_ep;
|
||||
|
||||
r= sendrec(pci_procnr, &m);
|
||||
if (r != 0)
|
||||
panic("syslib/" __FILE__, "pci_del_acl: can't talk to PCI", r);
|
||||
panic("pci_del_acl: can't talk to PCI: %d", r);
|
||||
|
||||
return m.m_type;
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@ u16_t did;
|
||||
r= sendrec(pci_procnr, &m);
|
||||
cpf_revoke(gid);
|
||||
if (r != 0)
|
||||
panic("syslib/" __FILE__, "pci_dev_name: can't talk to PCI", r);
|
||||
panic("pci_dev_name: can't talk to PCI: %d", r);
|
||||
|
||||
if (m.m_type == ENOENT)
|
||||
{
|
||||
@@ -47,7 +47,7 @@ u16_t did;
|
||||
return NULL; /* No name for this device */
|
||||
}
|
||||
if (m.m_type != 0)
|
||||
panic("syslib/" __FILE__, "pci_dev_name: got bad reply from PCI", m.m_type);
|
||||
panic("pci_dev_name: got bad reply from PCI: %d", m.m_type);
|
||||
|
||||
name[sizeof(name)-1]= '\0'; /* Make sure that the string is NUL
|
||||
* terminated.
|
||||
|
||||
@@ -25,7 +25,7 @@ int *devindp;
|
||||
|
||||
r= sendrec(pci_procnr, &m);
|
||||
if (r != 0)
|
||||
panic("syslib/" __FILE__, "pci_find_dev: can't talk to PCI", r);
|
||||
panic("pci_find_dev: can't talk to PCI: %d", r);
|
||||
|
||||
if (m.m_type == 1)
|
||||
{
|
||||
@@ -35,7 +35,7 @@ int *devindp;
|
||||
return 1;
|
||||
}
|
||||
if (m.m_type != 0)
|
||||
panic("syslib/" __FILE__, "pci_find_dev: got bad reply from PCI", m.m_type);
|
||||
panic("pci_find_dev: got bad reply from PCI: %d", m.m_type);
|
||||
|
||||
printf("pci_find_dev: got nothing\n");
|
||||
return 0;
|
||||
|
||||
@@ -20,7 +20,7 @@ u16_t *didp;
|
||||
m.m_type= BUSC_PCI_FIRST_DEV;
|
||||
r= sendrec(pci_procnr, &m);
|
||||
if (r != 0)
|
||||
panic("syslib/" __FILE__, "pci_first_dev: can't talk to PCI", r);
|
||||
panic("pci_first_dev: can't talk to PCI: %d", r);
|
||||
if (m.m_type == 1)
|
||||
{
|
||||
*devindp= m.m1_i1;
|
||||
@@ -33,7 +33,7 @@ u16_t *didp;
|
||||
return 1;
|
||||
}
|
||||
if (m.m_type != 0)
|
||||
panic("syslib/" __FILE__, "pci_first_dev: got bad reply from PCI", m.m_type);
|
||||
panic("pci_first_dev: got bad reply from PCI: %d", m.m_type);
|
||||
|
||||
#if DEBUG
|
||||
printf("pci_first_dev: got nothing\n");
|
||||
|
||||
@@ -22,10 +22,10 @@ u16_t *didp;
|
||||
|
||||
r= sendrec(pci_procnr, &m);
|
||||
if (r != 0)
|
||||
panic("syslib/" __FILE__, "pci_ids: can't talk to PCI", r);
|
||||
panic("pci_ids: can't talk to PCI: %d", r);
|
||||
|
||||
if (m.m_type != 0)
|
||||
panic("syslib/" __FILE__, "pci_ids: got bad reply from PCI", m.m_type);
|
||||
panic("pci_ids: got bad reply from PCI: %d", m.m_type);
|
||||
*vidp= m.m1_i1;
|
||||
*didp= m.m1_i2;
|
||||
printf("pci_ids: %04x/%04x\n", *vidp, *didp);
|
||||
|
||||
@@ -24,7 +24,7 @@ char *name;
|
||||
|
||||
r= ds_retrieve_label_num("pci", &u32);
|
||||
if (r != 0)
|
||||
panic("syslib/" __FILE__, "pci_init1: ds_retrieve_label_num failed for 'pci'", r);
|
||||
panic("pci_init1: ds_retrieve_label_num failed for 'pci': %d", r);
|
||||
pci_procnr= u32;
|
||||
|
||||
m.m_type= BUSC_PCI_INIT;
|
||||
@@ -39,8 +39,8 @@ char *name;
|
||||
}
|
||||
r= sendrec(pci_procnr, &m);
|
||||
if (r != 0)
|
||||
panic("syslib/" __FILE__, "pci_init1: can't talk to PCI", r);
|
||||
panic("pci_init1: can't talk to PCI: %d", r);
|
||||
if (m.m_type != 0)
|
||||
panic("syslib/" __FILE__, "pci_init1: got bad reply from PCI", m.m_type);
|
||||
panic("pci_init1: got bad reply from PCI: %d", m.m_type);
|
||||
}
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ u16_t *didp;
|
||||
|
||||
r= sendrec(pci_procnr, &m);
|
||||
if (r != 0)
|
||||
panic("syslib/" __FILE__, "pci_next_dev: can't talk to PCI", r);
|
||||
panic("pci_next_dev: can't talk to PCI: %d", r);
|
||||
|
||||
if (m.m_type == 1)
|
||||
{
|
||||
@@ -36,7 +36,7 @@ u16_t *didp;
|
||||
return 1;
|
||||
}
|
||||
if (m.m_type != 0)
|
||||
panic("syslib/" __FILE__, "pci_next_dev: got bad reply from PCI", m.m_type);
|
||||
panic("pci_next_dev: got bad reply from PCI: %d", m.m_type);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -20,12 +20,11 @@ u8_t busnr;
|
||||
|
||||
r= sendrec(pci_procnr, &m);
|
||||
if (r != 0)
|
||||
panic("syslib/" __FILE__, "pci_rescan_bus: can't talk to PCI", r);
|
||||
panic("pci_rescan_bus: can't talk to PCI: %d", r);
|
||||
|
||||
if (m.m_type != 0)
|
||||
{
|
||||
panic("syslib/" __FILE__, "pci_rescan_bus: got bad reply from PCI",
|
||||
m.m_type);
|
||||
panic("pci_rescan_bus: got bad reply from PCI: %d", m.m_type);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -20,10 +20,10 @@ int devind;
|
||||
|
||||
r= sendrec(pci_procnr, &m);
|
||||
if (r != 0)
|
||||
panic("syslib/" __FILE__, "pci_reserve: can't talk to PCI", r);
|
||||
panic("pci_reserve: can't talk to PCI: %d", r);
|
||||
|
||||
if (m.m_type != 0)
|
||||
panic("syslib/" __FILE__, "pci_reserve: got bad reply from PCI", m.m_type);
|
||||
panic("pci_reserve: got bad reply from PCI: %d", m.m_type);
|
||||
}
|
||||
|
||||
/*===========================================================================*
|
||||
|
||||
@@ -25,9 +25,7 @@ struct rs_pci *rs_pci;
|
||||
r= ds_retrieve_label_num("pci", &u32);
|
||||
if (r != 0)
|
||||
{
|
||||
panic("syslib/" __FILE__,
|
||||
"pci_set_acl: ds_retrieve_label_num failed for 'pci'",
|
||||
r);
|
||||
panic("pci_set_acl: ds_retrieve_label_num failed for 'pci': %d", r);
|
||||
}
|
||||
pci_procnr = u32;
|
||||
}
|
||||
@@ -48,7 +46,7 @@ struct rs_pci *rs_pci;
|
||||
r= sendrec(pci_procnr, &m);
|
||||
cpf_revoke(gid);
|
||||
if (r != 0)
|
||||
panic("syslib/" __FILE__, "pci_set_acl: can't talk to PCI", r);
|
||||
panic("pci_set_acl: can't talk to PCI: %d", r);
|
||||
|
||||
return m.m_type;
|
||||
}
|
||||
|
||||
@@ -35,10 +35,10 @@ int devind;
|
||||
r= sendrec(pci_procnr, &m);
|
||||
cpf_revoke(gid);
|
||||
if (r != 0)
|
||||
panic("syslib/" __FILE__, "pci_slot_name: can't talk to PCI", r);
|
||||
panic("pci_slot_name: can't talk to PCI: %d", r);
|
||||
|
||||
if (m.m_type != 0)
|
||||
panic("syslib/" __FILE__, "pci_slot_name: got bad reply from PCI", m.m_type);
|
||||
panic("pci_slot_name: got bad reply from PCI: %d", m.m_type);
|
||||
|
||||
name[sizeof(name)-1]= '\0'; /* Make sure that the string is NUL
|
||||
* terminated.
|
||||
|
||||
@@ -1,20 +0,0 @@
|
||||
#include "sysutil.h"
|
||||
|
||||
/*===========================================================================*
|
||||
* report *
|
||||
*===========================================================================*/
|
||||
PUBLIC void report(who, mess, num)
|
||||
char *who; /* server identification */
|
||||
char *mess; /* message format to print */
|
||||
int num; /* number to go with the message */
|
||||
{
|
||||
/* Display a message for a server. */
|
||||
|
||||
if (num != NO_NUM) {
|
||||
printf("%s: %s %d\n", who, mess, num);
|
||||
} else {
|
||||
printf("%s: %s\n", who, mess);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -48,22 +48,22 @@ PUBLIC void sef_startup()
|
||||
/* Intercept SEF Init requests. */
|
||||
if(sef_self_endpoint == RS_PROC_NR) {
|
||||
if((r = do_sef_rs_init()) != OK) {
|
||||
panic("SEF", "unable to complete init", r);
|
||||
panic("unable to complete init: %d", r);
|
||||
}
|
||||
}
|
||||
else {
|
||||
message m;
|
||||
|
||||
if((r = receive(RS_PROC_NR, &m)) != OK) {
|
||||
panic("SEF", "unable to receive from RS", r);
|
||||
panic("unable to receive from RS: %d", r);
|
||||
}
|
||||
if(IS_SEF_INIT_REQUEST(&m)) {
|
||||
if((r = do_sef_init_request(&m)) != OK) {
|
||||
panic("SEF", "unable to process init request", r);
|
||||
panic("unable to process init request: %d", r);
|
||||
}
|
||||
}
|
||||
else {
|
||||
panic("SEF", "unable to receive init request", NO_NUM);
|
||||
panic("unable to receive init request");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -122,7 +122,7 @@ PUBLIC void sef_lu_ready(int result)
|
||||
m.RS_LU_RESULT = result;
|
||||
r = sendrec(RS_PROC_NR, &m);
|
||||
if ( r != OK) {
|
||||
panic("SEF", "sendrec failed", r);
|
||||
panic("sendrec failed: %d", r);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ void util_timer_start(util_timingdata_t *timingdata, char *name)
|
||||
}
|
||||
|
||||
if (timingdata->starttimes[HIGHCOUNT]) {
|
||||
panic(__FILE__, "restart timer?", NO_NUM);
|
||||
panic("restart timer?");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@ void util_timer_end(util_timingdata_t *timingdata)
|
||||
|
||||
read_tsc(&h, &l);
|
||||
if (!timingdata->starttimes[HIGHCOUNT]) {
|
||||
panic(__FILE__, "timer stopped but not started", NO_NUM);
|
||||
panic("timer stopped but not started");
|
||||
return;
|
||||
}
|
||||
if (timingdata->starttimes[HIGHCOUNT] == h) {
|
||||
@@ -73,7 +73,7 @@ void util_timer_end(util_timingdata_t *timingdata)
|
||||
timingdata->binsize;
|
||||
if (bin < 0 || bin >= TIMING_POINTS) {
|
||||
/* not serious, but can't happen, so shouldn't */
|
||||
panic(__FILE__, "bin out of range", bin);
|
||||
panic("bin out of range: %d", bin);
|
||||
} else {
|
||||
timingdata->lock_timings[bin]++;
|
||||
timingdata->measurements++;
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
if(!calibrated) { \
|
||||
int r; \
|
||||
if((r=tsc_calibrate()) != OK) \
|
||||
panic(__FILE__, "calibrate failed\n", r); \
|
||||
panic("calibrate failed: %d", r); \
|
||||
}
|
||||
|
||||
static u32_t calib_tsc, Hz = 0;
|
||||
@@ -48,9 +48,7 @@ tsc_calibrate(void)
|
||||
|
||||
diff = sub64(end, start);
|
||||
if(ex64hi(diff) != 0)
|
||||
panic(__FILE__,
|
||||
"tsc_calibrate: CALIBRATE_TICKS too high "
|
||||
"for TSC frequency\n", NO_NUM);
|
||||
panic("tsc_calibrate: CALIBRATE_TICKS too high for TSC frequency");
|
||||
calib_tsc = ex64lo(diff);
|
||||
#if 0
|
||||
printf("tsc_calibrate: "
|
||||
|
||||
175
lib/libsys/vprintf.c
Normal file
175
lib/libsys/vprintf.c
Normal file
@@ -0,0 +1,175 @@
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <stddef.h>
|
||||
#include <ctype.h>
|
||||
#include <limits.h>
|
||||
|
||||
/* vprintf() uses kputc() to print characters. */
|
||||
void kputc(int c);
|
||||
|
||||
#define count_kputc(c) do { charcount++; kputc(c); } while(0)
|
||||
|
||||
int vprintf(const char *fmt, va_list argp)
|
||||
{
|
||||
int c, charcount = 0;
|
||||
enum { LEFT, RIGHT } adjust;
|
||||
enum { LONG, INT } intsize;
|
||||
int fill;
|
||||
int width, max, len, base;
|
||||
static char X2C_tab[]= "0123456789ABCDEF";
|
||||
static char x2c_tab[]= "0123456789abcdef";
|
||||
char *x2c;
|
||||
char *p;
|
||||
long i;
|
||||
unsigned long u;
|
||||
char temp[8 * sizeof(long) / 3 + 2];
|
||||
|
||||
while ((c= *fmt++) != 0) {
|
||||
if (c != '%') {
|
||||
/* Ordinary character. */
|
||||
count_kputc(c);
|
||||
continue;
|
||||
}
|
||||
|
||||
/* Format specifier of the form:
|
||||
* %[adjust][fill][width][.max]keys
|
||||
*/
|
||||
c= *fmt++;
|
||||
|
||||
adjust= RIGHT;
|
||||
if (c == '-') {
|
||||
adjust= LEFT;
|
||||
c= *fmt++;
|
||||
}
|
||||
|
||||
fill= ' ';
|
||||
if (c == '0') {
|
||||
fill= '0';
|
||||
c= *fmt++;
|
||||
}
|
||||
|
||||
width= 0;
|
||||
if (c == '*') {
|
||||
/* Width is specified as an argument, e.g. %*d. */
|
||||
width= va_arg(argp, int);
|
||||
c= *fmt++;
|
||||
} else
|
||||
if (isdigit(c)) {
|
||||
/* A number tells the width, e.g. %10d. */
|
||||
do {
|
||||
width= width * 10 + (c - '0');
|
||||
} while (isdigit(c= *fmt++));
|
||||
}
|
||||
|
||||
max= INT_MAX;
|
||||
if (c == '.') {
|
||||
/* Max field length coming up. */
|
||||
if ((c= *fmt++) == '*') {
|
||||
max= va_arg(argp, int);
|
||||
c= *fmt++;
|
||||
} else
|
||||
if (isdigit(c)) {
|
||||
max= 0;
|
||||
do {
|
||||
max= max * 10 + (c - '0');
|
||||
} while (isdigit(c= *fmt++));
|
||||
}
|
||||
}
|
||||
|
||||
/* Set a few flags to the default. */
|
||||
x2c= x2c_tab;
|
||||
i= 0;
|
||||
base= 10;
|
||||
intsize= INT;
|
||||
if (c == 'l' || c == 'L') {
|
||||
/* "Long" key, e.g. %ld. */
|
||||
intsize= LONG;
|
||||
c= *fmt++;
|
||||
}
|
||||
if (c == 0) break;
|
||||
|
||||
switch (c) {
|
||||
/* Decimal. */
|
||||
case 'd':
|
||||
i= intsize == LONG ? va_arg(argp, long)
|
||||
: va_arg(argp, int);
|
||||
u= i < 0 ? -i : i;
|
||||
goto int2ascii;
|
||||
|
||||
/* Octal. */
|
||||
case 'o':
|
||||
base= 010;
|
||||
goto getint;
|
||||
|
||||
/* Pointer, interpret as %X or %lX. */
|
||||
case 'p':
|
||||
if (sizeof(char *) > sizeof(int)) intsize= LONG;
|
||||
|
||||
/* Hexadecimal. %X prints upper case A-F, not %lx. */
|
||||
case 'X':
|
||||
x2c= X2C_tab;
|
||||
case 'x':
|
||||
base= 0x10;
|
||||
goto getint;
|
||||
|
||||
/* Unsigned decimal. */
|
||||
case 'u':
|
||||
getint:
|
||||
u= intsize == LONG ? va_arg(argp, unsigned long)
|
||||
: va_arg(argp, unsigned int);
|
||||
int2ascii:
|
||||
p= temp + sizeof(temp)-1;
|
||||
*p= 0;
|
||||
do {
|
||||
*--p= x2c[(ptrdiff_t) (u % base)];
|
||||
} while ((u /= base) > 0);
|
||||
goto string_length;
|
||||
|
||||
/* A character. */
|
||||
case 'c':
|
||||
p= temp;
|
||||
*p= va_arg(argp, int);
|
||||
len= 1;
|
||||
goto string_print;
|
||||
|
||||
/* Simply a percent. */
|
||||
case '%':
|
||||
p= temp;
|
||||
*p= '%';
|
||||
len= 1;
|
||||
goto string_print;
|
||||
|
||||
/* A string. The other cases will join in here. */
|
||||
case 's':
|
||||
p= va_arg(argp, char *);
|
||||
|
||||
string_length:
|
||||
for (len= 0; p[len] != 0 && len < max; len++) {}
|
||||
|
||||
string_print:
|
||||
width -= len;
|
||||
if (i < 0) width--;
|
||||
if (fill == '0' && i < 0) count_kputc('-');
|
||||
if (adjust == RIGHT) {
|
||||
while (width > 0) { count_kputc(fill); width--; }
|
||||
}
|
||||
if (fill == ' ' && i < 0) count_kputc('-');
|
||||
while (len > 0) { count_kputc((unsigned char) *p++); len--; }
|
||||
while (width > 0) { count_kputc(fill); width--; }
|
||||
break;
|
||||
|
||||
/* Unrecognized format key, echo it back. */
|
||||
default:
|
||||
count_kputc('%');
|
||||
count_kputc(c);
|
||||
}
|
||||
}
|
||||
|
||||
/* Mark the end with a null (should be something else, like -1). */
|
||||
kputc(0);
|
||||
return charcount;
|
||||
}
|
||||
|
||||
/*
|
||||
* $PchId: kprintf.c,v 1.5 1996/04/11 06:59:05 philip Exp $
|
||||
*/
|
||||
Reference in New Issue
Block a user