Created new devctl system call to FS. Moved dmap.h header to include/minix/.

Various updates to support dynamically starting servers and suppress output.
This commit is contained in:
Jorrit Herder
2005-08-02 15:29:17 +00:00
parent ab7c0a9926
commit f44725b777
25 changed files with 215 additions and 141 deletions
+43 -24
View File
@@ -5,10 +5,10 @@
#include "fs.h"
#include "fproc.h"
#include "dmap.h"
#include <string.h>
#include <unistd.h>
#include <minix/com.h>
#include "param.h"
/* Some devices may or may not be there in the next table. */
#define DT(enable, opcl, io, driver, flags) \
@@ -28,39 +28,58 @@
-------------- -------- ------ ----------- ----- ------ ----
*/
struct dmap dmap[NR_DEVICES] = {
DT(1, no_dev, 0, 0, 0) /* 0 = not used */
DT(1, gen_opcl, gen_io, MEMORY, 0) /* 1 = /dev/mem */
DT(ENABLE_FLOPPY, gen_opcl, gen_io, FLOPPY, 0) /* 2 = /dev/fd0 */
DT(NR_CTRLRS >= 1, gen_opcl, gen_io, CTRLR(0), DMAP_MUTABLE) /* 3 = /dev/c0 */
#if ENABLE_USER_TTY
DT(1, tty_opcl, gen_io, TERMINAL, 0) /* 4 = /dev/tty00 */
DT(1, ctty_opcl,ctty_io,TERMINAL, 0) /* 5 = /dev/tty */
#else
DT(1, tty_opcl, gen_io, TTY, 0) /* 4 = /dev/tty00 */
DT(1, ctty_opcl,ctty_io,TTY, 0) /* 5 = /dev/tty */
#endif
DT(ENABLE_PRINTER, gen_opcl, gen_io, PRINTER, 0) /* 6 = /dev/lp */
DT(1, no_dev, 0, 0, 0) /* 0 = not used */
DT(1, gen_opcl, gen_io, MEMORY, 0) /* 1 = /dev/mem */
DT(ENABLE_FLOPPY, gen_opcl, gen_io, NONE, DMAP_MUTABLE) /* 2 = /dev/fd0 */
DT(NR_CTRLRS >= 1, gen_opcl, gen_io, CTRLR(0),DMAP_MUTABLE) /* 3 = /dev/c0 */
DT(1, tty_opcl, gen_io, TTY, 0) /* 4 = /dev/tty00 */
DT(1, ctty_opcl,ctty_io,TTY, 0) /* 5 = /dev/tty */
DT(ENABLE_PRINTER, gen_opcl, gen_io, NONE, DMAP_MUTABLE) /* 6 = /dev/lp */
#if (MACHINE == IBM_PC)
DT(1, no_dev, 0, 0, DMAP_MUTABLE) /* 7 = /dev/ip */
DT(NR_CTRLRS >= 2, gen_opcl, gen_io, CTRLR(1), DMAP_MUTABLE) /* 8 = /dev/c1 */
DT(0, 0, 0, 0, DMAP_MUTABLE) /* 9 = not used */
DT(NR_CTRLRS >= 3, gen_opcl, gen_io, CTRLR(2), DMAP_MUTABLE) /*10 = /dev/c2 */
DT(0, 0, 0, 0, DMAP_MUTABLE) /*11 = not used */
DT(NR_CTRLRS >= 4, gen_opcl, gen_io, CTRLR(3), DMAP_MUTABLE) /*12 = /dev/c3 */
DT(ENABLE_SB16, gen_opcl, gen_io, NONE, 0) /*13 = /dev/audio */
DT(ENABLE_SB16, gen_opcl, gen_io, NONE, 0) /*14 = /dev/mixer */
DT(1, no_dev, 0, 0, DMAP_MUTABLE) /* 7 = /dev/ip */
DT(NR_CTRLRS >= 2, gen_opcl, gen_io, CTRLR(1),DMAP_MUTABLE) /* 8 = /dev/c1 */
DT(0, 0, 0, 0, DMAP_MUTABLE) /* 9 = not used */
DT(NR_CTRLRS >= 3, gen_opcl, gen_io, CTRLR(2),DMAP_MUTABLE) /*10 = /dev/c2 */
DT(0, 0, 0, 0, DMAP_MUTABLE) /*11 = not used */
DT(NR_CTRLRS >= 4, gen_opcl, gen_io, CTRLR(3),DMAP_MUTABLE) /*12 = /dev/c3 */
DT(ENABLE_SB16, gen_opcl, gen_io, NONE, DMAP_MUTABLE) /*13 = /dev/audio */
DT(ENABLE_SB16, gen_opcl, gen_io, NONE, DMAP_MUTABLE) /*14 = /dev/mixer */
DT(1, gen_opcl, gen_io, LOG_PROC_NR, 0) /* 15 = /dev/klog */
#endif /* IBM_PC */
};
/*===========================================================================*
* do_devctl *
*===========================================================================*/
PUBLIC int do_devctl()
{
int result;
switch(m_in.ctl_req) {
case DEV_MAP:
/* Try to update device mapping. */
result = map_driver(m_in.dev_nr, m_in.driver_nr, m_in.dev_style);
break;
case DEV_UNMAP:
result = ENOSYS;
break;
default:
result = EINVAL;
}
return(result);
}
/*===========================================================================*
* map_driver *
*===========================================================================*/
PUBLIC int map_driver(major, proc_nr, dev_style)
PUBLIC int map_driver(major, proc_nr, style)
int major; /* major number of the device */
int proc_nr; /* process number of the driver */
int dev_style; /* style of the device */
int style; /* style of the device */
{
/* Set a new device driver mapping in the dmap table. Given that correct
* arguments are given, this only works if the entry is mutable and the
@@ -82,7 +101,7 @@ int dev_style; /* style of the device */
if (! isokprocnr(proc_nr)) return(EINVAL);
/* Try to update the entry. */
switch (dev_style) {
switch (style) {
case STYLE_DEV: dp->dmap_opcl = gen_opcl; break;
case STYLE_TTY: dp->dmap_opcl = tty_opcl; break;
case STYLE_CLONE: dp->dmap_opcl = clone_opcl; break;