isavar.h revision 47398
1146449Sharti/*-
2146449Sharti * Copyright (c) 1998 Doug Rabson
3146449Sharti * All rights reserved.
4146449Sharti *
5146449Sharti * Redistribution and use in source and binary forms, with or without
6146449Sharti * modification, are permitted provided that the following conditions
7146449Sharti * are met:
8146449Sharti * 1. Redistributions of source code must retain the above copyright
9146449Sharti *    notice, this list of conditions and the following disclaimer.
10146449Sharti * 2. Redistributions in binary form must reproduce the above copyright
11146449Sharti *    notice, this list of conditions and the following disclaimer in the
12146449Sharti *    documentation and/or other materials provided with the distribution.
13146822Sharti *
14146449Sharti * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15146449Sharti * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16146449Sharti * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17146449Sharti * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18146449Sharti * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19146449Sharti * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20146449Sharti * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21146449Sharti * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 *
26 *	$Id: isavar.h,v 1.6 1999/05/14 11:22:35 dfr Exp $
27 */
28
29#include "isa_if.h"
30
31#define	ISA_NPORT_IVARS	2
32#define	ISA_NMEM_IVARS	2
33#define	ISA_NIRQ_IVARS	2
34#define	ISA_NDRQ_IVARS	2
35
36enum isa_device_ivars {
37	ISA_IVAR_PORT,
38	ISA_IVAR_PORT_0 = ISA_IVAR_PORT,
39	ISA_IVAR_PORT_1,
40	ISA_IVAR_PORTSIZE,
41	ISA_IVAR_PORTSIZE_0 = ISA_IVAR_PORTSIZE,
42	ISA_IVAR_PORTSIZE_1,
43	ISA_IVAR_MADDR,
44	ISA_IVAR_MADDR_0 = ISA_IVAR_MADDR,
45	ISA_IVAR_MADDR_1,
46	ISA_IVAR_MSIZE,
47	ISA_IVAR_MSIZE_0 = ISA_IVAR_MSIZE,
48	ISA_IVAR_MSIZE_1,
49	ISA_IVAR_FLAGS,
50	ISA_IVAR_IRQ,
51	ISA_IVAR_IRQ_0 = ISA_IVAR_IRQ,
52	ISA_IVAR_IRQ_1,
53	ISA_IVAR_DRQ,
54	ISA_IVAR_DRQ_0 = ISA_IVAR_DRQ,
55	ISA_IVAR_DRQ_1
56};
57
58extern intrmask_t isa_irq_pending(void);
59extern intrmask_t isa_irq_mask(void);
60#ifdef __i386__
61extern void isa_wrap_old_drivers(void);
62#endif
63
64/*
65 * Simplified accessors for isa devices
66 */
67#define ISA_ACCESSOR(A, B, T)						\
68									\
69static __inline T isa_get_ ## A(device_t dev)				\
70{									\
71	uintptr_t v;							\
72	BUS_READ_IVAR(device_get_parent(dev), dev, ISA_IVAR_ ## B, &v);	\
73	return (T) v;							\
74}									\
75									\
76static __inline void isa_set_ ## A(device_t dev, T t)			\
77{									\
78	u_long v = (u_long) t;						\
79	BUS_WRITE_IVAR(device_get_parent(dev), dev, ISA_IVAR_ ## B, v);	\
80}
81
82ISA_ACCESSOR(port, PORT, int)
83ISA_ACCESSOR(portsize, PORTSIZE, int)
84ISA_ACCESSOR(irq, IRQ, int)
85ISA_ACCESSOR(drq, DRQ, int)
86ISA_ACCESSOR(maddr, MADDR, int)
87ISA_ACCESSOR(msize, MSIZE, int)
88ISA_ACCESSOR(flags, FLAGS, int)
89