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/atkbd_isa.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$
   27  */
   28 
   29 #include "atkbd.h"
   30 #include "opt_kbd.h"
   31 
   32 #if NATKBD > 0
   33 
   34 #include <sys/param.h>
   35 #include <sys/systm.h>
   36 #include <sys/kernel.h>
   37 #include <sys/conf.h>
   38 #include <sys/tty.h>
   39 #include <sys/bus.h>
   40 #include <sys/rman.h>
   41 
   42 #include <machine/resource.h>
   43 
   44 #include <dev/kbd/kbdreg.h>
   45 #include <dev/kbd/atkbdreg.h>
   46 #include <dev/kbd/atkbdcreg.h>
   47 
   48 #include <isa/isareg.h>
   49 #include <isa/isavar.h>
   50 
   51 devclass_t      atkbd_devclass;
   52 
   53 static int      atkbdprobe(device_t dev);
   54 static int      atkbdattach(device_t dev);
   55 static void     atkbd_isa_intr(void *arg);
   56 
   57 static device_method_t atkbd_methods[] = {
   58         DEVMETHOD(device_probe,         atkbdprobe),
   59         DEVMETHOD(device_attach,        atkbdattach),
   60         { 0, 0 }
   61 };
   62 
   63 static driver_t atkbd_driver = {
   64         ATKBD_DRIVER_NAME,
   65         atkbd_methods,
   66         DRIVER_TYPE_TTY,
   67         1,
   68 };
   69 
   70 static int
   71 atkbdprobe(device_t dev)
   72 {
   73         u_long port;
   74         u_long irq;
   75         u_long flags;
   76 
   77         device_set_desc(dev, "AT Keyboard");
   78 
   79         /* obtain parameters */
   80         BUS_READ_IVAR(device_get_parent(dev), dev, KBDC_IVAR_PORT, &port);
   81         BUS_READ_IVAR(device_get_parent(dev), dev, KBDC_IVAR_IRQ, &irq);
   82         BUS_READ_IVAR(device_get_parent(dev), dev, KBDC_IVAR_FLAGS, &flags);
   83 
   84         /* probe the device */
   85         return atkbd_probe_unit(device_get_unit(dev), port, irq, flags);
   86 }
   87 
   88 static int
   89 atkbdattach(device_t dev)
   90 {
   91         keyboard_t *kbd;
   92         u_long port;
   93         u_long irq;
   94         u_long flags;
   95         struct resource *res;
   96         void *ih;
   97         int zero = 0;
   98         int error;
   99 
  100         BUS_READ_IVAR(device_get_parent(dev), dev, KBDC_IVAR_PORT, &port);
  101         BUS_READ_IVAR(device_get_parent(dev), dev, KBDC_IVAR_IRQ, &irq);
  102         BUS_READ_IVAR(device_get_parent(dev), dev, KBDC_IVAR_FLAGS, &flags);
  103 
  104         error = atkbd_attach_unit(device_get_unit(dev), &kbd, port, irq, flags);
  105         if (error)
  106                 return error;
  107 
  108         /* declare our interrupt handler */
  109         res = bus_alloc_resource(dev, SYS_RES_IRQ, &zero, irq, irq, 1,
  110                                  RF_SHAREABLE | RF_ACTIVE);
  111         BUS_SETUP_INTR(device_get_parent(dev), dev, res, atkbd_isa_intr, kbd,
  112                        &ih);
  113 
  114         return 0;
  115 }
  116 
  117 static void
  118 atkbd_isa_intr(void *arg)
  119 {
  120         keyboard_t *kbd;
  121 
  122         kbd = (keyboard_t *)arg;
  123         (*kbdsw[kbd->kb_index]->intr)(kbd, NULL);
  124 }
  125 
  126 DRIVER_MODULE(atkbd, atkbdc, atkbd_driver, atkbd_devclass, 0, 0);
  127 
  128 #endif /* NATKBD > 0 */

Cache object: d10a97cd739f3707e31217e1fe73bcbc


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