isavar.h revision 38136
138136Sdfr/*-
238136Sdfr * Copyright (c) 1998 Doug Rabson
338136Sdfr * All rights reserved.
438136Sdfr *
538136Sdfr * Redistribution and use in source and binary forms, with or without
638136Sdfr * modification, are permitted provided that the following conditions
738136Sdfr * are met:
838136Sdfr * 1. Redistributions of source code must retain the above copyright
938136Sdfr *    notice, this list of conditions and the following disclaimer.
1038136Sdfr * 2. Redistributions in binary form must reproduce the above copyright
1138136Sdfr *    notice, this list of conditions and the following disclaimer in the
1238136Sdfr *    documentation and/or other materials provided with the distribution.
1338136Sdfr *
1438136Sdfr * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
1538136Sdfr * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1638136Sdfr * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
1738136Sdfr * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
1838136Sdfr * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
1938136Sdfr * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2038136Sdfr * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2138136Sdfr * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2238136Sdfr * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2338136Sdfr * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2438136Sdfr * SUCH DAMAGE.
2538136Sdfr *
2638136Sdfr *	$Id$
2738136Sdfr */
2838136Sdfr
2938136Sdfrenum isa_device_ivars {
3038136Sdfr    ISA_IVAR_PORT,
3138136Sdfr    ISA_IVAR_PORTSIZE,
3238136Sdfr    ISA_IVAR_FLAGS,
3338136Sdfr    ISA_IVAR_IRQ
3438136Sdfr};
3538136Sdfr
3638136Sdfrextern int isa_irq_pending(void);
3738136Sdfrextern int isa_irq_mask(void);
3838136Sdfr
3938136Sdfr/*
4038136Sdfr * Simplified accessors for isa devices
4138136Sdfr */
4238136Sdfr#define ISA_ACCESSOR(A, B, T)						\
4338136Sdfr									\
4438136Sdfrstatic __inline T isa_get_ ## A(device_t dev)				\
4538136Sdfr{									\
4638136Sdfr	u_long v;							\
4738136Sdfr	BUS_READ_IVAR(device_get_parent(dev), dev, ISA_IVAR_ ## B, &v);	\
4838136Sdfr	return (T) v;							\
4938136Sdfr}									\
5038136Sdfr									\
5138136Sdfrstatic __inline void isa_set_ ## A(device_t dev, T t)			\
5238136Sdfr{									\
5338136Sdfr	u_long v = (u_long) t;						\
5438136Sdfr	BUS_WRITE_IVAR(device_get_parent(dev), dev, ISA_IVAR_ ## B, v);	\
5538136Sdfr}
5638136Sdfr
5738136SdfrISA_ACCESSOR(port, PORT, int)
5838136SdfrISA_ACCESSOR(portsize, PORTSIZE, int)
5938136SdfrISA_ACCESSOR(flags, FLAGS, int)
6038136SdfrISA_ACCESSOR(irq, IRQ, int)
6138136Sdfr
62