Home | History | Annotate | Line # | Download | only in isapnp
isapnpvar.h revision 1.3.4.1
      1  1.3.4.1   thorpej /*	$NetBSD: isapnpvar.h,v 1.3.4.1 1997/08/23 07:13:44 thorpej Exp $	*/
      2      1.1  christos 
      3      1.1  christos /*
      4      1.1  christos  * Copyright (c) 1996 Christos Zoulas.  All rights reserved.
      5      1.1  christos  *
      6      1.1  christos  * Redistribution and use in source and binary forms, with or without
      7      1.1  christos  * modification, are permitted provided that the following conditions
      8      1.1  christos  * are met:
      9      1.1  christos  * 1. Redistributions of source code must retain the above copyright
     10      1.1  christos  *    notice, this list of conditions and the following disclaimer.
     11      1.1  christos  * 2. Redistributions in binary form must reproduce the above copyright
     12      1.1  christos  *    notice, this list of conditions and the following disclaimer in the
     13      1.1  christos  *    documentation and/or other materials provided with the distribution.
     14      1.1  christos  * 3. All advertising materials mentioning features or use of this software
     15      1.1  christos  *    must display the following acknowledgement:
     16      1.1  christos  *	This product includes software developed by Christos Zoulas.
     17      1.1  christos  * 4. The name of the author may not be used to endorse or promote products
     18      1.1  christos  *    derived from this software without specific prior written permission.
     19      1.1  christos  *
     20      1.1  christos  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     21      1.1  christos  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     22      1.1  christos  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     23      1.1  christos  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     24      1.1  christos  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     25      1.1  christos  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     26      1.1  christos  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     27      1.1  christos  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     28      1.1  christos  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     29      1.1  christos  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     30      1.1  christos  */
     31      1.1  christos 
     32      1.1  christos #ifndef _DEV_ISAPNP_ISAPNPVAR_H_
     33      1.1  christos #define _DEV_ISAPNP_ISAPNPVAR_H_
     34      1.1  christos 
     35      1.1  christos /*
     36      1.1  christos  * ISA Plug and Play register definitions;
     37      1.1  christos  * From Plug and Play ISA Specification V1.0a, May 5 1994
     38      1.1  christos  */
     39      1.1  christos 
     40      1.1  christos /*
     41      1.1  christos  * Structures and definitions needed by the machine-dependent header.
     42      1.1  christos  */
     43      1.1  christos struct isapnp_softc;
     44      1.1  christos 
     45      1.1  christos #if (i386 != 1)
     46      1.1  christos ERROR: COMPILING FOR UNSUPPORTED MACHINE, OR MORE THAN ONE.
     47      1.1  christos #endif
     48      1.1  christos #if i386
     49      1.1  christos #include <i386/isa/isapnp_machdep.h>
     50      1.1  christos #endif
     51      1.1  christos 
     52      1.1  christos #ifndef _KERNEL
     53      1.1  christos 
     54  1.3.4.1   thorpej # include <stdlib.h>
     55      1.1  christos # include <string.h>
     56      1.1  christos # include <unistd.h>
     57      1.1  christos 
     58      1.1  christos # define ISAPNP_WRITE_ADDR(sc, v) outb(ISAPNP_ADDR, v)
     59      1.1  christos # define ISAPNP_WRITE_DATA(sc, v) outb(ISAPNP_WRDATA, v)
     60      1.1  christos # define ISAPNP_READ_DATA(sc) inb(sc->sc_read_port)
     61      1.1  christos 
     62      1.1  christos # define DELAY(us) usleep(us)
     63      1.1  christos # define ISAPNP_MALLOC(a) malloc(a)
     64      1.1  christos # define ISAPNP_FREE(a) free(a)
     65      1.1  christos 
     66      1.1  christos # define panic printf
     67      1.1  christos 
     68      1.1  christos #else
     69      1.1  christos 
     70      1.1  christos /* XXX */
     71      1.1  christos # define memset(a, b, c)	bzero(a, c)
     72      1.1  christos 
     73      1.1  christos # define ISAPNP_WRITE_ADDR(sc, v) \
     74      1.1  christos     bus_space_write_1(sc->sc_iot, sc->sc_addr_ioh, 0, v)
     75  1.3.4.1   thorpej # define ISAPNP_WRITE_DATA(sc, v) \
     76      1.1  christos     bus_space_write_1(sc->sc_iot, sc->sc_wrdata_ioh, 0, v)
     77  1.3.4.1   thorpej # define ISAPNP_READ_DATA(sc) \
     78      1.1  christos     bus_space_read_1(sc->sc_iot, sc->sc_read_ioh, 0)
     79      1.1  christos 
     80  1.3.4.1   thorpej # define ISAPNP_MALLOC(a) malloc(a, M_DEVBUF, M_WAITOK)
     81  1.3.4.1   thorpej # define ISAPNP_FREE(a) free(a, M_DEVBUF)
     82      1.1  christos 
     83      1.1  christos #endif
     84      1.1  christos 
     85      1.1  christos #ifdef DEBUG_ISAPNP
     86      1.1  christos # define DPRINTF(a) printf a
     87      1.1  christos #else
     88      1.1  christos # define DPRINTF(a)
     89      1.1  christos #endif
     90      1.1  christos 
     91      1.1  christos struct isapnp_softc {
     92      1.1  christos 	struct device		sc_dev;
     93      1.1  christos 	int			sc_read_port;
     94      1.1  christos 	bus_space_tag_t		sc_iot;
     95      1.1  christos 	bus_space_tag_t		sc_memt;
     96      1.1  christos 	bus_space_handle_t	sc_addr_ioh;
     97      1.1  christos 	bus_space_handle_t	sc_wrdata_ioh;
     98      1.1  christos 	bus_space_handle_t	sc_read_ioh;
     99      1.1  christos 	bus_space_handle_t	sc_memh;
    100      1.1  christos 	u_int8_t		sc_ncards;
    101      1.1  christos     	u_int8_t		sc_id[ISAPNP_MAX_CARDS][ISAPNP_SERIAL_SIZE];
    102      1.1  christos };
    103      1.1  christos 
    104      1.1  christos struct isapnp_region {
    105      1.1  christos 	bus_space_handle_t h;
    106      1.1  christos 	u_int32_t base;
    107      1.1  christos 
    108      1.1  christos 	u_int32_t minbase;
    109      1.1  christos 	u_int32_t maxbase;
    110      1.1  christos 	u_int32_t length;
    111      1.1  christos 	u_int32_t align;
    112      1.1  christos 	u_int8_t  flags;
    113      1.1  christos };
    114      1.1  christos 
    115      1.1  christos struct isapnp_pin {
    116      1.1  christos 	u_int8_t num;
    117      1.1  christos 
    118      1.1  christos 	u_int16_t bits;
    119      1.1  christos 	u_int8_t flags;
    120      1.1  christos };
    121      1.1  christos 
    122      1.1  christos struct isapnp_attach_args {
    123      1.1  christos 	bus_space_tag_t ipa_iot;	/* isa i/o space tag */
    124      1.1  christos 	bus_space_tag_t ipa_memt;	/* isa mem space tag */
    125      1.3   thorpej 	bus_dma_tag_t	ipa_dmat;	/* isa dma tag */
    126      1.1  christos 
    127      1.1  christos 	isa_chipset_tag_t ipa_ic;
    128      1.1  christos 
    129      1.2  christos 	struct isapnp_attach_args *ipa_sibling;
    130      1.2  christos 	struct isapnp_attach_args *ipa_child;
    131      1.1  christos 
    132      1.1  christos 	char	ipa_devident[ISAPNP_MAX_IDENT];
    133      1.1  christos 	char	ipa_devlogic[ISAPNP_MAX_DEVCLASS];
    134  1.3.4.1   thorpej 	char	ipa_devcompat[ISAPNP_MAX_DEVCLASS];
    135      1.1  christos 	char	ipa_devclass[ISAPNP_MAX_DEVCLASS];
    136      1.1  christos 
    137      1.1  christos 	u_char	ipa_pref;
    138      1.1  christos 	u_char	ipa_devnum;
    139      1.1  christos 
    140      1.1  christos 	u_char	ipa_nio;
    141      1.1  christos 	u_char	ipa_nirq;
    142      1.1  christos 	u_char	ipa_ndrq;
    143      1.1  christos 	u_char	ipa_nmem;
    144      1.1  christos 	u_char	ipa_nmem32;
    145      1.1  christos 
    146      1.1  christos 	struct isapnp_region	ipa_io[ISAPNP_NUM_IO];
    147      1.1  christos 	struct isapnp_region	ipa_mem[ISAPNP_NUM_MEM];
    148      1.1  christos 	struct isapnp_region	ipa_mem32[ISAPNP_NUM_MEM32];
    149      1.1  christos 	struct isapnp_pin	ipa_irq[ISAPNP_NUM_IRQ];
    150      1.1  christos 	struct isapnp_pin	ipa_drq[ISAPNP_NUM_DRQ];
    151      1.1  christos };
    152      1.1  christos 
    153      1.1  christos static __inline void isapnp_write_reg __P((struct isapnp_softc *, int, u_char));
    154      1.1  christos static __inline u_char isapnp_read_reg __P((struct isapnp_softc *, int));
    155      1.1  christos 
    156      1.1  christos static __inline void
    157      1.1  christos isapnp_write_reg(sc, r, v)
    158      1.1  christos 	struct isapnp_softc *sc;
    159      1.1  christos 	int r;
    160      1.1  christos 	u_char v;
    161      1.1  christos {
    162      1.1  christos 	ISAPNP_WRITE_ADDR(sc, r);
    163      1.1  christos 	ISAPNP_WRITE_DATA(sc, v);
    164      1.1  christos }
    165      1.1  christos 
    166      1.1  christos static __inline u_char
    167      1.1  christos isapnp_read_reg(sc, r)
    168      1.1  christos 	struct isapnp_softc *sc;
    169      1.1  christos {
    170      1.1  christos 	ISAPNP_WRITE_ADDR(sc, r);
    171      1.1  christos 	return ISAPNP_READ_DATA(sc);
    172      1.1  christos }
    173      1.1  christos 
    174      1.1  christos struct isapnp_attach_args *
    175      1.1  christos     isapnp_get_resource __P((struct isapnp_softc *, int));
    176      1.1  christos char *isapnp_id_to_vendor __P((char *, const u_char *));
    177      1.1  christos 
    178      1.1  christos int isapnp_config __P((bus_space_tag_t, bus_space_tag_t,
    179      1.1  christos     struct isapnp_attach_args *));
    180      1.1  christos void isapnp_unconfig __P((bus_space_tag_t, bus_space_tag_t,
    181      1.1  christos     struct isapnp_attach_args *));
    182      1.1  christos 
    183      1.1  christos #ifdef DEBUG_ISAPNP
    184      1.1  christos void isapnp_print_mem __P((const char *, const struct isapnp_region *));
    185      1.1  christos void isapnp_print_io __P((const char *, const struct isapnp_region *));
    186      1.1  christos void isapnp_print_irq __P((const char *, const struct isapnp_pin *));
    187      1.1  christos void isapnp_print_drq __P((const char *, const struct isapnp_pin *));
    188      1.1  christos void isapnp_print_dep_start __P((const char *, const u_char));
    189      1.1  christos void isapnp_print_attach __P((const struct isapnp_attach_args *));
    190      1.1  christos void isapnp_get_config __P((struct isapnp_softc *,
    191      1.1  christos 	struct isapnp_attach_args *));
    192      1.1  christos void isapnp_print_config __P((const struct isapnp_attach_args *));
    193      1.1  christos #endif
    194      1.1  christos 
    195      1.1  christos #endif /* ! _DEV_ISAPNP_ISAPNPVAR_H_ */
    196