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/isa/syscons_isa.c

Version: -  FREEBSD  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-2  -  FREEBSD-11-1  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-4  -  FREEBSD-10-3  -  FREEBSD-10-2  -  FREEBSD-10-1  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-3  -  FREEBSD-9-2  -  FREEBSD-9-1  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-4  -  FREEBSD-8-3  -  FREEBSD-8-2  -  FREEBSD-8-1  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-4  -  FREEBSD-7-3  -  FREEBSD-7-2  -  FREEBSD-7-1  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-4  -  FREEBSD-6-3  -  FREEBSD-6-2  -  FREEBSD-6-1  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-5  -  FREEBSD-5-4  -  FREEBSD-5-3  -  FREEBSD-5-2  -  FREEBSD-5-1  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  linux-2.6  -  linux-2.4.22  -  MK83  -  MK84  -  PLAN9  -  DFBSD  -  NETBSD  -  NETBSD5  -  NETBSD4  -  NETBSD3  -  NETBSD20  -  OPENBSD  -  xnu-517  -  xnu-792  -  xnu-792.6.70  -  xnu-1228  -  xnu-1456.1.26  -  xnu-1699.24.8  -  xnu-2050.18.24  -  OPENSOLARIS  -  minix-3-1-1 
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 
   27 #include <sys/cdefs.h>
   28 __FBSDID("$FreeBSD: stable/10/sys/isa/syscons_isa.c 221708 2011-05-09 18:46:49Z jkim $");
   29 
   30 #include "opt_syscons.h"
   31 
   32 #include <sys/param.h>
   33 #include <sys/systm.h>
   34 #include <sys/kernel.h>
   35 #include <sys/module.h>
   36 #include <sys/bus.h>
   37 #include <sys/cons.h>
   38 #include <sys/kbio.h>
   39 #include <sys/consio.h>
   40 #include <sys/sysctl.h>
   41 
   42 #if defined(__i386__) || defined(__amd64__)
   43 
   44 #include <machine/clock.h>
   45 #include <machine/md_var.h>
   46 #include <machine/pc/bios.h>
   47 
   48 #include <vm/vm.h>
   49 #include <vm/pmap.h>
   50 #include <vm/vm_param.h>
   51 
   52 #define BIOS_CLKED      (1 << 6)
   53 #define BIOS_NLKED      (1 << 5)
   54 #define BIOS_SLKED      (1 << 4)
   55 #define BIOS_ALKED      0
   56 
   57 #endif
   58 
   59 #include <dev/syscons/syscons.h>
   60 
   61 #include <isa/isavar.h>
   62 
   63 #include "opt_xbox.h"
   64 
   65 #ifdef XBOX
   66 #include <machine/xbox.h>
   67 #endif
   68 
   69 static devclass_t       sc_devclass;
   70 
   71 static sc_softc_t       main_softc;
   72 
   73 static void
   74 scidentify(driver_t *driver, device_t parent)
   75 {
   76 
   77         BUS_ADD_CHILD(parent, ISA_ORDER_SPECULATIVE, "sc", 0);
   78 }
   79 
   80 static int
   81 scprobe(device_t dev)
   82 {
   83 
   84         /* No pnp support */
   85         if (isa_get_vendorid(dev))
   86                 return (ENXIO);
   87 
   88         device_set_desc(dev, "System console");
   89         return (sc_probe_unit(device_get_unit(dev), device_get_flags(dev)));
   90 }
   91 
   92 static int
   93 scattach(device_t dev)
   94 {
   95 
   96         return (sc_attach_unit(device_get_unit(dev), device_get_flags(dev) |
   97             SC_AUTODETECT_KBD));
   98 }
   99 
  100 int
  101 sc_max_unit(void)
  102 {
  103 
  104         return (devclass_get_maxunit(sc_devclass));
  105 }
  106 
  107 sc_softc_t
  108 *sc_get_softc(int unit, int flags)
  109 {
  110         sc_softc_t *sc;
  111 
  112         if (unit < 0)
  113                 return (NULL);
  114         if ((flags & SC_KERNEL_CONSOLE) != 0) {
  115                 /* FIXME: clear if it is wired to another unit! */
  116                 sc = &main_softc;
  117         } else {
  118                 sc = device_get_softc(devclass_get_device(sc_devclass, unit));
  119                 if (sc == NULL)
  120                         return (NULL);
  121         }
  122         sc->unit = unit;
  123         if ((sc->flags & SC_INIT_DONE) == 0) {
  124                 sc->keyboard = -1;
  125                 sc->adapter = -1;
  126                 sc->cursor_char = SC_CURSOR_CHAR;
  127                 sc->mouse_char = SC_MOUSE_CHAR;
  128         }
  129         return (sc);
  130 }
  131 
  132 sc_softc_t
  133 *sc_find_softc(struct video_adapter *adp, struct keyboard *kbd)
  134 {
  135         sc_softc_t *sc;
  136         int i;
  137         int units;
  138 
  139         sc = &main_softc;
  140         if ((adp == NULL || adp == sc->adp) &&
  141             (kbd == NULL || kbd == sc->kbd))
  142                 return (sc);
  143         units = devclass_get_maxunit(sc_devclass);
  144         for (i = 0; i < units; ++i) {
  145                 sc = device_get_softc(devclass_get_device(sc_devclass, i));
  146                 if (sc == NULL)
  147                         continue;
  148                 if ((adp == NULL || adp == sc->adp) &&
  149                     (kbd == NULL || kbd == sc->kbd))
  150                         return (sc);
  151         }
  152         return (NULL);
  153 }
  154 
  155 int
  156 sc_get_cons_priority(int *unit, int *flags)
  157 {
  158         const char *at;
  159         int f, u;
  160 
  161 #ifdef XBOX
  162         /*
  163          * The XBox Loader does not support hints, which makes our initial
  164          * console probe fail. Therefore, if an XBox is found, we hardcode the
  165          * existence of the console, as it is always there anyway.
  166          */
  167         if (arch_i386_is_xbox) {
  168                 *unit = 0;
  169                 *flags = SC_KERNEL_CONSOLE;
  170                 return (CN_INTERNAL);
  171         }
  172 #endif
  173 
  174         *unit = -1;
  175         for (u = 0; u < 16; u++) {
  176                 if (resource_disabled(SC_DRIVER_NAME, u))
  177                         continue;
  178                 if (resource_string_value(SC_DRIVER_NAME, u, "at", &at) != 0)
  179                         continue;
  180                 if (resource_int_value(SC_DRIVER_NAME, u, "flags", &f) != 0)
  181                         f = 0;
  182                 if (f & SC_KERNEL_CONSOLE) {
  183                         /* the user designates this unit to be the console */
  184                         *unit = u;
  185                         *flags = f;
  186                         break;
  187                 }
  188                 if (*unit < 0) {
  189                         /* ...otherwise remember the first found unit */
  190                         *unit = u;
  191                         *flags = f;
  192                 }
  193         }
  194         if (*unit < 0) {
  195                 *unit = 0;
  196                 *flags = 0;
  197         }
  198 #if 0
  199         return ((*flags & SC_KERNEL_CONSOLE) != 0 ? CN_INTERNAL : CN_NORMAL);
  200 #endif
  201         return (CN_INTERNAL);
  202 }
  203 
  204 void
  205 sc_get_bios_values(bios_values_t *values)
  206 {
  207 #if defined(__i386__) || defined(__amd64__)
  208         uint8_t shift;
  209 
  210         values->cursor_start = *(uint8_t *)BIOS_PADDRTOVADDR(0x461);
  211         values->cursor_end = *(uint8_t *)BIOS_PADDRTOVADDR(0x460);
  212         shift = *(uint8_t *)BIOS_PADDRTOVADDR(0x417);
  213         values->shift_state = ((shift & BIOS_CLKED) != 0 ? CLKED : 0) |
  214             ((shift & BIOS_NLKED) != 0 ? NLKED : 0) |
  215             ((shift & BIOS_SLKED) != 0 ? SLKED : 0) |
  216             ((shift & BIOS_ALKED) != 0 ? ALKED : 0);
  217 #else
  218         values->cursor_start = 0;
  219         values->cursor_end = 32;
  220         values->shift_state = 0;
  221 #endif
  222         values->bell_pitch = BELL_PITCH;
  223 }
  224 
  225 int
  226 sc_tone(int herz)
  227 {
  228 
  229 #if defined(HAS_TIMER_SPKR)
  230         if (herz) {
  231                 if (timer_spkr_acquire())
  232                         return (EBUSY);
  233                 timer_spkr_setfreq(herz);
  234         } else
  235                 timer_spkr_release();
  236 #endif
  237 
  238         return (0);
  239 }
  240 
  241 static device_method_t sc_methods[] = {
  242         DEVMETHOD(device_identify,      scidentify),
  243         DEVMETHOD(device_probe,         scprobe),
  244         DEVMETHOD(device_attach,        scattach),
  245         { 0, 0 }
  246 };
  247 
  248 static driver_t sc_driver = {
  249         SC_DRIVER_NAME,
  250         sc_methods,
  251         sizeof(sc_softc_t),
  252 };
  253 
  254 DRIVER_MODULE(sc, isa, sc_driver, sc_devclass, 0, 0);

Cache object: a52f875ea1b297ab30411a9cd6ab416d


[ 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.