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/isa/isavar.h

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 /*      $OpenBSD: isavar.h,v 1.58 2014/03/18 22:36:37 miod Exp $        */
    2 /*      $NetBSD: isavar.h,v 1.26 1997/06/06 23:43:57 thorpej Exp $      */
    3 
    4 /*-
    5  * Copyright (c) 1997 The NetBSD Foundation, Inc.
    6  * All rights reserved.
    7  *
    8  * This code is derived from software contributed to The NetBSD Foundation
    9  * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility,
   10  * NASA Ames Research Center.
   11  *
   12  * Redistribution and use in source and binary forms, with or without
   13  * modification, are permitted provided that the following conditions
   14  * are met:
   15  * 1. Redistributions of source code must retain the above copyright
   16  *    notice, this list of conditions and the following disclaimer.
   17  * 2. Redistributions in binary form must reproduce the above copyright
   18  *    notice, this list of conditions and the following disclaimer in the
   19  *    documentation and/or other materials provided with the distribution.
   20  *
   21  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
   22  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
   23  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
   24  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
   25  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
   26  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
   27  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
   28  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
   29  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
   30  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
   31  * POSSIBILITY OF SUCH DAMAGE.
   32  */
   33 
   34 /*
   35  * Copyright (c) 1996 Christos Zoulas.  All rights reserved.
   36  *
   37  * Redistribution and use in source and binary forms, with or without
   38  * modification, are permitted provided that the following conditions
   39  * are met:
   40  * 1. Redistributions of source code must retain the above copyright
   41  *    notice, this list of conditions and the following disclaimer.
   42  * 2. Redistributions in binary form must reproduce the above copyright
   43  *    notice, this list of conditions and the following disclaimer in the
   44  *    documentation and/or other materials provided with the distribution.
   45  * 3. All advertising materials mentioning features or use of this software
   46  *    must display the following acknowledgement:
   47  *      This product includes software developed by Christos Zoulas.
   48  * 4. The name of the author may not be used to endorse or promote products
   49  *    derived from this software without specific prior written permission.
   50  *
   51  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
   52  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   53  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
   54  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
   55  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
   56  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
   57  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
   58  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
   59  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
   60  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
   61  */
   62 
   63 /*
   64  * Copyright (c) 1995 Chris G. Demetriou
   65  * Copyright (c) 1992 Berkeley Software Design, Inc.
   66  * All rights reserved.
   67  *
   68  * Redistribution and use in source and binary forms, with or without
   69  * modification, are permitted provided that the following conditions
   70  * are met:
   71  * 1. Redistributions of source code must retain the above copyright
   72  *    notice, this list of conditions and the following disclaimer.
   73  * 2. Redistributions in binary form must reproduce the above copyright
   74  *    notice, this list of conditions and the following disclaimer in the
   75  *    documentation and/or other materials provided with the distribution.
   76  * 3. All advertising materials mentioning features or use of this software
   77  *    must display the following acknowledgement:
   78  *      This product includes software developed by Berkeley Software
   79  *      Design, Inc.
   80  * 4. The name of Berkeley Software Design must not be used to endorse
   81  *    or promote products derived from this software without specific
   82  *    prior written permission.
   83  *
   84  * THIS SOFTWARE IS PROVIDED BY BERKELEY SOFTWARE DESIGN, INC. ``AS IS'' AND
   85  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
   86  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
   87  * ARE DISCLAIMED.  IN NO EVENT SHALL BERKELEY SOFTWARE DESIGN, INC. BE LIABLE
   88  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
   89  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
   90  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
   91  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
   92  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
   93  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   94  * SUCH DAMAGE.
   95  *
   96  *      BSDI Id: isavar.h,v 1.5 1992/12/01 18:06:00 karels Exp 
   97  */
   98 
   99 #ifndef _DEV_ISA_ISAVAR_H_
  100 #define _DEV_ISA_ISAVAR_H_
  101 
  102 /*
  103  * Definitions for ISA and ISA PnP autoconfiguration.
  104  */
  105 
  106 #include <sys/queue.h>
  107 #include <machine/bus.h>
  108 
  109 #ifndef NISADMA
  110 #include "isadma.h"
  111 #endif
  112 
  113 /* 
  114  * Structures and definitions needed by the machine-dependent header.
  115  */
  116 struct isabus_attach_args;
  117 
  118 #if defined(__alpha__)
  119 #include <alpha/isa/isa_machdep.h>
  120 #elif defined(__i386__)
  121 #include <i386/isa/isa_machdep.h>
  122 #elif defined(__powerpc__)
  123 #include <powerpc/isa/isa_machdep.h>
  124 #else
  125 #include <machine/isa_machdep.h>
  126 #endif
  127 
  128 #include "isapnp.h"
  129 
  130 #if NISAPNP > 0
  131 /*
  132  * Structures and definitions needed by the machine-dependent header.
  133  */
  134 struct isapnp_softc;
  135 
  136 #if defined(__alpha__)
  137 #include <alpha/isa/isapnp_machdep.h>
  138 #elif defined(__i386__)
  139 #include <i386/isa/isapnp_machdep.h>
  140 #else
  141 #error COMPILING ISAPNP FOR UNSUPPORTED MACHINE.
  142 #endif
  143 #endif  /* NISAPNP */
  144 
  145 # define ISAPNP_WRITE_ADDR(sc, v) \
  146     bus_space_write_1(sc->sc_iot, sc->sc_addr_ioh, 0, v)
  147 # define ISAPNP_WRITE_DATA(sc, v) \
  148     bus_space_write_1(sc->sc_iot, sc->sc_wrdata_ioh, 0, v)
  149 # define ISAPNP_READ_DATA(sc) \
  150     bus_space_read_1(sc->sc_iot, sc->sc_read_ioh, 0)
  151 
  152 # define ISAPNP_CLONE_SETUP(dest, src) \
  153         do { \
  154                 bzero((dest), sizeof(*(dest))); \
  155                 (dest)->ia_ic = (src)->ia_ic; \
  156         } while (0)
  157 
  158 #ifndef _DEV_ISA_ISAPNPREG_H_
  159 /*
  160  * `reg' defines needed only for these structures.
  161  */
  162 #define ISAPNP_MAX_CARDS        8
  163 #define ISAPNP_MAX_IDENT        32
  164 #define ISAPNP_MAX_DEVCLASS     16
  165 #define ISAPNP_SERIAL_SIZE      9
  166 
  167 #define ISAPNP_NUM_MEM          4
  168 #define ISAPNP_NUM_IO           8
  169 #define ISAPNP_NUM_IRQ          16
  170 #define ISAPNP_NUM_DRQ          8
  171 #define ISAPNP_NUM_MEM32        4
  172 #endif  /* _DEV_ISA_ISAPNPREG_H_ */
  173 
  174 /*
  175  * ISA PnP-specific structures.
  176  */
  177 struct isapnp_softc {
  178         struct device           sc_dev;
  179         TAILQ_HEAD(, isadev)
  180                 sc_subdevs;             /* list of all children */
  181 
  182         bus_space_tag_t sc_iot;         /* isa io space tag */
  183         bus_space_tag_t sc_memt;        /* isa mem space tag */
  184 #if NISADMA > 0
  185         bus_dma_tag_t sc_dmat;          /* isa DMA tag */
  186 #endif /* NISADMA > 0 */
  187 
  188         int                     sc_read_port;
  189         bus_space_handle_t      sc_addr_ioh;
  190         bus_space_handle_t      sc_wrdata_ioh;
  191         bus_space_handle_t      sc_read_ioh;
  192         bus_space_handle_t      sc_memh;
  193         u_int8_t                sc_ncards;
  194         u_int8_t                sc_id[ISAPNP_MAX_CARDS][ISAPNP_SERIAL_SIZE];
  195 };
  196 
  197 struct isapnp_region {
  198         bus_space_handle_t h;
  199         u_int32_t base;
  200 
  201         u_int32_t minbase;
  202         u_int32_t maxbase;
  203         u_int32_t length;
  204         u_int32_t align;
  205         u_int8_t  flags;
  206 };
  207 
  208 struct isapnp_pin {
  209         int16_t   num;
  210         u_int8_t  flags:4;
  211         u_int8_t  type:4;
  212         u_int16_t bits;
  213 };
  214 
  215 struct isapnp_knowndev {
  216         const char pnpid[8];
  217         const char driver[5];
  218 };
  219 
  220 /*
  221  * ISA bus attach arguments
  222  */
  223 struct isabus_attach_args {
  224         char    *iba_busname;           /* XXX should be common */
  225         bus_space_tag_t iba_iot;        /* isa i/o space tag */
  226         bus_space_tag_t iba_memt;       /* isa mem space tag */
  227 #if NISADMA > 0
  228         bus_dma_tag_t iba_dmat;         /* isa DMA tag */
  229 #endif
  230         isa_chipset_tag_t iba_ic;
  231 };
  232 
  233 /*
  234  * ISA/ISA PnP shared driver attach arguments
  235  */
  236 struct isa_attach_args {
  237         struct device  *ia_isa;         /* isa device */
  238         bus_space_tag_t ia_iot;         /* isa i/o space tag */
  239         bus_space_tag_t ia_memt;        /* isa mem space tag */
  240 #if NISADMA > 0
  241         bus_dma_tag_t ia_dmat;          /* DMA tag */
  242 #endif
  243         bus_space_handle_t ia_delaybah; /* i/o handle for `delay port' */
  244 
  245         isa_chipset_tag_t ia_ic;
  246 
  247         /*
  248          * ISA PnP configuration support.  `ipa_' prefixes are used to denote
  249          * PnP specific members of this structure.
  250          */
  251         struct isa_attach_args  *ipa_sibling;
  252         struct isa_attach_args  *ipa_child;
  253 
  254         char    ipa_devident[ISAPNP_MAX_IDENT];
  255         char    ipa_devlogic[ISAPNP_MAX_DEVCLASS];
  256         char    ipa_devcompat[ISAPNP_MAX_DEVCLASS];
  257         char    ipa_devclass[ISAPNP_MAX_DEVCLASS];
  258 
  259         u_char  ipa_pref;
  260         u_char  ipa_devnum;
  261 
  262         u_char  ipa_nio;
  263         u_char  ipa_nirq;
  264         u_char  ipa_ndrq;
  265         u_char  ipa_nmem;
  266         u_char  ipa_nmem32;
  267 
  268         struct isapnp_region    ipa_io[ISAPNP_NUM_IO];
  269         struct isapnp_region    ipa_mem[ISAPNP_NUM_MEM];
  270         struct isapnp_region    ipa_mem32[ISAPNP_NUM_MEM32];
  271         struct isapnp_pin       ipa_irq[ISAPNP_NUM_IRQ];
  272         struct isapnp_pin       ipa_drq[ISAPNP_NUM_DRQ];
  273 
  274         /*
  275          * Compatibility defines for ISA drivers.
  276          */
  277 #define ia_iobase       ipa_io[0].base
  278 #define ia_iosize       ipa_io[0].length
  279 #define ia_ioh          ipa_io[0].h
  280 #define ia_irq          ipa_irq[0].num
  281 #define ia_drq          ipa_drq[0].num
  282 #define ia_drq2         ipa_drq[1].num
  283 #define ia_maddr        ipa_mem[0].base
  284 #define ia_msize        ipa_mem[0].length
  285 #define ia_memh         ipa_mem[0].h
  286 
  287         void    *ia_aux;                /* driver specific */
  288 };
  289 
  290 #define IOBASEUNK       -1              /* i/o address is unknown */
  291 #define IRQUNK          -1              /* interrupt request line is unknown */
  292 #define DRQUNK          -1              /* DMA request line is unknown */
  293 #define MADDRUNK        -1              /* shared memory address is unknown */
  294 
  295 /*
  296  * Per-device ISA variables
  297  */
  298 struct isadev {
  299         struct  device *id_dev;         /* back pointer to generic */
  300         TAILQ_ENTRY(isadev)
  301                 id_bchain;              /* bus chain */
  302 };
  303 
  304 /*
  305  * ISA master bus
  306  */
  307 struct isa_softc {
  308         struct  device sc_dev;          /* base device */
  309         TAILQ_HEAD(, isadev)
  310                 sc_subdevs;             /* list of all children */
  311 
  312         bus_space_tag_t sc_iot;         /* isa io space tag */
  313         bus_space_tag_t sc_memt;        /* isa mem space tag */
  314 #if NISADMA > 0
  315         bus_dma_tag_t sc_dmat;          /* isa DMA tag */
  316 #endif /* NISADMA > 0 */
  317 
  318         isa_chipset_tag_t sc_ic;
  319 
  320 #if NISADMA > 0
  321         /*
  322          * Bitmap representing the DRQ channels available
  323          * for ISA.
  324          */
  325         int     sc_drqmap;
  326 #define sc_drq  sc_drqmap               /* XXX compatibility mode */
  327 
  328         bus_space_handle_t sc_dma1h;    /* i/o handle for DMA controller #1 */
  329         bus_space_handle_t sc_dma2h;    /* i/o handle for DMA controller #2 */
  330         bus_space_handle_t sc_dmapgh;   /* i/o handle for DMA page registers */
  331 
  332         /*
  333          * DMA maps used for the 8 DMA channels.
  334          */
  335         bus_dmamap_t    sc_dmamaps[8];
  336         bus_size_t      sc_dmalength[8];
  337 
  338         int     sc_dmareads;            /* state for isa_dmadone() */
  339         int     sc_dmafinished;         /* DMA completion state */
  340 #endif /* NISADMA > 0 */
  341 
  342         /*
  343          * This i/o handle is used to map port 0x84, which is
  344          * read to provide a 1.25us delay.  This access handle
  345          * is mapped in isaattach(), and exported to drivers
  346          * via isa_attach_args.
  347          */
  348         bus_space_handle_t   sc_delaybah;
  349 };
  350 
  351 #define ISA_DRQ_ISFREE(isadev, drq) \
  352         ((((struct isa_softc *)(isadev))->sc_drqmap & (1 << (drq))) == 0)
  353 
  354 #define ISA_DRQ_ALLOC(isadev, drq) \
  355         ((struct isa_softc *)(isadev))->sc_drqmap |= (1 << (drq))
  356 
  357 #define ISA_DRQ_FREE(isadev, drq) \
  358         ((struct isa_softc *)(isadev))->sc_drqmap &= ~(1 << (drq))
  359 
  360 #define         cf_iobase               cf_loc[0]
  361 #define         cf_iosize               cf_loc[1]
  362 #define         cf_maddr                cf_loc[2]
  363 #define         cf_msize                cf_loc[3]
  364 #define         cf_irq                  cf_loc[4]
  365 #define         cf_drq                  cf_loc[5]
  366 #define         cf_drq2                 cf_loc[6]
  367 
  368 /*
  369  * ISA interrupt handler manipulation.
  370  * 
  371  * To establish an ISA interrupt handler, a driver calls isa_intr_establish()
  372  * with the interrupt number, type, level, function, and function argument of
  373  * the interrupt it wants to handle.  Isa_intr_establish() returns an opaque
  374  * handle to an event descriptor if it succeeds, and invokes panic() if it
  375  * fails.  (XXX It should return NULL, then drivers should handle that, but
  376  * what should they do?)  Interrupt handlers should return 0 for "interrupt
  377  * not for me", 1  for "I took care of it", or -1 for "I guess it was mine,
  378  * but I wasn't expecting it."
  379  *
  380  * To remove an interrupt handler, the driver calls isa_intr_disestablish() 
  381  * with the handle returned by isa_intr_establish() for that handler.
  382  */
  383 
  384 /* ISA interrupt sharing types */
  385 char    *isa_intr_typename(int type);
  386 
  387 void    isascan(struct device *parent, void *match);
  388 int     isaprint(void *, const char *);
  389 
  390 /*
  391  * Some ISA devices (e.g. on a VLB) can perform 32-bit DMA.  This
  392  * flag is passed to bus_dmamap_create() to indicate that fact.
  393  */
  394 #define ISABUS_DMA_32BIT        BUS_DMA_BUS1
  395 
  396 /*
  397  * ISA PnP prototypes and support macros.
  398  */
  399 static __inline void isapnp_write_reg(struct isapnp_softc *, int, u_char);
  400 static __inline u_char isapnp_read_reg(struct isapnp_softc *, int);
  401 
  402 static __inline void
  403 isapnp_write_reg(struct isapnp_softc *sc, int r, u_char v)
  404 {
  405         ISAPNP_WRITE_ADDR(sc, r);
  406         ISAPNP_WRITE_DATA(sc, v);
  407 }
  408 
  409 static __inline u_char
  410 isapnp_read_reg(struct isapnp_softc *sc, int r)
  411 {
  412         ISAPNP_WRITE_ADDR(sc, r);
  413         return ISAPNP_READ_DATA(sc);
  414 }
  415 
  416 struct isa_attach_args *
  417     isapnp_get_resource(struct isapnp_softc *, int, struct isa_attach_args *);
  418 char *isapnp_id_to_vendor(char *, const u_char *);
  419 
  420 int isapnp_config(bus_space_tag_t, bus_space_tag_t,
  421     struct isa_attach_args *);
  422 void isapnp_unconfig(bus_space_tag_t, bus_space_tag_t,
  423     struct isa_attach_args *);
  424 
  425 void isapnp_isa_attach_hook(struct isa_softc *);
  426 #ifdef DEBUG_ISAPNP
  427 void isapnp_print_mem(const char *, const struct isapnp_region *);
  428 void isapnp_print_io(const char *, const struct isapnp_region *);
  429 void isapnp_print_irq(const char *, const struct isapnp_pin *);
  430 void isapnp_print_drq(const char *, const struct isapnp_pin *);
  431 void isapnp_print_dep_start(const char *, const u_char);
  432 void isapnp_print_attach(const struct isa_attach_args *);
  433 void isapnp_get_config(struct isapnp_softc *,
  434         struct isa_attach_args *);
  435 void isapnp_print_config(const struct isa_attach_args *);
  436 #endif  /* DEBUG_ISAPNP */
  437 #endif /* _DEV_ISA_ISAVAR_H_ */

Cache object: 71047ffa47a2475441cad749da77efb3


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