From: Jorrit Herder Date: Tue, 2 Aug 2005 15:30:36 +0000 (+0000) Subject: Various updates to support dynamically starting drivers. X-Git-Tag: v3.1.0~480 X-Git-Url: http://zhaoyanbai.com/repos/%22http:/www.isc.org/icons/FAQ?a=commitdiff_plain;h=52965b6f17d2a23e6460c3c63e2e7aebfc99b74a;p=minix.git Various updates to support dynamically starting drivers. Output during initialization should be suppressed. Unless an error occurs. Note that main() can now be main(int argc, char **argv) and arguments can be passed when bringing up the driver. --- diff --git a/drivers/dpeth/dp.c b/drivers/dpeth/dp.c index e1ad6dabf..83b81eb3a 100644 --- a/drivers/dpeth/dp.c +++ b/drivers/dpeth/dp.c @@ -49,6 +49,12 @@ ** +------------+---------+---------+---------------+ ** ** $Log$ +** Revision 1.5 2005/08/02 15:30:35 jnherder +** Various updates to support dynamically starting drivers. +** Output during initialization should be suppressed. Unless an error occurs. +** Note that main() can now be main(int argc, char **argv) and arguments can +** be passed when bringing up the driver. +** ** Revision 1.4 2005/07/29 12:44:41 jnherder ** Small update to SYS_IRQCTL -> setting an interrupt policy now allows the caller ** to provide an index (0 .. 31) that is passed in the HARD_INT message when an @@ -79,11 +85,10 @@ #include "dp.h" -#if ENABLE_NETWORKING == 1 - /* ** Local data */ +extern int errno; static dpeth_t de_table[DE_PORT_NR]; static int dpeth_tasknr = ANY; @@ -556,15 +561,15 @@ static void do_watchdog(void *message) ** Name: int dpeth_task(void) ** Function: Main entry for dp task */ -PUBLIC int main(void) +PUBLIC int main(int argc, char **argv) { message m; dpeth_t *dep; int rc, fkeys, sfkeys; /* Get precess number */ - if ((rc = getprocnr(&dpeth_tasknr)) != OK) - panic(DevName, "getprocnr() failed", rc); + if ((dpeth_tasknr = getprocnr()) < 0) + panic(DevName, "getprocnr() failed", errno); #if defined USE_IOPL /* Request direct access to hardware I/O ports */ if ((rc = sys_enable_iop(dpeth_tasknr)) != OK) @@ -575,6 +580,7 @@ PUBLIC int main(void) if ((fkey_map(&fkeys, &sfkeys)) != OK) printf("%s: couldn't program Shift+F8 key (%d)\n", DevName, errno); + #ifdef ETH_IGN_PROTO { static u16_t eth_ign_proto = 0; @@ -585,7 +591,6 @@ PUBLIC int main(void) } #endif - printf("DPETH: ethernet driver task initialized (process No. %d)\n", dpeth_tasknr); while (TRUE) { if ((rc = receive(ANY, &m)) != OK) panic(dep->de_name, RecvErrMsg, rc); @@ -616,7 +621,7 @@ PUBLIC int main(void) case DL_STOP: /* Stop device */ do_stop(&m); break; - case SYS_EVENT: { + case SYS_SIG: { sigset_t sigset = m.NOTIFY_ARG; if (sigismember(&sigset, SIGKSTOP)) { /* Shut down */ for (rc = 0; rc < DE_PORT_NR; rc += 1) { @@ -652,8 +657,5 @@ PUBLIC int main(void) return OK; /* Never reached, but keeps compiler happy */ } -#else -int main(void) { return 0; } -#endif /* ENABLE_NETWORKING */ /** dp.c **/ diff --git a/drivers/dpeth/dp.h b/drivers/dpeth/dp.h index de4f034b4..6f098accc 100644 --- a/drivers/dpeth/dp.h +++ b/drivers/dpeth/dp.h @@ -6,6 +6,12 @@ ** Interface description for ethernet device driver ** ** $Log$ +** Revision 1.2 2005/08/02 15:30:35 jnherder +** Various updates to support dynamically starting drivers. +** Output during initialization should be suppressed. Unless an error occurs. +** Note that main() can now be main(int argc, char **argv) and arguments can +** be passed when bringing up the driver. +** ** Revision 1.1 2005/06/29 10:16:46 beng ** Import of dpeth 3c501/3c509b/.. ethernet driver by ** Giovanni Falzoni . @@ -23,7 +29,7 @@ #undef ENABLE_WDETH #undef ENABLE_DP8390 -#define ENABLE_NETWORKING ENABLE_DPETH /** (from /usr/include/minix/config.h **/ +#define ENABLE_NETWORKING 1 #define ENABLE_3C501 1 /* enable 3Com Etherlink I board */ #define ENABLE_3C503 1 /* enable 3Com Etherlink II board */ diff --git a/drivers/floppy/floppy.c b/drivers/floppy/floppy.c index 829d0317d..0d775d8a6 100644 --- a/drivers/floppy/floppy.c +++ b/drivers/floppy/floppy.c @@ -309,7 +309,6 @@ PUBLIC void main() if ((s=sys_irqenable(&irq_hook_id)) != OK) panic("FLOPPY", "Couldn't enable IRQs", s); - printf("FLOPPY: user-level floppy disk driver initialized\n"); driver_task(&f_dtab); } diff --git a/drivers/fxp/Makefile b/drivers/fxp/Makefile index 317e62481..3f9ce5157 100644 --- a/drivers/fxp/Makefile +++ b/drivers/fxp/Makefile @@ -22,7 +22,7 @@ LIBPCI = $d/libpci/pci.o $d/libpci/pci_table.o all build: $(DRIVER) $(DRIVER): $(OBJ) $(LIBPCI) $(CC) -o $@ $(LDFLAGS) $(OBJ) $(LIBPCI) $(LIBS) - install -S 64w $(DRIVER) + install -S 256w $(DRIVER) $(LIBPCI): cd $d/libpci && $(MAKE) diff --git a/drivers/fxp/fxp.c b/drivers/fxp/fxp.c index 3e46c7d1d..109393deb 100644 --- a/drivers/fxp/fxp.c +++ b/drivers/fxp/fxp.c @@ -57,7 +57,6 @@ #define printW() ((void)0) #define vm_1phys2bus(p) (p) -#if ENABLE_FXP #if !ENABLE_PCI #error PCI support not enabled #endif @@ -207,6 +206,8 @@ static int fxp_tasknr= ANY; static u16_t eth_ign_proto; static tmra_ut fxp_watchdog; +extern int errno; + #define fxp_inb(port, offset) (do_inb((port) + (offset))) #define fxp_inw(port, offset) (do_inw((port) + (offset))) #define fxp_inl(port, offset) (do_inl((port) + (offset))) @@ -266,7 +267,8 @@ int main(void) fxp_t *fp; long v; - fxp_tasknr= FXP; + if ((fxp_tasknr= getprocnr())<0) + panic("FXP", "couldn't get proc nr", errno); v= 0; #if 0 @@ -315,7 +317,7 @@ int main(void) fxp_check_ints(fp); } break; - case SYS_EVENT: { + case SYS_SIG: { sigset_t sigset = m.NOTIFY_ARG; if (sigismember(&sigset, SIGKSTOP)) fxp_stop(); break; @@ -2471,7 +2473,6 @@ static void do_outl(port_t port, u32_t value) panic("FXP","sys_outl failed", r); } -#endif /* ENABLE_FXP */ /* * $PchId: fxp.c,v 1.4 2005/01/31 22:10:37 philip Exp $ diff --git a/drivers/fxp/mii.c b/drivers/fxp/mii.c index 772d6c089..4fae54cef 100644 --- a/drivers/fxp/mii.c +++ b/drivers/fxp/mii.c @@ -11,7 +11,6 @@ Media Independent (Ethernet) Interface functions #include "config.h" #endif -#if ENABLE_FXP #include "mii.h" @@ -197,8 +196,6 @@ u16_t techab; } } -#endif /* ENABLE_FXP */ - /* * $PchId: mii.c,v 1.2 2005/01/31 22:17:26 philip Exp $ */ diff --git a/drivers/libdriver/driver.c b/drivers/libdriver/driver.c index e61cbf949..b6bcc2e1f 100644 --- a/drivers/libdriver/driver.c +++ b/drivers/libdriver/driver.c @@ -1,7 +1,7 @@ /* This file contains device independent device driver interface. * * Changes: - * Jul 25, 2005 added SYS_EVENT type for signals (Jorrit N. Herder) + * Jul 25, 2005 added SYS_SIG type for signals (Jorrit N. Herder) * Sep 15, 2004 added SYN_ALARM type for timeouts (Jorrit N. Herder) * Jul 23, 2004 removed kernel dependencies (Jorrit N. Herder) * Apr 02, 1992 constructed from AT wini and floppy driver (Kees J. Bot) @@ -108,7 +108,7 @@ struct driver *dp; /* Device dependent entry points. */ case HARD_INT: /* leftover interrupt or expired timer. */ continue; - case SYS_EVENT: (*dp->dr_signal)(dp, &mess); + case SYS_SIG: (*dp->dr_signal)(dp, &mess); continue; /* don't reply */ case SYN_ALARM: (*dp->dr_alarm)(dp, &mess); continue; /* don't reply */ diff --git a/drivers/libpci/pci.c b/drivers/libpci/pci.c index ba04f257b..ebcb761e8 100644 --- a/drivers/libpci/pci.c +++ b/drivers/libpci/pci.c @@ -25,7 +25,7 @@ Created: Jan 2000 by Philip Homburg #if ENABLE_PCI #if !__minix_vmd -#define debug 1 /* for ast */ +#define debug 0 #define irq_mode_pci(irq) ((void)0) #endif diff --git a/drivers/log/log.c b/drivers/log/log.c index 9052c5159..67795bb8a 100644 --- a/drivers/log/log.c +++ b/drivers/log/log.c @@ -420,7 +420,7 @@ message *m_ptr; r = do_diagnostics(m_ptr); break; } - case SYS_EVENT: { + case SYS_SIG: { sigset_t sigset = m_ptr->NOTIFY_ARG; if (sigismember(&sigset, SIGKMESS)) { do_new_kmess(m_ptr); diff --git a/drivers/printer/printer.c b/drivers/printer/printer.c index 9d570f478..0ec5cf198 100644 --- a/drivers/printer/printer.c +++ b/drivers/printer/printer.c @@ -135,19 +135,7 @@ int sig; /* signal number */ PUBLIC void main(void) { /* Main routine of the printer task. */ - message pr_mess; /* buffer for all incoming messages */ -#if DEAD_CODE - struct sigaction sigact; - - /* Install signal handler.*/ - sigact.sa_handler = signal_handler; - sigact.sa_mask = ~0; /* block all other signals */ - sigact.sa_flags = 0; /* default behaviour */ - printf("PRINTER calls sigaction()\n"); - if (sigaction(SIGTERM, &sigact, NULL) != OK) - report("PRINTER","warning, sigaction() failed", errno); -#endif while (TRUE) { receive(ANY, &pr_mess); diff --git a/drivers/rtl8139/rtl8139.c b/drivers/rtl8139/rtl8139.c index 1616bd26e..fd9d20ab1 100755 --- a/drivers/rtl8139/rtl8139.c +++ b/drivers/rtl8139/rtl8139.c @@ -10,7 +10,7 @@ * |------------+----------+---------+----------+---------+---------| * | HARD_INT | | | | | | * |------------|----------|---------|----------|---------|---------| - * | HARD_STOP | | | | | | + * | SYS_SIG | | | | | | * |------------|----------|---------|----------|---------|---------| * | DL_WRITE | port nr | proc nr | count | mode | address | * |------------|----------|---------|----------|---------|---------| @@ -79,7 +79,8 @@ #define printW() ((void)0) #define vm_1phys2bus(p) (p) -#if ENABLE_RTL8139 +#define VERBOSE 0 /* display message during init */ + #if !ENABLE_PCI #error PCI support not enabled #endif @@ -285,7 +286,7 @@ void main(void) re_t *rep; long v; - if (getprocnr(&rl_tasknr) != OK) + if ((rl_tasknr = getprocnr()) < 0) panic("RTL8139", "getprocnr failed", errno); v= 0; @@ -337,7 +338,7 @@ void main(void) check_int_events(); break ; case FKEY_PRESSED: rtl8139_dump(&m); break; - case SYS_EVENT: { + case SYS_SIG: { sigset_t sigset = m.NOTIFY_ARG; if (sigismember(&sigset, SIGKSTOP)) rtl8139_stop(); break; @@ -485,7 +486,9 @@ message *mp; } if (rep->re_mode == REM_ENABLED) rl_init_hw(rep); +#if VERBOSE /* load silently ... can always check status later */ rl_report_link(rep); +#endif } assert(rep->re_mode == REM_ENABLED); @@ -628,11 +631,13 @@ re_t *rep; return 0; } +#if VERBOSE /* stay silent at startup, can always get status later */ dname= pci_dev_name(vid, did); if (!dname) dname= "unknown device"; printf("%s: ", rep->re_name); printf("%s (%x/%x) at %s\n", dname, vid, did, pci_slot_name(devind)); +#endif pci_reserve(devind); /* printf("cr = 0x%x\n", pci_attr_r16(devind, PCI_CR)); */ bar= pci_attr_r32(devind, PCI_BAR) & 0xffffffe0; @@ -760,6 +765,7 @@ re_t *rep; if ((s=sys_irqenable(&rep->re_hook_id)) != OK) printf("RTL8139: error, couldn't enable interrupts: %d\n", s); +#if VERBOSE /* stay silent during startup, can always get status later */ if (rep->re_mode) { printf("%s: model %s\n", rep->re_name, rep->re_model); } else @@ -769,6 +775,7 @@ re_t *rep; rl_inl(rep->re_base_port, RL_TCR) & (RL_TCR_HWVER_AM | RL_TCR_HWVER_BM)); } +#endif rl_confaddr(rep); if (debug) @@ -2619,7 +2626,6 @@ dpeth_t *dep; outb_reg0(dep, DP_CR, CR_PS_P0); /* back to bank 0 */ } #endif -#endif /* ENABLE_RTL8139 */ /* * $PchId: rtl8139.c,v 1.3 2003/09/11 14:15:15 philip Exp $ diff --git a/drivers/rtl8139/rtl8139.h b/drivers/rtl8139/rtl8139.h index 1b5ee93fc..1bacfc4c3 100755 --- a/drivers/rtl8139/rtl8139.h +++ b/drivers/rtl8139/rtl8139.h @@ -4,6 +4,8 @@ ibm/rtl8139.h Created: Aug 2003 by Philip Homburg */ +#define ENABLE_RTL8139 1 + #define RL_IDR 0x00 /* Ethernet address * Note: RL_9346CR_EEM_CONFIG mode is * required the change the ethernet diff --git a/drivers/tty/keyboard.c b/drivers/tty/keyboard.c index 6023e3252..2fa3ab180 100644 --- a/drivers/tty/keyboard.c +++ b/drivers/tty/keyboard.c @@ -440,6 +440,7 @@ message *m_ptr; /* pointer to the request message */ switch (m_ptr->FKEY_REQUEST) { /* see what we must do */ case FKEY_MAP: /* request for new mapping */ + result = OK; /* assume everything will be ok*/ for (i=0; i < 12; i++) { /* check F1-F12 keys */ if (bit_isset(m_ptr->FKEY_FKEYS, i+1) ) { if (fkey_obs[i].proc_nr == NONE) { @@ -448,8 +449,7 @@ message *m_ptr; /* pointer to the request message */ bit_unset(m_ptr->FKEY_FKEYS, i+1); } else { printf("WARNING, fkey_map failed F%d\n", i); - result = EBUSY; - break; + result = EBUSY; /* report failure, but try rest */ } } } @@ -461,15 +461,35 @@ message *m_ptr; /* pointer to the request message */ bit_unset(m_ptr->FKEY_SFKEYS, i+1); } else { printf("WARNING, fkey_map failed Shift F%d\n", i); - result = EBUSY; - break; + result = EBUSY; /* report failure but try rest */ } } } - result = OK; /* done, new observer registered */ break; case FKEY_UNMAP: - result = ENOSYS; /* not yet supported (not needed) */ + result = OK; /* assume everything will be ok*/ + for (i=0; i < 12; i++) { /* check F1-F12 keys */ + if (bit_isset(m_ptr->FKEY_FKEYS, i+1) ) { + if (fkey_obs[i].proc_nr == m_ptr->m_source) { + fkey_obs[i].proc_nr = NONE; + fkey_obs[i].events = 0; + bit_unset(m_ptr->FKEY_FKEYS, i+1); + } else { + result = EPERM; /* report failure, but try rest */ + } + } + } + for (i=0; i < 12; i++) { /* check Shift+F1-F12 keys */ + if (bit_isset(m_ptr->FKEY_SFKEYS, i+1) ) { + if (sfkey_obs[i].proc_nr == m_ptr->m_source) { + sfkey_obs[i].proc_nr = NONE; + sfkey_obs[i].events = 0; + bit_unset(m_ptr->FKEY_SFKEYS, i+1); + } else { + result = EPERM; /* report failure, but try rest */ + } + } + } break; case FKEY_EVENTS: m_ptr->FKEY_FKEYS = m_ptr->FKEY_SFKEYS = 0; @@ -626,7 +646,7 @@ message *m; /* request message to TTY */ while (nb_receive(ANY, m) == OK) { switch(m->m_type) { case FKEY_CONTROL: do_fkey_ctl(m); break; - case SYS_EVENT: do_new_kmess(m); break; + case SYS_SIG: do_new_kmess(m); break; case DIAGNOSTICS: do_diagnostics(m); break; default: ; /* do nothing */ } diff --git a/drivers/tty/tty.c b/drivers/tty/tty.c index 57af7b7e6..0cec43b89 100644 --- a/drivers/tty/tty.c +++ b/drivers/tty/tty.c @@ -20,7 +20,7 @@ * The valid messages and their parameters are: * * HARD_INT: output has been completed or input has arrived - * SYS_EVENT: e.g., MINIX wants to shutdown; run code to cleanly stop + * SYS_SIG: e.g., MINIX wants to shutdown; run code to cleanly stop * DEV_READ: a process wants to read from a terminal * DEV_WRITE: a process wants to write on a terminal * DEV_IOCTL: a process wants to change a terminal's parameters @@ -34,7 +34,7 @@ * --------------------------------------------------------------------------- * | HARD_INT | | | | | | | * |-------------+---------+---------+---------+---------+---------+---------| - * | SYS_EVENT | sig set | | | | | | + * | SYS_SIG | sig set | | | | | | * |-------------+---------+---------+---------+---------+---------+---------| * | DEV_READ |minor dev| proc nr | count | O_NONBLOCK| buf ptr | * |-------------+---------+---------+---------+---------+---------+---------| @@ -214,7 +214,7 @@ PUBLIC void main(void) expire_timers(); /* run watchdogs of expired timers */ continue; /* contine to check for events */ } - case SYS_EVENT: { /* new kernel message is available */ + case SYS_SIG: { /* system signal */ sigset_t sigset = (sigset_t) tty_mess.NOTIFY_ARG; if (sigismember(&sigset, SIGKSTOP)) {