LCOV - code coverage report
Current view: top level - dev/puc - com_puc.c (source / functions) Hit Total Coverage
Test: 6.4 Lines: 0 31 0.0 %
Date: 2018-10-19 03:25:38 Functions: 0 3 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /*      $OpenBSD: com_puc.c,v 1.24 2018/04/15 00:10:59 jcs Exp $        */
       2             : 
       3             : /*
       4             :  * Copyright (c) 1997 - 1999, Jason Downs.  All rights reserved.
       5             :  *
       6             :  * Redistribution and use in source and binary forms, with or without
       7             :  * modification, are permitted provided that the following conditions
       8             :  * are met:
       9             :  * 1. Redistributions of source code must retain the above copyright
      10             :  *    notice, this list of conditions and the following disclaimer.
      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             :  * 3. Neither the name(s) of the author(s) nor the name OpenBSD
      15             :  *    may be used to endorse or promote products derived from this software
      16             :  *    without specific prior written permission.
      17             :  *
      18             :  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS
      19             :  * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
      20             :  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
      21             :  * DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT,
      22             :  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
      23             :  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
      24             :  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
      25             :  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
      26             :  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
      27             :  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
      28             :  * SUCH DAMAGE.
      29             :  */
      30             : 
      31             : #include <sys/param.h>
      32             : #include <sys/systm.h>
      33             : #include <sys/ioctl.h>
      34             : #include <sys/selinfo.h>
      35             : #include <sys/tty.h>
      36             : #include <sys/conf.h>
      37             : #include <sys/uio.h>
      38             : #include <sys/kernel.h>
      39             : #include <sys/syslog.h>
      40             : #include <sys/device.h>
      41             : 
      42             : #include <machine/intr.h>
      43             : #include <machine/bus.h>
      44             : 
      45             : #include <dev/pci/pucvar.h>
      46             : 
      47             : #include "com.h"
      48             : 
      49             : #include <dev/ic/comreg.h>
      50             : #include <dev/ic/comvar.h>
      51             : #include <dev/ic/ns16550reg.h>
      52             : 
      53             : #define com_lcr         com_cfcr
      54             : 
      55             : int     com_puc_match(struct device *, void *, void *);
      56             : void    com_puc_attach(struct device *, struct device *, void *);
      57             : int     com_puc_detach(struct device *, int);
      58             : 
      59             : struct cfattach com_puc_ca = {
      60             :         sizeof(struct com_softc), com_puc_match,
      61             :         com_puc_attach, com_puc_detach, com_activate
      62             : };
      63             : 
      64             : int
      65           0 : com_puc_match(parent, match, aux)
      66             :         struct device *parent;
      67             :         void *match, *aux;
      68             : {
      69           0 :         struct puc_attach_args *pa = aux;
      70             : 
      71           0 :         if (PUC_IS_COM(pa->type))
      72           0 :                 return(1);
      73             : 
      74           0 :         return(0);
      75           0 : }
      76             : 
      77             : void
      78           0 : com_puc_attach(parent, self, aux)
      79             :         struct device *parent, *self;
      80             :         void *aux;
      81             : {
      82           0 :         struct com_softc *sc = (void *)self;
      83           0 :         struct puc_attach_args *pa = aux;
      84             :         const char *intrstr;
      85             :         int i;
      86             : 
      87             :         /* Grab a PCI interrupt. */
      88           0 :         intrstr = pa->intr_string(pa);
      89           0 :         sc->sc_ih = pa->intr_establish(pa, IPL_TTY, comintr, sc,
      90           0 :             sc->sc_dev.dv_xname);
      91           0 :         if (sc->sc_ih == NULL) {
      92           0 :                 printf(": couldn't establish interrupt");
      93           0 :                 if (intrstr != NULL)
      94           0 :                         printf(" at %s", intrstr);
      95           0 :                 printf("\n");
      96           0 :                 return;
      97             :         }
      98           0 :         printf(" %s", intrstr);
      99             : 
     100           0 :         sc->sc_iot = pa->t;
     101           0 :         sc->sc_ioh = pa->h;
     102           0 :         sc->sc_iobase = pa->a;
     103             : 
     104           0 :         sc->sc_frequency = COM_FREQ;
     105             : 
     106           0 :         for (i = 0; i < nitems(puc_port_types); i++)
     107           0 :                 if (puc_port_types[i].type == pa->type) {
     108           0 :                         sc->sc_frequency = puc_port_types[i].freq;
     109           0 :                         break;
     110             :                 }
     111             : 
     112           0 :         com_attach_subr(sc);
     113           0 : }
     114             : 
     115             : int
     116           0 : com_puc_detach(struct device *self, int flags)
     117             : {
     118           0 :         return com_detach(self, flags);
     119             : }

Generated by: LCOV version 1.13