Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 24 Aug 2009 10:53:30 +0000 (UTC)
From:      Ed Schouten <ed@FreeBSD.org>
To:        cvs-src-old@freebsd.org
Subject:   cvs commit: src/sys/kern kern_cons.c src/sys/sys cons.h
Message-ID:  <200908241053.n7OArrEO044031@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
ed          2009-08-24 10:53:30 UTC

  FreeBSD src repository

  Modified files:
    sys/kern             kern_cons.c 
    sys/sys              cons.h 
  Log:
  SVN rev 196506 on 2009-08-24 10:53:30Z by ed
  
  Allow multiple console devices per driver without insane code duplication.
  
  Say, a driver wants to have multiple console devices to pick from, you
  would normally write down something like this:
  
          CONSOLE_DRIVER(dev1);
          CONSOLE_DRIVER(dev2);
  
  Unfortunately, this means that you have to declare 10 cn routines,
  instead of 5. It also isn't possible to initialize cn_arg on beforehand.
  
  I noticed this restriction when I was implementing some of the console
  bits for my vt(4) driver in my newcons branch. I have a single set of cn
  routines (termcn_*) which are shared by all vt(4) console devices.
  
  In order to solve this, I'm adding a separate consdev_ops structure,
  which contains all the function pointers. This structure is referenced
  through consdev's cn_ops field.
  
  While there, I'm removing CONS_DRIVER() and cn_checkc, which have been
  deprecated for years. They weren't used throughout the source, until the
  Xen console driver showed up. CONSOLE_DRIVER() has been changed to do
  the right thing. It now declares both the consdev and consdev_ops
  structure and ties them together. In other words: this change doesn't
  change the KPI for drivers that used the regular way of declaring
  console devices.
  
  If drivers want to use multiple console devices, they can do this as
  follows:
  
          static const struct consdev_ops mydriver_cnops = {
                  .cn_probe       = mydriver_cnprobe,
                  ...
          };
          static struct mydriver_softc cons0_softc = {
                  ...
          };
          CONSOLE_DEVICE(cons0, mydriver_cnops, &cons0_softc);
          static struct mydriver_softc cons1_softc = {
                  ...
          };
          CONSOLE_DEVICE(cons1, mydriver_cnops, &cons1_softc);
  
  Obtained from:  //depot/user/ed/newcons/...
  
  Revision  Changes    Path
  1.3       +10 -13    src/sys/kern/kern_cons.c
  1.43      +14 -11    src/sys/sys/cons.h



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200908241053.n7OArrEO044031>