isavar.h revision 55206
118316Swollman/*-
218316Swollman * Copyright (c) 1998 Doug Rabson
318316Swollman * All rights reserved.
418316Swollman *
518316Swollman * Redistribution and use in source and binary forms, with or without
618316Swollman * modification, are permitted provided that the following conditions
718316Swollman * are met:
818316Swollman * 1. Redistributions of source code must retain the above copyright
918316Swollman *    notice, this list of conditions and the following disclaimer.
1018316Swollman * 2. Redistributions in binary form must reproduce the above copyright
1118316Swollman *    notice, this list of conditions and the following disclaimer in the
1218316Swollman *    documentation and/or other materials provided with the distribution.
1318316Swollman *
1446303Smarkm * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
1518316Swollman * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1618316Swollman * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
1718316Swollman * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
1818316Swollman * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
1918316Swollman * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2018316Swollman * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2118316Swollman * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2218316Swollman * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2318316Swollman * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2418316Swollman * SUCH DAMAGE.
2518316Swollman *
2618316Swollman * $FreeBSD: head/sys/isa/isavar.h 55206 1999-12-29 05:07:58Z peter $
2718316Swollman */
2818316Swollman
2918316Swollman#ifndef _ISA_ISAVAR_H_
3018316Swollman#define _ISA_ISAVAR_H_
3118316Swollman
3246303Smarkmstruct isa_config;
3350476Speterstruct isa_pnp_id;
3418316Swollmantypedef void isa_config_cb(void *arg, struct isa_config *config, int enable);
3518316Swollman
3618316Swollman#include "isa_if.h"
3718316Swollman#include <isa/pnpvar.h>
3818316Swollman
3918316Swollman#ifdef _KERNEL
4018316Swollman
4146303Smarkm/*
4246303Smarkm * ISA devices are partially ordered to ensure that devices which are
4346303Smarkm * sensitive to other driver probe routines are probed first. Plug and
4446303Smarkm * Play devices are added after devices with speculative probes so that
4546303Smarkm * the legacy hardware can claim resources allowing the Plug and Play
4650476Speter * hardware to choose different resources.
4746303Smarkm */
4818316Swollman#define ISA_ORDER_SENSITIVE	0 /* legacy sensitive hardware */
4918316Swollman#define ISA_ORDER_SPECULATIVE	1 /* legacy non-sensitive hardware */
5018316Swollman#define ISA_ORDER_PNP		2 /* plug-and-play hardware */
5118316Swollman
5218316Swollman#define	ISA_NPORT	32
5318316Swollman#define	ISA_NMEM	8
5418316Swollman#define	ISA_NIRQ	2
5518316Swollman#define	ISA_NDRQ	2
5618316Swollman
5718316Swollman/*
5818316Swollman * Plug and play cards can support a range of resource
5918316Swollman * configurations. This structure is used by the isapnp parser to
6018316Swollman * inform the isa bus about the resource possibilities of the
6118316Swollman * device. Each different alternative should be supplied by calling
6218316Swollman * ISA_ADD_CONFIG().
6318316Swollman */
6418316Swollmanstruct isa_range {
6518316Swollman	u_int32_t		ir_start;
6618316Swollman	u_int32_t		ir_end;
6718316Swollman	u_int32_t		ir_size;
6818316Swollman	u_int32_t		ir_align;
6918316Swollman};
7018316Swollman
7118316Swollmanstruct isa_config {
7218316Swollman	struct isa_range	ic_mem[ISA_NMEM];
7318316Swollman	struct isa_range	ic_port[ISA_NPORT];
7418316Swollman	u_int32_t		ic_irqmask[ISA_NIRQ];
7518316Swollman	u_int32_t		ic_drqmask[ISA_NDRQ];
7618316Swollman	int			ic_nmem;
7718316Swollman	int			ic_nport;
7818316Swollman	int			ic_nirq;
7918316Swollman	int			ic_ndrq;
8018316Swollman};
8118316Swollman
8218316Swollman/*
8318316Swollman * Used to build lists of IDs and description strings for PnP drivers.
8446303Smarkm */
8518316Swollmanstruct isa_pnp_id {
8618316Swollman	u_int32_t		ip_id;
8718316Swollman	const char		*ip_desc;
8818316Swollman};
8918316Swollman
9018316Swollmanenum isa_device_ivars {
9118316Swollman	ISA_IVAR_PORT,
9218316Swollman	ISA_IVAR_PORT_0 = ISA_IVAR_PORT,
9318316Swollman	ISA_IVAR_PORT_1,
9446303Smarkm	ISA_IVAR_PORTSIZE,
9546303Smarkm	ISA_IVAR_PORTSIZE_0 = ISA_IVAR_PORTSIZE,
9646303Smarkm	ISA_IVAR_PORTSIZE_1,
9746303Smarkm	ISA_IVAR_MADDR,
9846303Smarkm	ISA_IVAR_MADDR_0 = ISA_IVAR_MADDR,
9946303Smarkm	ISA_IVAR_MADDR_1,
10046303Smarkm	ISA_IVAR_MSIZE,
10118316Swollman	ISA_IVAR_MSIZE_0 = ISA_IVAR_MSIZE,
10218316Swollman	ISA_IVAR_MSIZE_1,
10318316Swollman	ISA_IVAR_IRQ,
10418316Swollman	ISA_IVAR_IRQ_0 = ISA_IVAR_IRQ,
10518316Swollman	ISA_IVAR_IRQ_1,
10618316Swollman	ISA_IVAR_DRQ,
10718316Swollman	ISA_IVAR_DRQ_0 = ISA_IVAR_DRQ,
10818316Swollman	ISA_IVAR_DRQ_1,
10946303Smarkm	ISA_IVAR_VENDORID,
11018316Swollman	ISA_IVAR_SERIAL,
11118316Swollman	ISA_IVAR_LOGICALID,
11218316Swollman	ISA_IVAR_COMPATID
11318316Swollman};
11418316Swollman
11518316Swollman/*
11618316Swollman * Simplified accessors for isa devices
11718316Swollman */
11818316Swollman#define ISA_ACCESSOR(A, B, T)						\
11918316Swollman									\
12018316Swollmanstatic __inline T isa_get_ ## A(device_t dev)				\
12118316Swollman{									\
12218316Swollman	uintptr_t v;							\
12318316Swollman	BUS_READ_IVAR(device_get_parent(dev), dev, ISA_IVAR_ ## B, &v);	\
12418316Swollman	return (T) v;							\
12518316Swollman}									\
12618316Swollman									\
12718316Swollmanstatic __inline void isa_set_ ## A(device_t dev, T t)			\
12818316Swollman{									\
12918316Swollman	u_long v = (u_long) t;						\
13018316Swollman	BUS_WRITE_IVAR(device_get_parent(dev), dev, ISA_IVAR_ ## B, v);	\
13118316Swollman}
13218316Swollman
13318316SwollmanISA_ACCESSOR(port, PORT, int)
13418316SwollmanISA_ACCESSOR(portsize, PORTSIZE, int)
13518316SwollmanISA_ACCESSOR(irq, IRQ, int)
13618316SwollmanISA_ACCESSOR(drq, DRQ, int)
13720339SwollmanISA_ACCESSOR(maddr, MADDR, int)
13818316SwollmanISA_ACCESSOR(msize, MSIZE, int)
13918316SwollmanISA_ACCESSOR(vendorid, VENDORID, int)
14018316SwollmanISA_ACCESSOR(serial, SERIAL, int)
14118316SwollmanISA_ACCESSOR(logicalid, LOGICALID, int)
14218316SwollmanISA_ACCESSOR(compatid, COMPATID, int)
14318316Swollman
14419880Swollmanextern intrmask_t isa_irq_pending(void);
14518316Swollmanextern intrmask_t isa_irq_mask(void);
14618316Swollman#ifdef __i386__
14746303Smarkmextern void	 isa_wrap_old_drivers(void);
14818316Swollman#endif
14918316Swollmanextern void	isa_probe_children(device_t dev);
15018316Swollman
15118316Swollmanextern void	isa_dmacascade __P((int chan));
15218316Swollmanextern void	isa_dmadone __P((int flags, caddr_t addr, int nbytes, int chan));
15318316Swollmanextern void	isa_dmainit __P((int chan, u_int bouncebufsize));
15418316Swollmanextern void	isa_dmastart __P((int flags, caddr_t addr, u_int nbytes, int chan));
15518316Swollmanextern int	isa_dma_acquire __P((int chan));
15618316Swollmanextern void	isa_dma_release __P((int chan));
15718316Swollmanextern int	isa_dmastatus __P((int chan));
15818316Swollmanextern int	isa_dmastop __P((int chan));
15918316Swollman
16018316Swollman#endif /* _KERNEL */
16118316Swollman
16218316Swollman#endif /* !_ISA_ISAVAR_H_ */
16318316Swollman