Removed macros that depend on NOTIFY_FROM from servers and drivers. They

determine the information defined by these macros from the m_source field of the
notify message.
This commit is contained in:
Tomas Hruby 2009-09-29 18:47:56 +00:00
parent 0e1fd9ea33
commit 4dad30937b
22 changed files with 660 additions and 382 deletions

View File

@ -21,6 +21,7 @@ Driver for the AMD Device Exclusion Vector (DEV)
#include <minix/ipc.h> #include <minix/ipc.h>
#include <minix/syslib.h> #include <minix/syslib.h>
#include <minix/sysutil.h> #include <minix/sysutil.h>
#include <minix/endpoint.h>
#include <ibm/pci.h> #include <ibm/pci.h>
/* Offsets from capability pointer */ /* Offsets from capability pointer */
@ -78,13 +79,13 @@ int main(void)
r= receive(ANY, &m); r= receive(ANY, &m);
if (r != OK) if (r != OK)
panic(__FILE__, "receive failed", r); panic(__FILE__, "receive failed", r);
switch(m.m_type) if (is_notify(m.m_type)) {
{ if (_ENDPOINT_P(m.m_source) == PM_PROC_NR) {
case PROC_EVENT: do_pm_notify(&m);
do_pm_notify(&m); continue;
continue; }
}
case IOMMU_MAP: else if (m.m_type == IOMMU_MAP) {
r= do_add4pci(&m); r= do_add4pci(&m);
m.m_type= r; m.m_type= r;
send(m.m_source, &m); send(m.m_source, &m);

View File

@ -19,6 +19,7 @@
#include <minix/sysutil.h> #include <minix/sysutil.h>
#include <minix/keymap.h> #include <minix/keymap.h>
#include <minix/type.h> #include <minix/type.h>
#include <minix/endpoint.h>
#include <sys/ioc_disk.h> #include <sys/ioc_disk.h>
#include <ibm/pci.h> #include <ibm/pci.h>
#include <sys/mman.h> #include <sys/mman.h>
@ -1586,11 +1587,10 @@ struct command *cmd; /* Command block */
return(ERR); return(ERR);
} }
/* Schedule a wakeup call, some controllers are flaky. This is done with /* Schedule a wakeup call, some controllers are flaky. This is done with a
* a synchronous alarm. If a timeout occurs a SYN_ALARM message is sent * synchronous alarm. If a timeout occurs a notify from CLOCK is sent, so that
* from HARDWARE, so that w_intr_wait() can call w_timeout() in case the * w_intr_wait() can call w_timeout() in case the controller was not able to
* controller was not able to execute the command. Leftover timeouts are * execute the command. Leftover timeouts are simply ignored by the main loop.
* simply ignored by the main loop.
*/ */
sys_setalarm(wakeup_ticks, 0); sys_setalarm(wakeup_ticks, 0);
@ -1639,11 +1639,10 @@ struct command *cmd; /* Command block */
return(ERR); return(ERR);
} }
/* Schedule a wakeup call, some controllers are flaky. This is done with /* Schedule a wakeup call, some controllers are flaky. This is done with a
* a synchronous alarm. If a timeout occurs a SYN_ALARM message is sent * synchronous alarm. If a timeout occurs a notify from CLOCK is sent, so that
* from HARDWARE, so that w_intr_wait() can call w_timeout() in case the * w_intr_wait() can call w_timeout() in case the controller was not able to
* controller was not able to execute the command. Leftover timeouts are * execute the command. Leftover timeouts are simply ignored by the main loop.
* simply ignored by the main loop.
*/ */
sys_setalarm(wakeup_ticks, 0); sys_setalarm(wakeup_ticks, 0);
@ -2057,26 +2056,38 @@ PRIVATE void w_intr_wait()
int rr; int rr;
if((rr=receive(ANY, &m)) != OK) if((rr=receive(ANY, &m)) != OK)
panic("at_wini", "receive(ANY) failed", rr); panic("at_wini", "receive(ANY) failed", rr);
switch(m.m_type) { if (is_notify(m.m_type)) {
case SYN_ALARM: switch (_ENDPOINT_P(m.m_source)) {
/* Timeout. */ case CLOCK:
w_timeout(); /* a.o. set w_status */ /* Timeout. */
break; w_timeout(); /* a.o. set w_status */
case HARD_INT: break;
/* Interrupt. */ case HARDWARE:
r= sys_inb(w_wn->base_cmd + REG_STATUS, &w_status); /* Interrupt. */
if (r != 0) r= sys_inb(w_wn->base_cmd +
panic("at_wini", "sys_inb failed", r); REG_STATUS, &w_status);
w_wn->w_status= w_status; if (r != 0)
ack_irqs(m.NOTIFY_ARG); panic("at_wini",
break; "sys_inb failed", r);
case DEV_PING: w_wn->w_status= w_status;
/* RS monitor ping. */ ack_irqs(m.NOTIFY_ARG);
notify(m.m_source); break;
break; case RS_PROC_NR:
default: /* RS monitor ping. */
/* unhandled message. notify(m.m_source);
* queue it and handle it in the libdriver loop. break;
default:
/*
* unhandled message. queue it and
* handle it in the libdriver loop.
*/
mq_queue(&m);
}
}
else {
/*
* unhandled message. queue it and handle it in the
* libdriver loop.
*/ */
mq_queue(&m); mq_queue(&m);
} }

View File

@ -56,6 +56,7 @@
#include <stdlib.h> #include <stdlib.h>
#include <minix/com.h> #include <minix/com.h>
#include <minix/endpoint.h>
#include <net/hton.h> #include <net/hton.h>
#include <net/gen/ether.h> #include <net/gen/ether.h>
#include <net/gen/eth_io.h> #include <net/gen/eth_io.h>
@ -202,13 +203,42 @@ _PROTOTYPE( static void do_vir_outsb, (port_t port, int proc,
_PROTOTYPE( static void do_vir_outsw, (port_t port, int proc, _PROTOTYPE( static void do_vir_outsw, (port_t port, int proc,
vir_bytes buf, size_t size) ); vir_bytes buf, size_t size) );
PRIVATE int handle_hw_intr(void)
{
int i, r, irq;
dpeth_t *dep;
for (i= 0, dep= &de_table[0]; i<DE_PORT_NR; i++, dep++)
{
if (dep->de_mode != DEM_ENABLED)
continue;
assert(dep->de_flags & DEF_ENABLED);
irq= dep->de_irq;
assert(irq >= 0 && irq < NR_IRQ_VECTORS);
if (dep->de_int_pending || 1)
{
dep->de_int_pending= 0;
dp_check_ints(dep);
do_int(dep);
r= sys_irqenable(&dep->de_hook);
if (r != OK)
{
panic("DP8390",
"unable enable interrupts", r);
}
}
}
return r;
}
/*===========================================================================* /*===========================================================================*
* dpeth_task * * dpeth_task *
*===========================================================================*/ *===========================================================================*/
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
message m; message m;
int i, irq, r, tasknr; int i, r, tasknr;
dpeth_t *dep; dpeth_t *dep;
long v; long v;
@ -243,9 +273,36 @@ int main(int argc, char *argv[])
if ((r= receive(ANY, &m)) != OK) if ((r= receive(ANY, &m)) != OK)
panic("", "dp8390: receive failed", r); panic("", "dp8390: receive failed", r);
if (is_notify(m.m_type)) {
switch (_ENDPOINT_P(m.m_source)) {
case RS_PROC_NR:
notify(m.m_source);
break;
case HARDWARE:
r = handle_hw_intr();
break;
case SYSTEM:
if (sigismember((sigset_t*)
&m.NOTIFY_ARG,
SIGKSTOP))
dp8390_stop();
break;
case CLOCK:
printf("dp8390: notify from CLOCK\n");
break;
case PM_PROC_NR:
break;
default:
panic("", "dp8390: illegal notify from",
m.m_source);
}
/* done, get a new message */
continue;
}
switch (m.m_type) switch (m.m_type)
{ {
case DEV_PING: notify(m.m_source); continue;
case DL_WRITE: do_vwrite(&m, FALSE, FALSE); break; case DL_WRITE: do_vwrite(&m, FALSE, FALSE); break;
case DL_WRITEV: do_vwrite(&m, FALSE, TRUE); break; case DL_WRITEV: do_vwrite(&m, FALSE, TRUE); break;
case DL_WRITEV_S: do_vwrite_s(&m, FALSE); break; case DL_WRITEV_S: do_vwrite_s(&m, FALSE); break;
@ -257,38 +314,6 @@ int main(int argc, char *argv[])
case DL_GETSTAT_S: do_getstat_s(&m); break; case DL_GETSTAT_S: do_getstat_s(&m); break;
case DL_GETNAME: do_getname(&m); break; case DL_GETNAME: do_getname(&m); break;
case DL_STOP: do_stop(&m); break; case DL_STOP: do_stop(&m); break;
case HARD_INT:
for (i= 0, dep= &de_table[0]; i<DE_PORT_NR; i++, dep++)
{
if (dep->de_mode != DEM_ENABLED)
continue;
assert(dep->de_flags & DEF_ENABLED);
irq= dep->de_irq;
assert(irq >= 0 && irq < NR_IRQ_VECTORS);
if (dep->de_int_pending || 1)
{
dep->de_int_pending= 0;
dp_check_ints(dep);
do_int(dep);
r= sys_irqenable(&dep->de_hook);
if (r != OK)
{
panic("DP8390",
"unable enable interrupts", r);
}
}
}
break;
case SYS_SIG: {
sigset_t sigset = m.NOTIFY_ARG;
if (sigismember(&sigset, SIGKSTOP)) dp8390_stop();
break;
}
case SYN_ALARM:
printf("dp8390: strange, got SYN_ALARM\n");
break;
case PROC_EVENT:
break;
default: default:
panic("", "dp8390: illegal message", m.m_type); panic("", "dp8390: illegal message", m.m_type);
} }

View File

@ -15,14 +15,10 @@
** **
** m_type DL_PORT DL_PROC DL_COUNT DL_MODE DL_ADDR ** m_type DL_PORT DL_PROC DL_COUNT DL_MODE DL_ADDR
** +------------+---------+---------+--------+-------+---------+ ** +------------+---------+---------+--------+-------+---------+
** | HARD_INT | | | | | | ** | NOTIFY from HARDWARE, CLOCK, TTY, RS, PM, SYSTEM |
** +------------+---------+---------+--------+-------+---------+
** | SYN_ALARM | | | | | |
** +------------+---------+---------+--------+-------+---------+ ** +------------+---------+---------+--------+-------+---------+
** | HARD_STOP | | | | | | ** | HARD_STOP | | | | | |
** +------------+---------+---------+--------+-------+---------+ ** +------------+---------+---------+--------+-------+---------+
** | FKEY_PRESSED | | | | | (99)
** +------------+---------+---------+--------+-------+---------+
** | DL_WRITE | port nr | proc nr | count | mode | address | (3) ** | DL_WRITE | port nr | proc nr | count | mode | address | (3)
** +------------+---------+---------+--------+-------+---------+ ** +------------+---------+---------+--------+-------+---------+
** | DL_WRITEV | port nr | proc nr | count | mode | address | (4) ** | DL_WRITEV | port nr | proc nr | count | mode | address | (4)
@ -60,6 +56,7 @@
#include "drivers.h" #include "drivers.h"
#include <minix/keymap.h> #include <minix/keymap.h>
#include <minix/endpoint.h>
#include <net/hton.h> #include <net/hton.h>
#include <net/gen/ether.h> #include <net/gen/ether.h>
#include <net/gen/eth_io.h> #include <net/gen/eth_io.h>
@ -545,6 +542,39 @@ static void do_watchdog(void *message)
return; return;
} }
PRIVATE void handle_system_signal(message *m)
{
sigset_t sigset = m->NOTIFY_ARG;
int port;
if (sigismember(&sigset, SIGKSTOP)) { /* Shut down */
for (port = 0; port < DE_PORT_NR; port += 1) {
if (de_table[port].de_mode == DEM_ENABLED) {
m->m_type = DL_STOP;
m->DL_PORT = port;
do_stop(m);
}
}
}
}
PRIVATE void handle_hw_intr(void)
{
dpeth_t *dep;
for (dep = de_table; dep < &de_table[DE_PORT_NR]; dep += 1) {
/* If device is enabled and interrupt pending */
if (dep->de_mode == DEM_ENABLED) {
dep->de_int_pending = TRUE;
(*dep->de_interruptf) (dep);
if (dep->de_flags & (DEF_ACK_SEND | DEF_ACK_RECV))
reply(dep, !OK, DL_TASK_REPLY);
dep->de_int_pending = FALSE;
sys_irqenable(&dep->de_hook);
}
}
}
/* /*
** Name: int dpeth_task(void) ** Name: int dpeth_task(void)
** Function: Main entry for dp task ** Function: Main entry for dp task
@ -584,10 +614,39 @@ PUBLIC int main(int argc, char **argv)
DEBUG(printf("eth: got message %d, ", m.m_type)); DEBUG(printf("eth: got message %d, ", m.m_type));
switch (m.m_type) { if (is_notify(m.m_type)) {
case DEV_PING: /* Status request from RS */ switch(_ENDPOINT_P(m.m_source)) {
notify(m.m_source); case CLOCK:
/* to be defined */
do_watchdog(&m);
break;
case RS_PROC_NR:
/* Status request from RS */
notify(m.m_source);
break;
case SYSTEM:
handle_system_signal(&m);
break;
case HARDWARE:
/* Interrupt from device */
handle_hw_intr();
break;
case TTY_PROC_NR:
/* Function key pressed */
do_dump(&m);
break;
case PM_PROC_NR:
break;
default:
/* Invalid message type */
panic(DevName, TypeErrMsg, m.m_type);
break;
}
/* message processed, get another one */
continue; continue;
}
switch (m.m_type) {
case DL_WRITEV_S: /* Write message to device */ case DL_WRITEV_S: /* Write message to device */
do_vwrite_s(&m); do_vwrite_s(&m);
break; break;
@ -603,43 +662,9 @@ PUBLIC int main(int argc, char **argv)
case DL_GETNAME: case DL_GETNAME:
do_getname(&m); do_getname(&m);
break; break;
case SYN_ALARM: /* to be defined */
do_watchdog(&m);
break;
case DL_STOP: /* Stop device */ case DL_STOP: /* Stop device */
do_stop(&m); do_stop(&m);
break; break;
case SYS_SIG: {
sigset_t sigset = m.NOTIFY_ARG;
if (sigismember(&sigset, SIGKSTOP)) { /* Shut down */
for (rc = 0; rc < DE_PORT_NR; rc += 1) {
if (de_table[rc].de_mode == DEM_ENABLED) {
m.m_type = DL_STOP;
m.DL_PORT = rc;
do_stop(&m);
}
}
}
break;
}
case HARD_INT: /* Interrupt from device */
for (dep = de_table; dep < &de_table[DE_PORT_NR]; dep += 1) {
/* If device is enabled and interrupt pending */
if (dep->de_mode == DEM_ENABLED) {
dep->de_int_pending = TRUE;
(*dep->de_interruptf) (dep);
if (dep->de_flags & (DEF_ACK_SEND | DEF_ACK_RECV))
reply(dep, !OK, DL_TASK_REPLY);
dep->de_int_pending = FALSE;
sys_irqenable(&dep->de_hook);
}
}
break;
case FKEY_PRESSED: /* Function key pressed */
do_dump(&m);
break;
case PROC_EVENT:
break;
default: /* Invalid message type */ default: /* Invalid message type */
panic(DevName, TypeErrMsg, m.m_type); panic(DevName, TypeErrMsg, m.m_type);
break; break;

View File

@ -28,6 +28,7 @@
#include <ibm/diskparm.h> #include <ibm/diskparm.h>
#include <minix/sysutil.h> #include <minix/sysutil.h>
#include <minix/syslib.h> #include <minix/syslib.h>
#include <minix/endpoint.h>
/* I/O Ports used by floppy disk task. */ /* I/O Ports used by floppy disk task. */
#define DOR 0x3F2 /* motor drive control bits */ #define DOR 0x3F2 /* motor drive control bits */
@ -760,16 +761,25 @@ PRIVATE void start_motor()
if (running) return; /* motor was already running */ if (running) return; /* motor was already running */
/* Set an alarm timer to force a timeout if the hardware does not interrupt /* Set an alarm timer to force a timeout if the hardware does not interrupt
* in time. Expect HARD_INT message, but check for SYN_ALARM timeout. * in time. Expect an interrupt, but check for a timeout.
*/ */
f_set_timer(&f_tmr_timeout, f_dp->start_ms * system_hz / 1000, f_timeout); f_set_timer(&f_tmr_timeout, f_dp->start_ms * system_hz / 1000, f_timeout);
f_busy = BSY_IO; f_busy = BSY_IO;
do { do {
receive(ANY, &mess); receive(ANY, &mess);
if (mess.m_type == SYN_ALARM) {
f_expire_tmrs(NULL, NULL); if (is_notify(mess.m_type)) {
} else if(mess.m_type == DEV_PING) { switch (_ENDPOINT_P(mess.m_source)) {
notify(mess.m_source); case CLOCK:
f_expire_tmrs(NULL, NULL);
break;
case RS_PROC_NR:
notify(mess.m_source);
break;
default :
f_busy = BSY_IDLE;
break;
}
} else { } else {
f_busy = BSY_IDLE; f_busy = BSY_IDLE;
} }
@ -844,16 +854,25 @@ PRIVATE int seek()
/* Give head time to settle on a format, no retrying here! */ /* Give head time to settle on a format, no retrying here! */
if (f_device & FORMAT_DEV_BIT) { if (f_device & FORMAT_DEV_BIT) {
/* Set a synchronous alarm to force a timeout if the hardware does /* Set a synchronous alarm to force a timeout if the hardware does
* not interrupt. Expect HARD_INT, but check for SYN_ALARM timeout. * not interrupt.
*/ */
f_set_timer(&f_tmr_timeout, system_hz/30, f_timeout); f_set_timer(&f_tmr_timeout, system_hz/30, f_timeout);
f_busy = BSY_IO; f_busy = BSY_IO;
do { do {
receive(ANY, &mess); receive(ANY, &mess);
if (mess.m_type == SYN_ALARM) {
f_expire_tmrs(NULL, NULL); if (is_notify(mess.m_type)) {
} else if(mess.m_type == DEV_PING) { switch (_ENDPOINT_P(mess.m_source)) {
notify(mess.m_source); case CLOCK:
f_expire_tmrs(NULL, NULL);
break;
case RS_PROC_NR:
notify(mess.m_source);
break;
default :
f_busy = BSY_IDLE;
break;
}
} else { } else {
f_busy = BSY_IDLE; f_busy = BSY_IDLE;
} }
@ -998,7 +1017,7 @@ int len; /* command length */
/* Output a command to the controller. */ /* Output a command to the controller. */
/* Set a synchronous alarm to force a timeout if the hardware does /* Set a synchronous alarm to force a timeout if the hardware does
* not interrupt. Expect HARD_INT, but check for SYN_ALARM timeout. * not interrupt.
* Note that the actual check is done by the code that issued the * Note that the actual check is done by the code that issued the
* fdc_command() call. * fdc_command() call.
*/ */
@ -1118,17 +1137,24 @@ PRIVATE void f_reset()
if ((s=sys_voutb(byte_out, 2)) != OK) if ((s=sys_voutb(byte_out, 2)) != OK)
panic("FLOPPY", "Sys_voutb in f_reset() failed", s); panic("FLOPPY", "Sys_voutb in f_reset() failed", s);
/* A synchronous alarm timer was set in fdc_command. Expect a HARD_INT /* A synchronous alarm timer was set in fdc_command. Expect an interrupt,
* message to collect the reset interrupt, but be prepared to handle the * but be prepared to handle a timeout.
* SYN_ALARM message on a timeout.
*/ */
do { do {
receive(ANY, &mess); receive(ANY, &mess);
if (mess.m_type == SYN_ALARM) { if (is_notify(mess.m_type)) {
f_expire_tmrs(NULL, NULL); switch (_ENDPOINT_P(mess.m_source)) {
} else if(mess.m_type == DEV_PING) { case CLOCK:
notify(mess.m_source); f_expire_tmrs(NULL, NULL);
} else { /* expect HARD_INT */ break;
case RS_PROC_NR:
notify(mess.m_source);
break;
default :
f_busy = BSY_IDLE;
break;
}
} else { /* expect hw interrupt */
f_busy = BSY_IDLE; f_busy = BSY_IDLE;
} }
} while (f_busy == BSY_IO); } while (f_busy == BSY_IO);
@ -1165,16 +1191,21 @@ PRIVATE int f_intr_wait()
*/ */
message mess; message mess;
/* We expect a HARD_INT message from the interrupt handler, but if there is /* We expect an interrupt, but if a timeout, occurs, report an error. */
* a timeout, a SYN_ALARM notification is received instead. If a timeout
* occurs, report an error.
*/
do { do {
receive(ANY, &mess); receive(ANY, &mess);
if (mess.m_type == SYN_ALARM) { if (is_notify(mess.m_type)) {
f_expire_tmrs(NULL, NULL); switch (_ENDPOINT_P(mess.m_source)) {
} else if(mess.m_type == DEV_PING) { case CLOCK:
notify(mess.m_source); f_expire_tmrs(NULL, NULL);
break;
case RS_PROC_NR:
notify(mess.m_source);
break;
default :
f_busy = BSY_IDLE;
break;
}
} else { } else {
f_busy = BSY_IDLE; f_busy = BSY_IDLE;
} }

View File

@ -60,6 +60,7 @@
#include <net/gen/eth_io.h> #include <net/gen/eth_io.h>
#include <ibm/pci.h> #include <ibm/pci.h>
#include <minix/ds.h> #include <minix/ds.h>
#include <minix/endpoint.h>
#include <timers.h> #include <timers.h>
@ -277,6 +278,29 @@ _PROTOTYPE( static void do_outl, (port_t port, u32_t v) );
_PROTOTYPE( static void tell_dev, (vir_bytes start, size_t size, _PROTOTYPE( static void tell_dev, (vir_bytes start, size_t size,
int pci_bus, int pci_dev, int pci_func) ); int pci_bus, int pci_dev, int pci_func) );
PRIVATE void handle_hw_intr(void)
{
int i, r;
fxp_t *fp;
for (i= 0, fp= &fxp_table[0]; i<FXP_PORT_NR; i++, fp++) {
if (fp->fxp_mode != FM_ENABLED)
return;
fxp_handler(fp);
r= sys_irqenable(&fp->fxp_hook);
if (r != OK) {
panic("FXP", "unable enable interrupts", r);
}
if (!fp->fxp_got_int)
return;
fp->fxp_got_int= 0;
assert(fp->fxp_flags & FF_ENABLED);
fxp_check_ints(fp);
}
}
/*===========================================================================* /*===========================================================================*
* main * * main *
*===========================================================================*/ *===========================================================================*/
@ -285,7 +309,6 @@ int main(int argc, char *argv[])
message m; message m;
int i, r; int i, r;
u32_t tasknr; u32_t tasknr;
fxp_t *fp;
long v; long v;
vir_bytes ft = sizeof(*fxp_table)*FXP_PORT_NR; vir_bytes ft = sizeof(*fxp_table)*FXP_PORT_NR;
@ -322,9 +345,33 @@ int main(int argc, char *argv[])
if ((r= receive(ANY, &m)) != OK) if ((r= receive(ANY, &m)) != OK)
panic("FXP","receive failed", r); panic("FXP","receive failed", r);
if (is_notify(m.m_type)) {
switch (_ENDPOINT_P(m.m_source)) {
case RS_PROC_NR:
notify(m.m_source);
break;
case HARDWARE:
handle_hw_intr();
break;
case SYSTEM:
if (sigismember((sigset_t *)&m.NOTIFY_ARG, SIGKSTOP))
fxp_stop();
break;
case PM_PROC_NR:
break;
case CLOCK:
fxp_expire_timers();
break;
default:
panic("FXP"," illegal notify from", m.m_source);
}
/* get new message */
continue;
}
switch (m.m_type) switch (m.m_type)
{ {
case DEV_PING: notify(m.m_source); continue;
case DL_WRITEV: fxp_writev(&m, FALSE, TRUE); break; case DL_WRITEV: fxp_writev(&m, FALSE, TRUE); break;
case DL_WRITE: fxp_writev(&m, FALSE, FALSE); break; case DL_WRITE: fxp_writev(&m, FALSE, FALSE); break;
case DL_WRITEV_S: fxp_writev_s(&m, FALSE); break; case DL_WRITEV_S: fxp_writev_s(&m, FALSE); break;
@ -335,34 +382,6 @@ int main(int argc, char *argv[])
case DL_GETSTAT: fxp_getstat(&m); break; case DL_GETSTAT: fxp_getstat(&m); break;
case DL_GETSTAT_S: fxp_getstat_s(&m); break; case DL_GETSTAT_S: fxp_getstat_s(&m); break;
case DL_GETNAME: fxp_getname(&m); break; case DL_GETNAME: fxp_getname(&m); break;
case HARD_INT:
for (i= 0, fp= &fxp_table[0]; i<FXP_PORT_NR; i++, fp++)
{
if (fp->fxp_mode != FM_ENABLED)
continue;
fxp_handler(fp);
r= sys_irqenable(&fp->fxp_hook);
if (r != OK)
{
panic("FXP",
"unable enable interrupts", r);
}
if (!fp->fxp_got_int)
continue;
fp->fxp_got_int= 0;
assert(fp->fxp_flags & FF_ENABLED);
fxp_check_ints(fp);
}
break;
case SYS_SIG: {
sigset_t sigset = m.NOTIFY_ARG;
if (sigismember(&sigset, SIGKSTOP)) fxp_stop();
break;
}
case PROC_EVENT: break;
case SYN_ALARM: fxp_expire_timers(); break;
default: default:
panic("FXP"," illegal message", m.m_type); panic("FXP"," illegal message", m.m_type);
} }

View File

@ -49,6 +49,7 @@
#include <assert.h> #include <assert.h>
#include <minix/syslib.h> #include <minix/syslib.h>
#include <minix/endpoint.h>
#include <ibm/pci.h> #include <ibm/pci.h>
#include <minix/ds.h> #include <minix/ds.h>
@ -318,11 +319,46 @@ void main( int argc, char **argv )
if (ec->ec_irq != 0) if (ec->ec_irq != 0)
sys_irqdisable(&ec->ec_hook); sys_irqdisable(&ec->ec_hook);
} }
if (is_notify(m.m_type)) {
switch(_ENDPOINT_P(m.m_source)) {
case RS_PROC_NR:
notify(m.m_source);
break;
case TTY_PROC_NR:
lance_dump();
break;
case SYSTEM:
if (sigismember((sigset_t*)&m.NOTIFY_ARG, SIGKSTOP))
lance_stop();
break;
case HARDWARE:
for (i=0;i<EC_PORT_NR_MAX;++i)
{
ec= &ec_table[i];
if (ec->mode != EC_ENABLED)
continue;
irq=ec->ec_irq;
{
ec->ec_int_pending = 0;
ec_check_ints(ec);
do_int(ec);
}
}
break;
case PM_PROC_NR:
break;
default:
panic( "lance", "illegal notify source", m.m_source);
}
/* get next message */
continue;
}
switch (m.m_type) switch (m.m_type)
{ {
case DEV_PING:
notify(m.m_source);
continue;
case DL_WRITEV_S: case DL_WRITEV_S:
do_vwrite_s(&m, FALSE); do_vwrite_s(&m, FALSE);
break; break;
@ -341,32 +377,6 @@ void main( int argc, char **argv )
case DL_GETNAME: case DL_GETNAME:
do_getname(&m); do_getname(&m);
break; break;
case FKEY_PRESSED:
lance_dump();
break;
case SYS_SIG:
{
sigset_t set = m.NOTIFY_ARG;
if ( sigismember( &set, SIGKSTOP ) )
lance_stop();
}
break;
case HARD_INT:
for (i=0;i<EC_PORT_NR_MAX;++i)
{
ec= &ec_table[i];
if (ec->mode != EC_ENABLED)
continue;
{
ec->ec_int_pending = 0;
ec_check_ints(ec);
do_int(ec);
}
}
break;
case PROC_EVENT:
/* ignore event */
break;
default: default:
panic( "lance", "illegal message", m.m_type); panic( "lance", "illegal message", m.m_type);
} }

View File

@ -41,6 +41,7 @@
#include "../drivers.h" #include "../drivers.h"
#include <sys/ioc_disk.h> #include <sys/ioc_disk.h>
#include <minix/mq.h> #include <minix/mq.h>
#include <minix/endpoint.h>
#include "driver.h" #include "driver.h"
/* Claim space for variables. */ /* Claim space for variables. */
@ -94,6 +95,35 @@ struct driver *dp; /* Device dependent entry points. */
proc_nr = mess.IO_ENDPT; proc_nr = mess.IO_ENDPT;
/* Now carry out the work. */ /* Now carry out the work. */
if (is_notify(mess.m_type)) {
switch (_ENDPOINT_P(mess.m_source)) {
case HARDWARE:
/* leftover interrupt or expired timer. */
if(dp->dr_hw_int) {
(*dp->dr_hw_int)(dp, &mess);
}
break;
case PM_PROC_NR:
case SYSTEM:
(*dp->dr_signal)(dp, &mess);
break;
case CLOCK:
(*dp->dr_alarm)(dp, &mess);
break;
case RS_PROC_NR:
notify(mess.m_source);
break;
default:
if(dp->dr_other)
r = (*dp->dr_other)(dp, &mess, 0);
else
r = EINVAL;
goto send_reply;
}
/* done, get a new message */
continue;
}
switch(mess.m_type) { switch(mess.m_type) {
case DEV_OPEN: r = (*dp->dr_open)(dp, &mess); break; case DEV_OPEN: r = (*dp->dr_open)(dp, &mess); break;
case DEV_CLOSE: r = (*dp->dr_close)(dp, &mess); break; case DEV_CLOSE: r = (*dp->dr_close)(dp, &mess); break;
@ -116,18 +146,6 @@ struct driver *dp; /* Device dependent entry points. */
case DEV_GATHER_S: case DEV_GATHER_S:
case DEV_SCATTER_S: r = do_vrdwt(dp, &mess, 1); break; case DEV_SCATTER_S: r = do_vrdwt(dp, &mess, 1); break;
case HARD_INT: /* leftover interrupt or expired timer. */
if(dp->dr_hw_int) {
(*dp->dr_hw_int)(dp, &mess);
}
continue;
case PROC_EVENT:
case SYS_SIG: (*dp->dr_signal)(dp, &mess);
continue; /* don't reply */
case SYN_ALARM: (*dp->dr_alarm)(dp, &mess);
continue; /* don't reply */
case DEV_PING: notify(mess.m_source);
continue;
default: default:
if(dp->dr_other) if(dp->dr_other)
r = (*dp->dr_other)(dp, &mess, 0); r = (*dp->dr_other)(dp, &mess, 0);
@ -136,6 +154,7 @@ struct driver *dp; /* Device dependent entry points. */
break; break;
} }
send_reply:
/* Clean up leftover state. */ /* Clean up leftover state. */
(*dp->dr_cleanup)(); (*dp->dr_cleanup)();

View File

@ -1,6 +1,7 @@
/* This file contains device independent device driver interface. /* This file contains device independent device driver interface.
* *
* Changes: * Changes:
* Sep 25, 2009 removed all macros depending on NOTIFY_FROM() (T. Hruby)
* Jul 25, 2005 added SYS_SIG 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) * Sep 15, 2004 added SYN_ALARM type for timeouts (Jorrit N. Herder)
* Jul 23, 2004 removed kernel dependencies (Jorrit N. Herder) * Jul 23, 2004 removed kernel dependencies (Jorrit N. Herder)
@ -41,6 +42,7 @@
#include "../drivers.h" #include "../drivers.h"
#include <sys/ioc_disk.h> #include <sys/ioc_disk.h>
#include <minix/mq.h> #include <minix/mq.h>
#include <minix/endpoint.h>
#include "driver.h" #include "driver.h"
/* Claim space for variables. */ /* Claim space for variables. */
@ -91,19 +93,6 @@ struct driver *dp; /* Device dependent entry points. */
device_caller = mess.m_source; device_caller = mess.m_source;
proc_nr = mess.IO_ENDPT; proc_nr = mess.IO_ENDPT;
#if 0
if (mess.m_type != SYN_ALARM && mess.m_type != DEV_PING &&
mess.m_type != 4105 /* notify from TTY */ &&
mess.m_type != DEV_SELECT &&
mess.m_type != DEV_READ_S &&
mess.m_type != DIAGNOSTICS_S &&
mess.m_type != CANCEL)
{
printf("libdriver_asyn`driver_task: msg %d / 0x%x from %d\n",
mess.m_type, mess.m_type, mess.m_source);
}
#endif
if (mess.m_type == DEV_SELECT) if (mess.m_type == DEV_SELECT)
{ {
static int first= 1; static int first= 1;
@ -119,6 +108,36 @@ struct driver *dp; /* Device dependent entry points. */
} }
/* Now carry out the work. */ /* Now carry out the work. */
if (is_notify(mess.m_type)) {
switch (_ENDPOINT_P(mess.m_source)) {
case HARDWARE:
/* leftover interrupt or expired timer. */
if(dp->dr_hw_int) {
(*dp->dr_hw_int)(dp, &mess);
}
break;
case PM_PROC_NR:
case SYSTEM:
(*dp->dr_signal)(dp, &mess);
break;
case CLOCK:
(*dp->dr_alarm)(dp, &mess);
break;
case RS_PROC_NR:
notify(mess.m_source);
break;
default:
if(dp->dr_other)
r = (*dp->dr_other)(dp, &mess, 0);
else
r = EINVAL;
goto send_reply;
}
/* done, get a new message */
continue;
}
switch(mess.m_type) { switch(mess.m_type) {
case DEV_OPEN: r = (*dp->dr_open)(dp, &mess); break; case DEV_OPEN: r = (*dp->dr_open)(dp, &mess); break;
case DEV_CLOSE: r = (*dp->dr_close)(dp, &mess); break; case DEV_CLOSE: r = (*dp->dr_close)(dp, &mess); break;
@ -141,18 +160,6 @@ struct driver *dp; /* Device dependent entry points. */
case DEV_GATHER_S: case DEV_GATHER_S:
case DEV_SCATTER_S: r = do_vrdwt(dp, &mess, 1); break; case DEV_SCATTER_S: r = do_vrdwt(dp, &mess, 1); break;
case HARD_INT: /* leftover interrupt or expired timer. */
if(dp->dr_hw_int) {
(*dp->dr_hw_int)(dp, &mess);
}
continue;
case PROC_EVENT:
case SYS_SIG: (*dp->dr_signal)(dp, &mess);
continue; /* don't reply */
case SYN_ALARM: (*dp->dr_alarm)(dp, &mess);
continue; /* don't reply */
case DEV_PING: notify(mess.m_source);
continue;
default: default:
if(dp->dr_other) if(dp->dr_other)
r = (*dp->dr_other)(dp, &mess, 0); r = (*dp->dr_other)(dp, &mess, 0);
@ -161,6 +168,7 @@ struct driver *dp; /* Device dependent entry points. */
break; break;
} }
send_reply:
/* Clean up leftover state. */ /* Clean up leftover state. */
(*dp->dr_cleanup)(); (*dp->dr_cleanup)();

View File

@ -64,6 +64,7 @@
#include <sys/ioc_memory.h> #include <sys/ioc_memory.h>
#include <ibm/pci.h> #include <ibm/pci.h>
#include <minix/ds.h> #include <minix/ds.h>
#include <minix/endpoint.h>
#include "../../kernel/const.h" #include "../../kernel/const.h"
#include "../../kernel/config.h" #include "../../kernel/config.h"
#include "../../kernel/type.h" #include "../../kernel/type.h"
@ -225,7 +226,7 @@ _PROTOTYPE (static int or_handler, (t_or *orp));
_PROTOTYPE (static void or_dump, (message *m)); _PROTOTYPE (static void or_dump, (message *m));
/* The message used in the main loop is made global, so that rl_watchdog_f() /* The message used in the main loop is made global, so that rl_watchdog_f()
* can change its message type to fake a HARD_INT message. * can change its message type to fake an interrupt message.
*/ */
PRIVATE message m; PRIVATE message m;
PRIVATE int int_event_check; /* set to TRUE if events arrived */ PRIVATE int int_event_check; /* set to TRUE if events arrived */
@ -271,10 +272,40 @@ int main(int argc, char *argv[]) {
if ((r = receive (ANY, &m)) != OK) if ((r = receive (ANY, &m)) != OK)
panic(__FILE__, "orinoco: receive failed", NO_NUM); panic(__FILE__, "orinoco: receive failed", NO_NUM);
if (is_notify(m.m_type)) {
switch (_ENDPOINT_P(m.m_source)) {
case RS_PROC_NR:
notify(m.m_source);
break;
case CLOCK:
or_watchdog_f(NULL);
break;
case SYSTEM:
if (sigismember((sigset_t*)&m.NOTIFY_ARG,
SIGKSTOP))
orinoco_stop();
break;
case HARDWARE:
do_hard_int();
if (int_event_check)
check_int_events();
break ;
case TTY_PROC_NR:
or_dump(&m);
break;
case PM_PROC_NR:
break;
default:
panic(__FILE__,
"orinoco: illegal notify from:",
m.m_source);
}
/* done, get new message */
continue;
}
switch (m.m_type) { switch (m.m_type) {
case DEV_PING:
notify(m.m_source);
break;
case DL_WRITEV: case DL_WRITEV:
or_writev (&m, FALSE, TRUE); or_writev (&m, FALSE, TRUE);
break; break;
@ -305,26 +336,6 @@ int main(int argc, char *argv[]) {
case DL_GETNAME: case DL_GETNAME:
or_getname(&m); or_getname(&m);
break; break;
case SYN_ALARM:
or_watchdog_f(NULL);
break;
case SYS_SIG:
{
sigset_t sigset = m.NOTIFY_ARG;
if ( sigismember( &sigset, SIGKSTOP ) )
orinoco_stop();
}
break;
case HARD_INT:
do_hard_int();
if (int_event_check)
check_int_events();
break ;
case FKEY_PRESSED:
or_dump(&m);
break;
case PROC_EVENT:
break;
default: default:
panic(__FILE__,"orinoco: illegal message:", m.m_type); panic(__FILE__,"orinoco: illegal message:", m.m_type);
} }
@ -341,8 +352,8 @@ static void check_int_events(void) {
int i; int i;
t_or *orp; t_or *orp;
/* the HARD_INT message doesn't contain information about the port, try /* the interrupt message doesn't contain information about the port, try
* to find it */ * to find it */
for (orp = or_table; for (orp = or_table;
orp < or_table + OR_PORT_NR; orp++) { orp < or_table + OR_PORT_NR; orp++) {
if (orp->or_mode != OR_M_ENABLED) if (orp->or_mode != OR_M_ENABLED)

View File

@ -6,6 +6,7 @@ main.c
#include <ibm/pci.h> #include <ibm/pci.h>
#include <minix/rs.h> #include <minix/rs.h>
#include <minix/endpoint.h>
#include "pci.h" #include "pci.h"
@ -55,6 +56,21 @@ int main(void)
printf("PCI: receive from ANY failed: %d\n", r); printf("PCI: receive from ANY failed: %d\n", r);
break; break;
} }
if (is_notify(m.m_type)) {
switch (_ENDPOINT_P(m.m_source)) {
case PM_PROC_NR:
break;
default:
printf("PCI: got notify from %d\n",
m.m_source);
break;
}
/* done, get a new message */
continue;
}
switch(m.m_type) switch(m.m_type)
{ {
case BUSC_PCI_INIT: do_init(&m); break; case BUSC_PCI_INIT: do_init(&m); break;
@ -75,7 +91,6 @@ int main(void)
case BUSC_PCI_SLOT_NAME_S: do_slot_name_s(&m); break; case BUSC_PCI_SLOT_NAME_S: do_slot_name_s(&m); break;
case BUSC_PCI_SET_ACL: do_set_acl(&m); break; case BUSC_PCI_SET_ACL: do_set_acl(&m); break;
case BUSC_PCI_DEL_ACL: do_del_acl(&m); break; case BUSC_PCI_DEL_ACL: do_del_acl(&m); break;
case PROC_EVENT: break;
default: default:
printf("PCI: got message from %d, type %d\n", printf("PCI: got message from %d, type %d\n",
m.m_source, m.m_type); m.m_source, m.m_type);

View File

@ -32,6 +32,7 @@
* Note: since only 1 printer is supported, minor dev is not used at present. * Note: since only 1 printer is supported, minor dev is not used at present.
*/ */
#include <minix/endpoint.h>
#include "../drivers.h" #include "../drivers.h"
/* Control bits (in port_base + 2). "+" means positive logic and "-" means /* Control bits (in port_base + 2). "+" means positive logic and "-" means
@ -133,6 +134,27 @@ PUBLIC void main(void)
while (TRUE) { while (TRUE) {
receive(ANY, &pr_mess); receive(ANY, &pr_mess);
if (is_notify(pr_mess.m_type)) {
switch (_ENDPOINT_P(pr_mess.m_source)) {
case HARDWARE:
do_printer_output();
break;
case SYSTEM:
do_signal(&pr_mess);
break;
case RS_PROC_NR:
notify(pr_mess.m_source);
break;
case PM_PROC_NR:
break;
default:
reply(TASK_REPLY, pr_mess.m_source,
pr_mess.IO_ENDPT, EINVAL);
}
continue;
}
switch(pr_mess.m_type) { switch(pr_mess.m_type) {
case DEV_OPEN: case DEV_OPEN:
do_initialize(); /* initialize */ do_initialize(); /* initialize */
@ -143,10 +165,6 @@ PUBLIC void main(void)
case DEV_WRITE_S: do_write(&pr_mess, 1); break; case DEV_WRITE_S: do_write(&pr_mess, 1); break;
case DEV_STATUS: do_status(&pr_mess); break; case DEV_STATUS: do_status(&pr_mess); break;
case CANCEL: do_cancel(&pr_mess); break; case CANCEL: do_cancel(&pr_mess); break;
case HARD_INT: do_printer_output(); break;
case SYS_SIG: do_signal(&pr_mess); break;
case DEV_PING: notify(pr_mess.m_source); break;
case PROC_EVENT: break;
default: default:
reply(TASK_REPLY, pr_mess.m_source, pr_mess.IO_ENDPT, EINVAL); reply(TASK_REPLY, pr_mess.m_source, pr_mess.IO_ENDPT, EINVAL);
} }
@ -385,10 +403,10 @@ PRIVATE void prepare_output()
*===========================================================================*/ *===========================================================================*/
PRIVATE void do_printer_output() PRIVATE void do_printer_output()
{ {
/* This function does the actual output to the printer. This is called on /* This function does the actual output to the printer. This is called on an
* a HARD_INT message sent from the generic interrupt handler that 'forwards' * interrupt message sent from the generic interrupt handler that 'forwards'
* interrupts to this driver. The generic handler did not reenable the * interrupts to this driver. The generic handler did not reenable the printer
* printer IRQ yet! * IRQ yet!
*/ */
unsigned long status; unsigned long status;

View File

@ -67,6 +67,7 @@
#include <minix/syslib.h> #include <minix/syslib.h>
#include <minix/type.h> #include <minix/type.h>
#include <minix/sysutil.h> #include <minix/sysutil.h>
#include <minix/endpoint.h>
#include <timers.h> #include <timers.h>
#include <net/hton.h> #include <net/hton.h>
#include <net/gen/ether.h> #include <net/gen/ether.h>
@ -293,7 +294,7 @@ _PROTOTYPE( static void tell_dev, (vir_bytes start, size_t size,
int pci_bus, int pci_dev, int pci_func) ); int pci_bus, int pci_dev, int pci_func) );
/* The message used in the main loop is made global, so that rl_watchdog_f() /* The message used in the main loop is made global, so that rl_watchdog_f()
* can change its message type to fake a HARD_INT message. * can change its message type to fake an interrupt message.
*/ */
PRIVATE message m; PRIVATE message m;
PRIVATE int int_event_check; /* set to TRUE if events arrived */ PRIVATE int int_event_check; /* set to TRUE if events arrived */
@ -347,9 +348,53 @@ int main(int argc, char *argv[])
if ((r= receive(ANY, &m)) != OK) if ((r= receive(ANY, &m)) != OK)
panic("rtl8139","receive failed", r); panic("rtl8139","receive failed", r);
if (is_notify(m.m_type)) {
switch (_ENDPOINT_P(m.m_source)) {
case RS_PROC_NR:
notify(m.m_source);
break;
case CLOCK:
/*
* Under MINIX, synchronous alarms are
* used instead of watchdog functions.
* The approach is very different: MINIX
* VMD timeouts are handled within the
* kernel (the watchdog is executed by
* CLOCK), and notify() the driver in
* some cases. MINIX timeouts result in
* a SYN_ALARM message to the driver and
* thus are handled where they should be
* handled. Locally, watchdog functions
* are used again.
*/
rl_watchdog_f(NULL);
break;
case SYSTEM:
if (sigismember((sigset_t*)&m.NOTIFY_ARG,
SIGKSTOP))
rtl8139_stop();
break;
case HARDWARE:
do_hard_int();
if (int_event_check)
check_int_events();
break ;
case TTY_PROC_NR:
rtl8139_dump(&m);
break;
case PM_PROC_NR:
break;
default:
panic("rtl8139","illegal notify from",
m.m_source);
}
/* done, get nwe message */
continue;
}
switch (m.m_type) switch (m.m_type)
{ {
case DEV_PING: notify(m.m_source); break;
case DL_WRITE: rl_writev(&m, FALSE, FALSE); break; case DL_WRITE: rl_writev(&m, FALSE, FALSE); break;
case DL_WRITEV: rl_writev(&m, FALSE, TRUE); break; case DL_WRITEV: rl_writev(&m, FALSE, TRUE); break;
case DL_WRITEV_S: rl_writev_s(&m, FALSE); break; case DL_WRITEV_S: rl_writev_s(&m, FALSE); break;
@ -363,33 +408,6 @@ int main(int argc, char *argv[])
#if 0 #if 0
case DL_STOP: do_stop(&m); break; case DL_STOP: do_stop(&m); break;
#endif #endif
case SYN_ALARM:
/* Under MINIX, synchronous alarms are used instead of
* watchdog functions. The approach is very different:
* MINIX VMD timeouts are handled within the kernel
* (the watchdog is executed by CLOCK), and notify()
* the driver in some cases.
* MINIX timeouts result in a SYN_ALARM message to the
* driver and thus are handled where they should be
* handled. Locally, watchdog functions are used again.
*/
rl_watchdog_f(NULL);
break;
case SYS_SIG:
{
sigset_t sigset = m.NOTIFY_ARG;
if ( sigismember( &sigset, SIGKSTOP ) )
rtl8139_stop();
}
break;
case HARD_INT:
do_hard_int();
if (int_event_check)
check_int_events();
break ;
case FKEY_PRESSED: rtl8139_dump(&m); break;
case PROC_EVENT:
break;
default: default:
panic("rtl8139","illegal message", m.m_type); panic("rtl8139","illegal message", m.m_type);
} }

View File

@ -24,6 +24,7 @@
* May 20 1995 Author: Michel R. Prevenier * May 20 1995 Author: Michel R. Prevenier
*/ */
#include <minix/endpoint.h>
#include "sb16.h" #include "sb16.h"
@ -97,6 +98,21 @@ PUBLIC void main()
caller = mess.m_source; caller = mess.m_source;
proc_nr = mess.IO_ENDPT; proc_nr = mess.IO_ENDPT;
if (is_notify(mess.m_type)) {
switch (_ENDPOINT_P(mess.m_source)) {
case HARDWARE:
dsp_hardware_msg();
continue; /* don't reply */
case SYSTEM:
continue; /* don't reply */
default:
r = EINVAL;
}
/* dont with this message */
goto send_reply;
}
/* Now carry out the work. */ /* Now carry out the work. */
switch(mess.m_type) { switch(mess.m_type) {
case DEV_OPEN: r = dsp_open(); break; case DEV_OPEN: r = dsp_open(); break;
@ -111,11 +127,10 @@ PUBLIC void main()
#endif #endif
case DEV_STATUS: dsp_status(&mess); continue; /* don't reply */ case DEV_STATUS: dsp_status(&mess); continue; /* don't reply */
case HARD_INT: dsp_hardware_msg(); continue; /* don't reply */
case SYS_SIG: continue; /* don't reply */
default: r = EINVAL; default: r = EINVAL;
} }
send_reply:
/* Finally, prepare and send the reply message. */ /* Finally, prepare and send the reply message. */
reply(TASK_REPLY, caller, proc_nr, r); reply(TASK_REPLY, caller, proc_nr, r);
} }

View File

@ -1176,7 +1176,6 @@ int scode; /* scan code for a function key */
/* See if an observer is registered and send it a message. */ /* See if an observer is registered and send it a message. */
if (proc_nr != NONE) { if (proc_nr != NONE) {
m.NOTIFY_TYPE = FKEY_PRESSED;
notify(proc_nr); notify(proc_nr);
} }
return(TRUE); return(TRUE);

View File

@ -18,8 +18,9 @@
* *
* The valid messages and their parameters are: * The valid messages and their parameters are:
* *
* HARD_INT: output has been completed or input has arrived * notify from HARDWARE: output has been completed or input has arrived
* SYS_SIG: e.g., MINIX wants to shutdown; run code to cleanly stop * notify from SYSTEM : e.g., MINIX wants to shutdown; run code to
* cleanly stop
* DEV_READ: a process wants to read from a terminal * DEV_READ: a process wants to read from a terminal
* DEV_WRITE: a process wants to write on a terminal * DEV_WRITE: a process wants to write on a terminal
* DEV_IOCTL: a process wants to change a terminal's parameters * DEV_IOCTL: a process wants to change a terminal's parameters
@ -64,6 +65,7 @@
#include <minix/sys_config.h> #include <minix/sys_config.h>
#include <minix/tty.h> #include <minix/tty.h>
#include <minix/keymap.h> #include <minix/keymap.h>
#include <minix/endpoint.h>
#include "tty.h" #include "tty.h"
#include <sys/time.h> #include <sys/time.h>
@ -190,32 +192,50 @@ PUBLIC int main(void)
* request and should be handled separately. These extra functions * request and should be handled separately. These extra functions
* do not operate on a device, in constrast to the driver requests. * do not operate on a device, in constrast to the driver requests.
*/ */
switch (tty_mess.m_type) {
case SYN_ALARM: /* fall through */ if (is_notify(tty_mess.m_type)) {
expire_timers(); /* run watchdogs of expired timers */ switch (_ENDPOINT_P(tty_mess.m_source)) {
continue; /* contine to check for events */ case CLOCK:
case DEV_PING: /* run watchdogs of expired timers */
notify(tty_mess.m_source); expire_timers();
continue; break;
case HARD_INT: { /* hardware interrupt notification */ case RS_PROC_NR:
if (tty_mess.NOTIFY_ARG & kbd_irq_set) notify(tty_mess.m_source);
kbd_interrupt(&tty_mess);/* fetch chars from keyboard */ break;
case HARDWARE:
/* hardware interrupt notification */
/* fetch chars from keyboard */
if (tty_mess.NOTIFY_ARG & kbd_irq_set)
kbd_interrupt(&tty_mess);
#if NR_RS_LINES > 0 #if NR_RS_LINES > 0
if (tty_mess.NOTIFY_ARG & rs_irq_set) /* serial I/O */
rs_interrupt(&tty_mess);/* serial I/O */ if (tty_mess.NOTIFY_ARG & rs_irq_set)
rs_interrupt(&tty_mess);
#endif #endif
expire_timers(); /* run watchdogs of expired timers */ /* run watchdogs of expired timers */
continue; /* contine to check for events */ expire_timers();
} break;
case PROC_EVENT: { case PM_PROC_NR:
cons_stop(); /* switch to primary console */ /* switch to primary console */
continue; cons_stop();
} break;
case SYS_SIG: { /* system signal */ case SYSTEM:
sigset_t sigset = (sigset_t) tty_mess.NOTIFY_ARG; /* system signal */
if (sigismember(&sigset, SIGKMESS)) do_new_kmess(&tty_mess); if (sigismember((sigset_t*)&tty_mess.NOTIFY_ARG,
SIGKMESS))
do_new_kmess(&tty_mess);
break;
default:
/* do nothing */
break;
}
/* done, get new message */
continue; continue;
} }
switch (tty_mess.m_type) {
case DIAGNOSTICS_OLD: /* a server wants to print some */ case DIAGNOSTICS_OLD: /* a server wants to print some */
#if 0 #if 0
if (tty_mess.m_source != LOG_PROC_NR) if (tty_mess.m_source != LOG_PROC_NR)

View File

@ -9,9 +9,10 @@
*/ */
#include "inc.h" /* include master header file */ #include "inc.h" /* include master header file */
#include <minix/endpoint.h>
/* Allocate space for the global variables. */ /* Allocate space for the global variables. */
int who_e; /* caller's proc number */ endpoint_t who_e; /* caller's proc number */
int callnr; /* system call number */ int callnr; /* system call number */
int sys_panic; /* flag to indicate system-wide panic */ int sys_panic; /* flag to indicate system-wide panic */
@ -46,10 +47,22 @@ PUBLIC int main(int argc, char **argv)
/* Wait for incoming message, sets 'callnr' and 'who'. */ /* Wait for incoming message, sets 'callnr' and 'who'. */
get_work(&m); get_work(&m);
if (is_notify(callnr)) {
switch (_ENDPOINT_P(who_e)) {
case PM_PROC_NR:
sig_handler();
break;
default:
report("DS","warning, got illegal notify from:",
m.m_source);
result = EINVAL;
goto send_reply;
}
/* done, get a new message */
}
switch (callnr) { switch (callnr) {
case PROC_EVENT:
sig_handler();
continue;
case DS_PUBLISH: case DS_PUBLISH:
result = do_publish(&m); result = do_publish(&m);
break; break;
@ -70,6 +83,7 @@ PUBLIC int main(int argc, char **argv)
result = EINVAL; result = EINVAL;
} }
send_reply:
/* Finally send reply message, unless disabled. */ /* Finally send reply message, unless disabled. */
if (result != EDONTREPLY) { if (result != EDONTREPLY) {
m.m_type = result; /* build reply message */ m.m_type = result; /* build reply message */

View File

@ -51,6 +51,7 @@ from DL_ETH:
#include <unistd.h> #include <unistd.h>
#include <sys/svrctl.h> #include <sys/svrctl.h>
#include <minix/ds.h> #include <minix/ds.h>
#include <minix/endpoint.h>
#include "mq.h" #include "mq.h"
#include "qp.h" #include "qp.h"
@ -253,22 +254,25 @@ PUBLIC void main()
mq_free(mq); mq_free(mq);
} }
#else /* Minix 3 */ #else /* Minix 3 */
else if (m_type == SYN_ALARM) else if (is_notify(m_type))
{ {
clck_tick(&mq->mq_mess); if (_ENDPOINT_P(source) == CLOCK)
mq_free(mq); {
} clck_tick(&mq->mq_mess);
else if (m_type == PROC_EVENT) mq_free(mq);
{ }
/* signaled */ else if (_ENDPOINT_P(source) == PM_PROC_NR)
/* probably SIGTERM */ {
mq_free(mq); /* signaled */
} /* probably SIGTERM */
else if (m_type & NOTIFY_MESSAGE) mq_free(mq);
{ }
/* A driver is (re)started. */ else
eth_check_drivers(&mq->mq_mess); {
mq_free(mq); /* A driver is (re)started. */
eth_check_drivers(&mq->mq_mess);
mq_free(mq);
}
} }
#endif #endif
else if (m_type == DL_CONF_REPLY || m_type == DL_TASK_REPLY || else if (m_type == DL_CONF_REPLY || m_type == DL_TASK_REPLY ||

View File

@ -8,6 +8,7 @@
*/ */
#include "inc.h" #include "inc.h"
#include <minix/endpoint.h>
/* Allocate space for the global variables. */ /* Allocate space for the global variables. */
message m_in; /* the input message itself */ message m_in; /* the input message itself */
@ -42,25 +43,28 @@ PUBLIC int main(int argc, char **argv)
/* Wait for incoming message, sets 'callnr' and 'who'. */ /* Wait for incoming message, sets 'callnr' and 'who'. */
get_work(); get_work();
switch (callnr) { if (is_notify(callnr)) {
case SYS_SIG: switch (_ENDPOINT_P(who_e)) {
printf("got SYS_SIG message\n"); case SYSTEM:
sigset = m_in.NOTIFY_ARG; printf("got message from SYSTEM\n");
for ( result=0; result< _NSIG; result++) { sigset = m_in.NOTIFY_ARG;
if (sigismember(&sigset, result)) for ( result=0; result< _NSIG; result++) {
printf("signal %d found\n", result); if (sigismember(&sigset, result))
} printf("signal %d found\n", result);
continue; }
case PROC_EVENT: continue;
result = EDONTREPLY; case PM_PROC_NR:
break; result = EDONTREPLY;
case FKEY_PRESSED: break;
result = do_fkey_pressed(&m_in); case TTY_PROC_NR:
break; result = do_fkey_pressed(&m_in);
case DEV_PING: break;
notify(m_in.m_source); case RS_PROC_NR:
continue; notify(m_in.m_source);
default: continue;
}
}
else {
printf("IS: warning, got illegal request %d from %d\n", printf("IS: warning, got illegal request %d from %d\n",
callnr, m_in.m_source); callnr, m_in.m_source);
result = EDONTREPLY; result = EDONTREPLY;

View File

@ -127,7 +127,7 @@ message *m_in; /* pointer to message */
if (src != FS_PROC_NR) { if (src != FS_PROC_NR) {
if(src == PM_PROC_NR) { if(src == PM_PROC_NR) {
if(fs_m_in.m_type == PROC_EVENT) if(is_notify(fs_m_in.m_type))
srcok = 1; /* Normal exit request. */ srcok = 1; /* Normal exit request. */
else else
printf("MFS: unexpected message from PM\n"); printf("MFS: unexpected message from PM\n");
@ -145,7 +145,7 @@ message *m_in; /* pointer to message */
} while(!srcok); } while(!srcok);
assert((src == FS_PROC_NR && !unmountdone) || assert((src == FS_PROC_NR && !unmountdone) ||
(src == PM_PROC_NR && fs_m_in.m_type == PROC_EVENT)); (src == PM_PROC_NR && is_notify(fs_m_in.m_type)));
} }

View File

@ -67,19 +67,29 @@ PUBLIC int main()
get_work(); /* wait for an PM system call */ get_work(); /* wait for an PM system call */
/* Check for system notifications first. Special cases. */ /* Check for system notifications first. Special cases. */
if (is_notify(call_nr)) {
switch(who_p) {
case CLOCK:
pm_expire_timers(m_in.NOTIFY_TIMESTAMP);
result = SUSPEND; /* don't reply */
break;
case SYSTEM: /* signals pending */
sigset = m_in.NOTIFY_ARG;
if (sigismember(&sigset, SIGKSIG)) {
(void) ksig_pending();
}
result = SUSPEND; /* don't reply */
break;
default :
result = ENOSYS;
}
/* done, send reply and continue */
goto send_reply;
}
switch(call_nr) switch(call_nr)
{ {
case SYN_ALARM:
pm_expire_timers(m_in.NOTIFY_TIMESTAMP);
result = SUSPEND; /* don't reply */
break;
case SYS_SIG: /* signals pending */
sigset = m_in.NOTIFY_ARG;
if (sigismember(&sigset, SIGKSIG)) {
(void) ksig_pending();
}
result = SUSPEND; /* don't reply */
break;
case PM_GET_WORK: case PM_GET_WORK:
if (who_e == FS_PROC_NR) if (who_e == FS_PROC_NR)
{ {
@ -139,6 +149,7 @@ PUBLIC int main()
break; break;
} }
send_reply:
/* Send the results back to the user to indicate completion. */ /* Send the results back to the user to indicate completion. */
if (result != SUSPEND) setreply(who_p, result); if (result != SUSPEND) setreply(who_p, result);

View File

@ -64,12 +64,12 @@ PUBLIC int main(void)
/* Notification messages are control messages and do not need a reply. /* Notification messages are control messages and do not need a reply.
* These include heartbeat messages and system notifications. * These include heartbeat messages and system notifications.
*/ */
if (m.m_type & NOTIFY_MESSAGE) { if (is_notify(m.m_type)) {
switch (call_nr) { switch (who_p) {
case SYN_ALARM: case CLOCK:
do_period(&m); /* check drivers status */ do_period(&m); /* check drivers status */
continue; continue;
case PROC_EVENT: case PM_PROC_NR:
sig_handler(); sig_handler();
continue; continue;
default: /* heartbeat notification */ default: /* heartbeat notification */