home *** CD-ROM | disk | FTP | other *** search
/ Otherware / Otherware_1_SB_Development.iso / amiga / os / bsdss4.tz / bsdss4 / bsdss / server / i386 / conf.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-07-09  |  7.1 KB  |  279 lines

  1. /* 
  2.  * Mach Operating System
  3.  * Copyright (c) 1992 Carnegie Mellon University
  4.  * All Rights Reserved.
  5.  * 
  6.  * Permission to use, copy, modify and distribute this software and its
  7.  * documentation is hereby granted, provided that both the copyright
  8.  * notice and this permission notice appear in all copies of the
  9.  * software, derivative works or modified versions, and any portions
  10.  * thereof, and that both notices appear in supporting documentation.
  11.  * 
  12.  * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
  13.  * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
  14.  * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
  15.  * 
  16.  * Carnegie Mellon requests users of this software to return to
  17.  * 
  18.  *  Software Distribution Coordinator  or  Software.Distribution@CS.CMU.EDU
  19.  *  School of Computer Science
  20.  *  Carnegie Mellon University
  21.  *  Pittsburgh PA 15213-3890
  22.  * 
  23.  * any improvements or extensions that they make and grant Carnegie Mellon 
  24.  * the rights to redistribute these changes.
  25.  */
  26. /*
  27.  * HISTORY
  28.  * $Log:    conf.c,v $
  29.  * Revision 2.4  92/07/08  16:17:04  mrt
  30.  *     Remove incorrect declaration of seltrue. It is declared
  31.  *     in sys/systm.h
  32.  *     [92/07/02            mrt]
  33.  * 
  34.  * Revision 2.3  92/05/28  17:41:41  rwd
  35.  *     Fix bdevsw "sd" inconsistancy.
  36.  *     [92/05/28            rwd]
  37.  * 
  38.  * Revision 2.2  92/05/25  14:42:07  rwd
  39.  *     Added scsi disk "sd".
  40.  *     [92/05/21            rwd]
  41.  * 
  42.  * Revision 2.1  92/04/21  17:19:07  rwd
  43.  * BSDSS
  44.  * 
  45.  *
  46.  */
  47.  
  48. /*
  49.  * Simplified configuration.
  50.  */
  51. #include <sys/param.h>
  52. #include <sys/systm.h>
  53. #include <sys/buf.h>    /* for B_TAPE */
  54. #include <sys/conf.h>
  55. #include <sys/errno.h>
  56.  
  57. #include <uxkern/device.h>
  58. #include <uxkern/device_utils.h>
  59.  
  60. #include <sys/ioctl.h>    /* for tty */
  61. #include <sys/tty.h>
  62.  
  63. extern int    nulldev();
  64. extern int    enodev();
  65. extern struct tty *nulltty();
  66.  
  67.  
  68. /*
  69.  * Block devices all use the same open/close/strategy routines.
  70.  */
  71. extern int    bdev_open(), bdev_close(), bio_strategy(), bdev_ioctl();
  72. extern int    bdev_dump(), bdev_size();
  73.  
  74. #define    bdev_ops    bdev_open, bdev_close, bio_strategy, bdev_ioctl,\
  75.             bdev_dump, bdev_size
  76.  
  77. struct bdevsw    bdevsw[] =
  78. {
  79. /*0*/    { "hd",        C_BLOCK(16),    bdev_ops },    /* isa */
  80. /*1*/   { "",           0,              bdev_ops },
  81. /*2*/    { "fd",        C_BLOCK(64),    bdev_ops },    /* isa */
  82. /*3*/    { "wt",        B_TAPE,        bdev_ops },    /* isa */
  83. /*4*/   { "",           0,              bdev_ops },
  84. /*5*/    { "sd",        C_BLOCK(16),    bdev_ops },    /* ipsc, isa */
  85.  
  86. };
  87. int    nblkdev = sizeof(bdevsw)/sizeof(bdevsw[0]);
  88.  
  89. extern int    char_open(), char_close(), char_read(), char_write();
  90. extern int    char_ioctl(), char_select();
  91. #define    char_ops \
  92.     char_open, char_close, char_read, char_write, char_ioctl, \
  93.     char_select, nulldev, nulltty
  94.  
  95. extern int    disk_open(), disk_close(), disk_read(), disk_write();
  96. extern int    disk_ioctl();
  97. int        isa_disk_ioctl();    /* forward */
  98. #define    disk_ops \
  99.     disk_open, disk_close, disk_read, disk_write, disk_ioctl, \
  100.     seltrue, nulldev, nulltty
  101.  
  102. #define    isa_disk_ops \
  103.     disk_open, disk_close, disk_read, disk_write, isa_disk_ioctl, \
  104.     seltrue, nulldev, nulltty
  105.  
  106. extern int    tty_open(), tty_close(), tty_read(), tty_write();
  107. extern int    tty_ioctl(), ttselect(), tty_stop();
  108. extern struct tty *tty_find_tty();
  109. #define    tty_ops    \
  110.     tty_open, tty_close, tty_read, tty_write, tty_ioctl, ttselect, \
  111.     tty_stop, tty_find_tty
  112.  
  113. extern int    cons_open(), cons_write(), cons_ioctl();
  114. extern mach_port_t    cons_port();
  115.  
  116. #define    console_ops    \
  117.     cons_open, tty_close, tty_read, cons_write, cons_ioctl, ttselect, \
  118.     tty_stop, tty_find_tty, cons_port
  119.  
  120. extern int    cttyopen(), cttyread(), cttywrite(), cttyioctl(), cttyselect();
  121. #define    ctty_ops \
  122.      cttyopen, nulldev, cttyread, cttywrite, cttyioctl, cttyselect, \
  123.      nulldev, nulltty
  124.  
  125. extern int    logopen(), logclose(), logread(), logioctl(), logselect();
  126. #define    log_ops \
  127.     logopen,  logclose,  logread,  nulldev,   logioctl,  logselect, \
  128.     nulldev, nulltty
  129.  
  130. extern int    mmopen(), mmread(), mmwrite();
  131. #define    mm_ops \
  132.     mmopen,   nulldev,   mmread,   mmwrite,   enodev,     seltrue,  \
  133.     nulldev, nulltty
  134.  
  135. extern int    ptsopen(), ptsclose(), ptsread(), ptswrite();
  136. extern int    ptyioctl(), ptsstop();
  137. #define    pts_ops \
  138.     ptsopen,  ptsclose,  ptsread,  ptswrite,  ptyioctl,  ttselect, \
  139.     ptsstop, nulltty
  140.  
  141. extern int    ptcopen(), ptcclose(), ptcread(), ptcwrite();
  142. extern int    ptcselect();
  143. #define    ptc_ops \
  144.     ptcopen,  ptcclose,  ptcread,  ptcwrite,  ptyioctl,  ptcselect, \
  145.     nulldev, nulltty
  146.  
  147. #define    no_ops \
  148.     enodev, enodev, enodev, enodev, enodev, enodev, nulldev, nulltty
  149.  
  150. struct cdevsw    cdevsw[] =
  151. {
  152. /*0*/    { "console",    0,        console_ops,    },
  153. /*1*/    { "",        0,        ctty_ops,        },    /* tty */
  154. /*2*/    { "",        0,        mm_ops,        },    /* kmem,null */
  155. /*3*/    { "hd",        C_BLOCK(16),    isa_disk_ops,    },    /* isa */
  156. /*4*/    { "",        0,        no_ops,        },      /* raw */
  157. /*5*/    { "",        0,        pts_ops,    },
  158. /*6*/    { "",        0,        ptc_ops,    },
  159. /*7*/    { "",        0,        log_ops,    },      /* log */
  160. /*8*/    { "com",    0,        tty_ops,    },    /* isa */
  161. /*9*/    { "fd",        C_BLOCK(64),    isa_disk_ops,    },    /* isa */
  162. /*10*/    { "wt",        0,        char_ops,    },    /* isa */
  163. /*11*/    { "",        0,        no_ops,        },      /* xd */
  164. /*12*/    { "",        0,        no_ops,        },      /* pc */
  165. /*13*/    { "sd",        C_BLOCK(16),    isa_disk_ops,    },    /* isa */
  166. };
  167. int    nchrdev = sizeof(cdevsw)/sizeof(cdevsw[0]);
  168.  
  169. dev_t    cttydev = makedev(1, 0);
  170. int    mem_no = 2;
  171.  
  172. /*
  173.  * Conjure up a name string for funny devices (not all minors have
  174.  * the same name).
  175.  */
  176. int
  177. check_dev(dev, str)
  178.     dev_t    dev;
  179.     char    *str;
  180. {
  181. }
  182.  
  183. /*
  184.  * ISA disk IOCTL
  185.  */
  186. #undef    p_flag            /* conflict from sys/{proc,user}.h */
  187. #include <i386at/disk.h>
  188.  
  189. extern mach_port_t    disk_port();
  190.  
  191. int
  192. isa_disk_ioctl(dev, cmd, data, flag)
  193.     dev_t    dev;
  194.     int    cmd;
  195.     caddr_t    data;
  196.     int    flag;
  197. {
  198.     mach_port_t    device_port = disk_port(dev);
  199.     unsigned int    count;
  200.     register int    error;
  201.  
  202.     switch (cmd) {
  203.         case V_RDABS:
  204.         {
  205.         char buf[512];
  206.  
  207.         error = device_set_status(device_port,
  208.                       V_ABS,
  209.                       &((struct absio *)data)->abs_sec,
  210.                       1);
  211.         if (error)
  212.             return (dev_error_to_errno(error));
  213.         count = 512/sizeof(int);
  214.         error = device_get_status(device_port,
  215.                       cmd,
  216.                       buf,
  217.                       &count);
  218.  
  219.         if (error)
  220.             return (dev_error_to_errno(error));
  221.         if (copyout(buf, ((struct absio *)data)->abs_buf, 512))
  222.             return (EFAULT);
  223.         break;
  224.         }
  225.  
  226.         case V_VERIFY:
  227.         {
  228.         union vfy_io *vfy_io = (union vfy_io *) data;
  229.         int vfy[2] = {    vfy_io->vfy_in.abs_sec,
  230.                 vfy_io->vfy_in.num_sec};
  231.  
  232.         error = device_set_status(device_port,
  233.                       V_ABS,
  234.                       vfy,
  235.                       2);
  236.         if (error)
  237.             return (dev_error_to_errno(error));
  238.         count = sizeof (int)/sizeof(int);
  239.         error = device_get_status(device_port,
  240.                       cmd,
  241.                       vfy,
  242.                       &count);
  243.  
  244.         vfy_io->vfy_out.err_code = vfy[0];
  245.         if (error)
  246.             return (dev_error_to_errno(error));
  247.         break;
  248.         }
  249.  
  250.         case V_WRABS:
  251.         {
  252.         char buf[512];
  253.  
  254.         error = device_set_status(device_port,
  255.                       V_ABS,
  256.                       &((struct absio *)data)->abs_sec,
  257.                       1);
  258.         if (error)
  259.             return (dev_error_to_errno(error));
  260.         if (copyin(((struct absio *)data)->abs_buf, buf, 512))
  261.             return (EFAULT);
  262.         count = 512/sizeof(int);
  263.         error = device_set_status(device_port,
  264.                       cmd,
  265.                       buf,
  266.                       count);
  267.         if (error)
  268.             return (dev_error_to_errno(error));
  269.         break;
  270.         }
  271.  
  272.         default:
  273.         {
  274.         return (disk_ioctl(dev, cmd, data, flag));
  275.         }
  276.     }
  277.     return (0);
  278. }
  279.