From: Philip Homburg Date: Fri, 21 Oct 2005 17:09:08 +0000 (+0000) Subject: Crash recovery changes. X-Git-Tag: v3.1.2a~560 X-Git-Url: http://zhaoyanbai.com/repos/%22http:/www.isc.org/icons/zpipe.c?a=commitdiff_plain;h=589e147ee3384f9a4157a428c09949eb929d7ede;p=minix.git Crash recovery changes. --- diff --git a/drivers/dp8390/dp8390.c b/drivers/dp8390/dp8390.c index ea1e0db80..6aa36294f 100644 --- a/drivers/dp8390/dp8390.c +++ b/drivers/dp8390/dp8390.c @@ -62,6 +62,7 @@ static dpeth_t de_table[DE_PORT_NR]; static u16_t eth_ign_proto; +static char *progname; /* Configuration */ typedef struct dp_conf @@ -111,6 +112,7 @@ _PROTOTYPE( static void do_vread, (message *mp, int vectored) ); _PROTOTYPE( static void do_init, (message *mp) ); _PROTOTYPE( static void do_int, (dpeth_t *dep) ); _PROTOTYPE( static void do_getstat, (message *mp) ); +_PROTOTYPE( static void do_getname, (message *mp) ); _PROTOTYPE( static void do_stop, (message *mp) ); _PROTOTYPE( static void dp_init, (dpeth_t *dep) ); _PROTOTYPE( static void dp_confaddr, (dpeth_t *dep) ); @@ -169,10 +171,17 @@ _PROTOTYPE( static void do_vir_outsw, (port_t port, int proc, int main(int argc, char *argv[]) { message m; - int i, irq, r; + int i, irq, r, tasknr; dpeth_t *dep; long v; + if (argc < 1) + { + panic("DP8390", + "A head which at this time has no name", NO_NUM); + } + (progname=strrchr(argv[0],'/')) ? progname++ : (progname=argv[0]); + env_setargs(argc, argv); for (i= 0, dep= de_table; iDL_NAME, progname, sizeof(mp->DL_NAME)); + mp->DL_NAME[sizeof(mp->DL_NAME)-1]= '\0'; + mp->m_type= DL_NAME_REPLY; + r= send(mp->m_source, mp); + if (r != OK) + panic("dp8390", "do_getname: send failed: %d\n", r); +} + /*===========================================================================* * do_stop * *===========================================================================*/ @@ -1861,7 +1892,7 @@ void *loc_addr; u8_t inb(port_t port) { int r; - u8_t value; + u32_t value; r= sys_inb(port, &value); if (r != OK) diff --git a/drivers/dpeth/dp.c b/drivers/dpeth/dp.c index 28e2a3cbc..1aaadee1d 100644 --- a/drivers/dpeth/dp.c +++ b/drivers/dpeth/dp.c @@ -64,6 +64,7 @@ */ extern int errno; static dpeth_t de_table[DE_PORT_NR]; +static char *progname; typedef struct dp_conf { /* Configuration description structure */ port_t dpc_port; @@ -87,6 +88,8 @@ static const char SizeErrMsg[] = "illegal packet size"; static const char TypeErrMsg[] = "illegal message type"; static const char DevName[] = "eth#?"; +static void do_getname(message *mp); + /* ** Name: void reply(dpeth_t *dep, int err) ** Function: Fills a DL_TASK_REPLY reply message and sends it. @@ -502,6 +505,19 @@ static void do_getstat(message * mp) return; } +static void do_getname(mp) +message *mp; +{ + int r; + + strncpy(mp->DL_NAME, progname, sizeof(mp->DL_NAME)); + mp->DL_NAME[sizeof(mp->DL_NAME)-1]= '\0'; + mp->m_type= DL_NAME_REPLY; + r= send(mp->m_source, mp); + if (r != OK) + panic("dpeth", "do_getname: send failed: %d\n", r); +} + /* ** Name: void do_stop(message *mp) ** Function: Stops network interface. @@ -541,7 +557,9 @@ PUBLIC int main(int argc, char **argv) { message m; dpeth_t *dep; - int rc, fkeys, sfkeys; + int rc, fkeys, sfkeys, tasknr; + + (progname=strrchr(argv[0],'/')) ? progname++ : (progname=argv[0]); env_setargs(argc, argv); @@ -560,6 +578,11 @@ PUBLIC int main(int argc, char **argv) } #endif + /* Try to notify inet that we are present (again) */ + rc = findproc("inet", &tasknr); + if (rc == OK) + notify(tasknr); + while (TRUE) { if ((rc = receive(ANY, &m)) != OK) panic(dep->de_name, RecvErrMsg, rc); @@ -587,6 +610,9 @@ PUBLIC int main(int argc, char **argv) case DL_GETSTAT: /* Get device statistics */ do_getstat(&m); break; + case DL_GETNAME: + do_getname(&m); + break; case SYN_ALARM: /* to be defined */ do_watchdog(&m); break;