xref: /freebsd/sys/isa/isavar.h (revision 1a4290e7f01272f193bc6cace761d7817adfba8a)
11a4290e7SDoug Rabson /*-
21a4290e7SDoug Rabson  * Copyright (c) 1998 Doug Rabson
31a4290e7SDoug Rabson  * All rights reserved.
41a4290e7SDoug Rabson  *
51a4290e7SDoug Rabson  * Redistribution and use in source and binary forms, with or without
61a4290e7SDoug Rabson  * modification, are permitted provided that the following conditions
71a4290e7SDoug Rabson  * are met:
81a4290e7SDoug Rabson  * 1. Redistributions of source code must retain the above copyright
91a4290e7SDoug Rabson  *    notice, this list of conditions and the following disclaimer.
101a4290e7SDoug Rabson  * 2. Redistributions in binary form must reproduce the above copyright
111a4290e7SDoug Rabson  *    notice, this list of conditions and the following disclaimer in the
121a4290e7SDoug Rabson  *    documentation and/or other materials provided with the distribution.
131a4290e7SDoug Rabson  *
141a4290e7SDoug Rabson  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
151a4290e7SDoug Rabson  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
161a4290e7SDoug Rabson  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
171a4290e7SDoug Rabson  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
181a4290e7SDoug Rabson  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
191a4290e7SDoug Rabson  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
201a4290e7SDoug Rabson  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
211a4290e7SDoug Rabson  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
221a4290e7SDoug Rabson  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
231a4290e7SDoug Rabson  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
241a4290e7SDoug Rabson  * SUCH DAMAGE.
251a4290e7SDoug Rabson  *
261a4290e7SDoug Rabson  *	$Id$
271a4290e7SDoug Rabson  */
281a4290e7SDoug Rabson 
291a4290e7SDoug Rabson enum isa_device_ivars {
301a4290e7SDoug Rabson     ISA_IVAR_PORT,
311a4290e7SDoug Rabson     ISA_IVAR_PORTSIZE,
321a4290e7SDoug Rabson     ISA_IVAR_FLAGS,
331a4290e7SDoug Rabson     ISA_IVAR_IRQ
341a4290e7SDoug Rabson };
351a4290e7SDoug Rabson 
361a4290e7SDoug Rabson extern int isa_irq_pending(void);
371a4290e7SDoug Rabson extern int isa_irq_mask(void);
381a4290e7SDoug Rabson 
391a4290e7SDoug Rabson /*
401a4290e7SDoug Rabson  * Simplified accessors for isa devices
411a4290e7SDoug Rabson  */
421a4290e7SDoug Rabson #define ISA_ACCESSOR(A, B, T)						\
431a4290e7SDoug Rabson 									\
441a4290e7SDoug Rabson static __inline T isa_get_ ## A(device_t dev)				\
451a4290e7SDoug Rabson {									\
461a4290e7SDoug Rabson 	u_long v;							\
471a4290e7SDoug Rabson 	BUS_READ_IVAR(device_get_parent(dev), dev, ISA_IVAR_ ## B, &v);	\
481a4290e7SDoug Rabson 	return (T) v;							\
491a4290e7SDoug Rabson }									\
501a4290e7SDoug Rabson 									\
511a4290e7SDoug Rabson static __inline void isa_set_ ## A(device_t dev, T t)			\
521a4290e7SDoug Rabson {									\
531a4290e7SDoug Rabson 	u_long v = (u_long) t;						\
541a4290e7SDoug Rabson 	BUS_WRITE_IVAR(device_get_parent(dev), dev, ISA_IVAR_ ## B, v);	\
551a4290e7SDoug Rabson }
561a4290e7SDoug Rabson 
571a4290e7SDoug Rabson ISA_ACCESSOR(port, PORT, int)
581a4290e7SDoug Rabson ISA_ACCESSOR(portsize, PORTSIZE, int)
591a4290e7SDoug Rabson ISA_ACCESSOR(flags, FLAGS, int)
601a4290e7SDoug Rabson ISA_ACCESSOR(irq, IRQ, int)
611a4290e7SDoug Rabson 
62