[BACK]Return to cons.c CVS log [TXT][DIR] Up to [cvs.NetBSD.org] / src / sys / dev

Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.

Diff for /src/sys/dev/cons.c between version 1.37.4.3 and 1.37.4.4

version 1.37.4.3, 2002/08/13 02:19:18 version 1.37.4.4, 2002/09/17 21:19:18
Line 58  __KERNEL_RCSID(0, "$NetBSD$");
Line 58  __KERNEL_RCSID(0, "$NetBSD$");
   
 #include <dev/cons.h>  #include <dev/cons.h>
   
   dev_type_open(cnopen);
   dev_type_close(cnclose);
   dev_type_read(cnread);
   dev_type_write(cnwrite);
   dev_type_ioctl(cnioctl);
   dev_type_poll(cnpoll);
   
   const struct cdevsw cons_cdevsw = {
           cnopen, cnclose, cnread, cnwrite, cnioctl,
           nostop, notty, cnpoll, nommap, D_TTY
   };
   
 struct  tty *constty = NULL;    /* virtual console output device */  struct  tty *constty = NULL;    /* virtual console output device */
 struct  consdev *cn_tab;        /* physical console device info */  struct  consdev *cn_tab;        /* physical console device info */
 struct  vnode *cn_devvp;        /* vnode for underlying device. */  struct  vnode *cn_devvp;        /* vnode for underlying device. */
Line 68  cnopen(dev, flag, mode, p)
Line 80  cnopen(dev, flag, mode, p)
         int flag, mode;          int flag, mode;
         struct proc *p;          struct proc *p;
 {  {
           const struct cdevsw *cdev;
         dev_t cndev;          dev_t cndev;
   
         if (cn_tab == NULL)          if (cn_tab == NULL)
Line 96  cnopen(dev, flag, mode, p)
Line 109  cnopen(dev, flag, mode, p)
                  */                   */
                 panic("cnopen: cn_tab->cn_dev == dev\n");                  panic("cnopen: cn_tab->cn_dev == dev\n");
         }          }
           cdev = cdevsw_lookup(cndev);
           if (cdev == NULL)
                   return (ENXIO);
   
         if (cn_devvp == NULLVP) {          if (cn_devvp == NULLVP) {
                 /* try to get a reference on its vnode, but fail silently */                  /* try to get a reference on its vnode, but fail silently */
                 cdevvp(cndev, &cn_devvp);                  cdevvp(cndev, &cn_devvp);
         }          }
         return ((*cdevsw[major(cndev)].d_open)(cndev, flag, mode, p));          return ((*cdev->d_open)(cndev, flag, mode, p));
 }  }
   
 int  int
Line 110  cnclose(dev, flag, mode, p)
Line 126  cnclose(dev, flag, mode, p)
         int flag, mode;          int flag, mode;
         struct proc *p;          struct proc *p;
 {  {
           const struct cdevsw *cdev;
         struct vnode *vp;          struct vnode *vp;
   
         if (cn_tab == NULL)          if (cn_tab == NULL)
Line 121  cnclose(dev, flag, mode, p)
Line 138  cnclose(dev, flag, mode, p)
          * screw up others who have it open.           * screw up others who have it open.
          */           */
         dev = cn_tab->cn_dev;          dev = cn_tab->cn_dev;
           cdev = cdevsw_lookup(dev);
           if (cdev == NULL)
                   return (ENXIO);
         if (cn_devvp != NULLVP) {          if (cn_devvp != NULLVP) {
                 /* release our reference to real dev's vnode */                  /* release our reference to real dev's vnode */
                 vrele(cn_devvp);                  vrele(cn_devvp);
Line 128  cnclose(dev, flag, mode, p)
Line 148  cnclose(dev, flag, mode, p)
         }          }
         if (vfinddev(dev, VCHR, &vp) && vcount(vp))          if (vfinddev(dev, VCHR, &vp) && vcount(vp))
                 return (0);                  return (0);
         return ((*cdevsw[major(dev)].d_close)(dev, flag, mode, p));          return ((*cdev->d_close)(dev, flag, mode, p));
 }  }
   
 int  int
Line 137  cnread(dev, uio, flag)
Line 157  cnread(dev, uio, flag)
         struct uio *uio;          struct uio *uio;
         int flag;          int flag;
 {  {
           const struct cdevsw *cdev;
   
         /*          /*
          * If we would redirect input, punt.  This will keep strange           * If we would redirect input, punt.  This will keep strange
Line 151  cnread(dev, uio, flag)
Line 172  cnread(dev, uio, flag)
                 return ENXIO;                  return ENXIO;
   
         dev = cn_tab->cn_dev;          dev = cn_tab->cn_dev;
         return ((*cdevsw[major(dev)].d_read)(dev, uio, flag));          cdev = cdevsw_lookup(dev);
           if (cdev == NULL)
                   return (ENXIO);
           return ((*cdev->d_read)(dev, uio, flag));
 }  }
   
 int  int
Line 160  cnwrite(dev, uio, flag)
Line 184  cnwrite(dev, uio, flag)
         struct uio *uio;          struct uio *uio;
         int flag;          int flag;
 {  {
           const struct cdevsw *cdev;
   
         /*          /*
          * Redirect output, if that's appropriate.           * Redirect output, if that's appropriate.
Line 171  cnwrite(dev, uio, flag)
Line 196  cnwrite(dev, uio, flag)
                 return ENXIO;                  return ENXIO;
         else          else
                 dev = cn_tab->cn_dev;                  dev = cn_tab->cn_dev;
         return ((*cdevsw[major(dev)].d_write)(dev, uio, flag));          cdev = cdevsw_lookup(dev);
           if (cdev == NULL)
                   return (ENXIO);
           return ((*cdev->d_write)(dev, uio, flag));
 }  }
   
 void  
 cnstop(tp, flag)  
         struct tty *tp;  
         int flag;  
 {  
   
 }  
   
 int  int
 cnioctl(dev, cmd, data, flag, p)  cnioctl(dev, cmd, data, flag, p)
         dev_t dev;          dev_t dev;
Line 190  cnioctl(dev, cmd, data, flag, p)
Line 210  cnioctl(dev, cmd, data, flag, p)
         int flag;          int flag;
         struct proc *p;          struct proc *p;
 {  {
           const struct cdevsw *cdev;
         int error;          int error;
   
         /*          /*
Line 216  cnioctl(dev, cmd, data, flag, p)
Line 237  cnioctl(dev, cmd, data, flag, p)
                 return ENXIO;                  return ENXIO;
         else          else
                 dev = cn_tab->cn_dev;                  dev = cn_tab->cn_dev;
         return ((*cdevsw[major(dev)].d_ioctl)(dev, cmd, data, flag, p));          cdev = cdevsw_lookup(dev);
           if (cdev == NULL)
                   return (ENXIO);
           return ((*cdev->d_ioctl)(dev, cmd, data, flag, p));
 }  }
   
 /*ARGSUSED*/  /*ARGSUSED*/
Line 226  cnpoll(dev, events, p)
Line 250  cnpoll(dev, events, p)
         int events;          int events;
         struct proc *p;          struct proc *p;
 {  {
           const struct cdevsw *cdev;
   
         /*          /*
          * Redirect the poll, if that's appropriate.           * Redirect the poll, if that's appropriate.
Line 238  cnpoll(dev, events, p)
Line 263  cnpoll(dev, events, p)
                 return ENXIO;                  return ENXIO;
         else          else
                 dev = cn_tab->cn_dev;                  dev = cn_tab->cn_dev;
         return ((*cdevsw[major(dev)].d_poll)(dev, events, p));          cdev = cdevsw_lookup(dev);
           if (cdev == NULL)
                   return (ENXIO);
           return ((*cdev->d_poll)(dev, events, p));
 }  }
   
 int  int

Legend:
Removed from v.1.37.4.3  
changed lines
  Added in v.1.37.4.4

CVSweb <webmaster@jp.NetBSD.org>