The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/dev/syscons/scterm-dumb.c

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

    1 /*-
    2  * Copyright (c) 1999 Kazutaka YOKOTA <yokota@zodiac.mech.utsunomiya-u.ac.jp>
    3  * All rights reserved.
    4  *
    5  * Redistribution and use in source and binary forms, with or without
    6  * modification, are permitted provided that the following conditions
    7  * are met:
    8  * 1. Redistributions of source code must retain the above copyright
    9  *    notice, this list of conditions and the following disclaimer as
   10  *    the first lines of this file unmodified.
   11  * 2. Redistributions in binary form must reproduce the above copyright
   12  *    notice, this list of conditions and the following disclaimer in the
   13  *    documentation and/or other materials provided with the distribution.
   14  *
   15  * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR
   16  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   17  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
   18  * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT,
   19  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
   20  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
   21  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
   22  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
   23  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
   24  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
   25  *
   26  * $FreeBSD: releng/5.0/sys/dev/syscons/scterm-dumb.c 59760 2000-04-29 15:36:14Z phk $
   27  */
   28 
   29 #include "opt_syscons.h"
   30 
   31 #include <sys/param.h>
   32 #include <sys/systm.h>
   33 #include <sys/consio.h>
   34 
   35 #include <machine/pc/display.h>
   36 
   37 #include <dev/syscons/syscons.h>
   38 #include <dev/syscons/sctermvar.h>
   39 
   40 #ifdef SC_DUMB_TERMINAL
   41 
   42 /* dumb terminal emulator */
   43 
   44 static sc_term_init_t   dumb_init;
   45 static sc_term_term_t   dumb_term;
   46 static sc_term_puts_t   dumb_puts;
   47 static sc_term_ioctl_t  dumb_ioctl;
   48 static sc_term_clear_t  dumb_clear;
   49 static sc_term_input_t  dumb_input;
   50 static void             dumb_nop(void);
   51 
   52 static sc_term_sw_t sc_term_dumb = {
   53         { NULL, NULL },
   54         "dumb",                         /* emulator name */
   55         "dumb terminal",                /* description */
   56         "*",                            /* matching renderer */
   57         0,                              /* softc size */
   58         0,
   59         dumb_init,
   60         dumb_term,
   61         dumb_puts,
   62         dumb_ioctl,
   63         (sc_term_reset_t *)dumb_nop,
   64         (sc_term_default_attr_t *)dumb_nop,
   65         dumb_clear,
   66         (sc_term_notify_t *)dumb_nop,
   67         dumb_input,
   68 };
   69 
   70 SCTERM_MODULE(dumb, sc_term_dumb);
   71 
   72 static int
   73 dumb_init(scr_stat *scp, void **softc, int code)
   74 {
   75         switch (code) {
   76         case SC_TE_COLD_INIT:
   77                 ++sc_term_dumb.te_refcount;
   78                 break;
   79         case SC_TE_WARM_INIT:
   80                 break;
   81         }
   82         return 0;
   83 }
   84 
   85 static int
   86 dumb_term(scr_stat *scp, void **softc)
   87 {
   88         --sc_term_dumb.te_refcount;
   89         return 0;
   90 }
   91 
   92 static void
   93 dumb_puts(scr_stat *scp, u_char *buf, int len)
   94 {
   95         while (len > 0) {
   96                 ++scp->sc->write_in_progress;
   97                 sc_term_gen_print(scp, &buf, &len, SC_NORM_ATTR << 8);
   98                 sc_term_gen_scroll(scp, scp->sc->scr_map[0x20],
   99                                    SC_NORM_ATTR << 8);
  100                 --scp->sc->write_in_progress;
  101         }
  102 }
  103 
  104 static int
  105 dumb_ioctl(scr_stat *scp, struct tty *tp, u_long cmd, caddr_t data,
  106            int flag, struct proc *p)
  107 {
  108         vid_info_t *vi;
  109 
  110         switch (cmd) {
  111         case GIO_ATTR:          /* get current attributes */
  112                 *(int*)data = SC_NORM_ATTR;
  113                 return 0;
  114         case CONS_GETINFO:      /* get current (virtual) console info */
  115                 vi = (vid_info_t *)data;
  116                 if (vi->size != sizeof(struct vid_info))
  117                         return EINVAL;
  118                 vi->mv_norm.fore = SC_NORM_ATTR & 0x0f;
  119                 vi->mv_norm.back = (SC_NORM_ATTR >> 4) & 0x0f;
  120                 vi->mv_rev.fore = SC_NORM_ATTR & 0x0f;
  121                 vi->mv_rev.back = (SC_NORM_ATTR >> 4) & 0x0f;
  122                 /*
  123                  * The other fields are filled by the upper routine. XXX
  124                  */
  125                 return ENOIOCTL;
  126         }
  127         return ENOIOCTL;
  128 }
  129 
  130 static void
  131 dumb_clear(scr_stat *scp)
  132 {
  133         sc_move_cursor(scp, 0, 0);
  134         sc_vtb_clear(&scp->vtb, scp->sc->scr_map[0x20], SC_NORM_ATTR << 8);
  135         mark_all(scp);
  136 }
  137 
  138 static int
  139 dumb_input(scr_stat *scp, int c, struct tty *tp)
  140 {
  141         return FALSE;
  142 }
  143 
  144 static void
  145 dumb_nop(void)
  146 {
  147         /* nothing */
  148 }
  149 
  150 #endif /* SC_DUMB_TERMINAL */

Cache object: 0ee28fbff1b3573bdf06737f4223a759


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.