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:
@@ -153,7 +153,7 @@ static void el1_send(dpeth_t * dep, int from_int, int pktsize)
|
||||
txbuff->client = dep->de_client;
|
||||
user2mem(dep, txbuff);
|
||||
} else
|
||||
panic(dep->de_name, "out of memory for Tx", NO_NUM);
|
||||
panic("out of memory for Tx");
|
||||
|
||||
} else if ((txbuff = dep->de_xmitq_head) != NULL) {
|
||||
|
||||
@@ -167,10 +167,10 @@ static void el1_send(dpeth_t * dep, int from_int, int pktsize)
|
||||
pktsize = txbuff->size;
|
||||
|
||||
} else
|
||||
panic(dep->de_name, "should not be sending ", NO_NUM);
|
||||
panic("should not be sending ");
|
||||
|
||||
if ((dep->de_flags & DEF_XMIT_BUSY)) {
|
||||
if (from_int) panic(dep->de_name, "should not be sending ", NO_NUM);
|
||||
if (from_int) panic("should not be sending ");
|
||||
getuptime(&now);
|
||||
if ((now - dep->de_xmit_start) > 4) {
|
||||
/* Transmitter timed out */
|
||||
|
||||
@@ -81,7 +81,7 @@ static void el2_init(dpeth_t * dep)
|
||||
/* Set interrupt level for 3c503 */
|
||||
irq = (dep->de_irq &= ~DEI_DEFAULT); /* Strip the default flag. */
|
||||
if (irq == 9) irq = 2;
|
||||
if (irq < 2 || irq > 5) panic(dep->de_name, "bad 3c503 irq configuration", irq);
|
||||
if (irq < 2 || irq > 5) panic("bad 3c503 irq configuration: %d", irq);
|
||||
outb_el2(dep, EL2_IDCFG, (0x04 << irq));
|
||||
|
||||
outb_el2(dep, EL2_DRQCNT, 0x08); /* Set burst size to 8 */
|
||||
|
||||
@@ -131,7 +131,7 @@ static void el3_write_fifo(dpeth_t * dep, int pktsize)
|
||||
r= sys_safe_outsb(dep->de_data_port, iovp->iod_proc_nr,
|
||||
iovp->iod_iovec[ix].iov_grant, 0, bytes);
|
||||
if (r != OK)
|
||||
panic(__FILE__, "el3_write_fifo: sys_safe_outsb failed", r);
|
||||
panic("el3_write_fifo: sys_safe_outsb failed: %d", r);
|
||||
|
||||
if (++ix >= IOVEC_NR) { /* Next buffer of IO vector */
|
||||
dp_next_iovec(iovp);
|
||||
@@ -416,11 +416,11 @@ static void el3_open(dpeth_t * dep)
|
||||
|
||||
AddrCfgReg = ((AddrCfgReg & EL3_CONFIG_IOBASE_MASK) << 4) + EL3_IO_BASE_ADDR;
|
||||
if (AddrCfgReg != dep->de_base_port)
|
||||
panic(dep->de_name, "Bad I/O port for Etherlink board", NO_NUM);
|
||||
panic("Bad I/O port for Etherlink board");
|
||||
|
||||
ResCfgReg >>= 12;
|
||||
dep->de_irq &= NOT(DEI_DEFAULT); /* Strips the default flag */
|
||||
if (ResCfgReg != dep->de_irq) panic(dep->de_name, "Bad IRQ for Etherlink board", NO_NUM);
|
||||
if (ResCfgReg != dep->de_irq) panic("Bad IRQ for Etherlink board");
|
||||
|
||||
SetWindow(WNO_Setup);
|
||||
|
||||
|
||||
@@ -76,7 +76,7 @@ static void ns_start_xmit(dpeth_t * dep, int size, int pageno)
|
||||
*/
|
||||
static void mem_getblock(dpeth_t *dep, u16_t offset, int size, void *dst)
|
||||
{
|
||||
panic(__FILE__, "mem_getblock: not converted to safecopies", NO_NUM);
|
||||
panic("mem_getblock: not converted to safecopies");
|
||||
#if 0
|
||||
sys_nic2mem(dep->de_linmem + offset, SELF, dst, size);
|
||||
return;
|
||||
@@ -93,7 +93,7 @@ static void mem_nic2user(dpeth_t * dep, int pageno, int pktsize)
|
||||
iovec_dat_s_t *iovp = &dep->de_read_iovec;
|
||||
int bytes, ix = 0;
|
||||
|
||||
panic(__FILE__, "mem_nic2user: not converted to safecopies", NO_NUM);
|
||||
panic("mem_nic2user: not converted to safecopies");
|
||||
#if 0
|
||||
|
||||
/* Computes shared memory address (skipping receive header) */
|
||||
@@ -141,7 +141,7 @@ static void mem_user2nic(dpeth_t *dep, int pageno, int pktsize)
|
||||
iovec_dat_s_t *iovp = &dep->de_write_iovec;
|
||||
int bytes, ix = 0;
|
||||
|
||||
panic(__FILE__, "mem_user2nic: not converted to safecopies", NO_NUM);
|
||||
panic("mem_user2nic: not converted to safecopies");
|
||||
#if 0
|
||||
|
||||
/* Computes shared memory address */
|
||||
@@ -217,10 +217,8 @@ static void pio_nic2user(dpeth_t *dep, int pageno, int pktsize)
|
||||
bytes = dep->de_stoppage * DP_PAGESIZE - offset;
|
||||
r= sys_safe_insb(dep->de_data_port, iovp->iod_proc_nr,
|
||||
iovp->iod_iovec[ix].iov_grant, iov_offset, bytes);
|
||||
if (r != OK)
|
||||
{
|
||||
panic(__FILE__, "pio_nic2user: sys_safe_insb failed",
|
||||
r);
|
||||
if (r != OK) {
|
||||
panic("pio_nic2user: sys_safe_insb failed: %d", r);
|
||||
}
|
||||
pktsize -= bytes;
|
||||
iov_offset += bytes;
|
||||
@@ -232,7 +230,7 @@ static void pio_nic2user(dpeth_t *dep, int pageno, int pktsize)
|
||||
r= sys_safe_insb(dep->de_data_port, iovp->iod_proc_nr,
|
||||
iovp->iod_iovec[ix].iov_grant, iov_offset, bytes);
|
||||
if (r != OK)
|
||||
panic(__FILE__, "pio_nic2user: sys_safe_insb failed", r);
|
||||
panic("pio_nic2user: sys_safe_insb failed: %d", r);
|
||||
offset += bytes;
|
||||
|
||||
if (++ix >= IOVEC_NR) { /* Next buffer of IO vector */
|
||||
@@ -264,7 +262,7 @@ static void pio_user2nic(dpeth_t *dep, int pageno, int pktsize)
|
||||
r= sys_safe_outsb(dep->de_data_port, iovp->iod_proc_nr,
|
||||
iovp->iod_iovec[ix].iov_grant, 0, bytes);
|
||||
if (r != OK)
|
||||
panic(__FILE__, "pio_user2nic: sys_safe_outsb failed", r);
|
||||
panic("pio_user2nic: sys_safe_outsb failed: %d", r);
|
||||
|
||||
if (++ix >= IOVEC_NR) { /* Next buffer of I/O vector */
|
||||
dp_next_iovec(iovp);
|
||||
@@ -277,7 +275,7 @@ static void pio_user2nic(dpeth_t *dep, int pageno, int pktsize)
|
||||
if (inb_reg0(dep, DP_ISR) & ISR_RDC) break;
|
||||
}
|
||||
if (ix == 100) {
|
||||
panic(dep->de_name, RdmaErrMsg, NO_NUM);
|
||||
panic(RdmaErrMsg);
|
||||
}
|
||||
return;
|
||||
}
|
||||
@@ -331,7 +329,7 @@ static void ns_send(dpeth_t * dep, int from_int, int size)
|
||||
int queue;
|
||||
|
||||
if (queue = dep->de_sendq_head, dep->de_sendq[queue].sq_filled) {
|
||||
if (from_int) panic(dep->de_name, "should not be sending ", NO_NUM);
|
||||
if (from_int) panic("should not be sending ");
|
||||
dep->de_send_s = size;
|
||||
return;
|
||||
}
|
||||
@@ -654,7 +652,7 @@ static void dp_pio16_user2nic(dpeth_t *dep, int pageno, int pktsize)
|
||||
if (bytes > pktsize) bytes = pktsize;
|
||||
|
||||
phys_user = numap(iovp->iod_proc_nr, iovp->iod_iovec[ix].iov_addr, bytes);
|
||||
if (!phys_user) panic(dep->de_name, UmapErrMsg, NO_NUM);
|
||||
if (!phys_user) panic(UmapErrMsg);
|
||||
|
||||
if (odd_byte) {
|
||||
phys_copy(phys_user, phys_2bytes + 1, (phys_bytes) 1);
|
||||
@@ -691,7 +689,7 @@ static void dp_pio16_user2nic(dpeth_t *dep, int pageno, int pktsize)
|
||||
if (inb_reg0(dep, DP_ISR) & ISR_RDC) break;
|
||||
}
|
||||
if (ix == 100) {
|
||||
panic(dep->de_name, RdmaErrMsg, NO_NUM);
|
||||
panic(RdmaErrMsg);
|
||||
}
|
||||
return;
|
||||
}
|
||||
@@ -727,7 +725,7 @@ static void dp_pio16_nic2user(dpeth_t * dep, int nic_addr, int count)
|
||||
|
||||
phys_user = numap(iovp->iod_proc_nr,
|
||||
iovp->iod_iovec[i].iov_addr, bytes);
|
||||
if (!phys_user) panic(dep->de_name, UmapErrMsg, NO_NUM);
|
||||
if (!phys_user) panic(UmapErrMsg);
|
||||
if (odd_byte) {
|
||||
phys_copy(phys_2bytes + 1, phys_user, (phys_bytes) 1);
|
||||
count--;
|
||||
|
||||
@@ -118,7 +118,7 @@ static void reply(dpeth_t * dep, int err, int m_type)
|
||||
dep->de_flags &= NOT(DEF_ACK_SEND | DEF_ACK_RECV);
|
||||
|
||||
} else if (status != ELOCKED || err == OK)
|
||||
panic(dep->de_name, SendErrMsg, status);
|
||||
panic(SendErrMsg, status);
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -236,7 +236,7 @@ static void get_userdata_s(int user_proc, cp_grant_id_t grant,
|
||||
|
||||
len = (count > IOVEC_NR ? IOVEC_NR : count) * sizeof(iovec_t);
|
||||
if ((rc = sys_safecopyfrom(user_proc, grant, 0, (vir_bytes)loc_addr, len, D)) != OK)
|
||||
panic(DevName, CopyErrMsg, rc);
|
||||
panic(CopyErrMsg, rc);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -351,7 +351,7 @@ static void do_init(message * mp)
|
||||
reply_mess.m3_i2 = DE_PORT_NR;
|
||||
DEBUG(printf("\t reply %d\n", reply_mess.m_type));
|
||||
if (send(mp->m_source, &reply_mess) != OK) /* Can't send */
|
||||
panic(portname, SendErrMsg, mp->m_source);
|
||||
panic(SendErrMsg, mp->m_source);
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -402,7 +402,7 @@ static void do_vwrite_s(message * mp)
|
||||
|
||||
port = mp->DL_PORT;
|
||||
if (port < 0 || port >= DE_PORT_NR) /* Check for illegal port number */
|
||||
panic(__FILE__, PortErrMsg, EINVAL);
|
||||
panic(PortErrMsg, EINVAL);
|
||||
|
||||
dep = &de_table[port];
|
||||
dep->de_client = mp->DL_PROC;
|
||||
@@ -410,7 +410,7 @@ static void do_vwrite_s(message * mp)
|
||||
if (dep->de_mode == DEM_ENABLED) {
|
||||
|
||||
if (dep->de_flags & DEF_SENDING) /* Is sending in progress? */
|
||||
panic(dep->de_name, "send already in progress ", NO_NUM);
|
||||
panic("send already in progress ");
|
||||
|
||||
dep->de_write_iovec.iod_proc_nr = mp->DL_PROC;
|
||||
get_userdata_s(mp->DL_PROC, mp->DL_GRANT, 0,
|
||||
@@ -420,7 +420,7 @@ static void do_vwrite_s(message * mp)
|
||||
dep->de_write_iovec.iod_iovec_offset = 0;
|
||||
size = calc_iovec_size(&dep->de_write_iovec);
|
||||
if (size < ETH_MIN_PACK_SIZE || size > ETH_MAX_PACK_SIZE)
|
||||
panic(dep->de_name, SizeErrMsg, size);
|
||||
panic(SizeErrMsg, size);
|
||||
|
||||
dep->de_flags |= DEF_SENDING;
|
||||
(*dep->de_sendf) (dep, FALSE, size);
|
||||
@@ -443,7 +443,7 @@ static void do_vread_s(message * mp)
|
||||
|
||||
port = mp->DL_PORT;
|
||||
if (port < 0 || port >= DE_PORT_NR) /* Check for illegal port number */
|
||||
panic(__FILE__, PortErrMsg, EINVAL);
|
||||
panic(PortErrMsg, EINVAL);
|
||||
|
||||
dep = &de_table[port];
|
||||
dep->de_client = mp->DL_PROC;
|
||||
@@ -451,7 +451,7 @@ static void do_vread_s(message * mp)
|
||||
if (dep->de_mode == DEM_ENABLED) {
|
||||
|
||||
if (dep->de_flags & DEF_READING) /* Reading in progress */
|
||||
panic(dep->de_name, "read already in progress", NO_NUM);
|
||||
panic("read already in progress");
|
||||
|
||||
dep->de_read_iovec.iod_proc_nr = mp->DL_PROC;
|
||||
get_userdata_s(mp->DL_PROC, (cp_grant_id_t) mp->DL_GRANT, 0,
|
||||
@@ -460,7 +460,7 @@ static void do_vread_s(message * mp)
|
||||
dep->de_read_iovec.iod_grant = (cp_grant_id_t) mp->DL_GRANT;
|
||||
dep->de_read_iovec.iod_iovec_offset = 0;
|
||||
size = calc_iovec_size(&dep->de_read_iovec);
|
||||
if (size < ETH_MAX_PACK_SIZE) panic(dep->de_name, SizeErrMsg, size);
|
||||
if (size < ETH_MAX_PACK_SIZE) panic(SizeErrMsg, size);
|
||||
|
||||
dep->de_flags |= DEF_READING;
|
||||
(*dep->de_recvf) (dep, FALSE, size);
|
||||
@@ -486,7 +486,7 @@ static void do_getstat_s(message * mp)
|
||||
|
||||
port = mp->DL_PORT;
|
||||
if (port < 0 || port >= DE_PORT_NR) /* Check for illegal port number */
|
||||
panic(__FILE__, PortErrMsg, EINVAL);
|
||||
panic(PortErrMsg, EINVAL);
|
||||
|
||||
dep = &de_table[port];
|
||||
dep->de_client = mp->DL_PROC;
|
||||
@@ -495,7 +495,7 @@ static void do_getstat_s(message * mp)
|
||||
if ((rc = sys_safecopyto(mp->DL_PROC, mp->DL_GRANT, 0,
|
||||
(vir_bytes)&dep->de_stat,
|
||||
(vir_bytes) sizeof(dep->de_stat), 0)) != OK)
|
||||
panic(DevName, CopyErrMsg, rc);
|
||||
panic(CopyErrMsg, rc);
|
||||
reply(dep, OK, DL_STAT_REPLY);
|
||||
return;
|
||||
}
|
||||
@@ -510,7 +510,7 @@ message *mp;
|
||||
mp->m_type= DL_NAME_REPLY;
|
||||
r= send(mp->m_source, mp);
|
||||
if (r != OK)
|
||||
panic("dpeth", "do_getname: send failed: %d\n", r);
|
||||
panic("do_getname: send failed: %d", r);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -524,7 +524,7 @@ static void do_stop(message * mp)
|
||||
|
||||
port = mp->DL_PORT;
|
||||
if (port < 0 || port >= DE_PORT_NR) /* Check for illegal port number */
|
||||
panic(__FILE__, PortErrMsg, EINVAL);
|
||||
panic(PortErrMsg, EINVAL);
|
||||
|
||||
dep = &de_table[port];
|
||||
if (dep->de_mode == DEM_ENABLED && (dep->de_flags & DEF_ENABLED)) {
|
||||
@@ -600,7 +600,7 @@ PUBLIC int main(int argc, char **argv)
|
||||
|
||||
while (TRUE) {
|
||||
if ((rc = sef_receive(ANY, &m)) != OK){
|
||||
panic(__FILE__, RecvErrMsg, rc);
|
||||
panic(RecvErrMsg, rc);
|
||||
}
|
||||
|
||||
DEBUG(printf("eth: got message %d, ", m.m_type));
|
||||
@@ -624,7 +624,7 @@ PUBLIC int main(int argc, char **argv)
|
||||
break;
|
||||
default:
|
||||
/* Invalid message type */
|
||||
panic(DevName, TypeErrMsg, m.m_type);
|
||||
panic(TypeErrMsg, m.m_type);
|
||||
break;
|
||||
}
|
||||
/* message processed, get another one */
|
||||
@@ -651,7 +651,7 @@ PUBLIC int main(int argc, char **argv)
|
||||
do_stop(&m);
|
||||
break;
|
||||
default: /* Invalid message type */
|
||||
panic(DevName, TypeErrMsg, m.m_type);
|
||||
panic(TypeErrMsg, m.m_type);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -123,7 +123,7 @@ PUBLIC void mem2user(dpeth_t *dep, buff_t *rxbuff)
|
||||
r= sys_safecopyto(iovp->iod_proc_nr, iovp->iod_iovec[ix].iov_grant, 0,
|
||||
(vir_bytes)buffer, bytes, D);
|
||||
if (r != OK)
|
||||
panic(__FILE__, "mem2user: sys_safecopyto failed", r);
|
||||
panic("mem2user: sys_safecopyto failed: %d", r);
|
||||
buffer += bytes;
|
||||
|
||||
if (++ix >= IOVEC_NR) { /* Next buffer of IO vector */
|
||||
@@ -153,7 +153,7 @@ PUBLIC void user2mem(dpeth_t *dep, buff_t *txbuff)
|
||||
r= sys_safecopyfrom(iovp->iod_proc_nr, iovp->iod_iovec[ix].iov_grant,
|
||||
0, (vir_bytes)buffer, bytes, D);
|
||||
if (r != OK)
|
||||
panic(__FILE__, "user2mem: sys_safecopyfrom failed", r);
|
||||
panic("user2mem: sys_safecopyfrom failed: %d", r);
|
||||
buffer += bytes;
|
||||
|
||||
if (++ix >= IOVEC_NR) { /* Next buffer of IO vector */
|
||||
|
||||
Reference in New Issue
Block a user