Small update to shared driver code: SYS_EVENT (signal) is now known.

Fixed drivers. HARD_STOP message no longer exists.
This commit is contained in:
Jorrit Herder 2005-07-26 12:50:25 +00:00
parent 3d0b9140f2
commit a63d324caa
8 changed files with 43 additions and 79 deletions

View file

@ -236,11 +236,10 @@ PRIVATE struct driver w_dtab = {
w_transfer, /* do the I/O */
nop_cleanup, /* nothing to clean up */
w_geometry, /* tell the geometry of the disk */
nop_stop, /* no cleanup needed on shutdown */
nop_alarm, /* ignore leftover alarms, function key presses, CANCELs, SELECTs */
nop_fkey,
nop_cancel,
nop_select,
nop_signal, /* no cleanup needed on shutdown */
nop_alarm, /* ignore leftover alarms */
nop_cancel, /* ignore CANCELs */
nop_select, /* ignore selects */
w_other /* catch-all for unrecognized commands and ioctls */
};

View file

@ -234,7 +234,7 @@ PRIVATE u8_t f_results[MAX_RESULTS];/* the controller can give lots of output */
PRIVATE timer_t f_tmr_timeout; /* timer for various timeouts */
PRIVATE timer_t *f_timers; /* queue of floppy timers */
PRIVATE clock_t f_next_timeout; /* the next timeout time */
FORWARD _PROTOTYPE( void f_expire_tmrs, (struct driver *dp) );
FORWARD _PROTOTYPE( void f_expire_tmrs, (struct driver *dp, message *m_ptr) );
FORWARD _PROTOTYPE( void f_set_timer, (timer_t *tp, clock_t delta,
tmr_func_t watchdog) );
FORWARD _PROTOTYPE( void stop_motor, (timer_t *tp) );
@ -257,7 +257,7 @@ FORWARD _PROTOTYPE( void f_reset, (void) );
FORWARD _PROTOTYPE( int f_intr_wait, (void) );
FORWARD _PROTOTYPE( int read_id, (void) );
FORWARD _PROTOTYPE( int f_do_open, (struct driver *dp, message *m_ptr) );
FORWARD _PROTOTYPE( void floppy_stop, (struct driver *dp) );
FORWARD _PROTOTYPE( void floppy_stop, (struct driver *dp, message *m_ptr) );
FORWARD _PROTOTYPE( int test_read, (int density) );
FORWARD _PROTOTYPE( void f_geometry, (struct partition *entry));
@ -274,7 +274,6 @@ PRIVATE struct driver f_dtab = {
f_geometry, /* tell the geometry of the diskette */
floppy_stop, /* floppy cleanup on shutdown */
f_expire_tmrs,/* expire all alarm timers */
nop_fkey, /* ignore function keys and CANCELs */
nop_cancel,
nop_select,
NULL
@ -315,7 +314,7 @@ PUBLIC void main()
/*===========================================================================*
* f_expire_tmrs *
*===========================================================================*/
PRIVATE void f_expire_tmrs(struct driver *dp)
PRIVATE void f_expire_tmrs(struct driver *dp, message *m_ptr)
{
/* A synchronous alarm message was received. Check if there are any expired
* timers. Possibly reschedule the next alarm.
@ -694,7 +693,7 @@ PRIVATE void start_motor()
do {
receive(ANY, &mess);
if (mess.m_type == SYN_ALARM) {
f_expire_tmrs(NULL);
f_expire_tmrs(NULL, NULL);
} else {
f_busy = BSY_IDLE;
}
@ -722,13 +721,16 @@ timer_t *tp;
/*===========================================================================*
* floppy_stop *
*===========================================================================*/
PRIVATE void floppy_stop(struct driver *dp)
PRIVATE void floppy_stop(struct driver *dp, message *m_ptr)
{
/* Stop all activity and cleanly exit with the system. */
int s;
if ((s=sys_outb(DOR, ENABLE_INT)) != OK)
panic("FLOPPY","Sys_outb in floppy_stop() failed", s);
sys_exit(0);
sigset_t sigset = m_ptr->NOTIFY_ARG;
if (sigismember(&sigset, SIGTERM) || sigismember(&sigset, SIGKSTOP)) {
if ((s=sys_outb(DOR, ENABLE_INT)) != OK)
panic("FLOPPY","Sys_outb in floppy_stop() failed", s);
exit(0);
}
}
@ -776,7 +778,7 @@ PRIVATE int seek()
do {
receive(ANY, &mess);
if (mess.m_type == SYN_ALARM) {
f_expire_tmrs(NULL);
f_expire_tmrs(NULL, NULL);
} else {
f_busy = BSY_IDLE;
}
@ -1051,7 +1053,7 @@ PRIVATE void f_reset()
do {
receive(ANY, &mess);
if (mess.m_type == SYN_ALARM) {
f_expire_tmrs(NULL);
f_expire_tmrs(NULL, NULL);
} else { /* expect HARD_INT */
f_busy = BSY_IDLE;
}
@ -1097,7 +1099,7 @@ PRIVATE int f_intr_wait()
do {
receive(ANY, &mess);
if (mess.m_type == SYN_ALARM) {
f_expire_tmrs(NULL);
f_expire_tmrs(NULL, NULL);
} else {
f_busy = BSY_IDLE;
}

View file

@ -1,9 +1,10 @@
/* This file contains device independent device driver interface.
* Author: Kees J. Bot.
*
* Changes:
* Jul 25, 2005 added SYS_EVENT type for signals (Jorrit N. Herder)
* Sep 15, 2004 added SYN_ALARM type for timeouts (Jorrit N. Herder)
* Aug 18, 2004 added HARD_STOP type for shutdown (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)
*
*
* The drivers support the following operations (using message format m2):
@ -32,9 +33,6 @@
* The file contains one entry point:
*
* driver_task: called by the device dependent task entry
*
*
* Constructed 92/04/02 by Kees J. Bot from the old AT wini and floppy driver.
*/
#include "../drivers.h"
@ -110,11 +108,9 @@ struct driver *dp; /* Device dependent entry points. */
case HARD_INT: /* leftover interrupt or expired timer. */
continue;
case HARD_STOP: (*dp->dr_stop)(dp);
case SYS_EVENT: (*dp->dr_signal)(dp, &mess);
continue; /* don't reply */
case SYN_ALARM: (*dp->dr_alarm)(dp);
continue; /* don't reply */
case FKEY_PRESSED: (*dp->dr_fkey)(dp, &mess);
case SYN_ALARM: (*dp->dr_alarm)(dp, &mess);
continue; /* don't reply */
default:
if(dp->dr_other)
@ -282,20 +278,21 @@ message *mp;
}
/*============================================================================*
* nop_stop *
* nop_signal *
*============================================================================*/
PUBLIC void nop_stop(dp)
PUBLIC void nop_signal(dp, mp)
struct driver *dp;
message *mp;
{
/* No cleanup needed on shutdown. */
sys_exit(0);
/* Default action for signal is to ignore. */
}
/*============================================================================*
* nop_alarm *
*============================================================================*/
PUBLIC void nop_alarm(dp)
PUBLIC void nop_alarm(dp, mp)
struct driver *dp;
message *mp;
{
/* Ignore the leftover alarm. */
}
@ -317,13 +314,6 @@ PUBLIC void nop_cleanup()
/* Nothing to clean up. */
}
/*===========================================================================*
* nop_fkey *
*===========================================================================*/
PUBLIC void nop_fkey(struct driver *dr, message *m)
{
/* Nothing to do for fkey. */
}
/*===========================================================================*
* nop_cancel *
@ -342,26 +332,6 @@ PUBLIC int nop_select(struct driver *dr, message *m)
}
/*===========================================================================*
* nop_task *
*===========================================================================*/
PUBLIC void nop_task()
{
/* Unused controllers are "serviced" by this task. */
struct driver nop_tab = {
no_name,
do_nop,
do_nop,
do_nop,
nop_prepare,
NULL,
nop_cleanup,
NULL,
nop_stop,
nop_alarm,
};
driver_task(&nop_tab);
}
/*============================================================================*

View file

@ -10,6 +10,7 @@
#include <minix/config.h> /* MUST be first */
#include <ansi.h> /* MUST be second */
#include <minix/type.h>
#include <minix/ipc.h>
#include <minix/com.h>
#include <minix/callnr.h>
#include <sys/types.h>
@ -36,9 +37,8 @@ struct driver {
iovec_t *iov, unsigned nr_req) );
_PROTOTYPE( void (*dr_cleanup), (void) );
_PROTOTYPE( void (*dr_geometry), (struct partition *entry) );
_PROTOTYPE( void (*dr_stop), (struct driver *dp) );
_PROTOTYPE( void (*dr_alarm), (struct driver *dp) );
_PROTOTYPE( void (*dr_fkey), (struct driver *dp, message *m_ptr) );
_PROTOTYPE( void (*dr_signal), (struct driver *dp, message *m_ptr) );
_PROTOTYPE( void (*dr_alarm), (struct driver *dp, message *m_ptr) );
_PROTOTYPE( int (*dr_cancel), (struct driver *dp, message *m_ptr) );
_PROTOTYPE( int (*dr_select), (struct driver *dp, message *m_ptr) );
_PROTOTYPE( int (*dr_other), (struct driver *dp, message *m_ptr) );
@ -67,9 +67,8 @@ _PROTOTYPE( int do_nop, (struct driver *dp, message *m_ptr) );
_PROTOTYPE( struct device *nop_prepare, (int device) );
_PROTOTYPE( void nop_cleanup, (void) );
_PROTOTYPE( void nop_task, (void) );
_PROTOTYPE( void nop_stop, (struct driver *dp) );
_PROTOTYPE( void nop_alarm, (struct driver *dp) );
_PROTOTYPE( void nop_fkey, (struct driver *dp, message *m_ptr) );
_PROTOTYPE( void nop_signal, (struct driver *dp, message *m_ptr) );
_PROTOTYPE( void nop_alarm, (struct driver *dp, message *m_ptr) );
_PROTOTYPE( int nop_cancel, (struct driver *dp, message *m_ptr) );
_PROTOTYPE( int nop_select, (struct driver *dp, message *m_ptr) );
_PROTOTYPE( int do_diocntl, (struct driver *dp, message *m_ptr) );

View file

@ -46,9 +46,8 @@ PRIVATE struct driver log_dtab = {
log_transfer, /* do the I/O */
nop_cleanup, /* no need to clean up */
log_geometry, /* geometry */
nop_stop, /* no need to clean up on shutdown */
nop_signal, /* no need to clean up on shutdown */
nop_alarm, /* no alarm */
nop_fkey, /* no fkey registered */
log_cancel, /* CANCEL request */
log_select, /* DEV_SELECT request */
log_other /* Unrecognized messages */

View file

@ -46,7 +46,7 @@ FORWARD _PROTOTYPE( int m_do_open, (struct driver *dp, message *m_ptr) );
FORWARD _PROTOTYPE( void m_init, (void) );
FORWARD _PROTOTYPE( int m_ioctl, (struct driver *dp, message *m_ptr) );
FORWARD _PROTOTYPE( void m_geometry, (struct partition *entry) );
FORWARD _PROTOTYPE( void m_random, (struct driver *dp) );
FORWARD _PROTOTYPE( void m_random, (struct driver *dp, message *m_ptr) );
/* Entry points to this driver. */
PRIVATE struct driver m_dtab = {
@ -58,9 +58,8 @@ PRIVATE struct driver m_dtab = {
m_transfer, /* do the I/O */
nop_cleanup, /* no need to clean up */
m_geometry, /* memory device "geometry" */
nop_stop, /* no need to clean up on shutdown */
nop_signal, /* system signals */
m_random, /* get randomness from kernel (alarm) */
nop_fkey, /* ignore function key presses and CANCELs */
nop_cancel,
nop_select,
NULL
@ -285,7 +284,7 @@ PRIVATE void m_init()
}
random_init();
m_random(NULL); /* also set periodic timer */
m_random(NULL, NULL); /* also set periodic timer */
/* Set up memory ranges for /dev/mem. */
#if (CHIP == INTEL)
@ -366,8 +365,9 @@ message *m_ptr; /* pointer to control message */
/*============================================================================*
* m_random *
*============================================================================*/
PRIVATE void m_random(dp)
PRIVATE void m_random(dp, m_ptr)
struct driver *dp; /* pointer to driver structure */
message *m_ptr; /* pointer to alarm message */
{
/* Fetch random information from the kernel to update /dev/random. */
int i, s, r_next, r_size, r_high;

View file

@ -22,7 +22,7 @@
* -------------------------------------------------------
* | HARD_INT | | | | |
* |-------------+---------+---------+---------+---------|
* | HARD_STOP | | | | |
* | SYS_EVENT | | | | |
* |-------------+---------+---------+---------+---------|
* | DEV_WRITE |minor dev| proc nr | count | buf ptr |
* |-------------+---------+---------+---------+---------|
@ -34,8 +34,6 @@
#include "../drivers.h"
#if ENABLE_PRINTER
/* Control bits (in port_base + 2). "+" means positive logic and "-" means
* negative logic. Most of the signals are negative logic on the pins but
* many are converted to positive logic in the ports. Some manuals are
@ -160,9 +158,6 @@ PUBLIC void main(void)
case DEV_WRITE: do_write(&pr_mess); break;
case CANCEL : do_cancel(&pr_mess); break;
case HARD_INT : do_printer_output(); break;
case HARD_STOP: sys_exit(0);
/* never reached */
break;
default:
reply(TASK_REPLY, pr_mess.m_source, pr_mess.PROC_NR, EINVAL);
}
@ -408,5 +403,4 @@ PRIVATE void do_printer_output()
}
#endif /* ENABLE_PRINTER */

View file

@ -542,6 +542,7 @@ int scode; /* scan code for a function key */
#if DEAD_CODE
notify(proc_nr, &m);
#else
printf("alerted %d \n", proc_nr);
alert(proc_nr);
#endif
}
@ -614,7 +615,6 @@ PUBLIC void do_panic_dumps(m)
message *m; /* request message to TTY */
{
/* Wait for keystrokes for printing debugging info and reboot. */
int quiet, code;
/* A panic! Allow debug dumps until user wants to shutdown. */
@ -629,6 +629,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 DIAGNOSTICS: do_diagnostics(m); break;
default: ; /* do nothing */