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.
This commit is contained in:
Jorrit Herder 2005-08-02 15:30:36 +00:00
parent f44725b777
commit 52965b6f17
14 changed files with 72 additions and 51 deletions

View file

@ -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 **/

View file

@ -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 <fgalzoni@inwind.it>.
@ -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 */

View file

@ -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);
}

View file

@ -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)

View file

@ -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 $

View file

@ -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 $
*/

View file

@ -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 */

View file

@ -25,7 +25,7 @@ Created: Jan 2000 by Philip Homburg <philip@cs.vu.nl>
#if ENABLE_PCI
#if !__minix_vmd
#define debug 1 /* for ast */
#define debug 0
#define irq_mode_pci(irq) ((void)0)
#endif

View file

@ -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);

View file

@ -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);

View file

@ -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 $

View file

@ -4,6 +4,8 @@ ibm/rtl8139.h
Created: Aug 2003 by Philip Homburg <philip@cs.vu.nl>
*/
#define ENABLE_RTL8139 1
#define RL_IDR 0x00 /* Ethernet address
* Note: RL_9346CR_EEM_CONFIG mode is
* required the change the ethernet

View file

@ -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 */
}

View file

@ -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)) {