Home | History | Annotate | Line # | Download | only in ic
mlxvar.h revision 1.7
      1  1.7   ad /*	$NetBSD: mlxvar.h,v 1.7 2002/09/22 18:59:00 ad Exp $	*/
      2  1.1   ad 
      3  1.1   ad /*-
      4  1.1   ad  * Copyright (c) 2001 The NetBSD Foundation, Inc.
      5  1.1   ad  * All rights reserved.
      6  1.1   ad  *
      7  1.1   ad  * This code is derived from software contributed to The NetBSD Foundation
      8  1.1   ad  * by Andrew Doran.
      9  1.1   ad  *
     10  1.1   ad  * Redistribution and use in source and binary forms, with or without
     11  1.1   ad  * modification, are permitted provided that the following conditions
     12  1.1   ad  * are met:
     13  1.1   ad  * 1. Redistributions of source code must retain the above copyright
     14  1.1   ad  *    notice, this list of conditions and the following disclaimer.
     15  1.1   ad  * 2. Redistributions in binary form must reproduce the above copyright
     16  1.1   ad  *    notice, this list of conditions and the following disclaimer in the
     17  1.1   ad  *    documentation and/or other materials provided with the distribution.
     18  1.1   ad  * 3. All advertising materials mentioning features or use of this software
     19  1.1   ad  *    must display the following acknowledgement:
     20  1.1   ad  *        This product includes software developed by the NetBSD
     21  1.1   ad  *        Foundation, Inc. and its contributors.
     22  1.1   ad  * 4. Neither the name of The NetBSD Foundation nor the names of its
     23  1.1   ad  *    contributors may be used to endorse or promote products derived
     24  1.1   ad  *    from this software without specific prior written permission.
     25  1.1   ad  *
     26  1.1   ad  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     27  1.1   ad  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     28  1.1   ad  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     29  1.1   ad  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     30  1.1   ad  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     31  1.1   ad  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     32  1.1   ad  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     33  1.1   ad  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     34  1.1   ad  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     35  1.1   ad  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     36  1.1   ad  * POSSIBILITY OF SUCH DAMAGE.
     37  1.1   ad  */
     38  1.1   ad 
     39  1.1   ad /*-
     40  1.1   ad  * Copyright (c) 1999 Michael Smith
     41  1.1   ad  * All rights reserved.
     42  1.1   ad  *
     43  1.1   ad  * Redistribution and use in source and binary forms, with or without
     44  1.1   ad  * modification, are permitted provided that the following conditions
     45  1.1   ad  * are met:
     46  1.1   ad  * 1. Redistributions of source code must retain the above copyright
     47  1.1   ad  *    notice, this list of conditions and the following disclaimer.
     48  1.1   ad  * 2. Redistributions in binary form must reproduce the above copyright
     49  1.1   ad  *    notice, this list of conditions and the following disclaimer in the
     50  1.1   ad  *    documentation and/or other materials provided with the distribution.
     51  1.1   ad  *
     52  1.1   ad  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
     53  1.1   ad  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     54  1.1   ad  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     55  1.1   ad  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
     56  1.1   ad  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     57  1.1   ad  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     58  1.1   ad  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     59  1.1   ad  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     60  1.1   ad  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     61  1.1   ad  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     62  1.1   ad  * SUCH DAMAGE.
     63  1.1   ad  *
     64  1.1   ad  * from FreeBSD: mlxvar.h,v 1.5.2.2 2000/04/24 19:40:50 msmith Exp
     65  1.1   ad  */
     66  1.1   ad 
     67  1.1   ad #ifndef _IC_MLXVAR_H_
     68  1.1   ad #define	_IC_MLXVAR_H_
     69  1.1   ad 
     70  1.1   ad #include "locators.h"
     71  1.1   ad 
     72  1.1   ad /* Older boards allow up to 17 segments and 64kB transfers. */
     73  1.1   ad #define	MLX_MAX_SEGS		17
     74  1.1   ad #define	MLX_MAX_XFER		65536
     75  1.1   ad #define MLX_SGL_SIZE		(sizeof(struct mlx_sgentry) * MLX_MAX_SEGS)
     76  1.1   ad 
     77  1.1   ad /* This shouldn't be ajusted lightly... */
     78  1.1   ad #define MLX_MAX_DRIVES		32
     79  1.1   ad 
     80  1.1   ad /* Maximum queue depth, matching the older controllers. */
     81  1.1   ad #define	MLX_MAX_QUEUECNT	63
     82  1.1   ad 
     83  1.7   ad /* Number of CCBs to reserve for control operations. */
     84  1.7   ad #define	MLX_NCCBS_CONTROL	7
     85  1.1   ad 
     86  1.1   ad /* Structure describing a system drive as attached to the controller. */
     87  1.1   ad struct mlx_sysdrive {
     88  1.1   ad 	u_int32_t	ms_size;
     89  1.1   ad 	u_short		ms_state;
     90  1.1   ad 	u_short		ms_raidlevel;
     91  1.1   ad 	struct device	*ms_dv;
     92  1.1   ad };
     93  1.1   ad 
     94  1.1   ad /* Optional per-CCB context. */
     95  1.1   ad struct mlx_ccb;
     96  1.1   ad struct mlx_context {
     97  1.1   ad 	void	(*mx_handler)(struct mlx_ccb *);
     98  1.1   ad 	void 	*mx_context;
     99  1.1   ad 	struct	device	*mx_dv;
    100  1.1   ad };
    101  1.1   ad 
    102  1.1   ad /* Command control block. */
    103  1.1   ad struct mlx_ccb {
    104  1.1   ad 	union {
    105  1.1   ad 		SIMPLEQ_ENTRY(mlx_ccb) simpleq;
    106  1.1   ad 		SLIST_ENTRY(mlx_ccb) slist;
    107  1.1   ad 		TAILQ_ENTRY(mlx_ccb) tailq;
    108  1.1   ad 	} mc_chain;
    109  1.1   ad 	u_int		mc_flags;
    110  1.1   ad 	u_int		mc_status;
    111  1.1   ad 	u_int		mc_ident;
    112  1.1   ad 	time_t		mc_expiry;
    113  1.1   ad 	u_int		mc_nsgent;
    114  1.1   ad 	u_int		mc_xfer_size;
    115  1.1   ad 	bus_addr_t	mc_xfer_phys;
    116  1.1   ad 	bus_dmamap_t	mc_xfer_map;
    117  1.1   ad 	struct mlx_context mc_mx;
    118  1.1   ad 	u_int8_t	mc_mbox[16];
    119  1.1   ad };
    120  1.1   ad #define	MC_XFER_IN	MU_XFER_IN	/* Map describes inbound xfer */
    121  1.1   ad #define	MC_XFER_OUT	MU_XFER_OUT	/* Map describes outbound xfer */
    122  1.1   ad #define	MC_WAITING	0x0400		/* We have waiters */
    123  1.7   ad #define	MC_CONTROL	0x0800		/* Control operation */
    124  1.1   ad 
    125  1.1   ad /*
    126  1.1   ad  * Per-controller state.
    127  1.1   ad  */
    128  1.1   ad struct mlx_softc {
    129  1.1   ad 	struct device		mlx_dv;
    130  1.1   ad 	bus_space_tag_t		mlx_iot;
    131  1.1   ad 	bus_space_handle_t	mlx_ioh;
    132  1.1   ad 	bus_dma_tag_t		mlx_dmat;
    133  1.1   ad 	bus_dmamap_t		mlx_dmamap;
    134  1.1   ad 	void			*mlx_ih;
    135  1.1   ad 
    136  1.1   ad 	SLIST_HEAD(, mlx_ccb)	mlx_ccb_freelist;
    137  1.1   ad 	TAILQ_HEAD(, mlx_ccb)	mlx_ccb_worklist;
    138  1.1   ad 	SIMPLEQ_HEAD(, mlx_ccb)	mlx_ccb_queue;
    139  1.1   ad 	struct mlx_ccb		*mlx_ccbs;
    140  1.1   ad 	int			mlx_nccbs;
    141  1.7   ad 	int			mlx_nccbs_ctrl;
    142  1.1   ad 
    143  1.1   ad 	caddr_t			mlx_sgls;
    144  1.1   ad 	bus_addr_t		mlx_sgls_paddr;
    145  1.1   ad 
    146  1.1   ad 	int	(*mlx_submit)(struct mlx_softc *, struct mlx_ccb *);
    147  1.1   ad 	int	(*mlx_findcomplete)(struct mlx_softc *, u_int *, u_int *);
    148  1.1   ad 	void	(*mlx_intaction)(struct mlx_softc *, int);
    149  1.1   ad 	int	(*mlx_fw_handshake)(struct mlx_softc *, int *, int *, int *);
    150  1.2   ad 	int	(*mlx_reset)(struct mlx_softc *);
    151  1.1   ad 
    152  1.1   ad 	int			mlx_max_queuecnt;
    153  1.6   ad 	struct mlx_cinfo	mlx_ci;
    154  1.1   ad 
    155  1.1   ad 	time_t			mlx_lastpoll;
    156  1.1   ad 	u_int			mlx_lastevent;
    157  1.1   ad 	u_int			mlx_currevent;
    158  1.1   ad 	u_int			mlx_bg;
    159  1.1   ad 	struct mlx_rebuild_status mlx_rebuildstat;
    160  1.1   ad 	struct mlx_pause	mlx_pause;
    161  1.1   ad 	int			mlx_flags;
    162  1.1   ad 
    163  1.1   ad 	struct mlx_sysdrive	mlx_sysdrive[MLX_MAX_DRIVES];
    164  1.3   ad 	int			mlx_numsysdrives;
    165  1.1   ad };
    166  1.1   ad 
    167  1.1   ad #define MLX_BG_CHECK		1	/* we started a check */
    168  1.1   ad #define MLX_BG_REBUILD		2	/* we started a rebuild */
    169  1.1   ad #define MLX_BG_SPONTANEOUS	3	/* it just happened somehow */
    170  1.1   ad 
    171  1.1   ad #define MLXF_SPINUP_REPORTED	0x0001	/* "spinning up drives" displayed */
    172  1.1   ad #define MLXF_EVENTLOG_BUSY	0x0002	/* currently reading event log */
    173  1.1   ad #define MLXF_FW_INITTED		0x0004	/* firmware init crap done */
    174  1.1   ad #define MLXF_PAUSEWORKS		0x0008	/* channel pause works as expected */
    175  1.1   ad #define MLXF_OPEN		0x0010	/* control device is open */
    176  1.5  wiz #define	MLXF_INITOK		0x0020	/* controller initialised OK */
    177  1.1   ad #define	MLXF_PERIODIC_CTLR	0x0040	/* periodic check running */
    178  1.1   ad #define	MLXF_PERIODIC_DRIVE	0x0080	/* periodic check running */
    179  1.1   ad #define	MLXF_PERIODIC_REBUILD	0x0100	/* periodic check running */
    180  1.4   ad #define	MLXF_RESCANNING		0x0400	/* rescanning drive table */
    181  1.1   ad 
    182  1.1   ad struct mlx_attach_args {
    183  1.1   ad 	int		mlxa_unit;
    184  1.1   ad };
    185  1.1   ad 
    186  1.1   ad #define	mlxacf_unit	cf_loc[MLXCF_UNIT]
    187  1.1   ad 
    188  1.1   ad int	mlx_flush(struct mlx_softc *, int);
    189  1.1   ad void	mlx_init(struct mlx_softc *, const char *);
    190  1.1   ad int	mlx_intr(void *);
    191  1.1   ad 
    192  1.1   ad int	mlx_ccb_alloc(struct mlx_softc *, struct mlx_ccb **, int);
    193  1.1   ad const char *mlx_ccb_diagnose(struct mlx_ccb *);
    194  1.1   ad void	mlx_ccb_enqueue(struct mlx_softc *, struct mlx_ccb *);
    195  1.1   ad void	mlx_ccb_free(struct mlx_softc *, struct mlx_ccb *);
    196  1.1   ad int	mlx_ccb_map(struct mlx_softc *, struct mlx_ccb *, void *, int, int);
    197  1.1   ad int	mlx_ccb_poll(struct mlx_softc *, struct mlx_ccb *, int);
    198  1.1   ad void	mlx_ccb_unmap(struct mlx_softc *, struct mlx_ccb *);
    199  1.1   ad int	mlx_ccb_wait(struct mlx_softc *, struct mlx_ccb *);
    200  1.1   ad 
    201  1.1   ad static __inline__ void	mlx_make_type1(struct mlx_ccb *, u_int8_t, u_int16_t,
    202  1.1   ad 				       u_int32_t, u_int8_t, u_int32_t,
    203  1.1   ad 				       u_int8_t);
    204  1.1   ad static __inline__ void	mlx_make_type2(struct mlx_ccb *, u_int8_t, u_int8_t,
    205  1.1   ad 				       u_int8_t, u_int8_t, u_int8_t,
    206  1.1   ad 				       u_int8_t, u_int8_t, u_int32_t,
    207  1.1   ad 				       u_int8_t);
    208  1.1   ad static __inline__ void	mlx_make_type3(struct mlx_ccb *, u_int8_t, u_int8_t,
    209  1.1   ad 				       u_int8_t, u_int16_t, u_int8_t,
    210  1.1   ad 				       u_int8_t, u_int32_t, u_int8_t);
    211  1.1   ad static __inline__ void	mlx_make_type4(struct mlx_ccb *, u_int8_t, u_int16_t,
    212  1.1   ad 				       u_int32_t, u_int32_t, u_int8_t);
    213  1.1   ad static __inline__ void	mlx_make_type5(struct mlx_ccb *, u_int8_t,  u_int8_t,
    214  1.1   ad 				       u_int8_t, u_int32_t, u_int32_t,
    215  1.1   ad 				       u_int8_t);
    216  1.1   ad 
    217  1.1   ad static __inline__ u_int8_t	mlx_inb(struct mlx_softc *, int);
    218  1.1   ad static __inline__ u_int16_t	mlx_inw(struct mlx_softc *, int);
    219  1.1   ad static __inline__ u_int32_t	mlx_inl(struct mlx_softc *, int);
    220  1.1   ad static __inline__ void		mlx_outb(struct mlx_softc *, int, u_int8_t);
    221  1.1   ad static __inline__ void		mlx_outw(struct mlx_softc *, int, u_int16_t);
    222  1.1   ad static __inline__ void		mlx_outl(struct mlx_softc *, int, u_int32_t);
    223  1.1   ad 
    224  1.1   ad static __inline__ void
    225  1.1   ad mlx_make_type1(struct mlx_ccb *mc, u_int8_t code, u_int16_t f1, u_int32_t f2,
    226  1.1   ad 	       u_int8_t f3, u_int32_t f4, u_int8_t f5)
    227  1.1   ad {
    228  1.1   ad 
    229  1.1   ad 	mc->mc_mbox[0x0] = code;
    230  1.1   ad 	mc->mc_mbox[0x2] = f1;
    231  1.7   ad 	mc->mc_mbox[0x3] = ((f2 >> 18) & 0xc0) | ((f1 >> 8) & 0x3f);
    232  1.1   ad 	mc->mc_mbox[0x4] = f2;
    233  1.1   ad 	mc->mc_mbox[0x5] = (f2 >> 8);
    234  1.1   ad 	mc->mc_mbox[0x6] = (f2 >> 16);
    235  1.1   ad 	mc->mc_mbox[0x7] = f3;
    236  1.1   ad 	mc->mc_mbox[0x8] = f4;
    237  1.1   ad 	mc->mc_mbox[0x9] = (f4 >> 8);
    238  1.1   ad 	mc->mc_mbox[0xa] = (f4 >> 16);
    239  1.1   ad 	mc->mc_mbox[0xb] = (f4 >> 24);
    240  1.1   ad 	mc->mc_mbox[0xc] = f5;
    241  1.1   ad }
    242  1.1   ad 
    243  1.1   ad static __inline__ void
    244  1.1   ad mlx_make_type2(struct mlx_ccb *mc, u_int8_t code, u_int8_t f1, u_int8_t f2,
    245  1.1   ad 	       u_int8_t f3, u_int8_t f4, u_int8_t f5, u_int8_t f6,
    246  1.1   ad 	       u_int32_t f7, u_int8_t f8)
    247  1.1   ad {
    248  1.1   ad 
    249  1.1   ad 	mc->mc_mbox[0x0] = code;
    250  1.1   ad 	mc->mc_mbox[0x2] = f1;
    251  1.1   ad 	mc->mc_mbox[0x3] = f2;
    252  1.1   ad 	mc->mc_mbox[0x4] = f3;
    253  1.1   ad 	mc->mc_mbox[0x5] = f4;
    254  1.1   ad 	mc->mc_mbox[0x6] = f5;
    255  1.1   ad 	mc->mc_mbox[0x7] = f6;
    256  1.1   ad 	mc->mc_mbox[0x8] = f7;
    257  1.1   ad 	mc->mc_mbox[0x9] = (f7 >> 8);
    258  1.1   ad 	mc->mc_mbox[0xa] = (f7 >> 16);
    259  1.1   ad 	mc->mc_mbox[0xb] = (f7 >> 24);
    260  1.1   ad 	mc->mc_mbox[0xc] = f8;
    261  1.1   ad }
    262  1.1   ad 
    263  1.1   ad static __inline__ void
    264  1.1   ad mlx_make_type3(struct mlx_ccb *mc, u_int8_t code, u_int8_t f1, u_int8_t f2,
    265  1.1   ad 	       u_int16_t f3, u_int8_t f4, u_int8_t f5, u_int32_t f6,
    266  1.1   ad 	       u_int8_t f7)
    267  1.1   ad {
    268  1.1   ad 
    269  1.1   ad 	mc->mc_mbox[0x0] = code;
    270  1.1   ad 	mc->mc_mbox[0x2] = f1;
    271  1.1   ad 	mc->mc_mbox[0x3] = f2;
    272  1.1   ad 	mc->mc_mbox[0x4] = f3;
    273  1.1   ad 	mc->mc_mbox[0x5] = (f3 >> 8);
    274  1.1   ad 	mc->mc_mbox[0x6] = f4;
    275  1.1   ad 	mc->mc_mbox[0x7] = f5;
    276  1.1   ad 	mc->mc_mbox[0x8] = f6;
    277  1.1   ad 	mc->mc_mbox[0x9] = (f6 >> 8);
    278  1.1   ad 	mc->mc_mbox[0xa] = (f6 >> 16);
    279  1.1   ad 	mc->mc_mbox[0xb] = (f6 >> 24);
    280  1.1   ad 	mc->mc_mbox[0xc] = f7;
    281  1.1   ad }
    282  1.1   ad 
    283  1.1   ad static __inline__ void
    284  1.1   ad mlx_make_type4(struct mlx_ccb *mc, u_int8_t code,  u_int16_t f1, u_int32_t f2,
    285  1.1   ad 	       u_int32_t f3, u_int8_t f4)
    286  1.1   ad {
    287  1.1   ad 
    288  1.1   ad 	mc->mc_mbox[0x0] = code;
    289  1.1   ad 	mc->mc_mbox[0x2] = f1;
    290  1.1   ad 	mc->mc_mbox[0x3] = (f1 >> 8);
    291  1.1   ad 	mc->mc_mbox[0x4] = f2;
    292  1.1   ad 	mc->mc_mbox[0x5] = (f2 >> 8);
    293  1.1   ad 	mc->mc_mbox[0x6] = (f2 >> 16);
    294  1.1   ad 	mc->mc_mbox[0x7] = (f2 >> 24);
    295  1.1   ad 	mc->mc_mbox[0x8] = f3;
    296  1.1   ad 	mc->mc_mbox[0x9] = (f3 >> 8);
    297  1.1   ad 	mc->mc_mbox[0xa] = (f3 >> 16);
    298  1.1   ad 	mc->mc_mbox[0xb] = (f3 >> 24);
    299  1.1   ad 	mc->mc_mbox[0xc] = f4;
    300  1.1   ad }
    301  1.1   ad 
    302  1.1   ad static __inline__ void
    303  1.1   ad mlx_make_type5(struct mlx_ccb *mc, u_int8_t code, u_int8_t f1, u_int8_t f2,
    304  1.1   ad 	       u_int32_t f3, u_int32_t f4, u_int8_t f5)
    305  1.1   ad {
    306  1.1   ad 
    307  1.1   ad 	mc->mc_mbox[0x0] = code;
    308  1.1   ad 	mc->mc_mbox[0x2] = f1;
    309  1.1   ad 	mc->mc_mbox[0x3] = f2;
    310  1.1   ad 	mc->mc_mbox[0x4] = f3;
    311  1.1   ad 	mc->mc_mbox[0x5] = (f3 >> 8);
    312  1.1   ad 	mc->mc_mbox[0x6] = (f3 >> 16);
    313  1.1   ad 	mc->mc_mbox[0x7] = (f3 >> 24);
    314  1.1   ad 	mc->mc_mbox[0x8] = f4;
    315  1.1   ad 	mc->mc_mbox[0x9] = (f4 >> 8);
    316  1.1   ad 	mc->mc_mbox[0xa] = (f4 >> 16);
    317  1.1   ad 	mc->mc_mbox[0xb] = (f4 >> 24);
    318  1.1   ad 	mc->mc_mbox[0xc] = f5;
    319  1.1   ad }
    320  1.1   ad 
    321  1.1   ad static __inline__ u_int8_t
    322  1.1   ad mlx_inb(struct mlx_softc *mlx, int off)
    323  1.1   ad {
    324  1.1   ad 
    325  1.1   ad 	bus_space_barrier(mlx->mlx_iot, mlx->mlx_ioh, off, 1,
    326  1.1   ad 	    BUS_SPACE_BARRIER_WRITE | BUS_SPACE_BARRIER_READ);
    327  1.1   ad 	return (bus_space_read_1(mlx->mlx_iot, mlx->mlx_ioh, off));
    328  1.1   ad }
    329  1.1   ad 
    330  1.1   ad static __inline__ u_int16_t
    331  1.1   ad mlx_inw(struct mlx_softc *mlx, int off)
    332  1.1   ad {
    333  1.1   ad 
    334  1.1   ad 	bus_space_barrier(mlx->mlx_iot, mlx->mlx_ioh, off, 2,
    335  1.1   ad 	    BUS_SPACE_BARRIER_WRITE | BUS_SPACE_BARRIER_READ);
    336  1.1   ad 	return (bus_space_read_2(mlx->mlx_iot, mlx->mlx_ioh, off));
    337  1.1   ad }
    338  1.1   ad 
    339  1.1   ad static __inline__ u_int32_t
    340  1.1   ad mlx_inl(struct mlx_softc *mlx, int off)
    341  1.1   ad {
    342  1.1   ad 
    343  1.1   ad 	bus_space_barrier(mlx->mlx_iot, mlx->mlx_ioh, off, 4,
    344  1.1   ad 	    BUS_SPACE_BARRIER_WRITE | BUS_SPACE_BARRIER_READ);
    345  1.1   ad 	return (bus_space_read_4(mlx->mlx_iot, mlx->mlx_ioh, off));
    346  1.1   ad }
    347  1.1   ad 
    348  1.1   ad static __inline__ void
    349  1.1   ad mlx_outb(struct mlx_softc *mlx, int off, u_int8_t val)
    350  1.1   ad {
    351  1.1   ad 
    352  1.1   ad 	bus_space_write_1(mlx->mlx_iot, mlx->mlx_ioh, off, val);
    353  1.1   ad 	bus_space_barrier(mlx->mlx_iot, mlx->mlx_ioh, off, 1,
    354  1.1   ad 	    BUS_SPACE_BARRIER_WRITE);
    355  1.1   ad }
    356  1.1   ad 
    357  1.1   ad static __inline__ void
    358  1.1   ad mlx_outw(struct mlx_softc *mlx, int off, u_int16_t val)
    359  1.1   ad {
    360  1.1   ad 
    361  1.1   ad 	bus_space_write_2(mlx->mlx_iot, mlx->mlx_ioh, off, val);
    362  1.1   ad 	bus_space_barrier(mlx->mlx_iot, mlx->mlx_ioh, off, 2,
    363  1.1   ad 	    BUS_SPACE_BARRIER_WRITE);
    364  1.1   ad }
    365  1.1   ad 
    366  1.1   ad static __inline__ void
    367  1.1   ad mlx_outl(struct mlx_softc *mlx, int off, u_int32_t val)
    368  1.1   ad {
    369  1.1   ad 
    370  1.1   ad 	bus_space_write_4(mlx->mlx_iot, mlx->mlx_ioh, off, val);
    371  1.1   ad 	bus_space_barrier(mlx->mlx_iot, mlx->mlx_ioh, off, 4,
    372  1.1   ad 	    BUS_SPACE_BARRIER_WRITE);
    373  1.1   ad }
    374  1.1   ad 
    375  1.1   ad #endif	/* !_IC_MLXVAR_H_ */
    376