determine the information defined by these macros from the m_source field of the
notify message.
#include <minix/ipc.h>
#include <minix/syslib.h>
#include <minix/sysutil.h>
+#include <minix/endpoint.h>
#include <ibm/pci.h>
/* Offsets from capability pointer */
r= receive(ANY, &m);
if (r != OK)
panic(__FILE__, "receive failed", r);
- switch(m.m_type)
- {
- case PROC_EVENT:
- do_pm_notify(&m);
- continue;
-
- case IOMMU_MAP:
+ if (is_notify(m.m_type)) {
+ if (_ENDPOINT_P(m.m_source) == PM_PROC_NR) {
+ do_pm_notify(&m);
+ continue;
+ }
+ }
+ else if (m.m_type == IOMMU_MAP) {
r= do_add4pci(&m);
m.m_type= r;
send(m.m_source, &m);
#include <minix/sysutil.h>
#include <minix/keymap.h>
#include <minix/type.h>
+#include <minix/endpoint.h>
#include <sys/ioc_disk.h>
#include <ibm/pci.h>
#include <sys/mman.h>
return(ERR);
}
- /* Schedule a wakeup call, some controllers are flaky. This is done with
- * a synchronous alarm. If a timeout occurs a SYN_ALARM message is sent
- * from HARDWARE, so that w_intr_wait() can call w_timeout() in case the
- * controller was not able to execute the command. Leftover timeouts are
- * simply ignored by the main loop.
+ /* Schedule a wakeup call, some controllers are flaky. This is done with a
+ * synchronous alarm. If a timeout occurs a notify from CLOCK is sent, so that
+ * w_intr_wait() can call w_timeout() in case the controller was not able to
+ * execute the command. Leftover timeouts are simply ignored by the main loop.
*/
sys_setalarm(wakeup_ticks, 0);
return(ERR);
}
- /* Schedule a wakeup call, some controllers are flaky. This is done with
- * a synchronous alarm. If a timeout occurs a SYN_ALARM message is sent
- * from HARDWARE, so that w_intr_wait() can call w_timeout() in case the
- * controller was not able to execute the command. Leftover timeouts are
- * simply ignored by the main loop.
+ /* Schedule a wakeup call, some controllers are flaky. This is done with a
+ * synchronous alarm. If a timeout occurs a notify from CLOCK is sent, so that
+ * w_intr_wait() can call w_timeout() in case the controller was not able to
+ * execute the command. Leftover timeouts are simply ignored by the main loop.
*/
sys_setalarm(wakeup_ticks, 0);
int rr;
if((rr=receive(ANY, &m)) != OK)
panic("at_wini", "receive(ANY) failed", rr);
- switch(m.m_type) {
- case SYN_ALARM:
- /* Timeout. */
- w_timeout(); /* a.o. set w_status */
- break;
- case HARD_INT:
- /* Interrupt. */
- r= sys_inb(w_wn->base_cmd + REG_STATUS, &w_status);
- if (r != 0)
- panic("at_wini", "sys_inb failed", r);
- w_wn->w_status= w_status;
- ack_irqs(m.NOTIFY_ARG);
- break;
- case DEV_PING:
- /* RS monitor ping. */
- notify(m.m_source);
- break;
- default:
- /* unhandled message.
- * queue it and handle it in the libdriver loop.
+ if (is_notify(m.m_type)) {
+ switch (_ENDPOINT_P(m.m_source)) {
+ case CLOCK:
+ /* Timeout. */
+ w_timeout(); /* a.o. set w_status */
+ break;
+ case HARDWARE:
+ /* Interrupt. */
+ r= sys_inb(w_wn->base_cmd +
+ REG_STATUS, &w_status);
+ if (r != 0)
+ panic("at_wini",
+ "sys_inb failed", r);
+ w_wn->w_status= w_status;
+ ack_irqs(m.NOTIFY_ARG);
+ break;
+ case RS_PROC_NR:
+ /* RS monitor ping. */
+ notify(m.m_source);
+ 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);
}
#include <stdlib.h>
#include <minix/com.h>
+#include <minix/endpoint.h>
#include <net/hton.h>
#include <net/gen/ether.h>
#include <net/gen/eth_io.h>
_PROTOTYPE( static void do_vir_outsw, (port_t port, int proc,
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 *
*===========================================================================*/
int main(int argc, char *argv[])
{
message m;
- int i, irq, r, tasknr;
+ int i, r, tasknr;
dpeth_t *dep;
long v;
if ((r= receive(ANY, &m)) != OK)
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)
{
- case DEV_PING: notify(m.m_source); continue;
case DL_WRITE: do_vwrite(&m, FALSE, FALSE); break;
case DL_WRITEV: do_vwrite(&m, FALSE, TRUE); break;
case DL_WRITEV_S: do_vwrite_s(&m, FALSE); break;
case DL_GETSTAT_S: do_getstat_s(&m); break;
case DL_GETNAME: do_getname(&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:
panic("", "dp8390: illegal message", m.m_type);
}
**
** m_type DL_PORT DL_PROC DL_COUNT DL_MODE DL_ADDR
** +------------+---------+---------+--------+-------+---------+
-** | HARD_INT | | | | | |
-** +------------+---------+---------+--------+-------+---------+
-** | SYN_ALARM | | | | | |
+** | NOTIFY from HARDWARE, CLOCK, TTY, RS, PM, SYSTEM |
** +------------+---------+---------+--------+-------+---------+
** | HARD_STOP | | | | | |
** +------------+---------+---------+--------+-------+---------+
-** | FKEY_PRESSED | | | | | (99)
-** +------------+---------+---------+--------+-------+---------+
** | DL_WRITE | port nr | proc nr | count | mode | address | (3)
** +------------+---------+---------+--------+-------+---------+
** | DL_WRITEV | port nr | proc nr | count | mode | address | (4)
#include "drivers.h"
#include <minix/keymap.h>
+#include <minix/endpoint.h>
#include <net/hton.h>
#include <net/gen/ether.h>
#include <net/gen/eth_io.h>
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)
** Function: Main entry for dp task
DEBUG(printf("eth: got message %d, ", m.m_type));
- switch (m.m_type) {
- case DEV_PING: /* Status request from RS */
- notify(m.m_source);
+ if (is_notify(m.m_type)) {
+ switch(_ENDPOINT_P(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;
+ }
+
+ switch (m.m_type) {
case DL_WRITEV_S: /* Write message to device */
do_vwrite_s(&m);
break;
case DL_GETNAME:
do_getname(&m);
break;
- case SYN_ALARM: /* to be defined */
- do_watchdog(&m);
- break;
case DL_STOP: /* Stop device */
do_stop(&m);
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 */
panic(DevName, TypeErrMsg, m.m_type);
break;
#include <ibm/diskparm.h>
#include <minix/sysutil.h>
#include <minix/syslib.h>
+#include <minix/endpoint.h>
/* I/O Ports used by floppy disk task. */
#define DOR 0x3F2 /* motor drive control bits */
if (running) return; /* motor was already running */
/* 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_busy = BSY_IO;
do {
receive(ANY, &mess);
- if (mess.m_type == SYN_ALARM) {
- f_expire_tmrs(NULL, NULL);
- } else if(mess.m_type == DEV_PING) {
- notify(mess.m_source);
+
+ if (is_notify(mess.m_type)) {
+ switch (_ENDPOINT_P(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 {
f_busy = BSY_IDLE;
}
/* Give head time to settle on a format, no retrying here! */
if (f_device & FORMAT_DEV_BIT) {
/* 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_busy = BSY_IO;
do {
receive(ANY, &mess);
- if (mess.m_type == SYN_ALARM) {
- f_expire_tmrs(NULL, NULL);
- } else if(mess.m_type == DEV_PING) {
- notify(mess.m_source);
+
+ if (is_notify(mess.m_type)) {
+ switch (_ENDPOINT_P(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 {
f_busy = BSY_IDLE;
}
/* Output a command to the controller. */
/* 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
* fdc_command() call.
*/
if ((s=sys_voutb(byte_out, 2)) != OK)
panic("FLOPPY", "Sys_voutb in f_reset() failed", s);
- /* A synchronous alarm timer was set in fdc_command. Expect a HARD_INT
- * message to collect the reset interrupt, but be prepared to handle the
- * SYN_ALARM message on a timeout.
+ /* A synchronous alarm timer was set in fdc_command. Expect an interrupt,
+ * but be prepared to handle a timeout.
*/
do {
receive(ANY, &mess);
- if (mess.m_type == SYN_ALARM) {
- f_expire_tmrs(NULL, NULL);
- } else if(mess.m_type == DEV_PING) {
- notify(mess.m_source);
- } else { /* expect HARD_INT */
+ if (is_notify(mess.m_type)) {
+ switch (_ENDPOINT_P(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 { /* expect hw interrupt */
f_busy = BSY_IDLE;
}
} while (f_busy == BSY_IO);
*/
message mess;
- /* We expect a HARD_INT message from the interrupt handler, but if there is
- * a timeout, a SYN_ALARM notification is received instead. If a timeout
- * occurs, report an error.
- */
+ /* We expect an interrupt, but if a timeout, occurs, report an error. */
do {
receive(ANY, &mess);
- if (mess.m_type == SYN_ALARM) {
- f_expire_tmrs(NULL, NULL);
- } else if(mess.m_type == DEV_PING) {
- notify(mess.m_source);
+ if (is_notify(mess.m_type)) {
+ switch (_ENDPOINT_P(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 {
f_busy = BSY_IDLE;
}
#include <net/gen/eth_io.h>
#include <ibm/pci.h>
#include <minix/ds.h>
+#include <minix/endpoint.h>
#include <timers.h>
_PROTOTYPE( static void tell_dev, (vir_bytes start, size_t size,
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 *
*===========================================================================*/
message m;
int i, r;
u32_t tasknr;
- fxp_t *fp;
long v;
vir_bytes ft = sizeof(*fxp_table)*FXP_PORT_NR;
if ((r= receive(ANY, &m)) != OK)
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)
{
- case DEV_PING: notify(m.m_source); continue;
case DL_WRITEV: fxp_writev(&m, FALSE, TRUE); break;
case DL_WRITE: fxp_writev(&m, FALSE, FALSE); break;
case DL_WRITEV_S: fxp_writev_s(&m, FALSE); break;
case DL_GETSTAT: fxp_getstat(&m); break;
case DL_GETSTAT_S: fxp_getstat_s(&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:
panic("FXP"," illegal message", m.m_type);
}
#include <assert.h>
#include <minix/syslib.h>
+#include <minix/endpoint.h>
#include <ibm/pci.h>
#include <minix/ds.h>
if (ec->ec_irq != 0)
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)
{
- case DEV_PING:
- notify(m.m_source);
- continue;
case DL_WRITEV_S:
do_vwrite_s(&m, FALSE);
break;
case DL_GETNAME:
do_getname(&m);
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:
panic( "lance", "illegal message", m.m_type);
}
#include "../drivers.h"
#include <sys/ioc_disk.h>
#include <minix/mq.h>
+#include <minix/endpoint.h>
#include "driver.h"
/* Claim space for variables. */
proc_nr = mess.IO_ENDPT;
/* 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) {
case DEV_OPEN: r = (*dp->dr_open)(dp, &mess); break;
case DEV_CLOSE: r = (*dp->dr_close)(dp, &mess); break;
case DEV_GATHER_S:
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:
if(dp->dr_other)
r = (*dp->dr_other)(dp, &mess, 0);
break;
}
+send_reply:
/* Clean up leftover state. */
(*dp->dr_cleanup)();
/* This file contains device independent device driver interface.
*
* 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)
* Sep 15, 2004 added SYN_ALARM type for timeouts (Jorrit N. Herder)
* Jul 23, 2004 removed kernel dependencies (Jorrit N. Herder)
#include "../drivers.h"
#include <sys/ioc_disk.h>
#include <minix/mq.h>
+#include <minix/endpoint.h>
#include "driver.h"
/* Claim space for variables. */
device_caller = mess.m_source;
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)
{
static int first= 1;
}
/* 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) {
case DEV_OPEN: r = (*dp->dr_open)(dp, &mess); break;
case DEV_CLOSE: r = (*dp->dr_close)(dp, &mess); break;
case DEV_GATHER_S:
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:
if(dp->dr_other)
r = (*dp->dr_other)(dp, &mess, 0);
break;
}
+send_reply:
/* Clean up leftover state. */
(*dp->dr_cleanup)();
#include <sys/ioc_memory.h>
#include <ibm/pci.h>
#include <minix/ds.h>
+#include <minix/endpoint.h>
#include "../../kernel/const.h"
#include "../../kernel/config.h"
#include "../../kernel/type.h"
_PROTOTYPE (static void or_dump, (message *m));
/* 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 int int_event_check; /* set to TRUE if events arrived */
if ((r = receive (ANY, &m)) != OK)
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) {
- case DEV_PING:
- notify(m.m_source);
- break;
case DL_WRITEV:
or_writev (&m, FALSE, TRUE);
break;
case DL_GETNAME:
or_getname(&m);
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:
panic(__FILE__,"orinoco: illegal message:", m.m_type);
}
int i;
t_or *orp;
- /* the HARD_INT message doesn't contain information about the port, try
- * to find it */
+ /* the interrupt message doesn't contain information about the port, try
+ * to find it */
for (orp = or_table;
orp < or_table + OR_PORT_NR; orp++) {
if (orp->or_mode != OR_M_ENABLED)
#include <ibm/pci.h>
#include <minix/rs.h>
+#include <minix/endpoint.h>
#include "pci.h"
printf("PCI: receive from ANY failed: %d\n", r);
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)
{
case BUSC_PCI_INIT: do_init(&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_DEL_ACL: do_del_acl(&m); break;
- case PROC_EVENT: break;
default:
printf("PCI: got message from %d, type %d\n",
m.m_source, m.m_type);
* Note: since only 1 printer is supported, minor dev is not used at present.
*/
+#include <minix/endpoint.h>
#include "../drivers.h"
/* Control bits (in port_base + 2). "+" means positive logic and "-" means
while (TRUE) {
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) {
case DEV_OPEN:
do_initialize(); /* initialize */
case DEV_WRITE_S: do_write(&pr_mess, 1); break;
case DEV_STATUS: do_status(&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:
reply(TASK_REPLY, pr_mess.m_source, pr_mess.IO_ENDPT, EINVAL);
}
*===========================================================================*/
PRIVATE void do_printer_output()
{
-/* This function does the actual output to the printer. This is called on
- * a HARD_INT message sent from the generic interrupt handler that 'forwards'
- * interrupts to this driver. The generic handler did not reenable the
- * printer IRQ yet!
+/* This function does the actual output to the printer. This is called on an
+ * interrupt message sent from the generic interrupt handler that 'forwards'
+ * interrupts to this driver. The generic handler did not reenable the printer
+ * IRQ yet!
*/
unsigned long status;
#include <minix/syslib.h>
#include <minix/type.h>
#include <minix/sysutil.h>
+#include <minix/endpoint.h>
#include <timers.h>
#include <net/hton.h>
#include <net/gen/ether.h>
int pci_bus, int pci_dev, int pci_func) );
/* 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 int int_event_check; /* set to TRUE if events arrived */
if ((r= receive(ANY, &m)) != OK)
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)
{
- case DEV_PING: notify(m.m_source); break;
case DL_WRITE: rl_writev(&m, FALSE, FALSE); break;
case DL_WRITEV: rl_writev(&m, FALSE, TRUE); break;
case DL_WRITEV_S: rl_writev_s(&m, FALSE); break;
#if 0
case DL_STOP: do_stop(&m); break;
#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:
panic("rtl8139","illegal message", m.m_type);
}
* May 20 1995 Author: Michel R. Prevenier
*/
+#include <minix/endpoint.h>
#include "sb16.h"
caller = mess.m_source;
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. */
switch(mess.m_type) {
case DEV_OPEN: r = dsp_open(); break;
#endif
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;
}
+send_reply:
/* Finally, prepare and send the reply message. */
reply(TASK_REPLY, caller, proc_nr, r);
}
/* See if an observer is registered and send it a message. */
if (proc_nr != NONE) {
- m.NOTIFY_TYPE = FKEY_PRESSED;
notify(proc_nr);
}
return(TRUE);
*
* The valid messages and their parameters are:
*
- * HARD_INT: output has been completed or input has arrived
- * SYS_SIG: e.g., MINIX wants to shutdown; run code to cleanly stop
+ * notify from HARDWARE: output has been completed or input has arrived
+ * 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_WRITE: a process wants to write on a terminal
* DEV_IOCTL: a process wants to change a terminal's parameters
#include <minix/sys_config.h>
#include <minix/tty.h>
#include <minix/keymap.h>
+#include <minix/endpoint.h>
#include "tty.h"
#include <sys/time.h>
* request and should be handled separately. These extra functions
* do not operate on a device, in constrast to the driver requests.
*/
- switch (tty_mess.m_type) {
- case SYN_ALARM: /* fall through */
- expire_timers(); /* run watchdogs of expired timers */
- continue; /* contine to check for events */
- case DEV_PING:
- notify(tty_mess.m_source);
- continue;
- case HARD_INT: { /* hardware interrupt notification */
- if (tty_mess.NOTIFY_ARG & kbd_irq_set)
- kbd_interrupt(&tty_mess);/* fetch chars from keyboard */
+
+ if (is_notify(tty_mess.m_type)) {
+ switch (_ENDPOINT_P(tty_mess.m_source)) {
+ case CLOCK:
+ /* run watchdogs of expired timers */
+ expire_timers();
+ break;
+ case RS_PROC_NR:
+ notify(tty_mess.m_source);
+ 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 (tty_mess.NOTIFY_ARG & rs_irq_set)
- rs_interrupt(&tty_mess);/* serial I/O */
+ /* serial I/O */
+ if (tty_mess.NOTIFY_ARG & rs_irq_set)
+ rs_interrupt(&tty_mess);
#endif
- expire_timers(); /* run watchdogs of expired timers */
- continue; /* contine to check for events */
- }
- case PROC_EVENT: {
- cons_stop(); /* switch to primary console */
- continue;
- }
- case SYS_SIG: { /* system signal */
- sigset_t sigset = (sigset_t) tty_mess.NOTIFY_ARG;
- if (sigismember(&sigset, SIGKMESS)) do_new_kmess(&tty_mess);
+ /* run watchdogs of expired timers */
+ expire_timers();
+ break;
+ case PM_PROC_NR:
+ /* switch to primary console */
+ cons_stop();
+ break;
+ case SYSTEM:
+ /* system signal */
+ if (sigismember((sigset_t*)&tty_mess.NOTIFY_ARG,
+ SIGKMESS))
+ do_new_kmess(&tty_mess);
+ break;
+ default:
+ /* do nothing */
+ break;
+ }
+
+ /* done, get new message */
continue;
}
+
+ switch (tty_mess.m_type) {
case DIAGNOSTICS_OLD: /* a server wants to print some */
#if 0
if (tty_mess.m_source != LOG_PROC_NR)
*/
#include "inc.h" /* include master header file */
+#include <minix/endpoint.h>
/* 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 sys_panic; /* flag to indicate system-wide panic */
/* Wait for incoming message, sets 'callnr' and 'who'. */
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) {
- case PROC_EVENT:
- sig_handler();
- continue;
case DS_PUBLISH:
result = do_publish(&m);
break;
result = EINVAL;
}
+send_reply:
/* Finally send reply message, unless disabled. */
if (result != EDONTREPLY) {
m.m_type = result; /* build reply message */
#include <unistd.h>
#include <sys/svrctl.h>
#include <minix/ds.h>
+#include <minix/endpoint.h>
#include "mq.h"
#include "qp.h"
mq_free(mq);
}
#else /* Minix 3 */
- else if (m_type == SYN_ALARM)
+ else if (is_notify(m_type))
{
- clck_tick(&mq->mq_mess);
- mq_free(mq);
- }
- else if (m_type == PROC_EVENT)
- {
- /* signaled */
- /* probably SIGTERM */
- mq_free(mq);
- }
- else if (m_type & NOTIFY_MESSAGE)
- {
- /* A driver is (re)started. */
- eth_check_drivers(&mq->mq_mess);
- mq_free(mq);
+ if (_ENDPOINT_P(source) == CLOCK)
+ {
+ clck_tick(&mq->mq_mess);
+ mq_free(mq);
+ }
+ else if (_ENDPOINT_P(source) == PM_PROC_NR)
+ {
+ /* signaled */
+ /* probably SIGTERM */
+ mq_free(mq);
+ }
+ else
+ {
+ /* A driver is (re)started. */
+ eth_check_drivers(&mq->mq_mess);
+ mq_free(mq);
+ }
}
#endif
else if (m_type == DL_CONF_REPLY || m_type == DL_TASK_REPLY ||
*/
#include "inc.h"
+#include <minix/endpoint.h>
/* Allocate space for the global variables. */
message m_in; /* the input message itself */
/* Wait for incoming message, sets 'callnr' and 'who'. */
get_work();
- switch (callnr) {
- case SYS_SIG:
- printf("got SYS_SIG message\n");
- sigset = m_in.NOTIFY_ARG;
- for ( result=0; result< _NSIG; result++) {
- if (sigismember(&sigset, result))
- printf("signal %d found\n", result);
- }
- continue;
- case PROC_EVENT:
- result = EDONTREPLY;
- break;
- case FKEY_PRESSED:
- result = do_fkey_pressed(&m_in);
- break;
- case DEV_PING:
- notify(m_in.m_source);
- continue;
- default:
+ if (is_notify(callnr)) {
+ switch (_ENDPOINT_P(who_e)) {
+ case SYSTEM:
+ printf("got message from SYSTEM\n");
+ sigset = m_in.NOTIFY_ARG;
+ for ( result=0; result< _NSIG; result++) {
+ if (sigismember(&sigset, result))
+ printf("signal %d found\n", result);
+ }
+ continue;
+ case PM_PROC_NR:
+ result = EDONTREPLY;
+ break;
+ case TTY_PROC_NR:
+ result = do_fkey_pressed(&m_in);
+ break;
+ case RS_PROC_NR:
+ notify(m_in.m_source);
+ continue;
+ }
+ }
+ else {
printf("IS: warning, got illegal request %d from %d\n",
callnr, m_in.m_source);
result = EDONTREPLY;
if (src != FS_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. */
else
printf("MFS: unexpected message from PM\n");
} while(!srcok);
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)));
}
get_work(); /* wait for an PM system call */
/* 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)
{
- 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:
if (who_e == FS_PROC_NR)
{
break;
}
+send_reply:
/* Send the results back to the user to indicate completion. */
if (result != SUSPEND) setreply(who_p, result);
/* Notification messages are control messages and do not need a reply.
* These include heartbeat messages and system notifications.
*/
- if (m.m_type & NOTIFY_MESSAGE) {
- switch (call_nr) {
- case SYN_ALARM:
+ if (is_notify(m.m_type)) {
+ switch (who_p) {
+ case CLOCK:
do_period(&m); /* check drivers status */
continue;
- case PROC_EVENT:
+ case PM_PROC_NR:
sig_handler();
continue;
default: /* heartbeat notification */