xref: /freebsd/sys/dev/mlx/mlxreg.h (revision 95ee2897e98f5d444f26ed2334cc7c439f9c16c6)
11ac4b82bSMike Smith /*-
2*4d846d26SWarner Losh  * SPDX-License-Identifier: BSD-2-Clause
3718cf2ccSPedro F. Giffuni  *
41ac4b82bSMike Smith  * Copyright (c) 1999 Michael Smith
51ac4b82bSMike Smith  * All rights reserved.
61ac4b82bSMike Smith  *
71ac4b82bSMike Smith  * Redistribution and use in source and binary forms, with or without
81ac4b82bSMike Smith  * modification, are permitted provided that the following conditions
91ac4b82bSMike Smith  * are met:
101ac4b82bSMike Smith  * 1. Redistributions of source code must retain the above copyright
111ac4b82bSMike Smith  *    notice, this list of conditions and the following disclaimer.
121ac4b82bSMike Smith  * 2. Redistributions in binary form must reproduce the above copyright
131ac4b82bSMike Smith  *    notice, this list of conditions and the following disclaimer in the
141ac4b82bSMike Smith  *    documentation and/or other materials provided with the distribution.
151ac4b82bSMike Smith  *
161ac4b82bSMike Smith  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
171ac4b82bSMike Smith  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
181ac4b82bSMike Smith  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
191ac4b82bSMike Smith  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
201ac4b82bSMike Smith  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
211ac4b82bSMike Smith  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
221ac4b82bSMike Smith  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
231ac4b82bSMike Smith  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
241ac4b82bSMike Smith  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
251ac4b82bSMike Smith  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
261ac4b82bSMike Smith  * SUCH DAMAGE.
271ac4b82bSMike Smith  */
281ac4b82bSMike Smith 
294b006d7bSMike Smith #define MLX_BLKSIZE	512		/* fixed feature */
304161b1a1SScott Long #define MLX_PAGE_SIZE	4096		/* controller, not cpu, attribute */
314b006d7bSMike Smith 
321ac4b82bSMike Smith /*
331ac4b82bSMike Smith  * Selected command codes.
341ac4b82bSMike Smith  */
35da8bb3a3SMike Smith #define MLX_CMD_ENQUIRY_OLD	0x05
361ac4b82bSMike Smith #define MLX_CMD_ENQUIRY		0x53
371ac4b82bSMike Smith #define MLX_CMD_ENQUIRY2	0x1c
381ac4b82bSMike Smith #define MLX_CMD_ENQSYSDRIVE	0x19
39da8bb3a3SMike Smith #define MLX_CMD_READSG		0xb6
40da8bb3a3SMike Smith #define MLX_CMD_WRITESG		0xb7
41da8bb3a3SMike Smith #define MLX_CMD_READSG_OLD	0x82
42da8bb3a3SMike Smith #define MLX_CMD_WRITESG_OLD	0x83
431ac4b82bSMike Smith #define MLX_CMD_FLUSH		0x0a
441ac4b82bSMike Smith #define MLX_CMD_LOGOP		0x72
451ac4b82bSMike Smith #define MLX_CMD_REBUILDASYNC	0x16
461ac4b82bSMike Smith #define MLX_CMD_CHECKASYNC	0x1e
471ac4b82bSMike Smith #define MLX_CMD_REBUILDSTAT	0x0c
481ac4b82bSMike Smith #define MLX_CMD_STOPCHANNEL	0x13
491ac4b82bSMike Smith #define MLX_CMD_STARTCHANNEL	0x12
50da8bb3a3SMike Smith #define MLX_CMD_READ_CONFIG	0x4e
51da8bb3a3SMike Smith #define MLX_CMD_DIRECT_CDB	0x04
52421f2f7dSMike Smith #define MLX_CMD_DEVICE_STATE	0x50
53da8bb3a3SMike Smith 
54da8bb3a3SMike Smith #ifdef _KERNEL
55da8bb3a3SMike Smith 
56da8bb3a3SMike Smith #define MLX_CFG_BASE0   0x10		/* first region */
57da8bb3a3SMike Smith #define MLX_CFG_BASE1   0x14		/* second region (type 3 only) */
581ac4b82bSMike Smith 
591ac4b82bSMike Smith /*
601ac4b82bSMike Smith  * Status values.
611ac4b82bSMike Smith  */
621ac4b82bSMike Smith #define MLX_STATUS_OK		0x0000
631ac4b82bSMike Smith #define MLX_STATUS_RDWROFFLINE	0x0002	/* read/write claims drive is offline */
641ac4b82bSMike Smith #define MLX_STATUS_WEDGED	0xdead	/* controller not listening */
655792b7feSMike Smith #define MLX_STATUS_LOST		0xbeef	/* never came back */
661ac4b82bSMike Smith #define MLX_STATUS_BUSY		0xffff	/* command is in controller */
671ac4b82bSMike Smith 
681ac4b82bSMike Smith /*
69f6b84b08SMike Smith  * Accessor defines for the V3 interface.
70f6b84b08SMike Smith  */
71f6b84b08SMike Smith #define MLX_V3_MAILBOX		0x00
72f6b84b08SMike Smith #define	MLX_V3_STATUS_IDENT	0x0d
73f6b84b08SMike Smith #define MLX_V3_STATUS		0x0e
74f6b84b08SMike Smith #define MLX_V3_IDBR		0x40
75f6b84b08SMike Smith #define MLX_V3_ODBR		0x41
76f6b84b08SMike Smith #define MLX_V3_IER		0x43
77da8bb3a3SMike Smith #define MLX_V3_FWERROR		0x3f
78da8bb3a3SMike Smith #define MLX_V3_FWERROR_PARAM1	0x00
79da8bb3a3SMike Smith #define MLX_V3_FWERROR_PARAM2	0x01
80f6b84b08SMike Smith 
810fca6f8bSJohn Baldwin #define MLX_V3_PUT_MAILBOX(sc, idx, val) bus_write_1(sc->mlx_mem, MLX_V3_MAILBOX + idx, val)
820fca6f8bSJohn Baldwin #define MLX_V3_GET_STATUS_IDENT(sc)	 bus_read_1 (sc->mlx_mem, MLX_V3_STATUS_IDENT)
830fca6f8bSJohn Baldwin #define MLX_V3_GET_STATUS(sc)		 bus_read_2 (sc->mlx_mem, MLX_V3_STATUS)
840fca6f8bSJohn Baldwin #define MLX_V3_GET_IDBR(sc)		 bus_read_1 (sc->mlx_mem, MLX_V3_IDBR)
850fca6f8bSJohn Baldwin #define MLX_V3_PUT_IDBR(sc, val)	 bus_write_1(sc->mlx_mem, MLX_V3_IDBR, val)
860fca6f8bSJohn Baldwin #define MLX_V3_GET_ODBR(sc)		 bus_read_1 (sc->mlx_mem, MLX_V3_ODBR)
870fca6f8bSJohn Baldwin #define MLX_V3_PUT_ODBR(sc, val)	 bus_write_1(sc->mlx_mem, MLX_V3_ODBR, val)
880fca6f8bSJohn Baldwin #define MLX_V3_PUT_IER(sc, val)		 bus_write_1(sc->mlx_mem, MLX_V3_IER, val)
890fca6f8bSJohn Baldwin #define MLX_V3_GET_FWERROR(sc)		 bus_read_1 (sc->mlx_mem, MLX_V3_FWERROR)
900fca6f8bSJohn Baldwin #define MLX_V3_PUT_FWERROR(sc, val)	 bus_write_1(sc->mlx_mem, MLX_V3_FWERROR, val)
910fca6f8bSJohn Baldwin #define MLX_V3_GET_FWERROR_PARAM1(sc)	 bus_read_1 (sc->mlx_mem, MLX_V3_FWERROR_PARAM1)
920fca6f8bSJohn Baldwin #define MLX_V3_GET_FWERROR_PARAM2(sc)	 bus_read_1 (sc->mlx_mem, MLX_V3_FWERROR_PARAM2)
93f6b84b08SMike Smith 
94f6b84b08SMike Smith #define MLX_V3_IDB_FULL		(1<<0)		/* mailbox is full */
95da8bb3a3SMike Smith #define MLX_V3_IDB_INIT_BUSY	(1<<1)		/* initialisation in progress */
96da8bb3a3SMike Smith 
97f6b84b08SMike Smith #define MLX_V3_IDB_SACK		(1<<1)		/* acknowledge status read */
98f6b84b08SMike Smith 
99f6b84b08SMike Smith #define MLX_V3_ODB_SAVAIL	(1<<0)		/* status is available */
100f6b84b08SMike Smith 
101da8bb3a3SMike Smith #define MLX_V3_FWERROR_PEND	(1<<2)		/* firmware error pending */
102da8bb3a3SMike Smith 
103f6b84b08SMike Smith /*
104f6b84b08SMike Smith  * Accessor defines for the V4 interface.
105f6b84b08SMike Smith  */
106f6b84b08SMike Smith #define MLX_V4_MAILBOX		0x1000
107da8bb3a3SMike Smith #define MLX_V4_MAILBOX_LENGTH		16
108f6b84b08SMike Smith #define MLX_V4_STATUS_IDENT	0x1018
109f6b84b08SMike Smith #define MLX_V4_STATUS		0x101a
110f6b84b08SMike Smith #define MLX_V4_IDBR		0x0020
111f6b84b08SMike Smith #define MLX_V4_ODBR		0x002c
112f6b84b08SMike Smith #define MLX_V4_IER		0x0034
113da8bb3a3SMike Smith #define MLX_V4_FWERROR		0x103f
114da8bb3a3SMike Smith #define MLX_V4_FWERROR_PARAM1	0x1000
115da8bb3a3SMike Smith #define MLX_V4_FWERROR_PARAM2	0x1001
116f6b84b08SMike Smith 
117f6b84b08SMike Smith /* use longword access? */
1180fca6f8bSJohn Baldwin #define MLX_V4_PUT_MAILBOX(sc, idx, val) bus_write_1(sc->mlx_mem, MLX_V4_MAILBOX + idx, val)
1190fca6f8bSJohn Baldwin #define MLX_V4_GET_STATUS_IDENT(sc)	 bus_read_1 (sc->mlx_mem, MLX_V4_STATUS_IDENT)
1200fca6f8bSJohn Baldwin #define MLX_V4_GET_STATUS(sc)		 bus_read_2 (sc->mlx_mem, MLX_V4_STATUS)
1210fca6f8bSJohn Baldwin #define MLX_V4_GET_IDBR(sc)		 bus_read_4 (sc->mlx_mem, MLX_V4_IDBR)
1220fca6f8bSJohn Baldwin #define MLX_V4_PUT_IDBR(sc, val)	 bus_write_4(sc->mlx_mem, MLX_V4_IDBR, val)
1230fca6f8bSJohn Baldwin #define MLX_V4_GET_ODBR(sc)		 bus_read_4 (sc->mlx_mem, MLX_V4_ODBR)
1240fca6f8bSJohn Baldwin #define MLX_V4_PUT_ODBR(sc, val)	 bus_write_4(sc->mlx_mem, MLX_V4_ODBR, val)
1250fca6f8bSJohn Baldwin #define MLX_V4_PUT_IER(sc, val)		 bus_write_4(sc->mlx_mem, MLX_V4_IER, val)
1260fca6f8bSJohn Baldwin #define MLX_V4_GET_FWERROR(sc)		 bus_read_1 (sc->mlx_mem, MLX_V4_FWERROR)
1270fca6f8bSJohn Baldwin #define MLX_V4_PUT_FWERROR(sc, val)	 bus_write_1(sc->mlx_mem, MLX_V4_FWERROR, val)
1280fca6f8bSJohn Baldwin #define MLX_V4_GET_FWERROR_PARAM1(sc)	 bus_read_1 (sc->mlx_mem, MLX_V4_FWERROR_PARAM1)
1290fca6f8bSJohn Baldwin #define MLX_V4_GET_FWERROR_PARAM2(sc)	 bus_read_1 (sc->mlx_mem, MLX_V4_FWERROR_PARAM2)
130f6b84b08SMike Smith 
131f6b84b08SMike Smith #define MLX_V4_IDB_FULL		(1<<0)		/* mailbox is full */
132da8bb3a3SMike Smith #define MLX_V4_IDB_INIT_BUSY	(1<<1)		/* initialisation in progress */
133f6b84b08SMike Smith 
134f6b84b08SMike Smith #define MLX_V4_IDB_HWMBOX_CMD	(1<<0)		/* posted hardware mailbox command */
135f6b84b08SMike Smith #define MLX_V4_IDB_SACK		(1<<1)		/* acknowledge status read */
136f6b84b08SMike Smith #define MLX_V4_IDB_MEMMBOX_CMD	(1<<4)		/* posted memory mailbox command */
137f6b84b08SMike Smith 
138f6b84b08SMike Smith #define MLX_V4_ODB_HWSAVAIL	(1<<0)		/* status is available for hardware mailbox */
139f6b84b08SMike Smith #define MLX_V4_ODB_MEMSAVAIL	(1<<1)		/* status is available for memory mailbox */
140f6b84b08SMike Smith 
141f6b84b08SMike Smith #define MLX_V4_ODB_HWMBOX_ACK	(1<<0)		/* ack status read from hardware mailbox */
142f6b84b08SMike Smith #define MLX_V4_ODB_MEMMBOX_ACK	(1<<1)		/* ack status read from memory mailbox */
143f6b84b08SMike Smith 
144f6b84b08SMike Smith #define MLX_V4_IER_MASK		0xfb		/* message unit interrupt mask */
145f6b84b08SMike Smith #define MLX_V4_IER_DISINT	(1<<2)		/* interrupt disable bit */
146f6b84b08SMike Smith 
147da8bb3a3SMike Smith #define MLX_V4_FWERROR_PEND	(1<<2)		/* firmware error pending */
148da8bb3a3SMike Smith 
149f6b84b08SMike Smith /*
1505792b7feSMike Smith  * Accessor defines for the V5 interface
1515792b7feSMike Smith  */
1525792b7feSMike Smith #define MLX_V5_MAILBOX		0x50
153da8bb3a3SMike Smith #define MLX_V5_MAILBOX_LENGTH		16
1545792b7feSMike Smith #define MLX_V5_STATUS_IDENT	0x5d
1555792b7feSMike Smith #define MLX_V5_STATUS		0x5e
1565792b7feSMike Smith #define MLX_V5_IDBR		0x60
1575792b7feSMike Smith #define MLX_V5_ODBR		0x61
1585792b7feSMike Smith #define MLX_V5_IER		0x34
159da8bb3a3SMike Smith #define MLX_V5_FWERROR		0x63
160da8bb3a3SMike Smith #define MLX_V5_FWERROR_PARAM1	0x50
161da8bb3a3SMike Smith #define MLX_V5_FWERROR_PARAM2	0x51
1625792b7feSMike Smith 
1630fca6f8bSJohn Baldwin #define MLX_V5_PUT_MAILBOX(sc, idx, val) bus_write_1(sc->mlx_mem, MLX_V5_MAILBOX + idx, val)
1640fca6f8bSJohn Baldwin #define MLX_V5_GET_STATUS_IDENT(sc)	 bus_read_1 (sc->mlx_mem, MLX_V5_STATUS_IDENT)
1650fca6f8bSJohn Baldwin #define MLX_V5_GET_STATUS(sc)		 bus_read_2 (sc->mlx_mem, MLX_V5_STATUS)
1660fca6f8bSJohn Baldwin #define MLX_V5_GET_IDBR(sc)		 bus_read_1 (sc->mlx_mem, MLX_V5_IDBR)
1670fca6f8bSJohn Baldwin #define MLX_V5_PUT_IDBR(sc, val)	 bus_write_1(sc->mlx_mem, MLX_V5_IDBR, val)
1680fca6f8bSJohn Baldwin #define MLX_V5_GET_ODBR(sc)		 bus_read_1 (sc->mlx_mem, MLX_V5_ODBR)
1690fca6f8bSJohn Baldwin #define MLX_V5_PUT_ODBR(sc, val)	 bus_write_1(sc->mlx_mem, MLX_V5_ODBR, val)
1700fca6f8bSJohn Baldwin #define MLX_V5_PUT_IER(sc, val)		 bus_write_1(sc->mlx_mem, MLX_V5_IER, val)
1710fca6f8bSJohn Baldwin #define MLX_V5_GET_FWERROR(sc)		 bus_read_1 (sc->mlx_mem, MLX_V5_FWERROR)
1720fca6f8bSJohn Baldwin #define MLX_V5_PUT_FWERROR(sc, val)	 bus_write_1(sc->mlx_mem, MLX_V5_FWERROR, val)
1730fca6f8bSJohn Baldwin #define MLX_V5_GET_FWERROR_PARAM1(sc)	 bus_read_1 (sc->mlx_mem, MLX_V5_FWERROR_PARAM1)
1740fca6f8bSJohn Baldwin #define MLX_V5_GET_FWERROR_PARAM2(sc)	 bus_read_1 (sc->mlx_mem, MLX_V5_FWERROR_PARAM2)
1755792b7feSMike Smith 
1765792b7feSMike Smith #define MLX_V5_IDB_EMPTY	(1<<0)		/* mailbox is empty */
177da8bb3a3SMike Smith #define MLX_V5_IDB_INIT_DONE	(1<<1)		/* initialisation has completed */
1785792b7feSMike Smith 
1795792b7feSMike Smith #define MLX_V5_IDB_HWMBOX_CMD	(1<<0)		/* posted hardware mailbox command */
1805792b7feSMike Smith #define MLX_V5_IDB_SACK		(1<<1)		/* acknowledge status read */
181da8bb3a3SMike Smith #define MLX_V5_IDB_RESET	(1<<3)		/* reset request */
1825792b7feSMike Smith #define MLX_V5_IDB_MEMMBOX_CMD	(1<<4)		/* posted memory mailbox command */
1835792b7feSMike Smith 
1845792b7feSMike Smith #define MLX_V5_ODB_HWSAVAIL	(1<<0)		/* status is available for hardware mailbox */
1855792b7feSMike Smith #define MLX_V5_ODB_MEMSAVAIL	(1<<1)		/* status is available for memory mailbox */
1865792b7feSMike Smith 
1875792b7feSMike Smith #define MLX_V5_ODB_HWMBOX_ACK	(1<<0)		/* ack status read from hardware mailbox */
1885792b7feSMike Smith #define MLX_V5_ODB_MEMMBOX_ACK	(1<<1)		/* ack status read from memory mailbox */
1895792b7feSMike Smith 
1905792b7feSMike Smith #define MLX_V5_IER_DISINT	(1<<2)		/* interrupt disable bit */
1915792b7feSMike Smith 
192da8bb3a3SMike Smith #define MLX_V5_FWERROR_PEND	(1<<2)		/* firmware error pending */
193da8bb3a3SMike Smith 
194da8bb3a3SMike Smith #endif /* _KERNEL */
1955792b7feSMike Smith 
1965792b7feSMike Smith /*
1971ac4b82bSMike Smith  * Scatter-gather list format, type 1, kind 00.
1981ac4b82bSMike Smith  */
1991ac4b82bSMike Smith struct mlx_sgentry
2001ac4b82bSMike Smith {
2011ac4b82bSMike Smith     u_int32_t	sg_addr;
2021ac4b82bSMike Smith     u_int32_t	sg_count;
2034f492bfaSAlfred Perlstein } __packed;
2041ac4b82bSMike Smith 
2051ac4b82bSMike Smith /*
2061ac4b82bSMike Smith  * Command result buffers, as placed in system memory by the controller.
2071ac4b82bSMike Smith  */
208da8bb3a3SMike Smith 
209da8bb3a3SMike Smith struct mlx_enquiry_old	/* MLX_CMD_ENQUIRY_OLD */
210da8bb3a3SMike Smith {
211da8bb3a3SMike Smith     u_int8_t		me_num_sys_drvs;
212da8bb3a3SMike Smith     u_int8_t		res1[3];
213da8bb3a3SMike Smith     u_int32_t		me_drvsize[8];
214da8bb3a3SMike Smith     u_int16_t		me_flash_age;
215da8bb3a3SMike Smith     u_int8_t		me_status_flags;
216da8bb3a3SMike Smith     u_int8_t		me_free_state_change_count;
217da8bb3a3SMike Smith     u_int8_t		me_fwminor;
218da8bb3a3SMike Smith     u_int8_t		me_fwmajor;
219da8bb3a3SMike Smith     u_int8_t		me_rebuild_flag;
220da8bb3a3SMike Smith     u_int8_t		me_max_commands;
221da8bb3a3SMike Smith     u_int8_t		me_offline_sd_count;
222da8bb3a3SMike Smith     u_int8_t		res3;
223da8bb3a3SMike Smith     u_int8_t		me_critical_sd_count;
224da8bb3a3SMike Smith     u_int8_t		res4[3];
225da8bb3a3SMike Smith     u_int8_t		me_dead_count;
226da8bb3a3SMike Smith     u_int8_t		res5;
227da8bb3a3SMike Smith     u_int8_t		me_rebuild_count;
228da8bb3a3SMike Smith     u_int8_t		me_misc_flags;
229da8bb3a3SMike Smith     struct
230da8bb3a3SMike Smith     {
231da8bb3a3SMike Smith 	u_int8_t	dd_targ;
232da8bb3a3SMike Smith 	u_int8_t	dd_chan;
2334f492bfaSAlfred Perlstein     } __packed me_dead[20];
2344f492bfaSAlfred Perlstein } __packed;
235da8bb3a3SMike Smith 
2361ac4b82bSMike Smith struct mlx_enquiry	/* MLX_CMD_ENQUIRY */
2371ac4b82bSMike Smith {
2381ac4b82bSMike Smith     u_int8_t		me_num_sys_drvs;
2391ac4b82bSMike Smith     u_int8_t		res1[3];
2401ac4b82bSMike Smith     u_int32_t		me_drvsize[32];
2411ac4b82bSMike Smith     u_int16_t		me_flash_age;
2421ac4b82bSMike Smith     u_int8_t		me_status_flags;
2431ac4b82bSMike Smith #define MLX_ENQ_SFLAG_DEFWRERR	(1<<0)	/* deferred write error indicator */
2441ac4b82bSMike Smith #define MLX_ENQ_SFLAG_BATTLOW	(1<<1)	/* battery low */
2451ac4b82bSMike Smith     u_int8_t		res2;
2461ac4b82bSMike Smith     u_int8_t		me_fwminor;
2471ac4b82bSMike Smith     u_int8_t		me_fwmajor;
2481ac4b82bSMike Smith     u_int8_t		me_rebuild_flag;
2491ac4b82bSMike Smith     u_int8_t		me_max_commands;
2501ac4b82bSMike Smith     u_int8_t		me_offline_sd_count;
2511ac4b82bSMike Smith     u_int8_t		res3;
2521ac4b82bSMike Smith     u_int16_t		me_event_log_seq_num;
2531ac4b82bSMike Smith     u_int8_t		me_critical_sd_count;
2541ac4b82bSMike Smith     u_int8_t		res4[3];
2551ac4b82bSMike Smith     u_int8_t		me_dead_count;
2561ac4b82bSMike Smith     u_int8_t		res5;
2571ac4b82bSMike Smith     u_int8_t		me_rebuild_count;
2581ac4b82bSMike Smith     u_int8_t		me_misc_flags;
2591ac4b82bSMike Smith #define MLX_ENQ_MISC_BBU	(1<<3)	/* battery backup present */
2601ac4b82bSMike Smith     struct
2611ac4b82bSMike Smith     {
2621ac4b82bSMike Smith 	u_int8_t	dd_targ;
2631ac4b82bSMike Smith 	u_int8_t	dd_chan;
2644f492bfaSAlfred Perlstein     } __packed me_dead[20];
2654f492bfaSAlfred Perlstein } __packed;
2661ac4b82bSMike Smith 
2671ac4b82bSMike Smith struct mlx_enquiry2	/* MLX_CMD_ENQUIRY2 */
2681ac4b82bSMike Smith {
2691ac4b82bSMike Smith     u_int32_t		me_hardware_id;
2701ac4b82bSMike Smith     u_int32_t		me_firmware_id;
2711ac4b82bSMike Smith     u_int32_t		res1;
2721ac4b82bSMike Smith     u_int8_t		me_configured_channels;
2731ac4b82bSMike Smith     u_int8_t		me_actual_channels;
2741ac4b82bSMike Smith     u_int8_t		me_max_targets;
2751ac4b82bSMike Smith     u_int8_t		me_max_tags;
2761ac4b82bSMike Smith     u_int8_t		me_max_sys_drives;
2771ac4b82bSMike Smith     u_int8_t		me_max_arms;
2781ac4b82bSMike Smith     u_int8_t		me_max_spans;
2791ac4b82bSMike Smith     u_int8_t		res2;
2801ac4b82bSMike Smith     u_int32_t		res3;
2811ac4b82bSMike Smith     u_int32_t		me_mem_size;
2821ac4b82bSMike Smith     u_int32_t		me_cache_size;
2831ac4b82bSMike Smith     u_int32_t		me_flash_size;
2841ac4b82bSMike Smith     u_int32_t		me_nvram_size;
2851ac4b82bSMike Smith     u_int16_t		me_mem_type;
2861ac4b82bSMike Smith     u_int16_t		me_clock_speed;
2871ac4b82bSMike Smith     u_int16_t		me_mem_speed;
2881ac4b82bSMike Smith     u_int16_t		me_hardware_speed;
2899eee27f1SMike Smith     u_int8_t		res4[12];
2901ac4b82bSMike Smith     u_int16_t		me_max_commands;
2911ac4b82bSMike Smith     u_int16_t		me_max_sg;
2921ac4b82bSMike Smith     u_int16_t		me_max_dp;
2931ac4b82bSMike Smith     u_int16_t		me_max_iod;
2941ac4b82bSMike Smith     u_int16_t		me_max_comb;
2951ac4b82bSMike Smith     u_int8_t		me_latency;
2961ac4b82bSMike Smith     u_int8_t		res5;
2971ac4b82bSMike Smith     u_int8_t		me_scsi_timeout;
2981ac4b82bSMike Smith     u_int8_t		res6;
2991ac4b82bSMike Smith     u_int16_t		me_min_freelines;
3001ac4b82bSMike Smith     u_int8_t		res7[8];
3011ac4b82bSMike Smith     u_int8_t		me_rate_const;
3021ac4b82bSMike Smith     u_int8_t		res8[11];
3031ac4b82bSMike Smith     u_int16_t		me_physblk;
3041ac4b82bSMike Smith     u_int16_t		me_logblk;
3051ac4b82bSMike Smith     u_int16_t		me_maxblk;
3061ac4b82bSMike Smith     u_int16_t		me_blocking_factor;
3071ac4b82bSMike Smith     u_int16_t		me_cacheline;
3081ac4b82bSMike Smith     u_int8_t		me_scsi_cap;
3091ac4b82bSMike Smith     u_int8_t		res9[5];
3109eee27f1SMike Smith     u_int16_t		me_firmware_build;
3111ac4b82bSMike Smith     u_int8_t		me_fault_mgmt_type;
3121ac4b82bSMike Smith     u_int8_t		res10;
3131ac4b82bSMike Smith     u_int32_t		me_firmware_features;
3141ac4b82bSMike Smith     u_int8_t		res11[8];
3154f492bfaSAlfred Perlstein } __packed;
3161ac4b82bSMike Smith 
3171ac4b82bSMike Smith struct mlx_enq_sys_drive /* MLX_CMD_ENQSYSDRIVE returns an array of 32 of these */
3181ac4b82bSMike Smith {
3191ac4b82bSMike Smith     u_int32_t		sd_size;
3201ac4b82bSMike Smith     u_int8_t		sd_state;
3211ac4b82bSMike Smith     u_int8_t		sd_raidlevel;
3221ac4b82bSMike Smith     u_int16_t		res1;
3234f492bfaSAlfred Perlstein } __packed;
3241ac4b82bSMike Smith 
3251ac4b82bSMike Smith struct mlx_eventlog_entry	/* MLX_CMD_LOGOP/MLX_LOGOP_GET */
3261ac4b82bSMike Smith {
3271ac4b82bSMike Smith     u_int8_t		el_type;
3281ac4b82bSMike Smith     u_int8_t		el_length;
3291ac4b82bSMike Smith     u_char		el_target:5;
3301ac4b82bSMike Smith     u_char		el_channel:3;
3311ac4b82bSMike Smith     u_char		el_lun:6;
3321ac4b82bSMike Smith     u_char		res1:2;
3331ac4b82bSMike Smith     u_int16_t		el_seqno;
3341ac4b82bSMike Smith     u_char		el_errorcode:7;
3351ac4b82bSMike Smith     u_char		el_valid:1;
3361ac4b82bSMike Smith     u_int8_t		el_segment;
3371ac4b82bSMike Smith     u_char		el_sensekey:4;
3381ac4b82bSMike Smith     u_char		res2:1;
3391ac4b82bSMike Smith     u_char		el_ILI:1;
3401ac4b82bSMike Smith     u_char		el_EOM:1;
3411ac4b82bSMike Smith     u_char		el_filemark:1;
3421ac4b82bSMike Smith     u_int8_t		el_information[4];
3431ac4b82bSMike Smith     u_int8_t		el_addsense;
3441ac4b82bSMike Smith     u_int8_t		el_csi[4];
3451ac4b82bSMike Smith     u_int8_t		el_asc;
3461ac4b82bSMike Smith     u_int8_t		el_asq;
3471ac4b82bSMike Smith     u_int8_t		res3[12];
3484f492bfaSAlfred Perlstein } __packed;
3491ac4b82bSMike Smith 
3501ac4b82bSMike Smith #define MLX_LOGOP_GET		0x00	/* operation codes for MLX_CMD_LOGOP */
3511ac4b82bSMike Smith #define MLX_LOGMSG_SENSE	0x00	/* log message contents codes */
3521ac4b82bSMike Smith 
3531ac4b82bSMike Smith struct mlx_rebuild_stat	/* MLX_CMD_REBUILDSTAT */
3541ac4b82bSMike Smith {
3551ac4b82bSMike Smith     u_int32_t	rb_drive;
3561ac4b82bSMike Smith     u_int32_t	rb_size;
3571ac4b82bSMike Smith     u_int32_t	rb_remaining;
3584f492bfaSAlfred Perlstein } __packed;
3591ac4b82bSMike Smith 
360da8bb3a3SMike Smith struct mlx_config2
361da8bb3a3SMike Smith {
362da8bb3a3SMike Smith     u_int16_t	cf_flags1;
363da8bb3a3SMike Smith #define MLX_CF2_ACTV_NEG	(1<<1)
364da8bb3a3SMike Smith #define MLX_CF2_NORSTRTRY	(1<<7)
365da8bb3a3SMike Smith #define MLX_CF2_STRGWRK		(1<<8)
366da8bb3a3SMike Smith #define MLX_CF2_HPSUPP		(1<<9)
367da8bb3a3SMike Smith #define MLX_CF2_NODISCN		(1<<10)
368da8bb3a3SMike Smith #define MLX_CF2_ARM    		(1<<13)
369da8bb3a3SMike Smith #define MLX_CF2_OFM		(1<<15)
370da8bb3a3SMike Smith #define MLX_CF2_AEMI (MLX_CF2_ARM | MLX_CF2_OFM)
371da8bb3a3SMike Smith     u_int8_t	cf_oemid;
372da8bb3a3SMike Smith     u_int8_t	cf_oem_model;
373da8bb3a3SMike Smith     u_int8_t	cf_physical_sector;
374da8bb3a3SMike Smith     u_int8_t	cf_logical_sector;
375da8bb3a3SMike Smith     u_int8_t	cf_blockfactor;
376da8bb3a3SMike Smith     u_int8_t	cf_flags2;
377da8bb3a3SMike Smith #define MLX_CF2_READAH		(1<<0)
378da8bb3a3SMike Smith #define MLX_CF2_BIOSDLY		(1<<1)
379da8bb3a3SMike Smith #define MLX_CF2_REASS1S		(1<<4)
380da8bb3a3SMike Smith #define MLX_CF2_FUAENABL	(1<<6)
381da8bb3a3SMike Smith #define MLX_CF2_R5ALLS		(1<<7)
382da8bb3a3SMike Smith     u_int8_t	cf_rcrate;
383da8bb3a3SMike Smith     u_int8_t	cf_res1;
384da8bb3a3SMike Smith     u_int8_t	cf_blocks_per_cache_line;
385da8bb3a3SMike Smith     u_int8_t	cf_blocks_per_stripe;
386da8bb3a3SMike Smith     u_int8_t	cf_scsi_param_0;
387da8bb3a3SMike Smith     u_int8_t	cf_scsi_param_1;
388da8bb3a3SMike Smith     u_int8_t	cf_scsi_param_2;
389da8bb3a3SMike Smith     u_int8_t	cf_scsi_param_3;
390da8bb3a3SMike Smith     u_int8_t	cf_scsi_param_4;
391da8bb3a3SMike Smith     u_int8_t	cf_scsi_param_5;
392da8bb3a3SMike Smith     u_int8_t	cf_scsi_initiator_id;
393da8bb3a3SMike Smith     u_int8_t	cf_res2;
394da8bb3a3SMike Smith     u_int8_t	cf_startup_mode;
395da8bb3a3SMike Smith     u_int8_t	cf_simultaneous_spinup_devices;
396da8bb3a3SMike Smith     u_int8_t	cf_delay_between_spinups;
397da8bb3a3SMike Smith     u_int8_t	cf_res3;
398da8bb3a3SMike Smith     u_int16_t	cf_checksum;
3994f492bfaSAlfred Perlstein } __packed;
400da8bb3a3SMike Smith 
401da8bb3a3SMike Smith struct mlx_sys_drv_span
402da8bb3a3SMike Smith {
403da8bb3a3SMike Smith     u_int32_t	sp_start_lba;
404da8bb3a3SMike Smith     u_int32_t	sp_nblks;
405da8bb3a3SMike Smith     u_int8_t	sp_arm[8];
4064f492bfaSAlfred Perlstein } __packed;
407da8bb3a3SMike Smith 
408da8bb3a3SMike Smith struct mlx_sys_drv
409da8bb3a3SMike Smith {
410da8bb3a3SMike Smith     u_int8_t	sd_status;
411da8bb3a3SMike Smith     u_int8_t	sd_ext_status;
412da8bb3a3SMike Smith     u_int8_t	sd_mod1;
413da8bb3a3SMike Smith     u_int8_t	sd_mod2;
414da8bb3a3SMike Smith     u_int8_t	sd_raidlevel;
415da8bb3a3SMike Smith #define MLX_SYS_DRV_WRITEBACK	(1<<7)
416da8bb3a3SMike Smith #define MLX_SYS_DRV_RAID0	0
417da8bb3a3SMike Smith #define MLX_SYS_DRV_RAID1	1
418da8bb3a3SMike Smith #define MLX_SYS_DRV_RAID3	3
419da8bb3a3SMike Smith #define MLX_SYS_DRV_RAID5	5
420da8bb3a3SMike Smith #define MLX_SYS_DRV_RAID6	6
421da8bb3a3SMike Smith #define MLX_SYS_DRV_JBOD	7
422da8bb3a3SMike Smith     u_int8_t	sd_valid_arms;
423da8bb3a3SMike Smith     u_int8_t	sd_valid_spans;
424da8bb3a3SMike Smith     u_int8_t	sd_init_state;
425da8bb3a3SMike Smith #define MLX_SYS_DRV_INITTED	0x81;
426da8bb3a3SMike Smith     struct mlx_sys_drv_span sd_span[4];
4274f492bfaSAlfred Perlstein } __packed;
428da8bb3a3SMike Smith 
429da8bb3a3SMike Smith struct mlx_phys_drv
430da8bb3a3SMike Smith {
431da8bb3a3SMike Smith     u_int8_t	pd_flags1;
432da8bb3a3SMike Smith #define	MLX_PHYS_DRV_PRESENT	(1<<0)
433da8bb3a3SMike Smith     u_int8_t	pd_flags2;
434da8bb3a3SMike Smith #define MLX_PHYS_DRV_OTHER	0x00
435da8bb3a3SMike Smith #define MLX_PHYS_DRV_DISK	0x01
436da8bb3a3SMike Smith #define MLX_PHYS_DRV_SEQUENTIAL	0x02
437da8bb3a3SMike Smith #define MLX_PHYS_DRV_CDROM	0x03
438da8bb3a3SMike Smith #define MLX_PHYS_DRV_FAST20	(1<<3)
439da8bb3a3SMike Smith #define MLX_PHYS_DRV_SYNC	(1<<4)
440da8bb3a3SMike Smith #define MLX_PHYS_DRV_FAST	(1<<5)
441da8bb3a3SMike Smith #define MLX_PHYS_DRV_WIDE	(1<<6)
442da8bb3a3SMike Smith #define MLX_PHYS_DRV_TAG	(1<<7)
443da8bb3a3SMike Smith     u_int8_t	pd_status;
444da8bb3a3SMike Smith #define MLX_PHYS_DRV_DEAD	0x00
445da8bb3a3SMike Smith #define MLX_PHYS_DRV_WRONLY	0x02
446da8bb3a3SMike Smith #define MLX_PHYS_DRV_ONLINE	0x03
447da8bb3a3SMike Smith #define MLX_PHYS_DRV_STANDBY	0x10
448da8bb3a3SMike Smith     u_int8_t	pd_res1;
449da8bb3a3SMike Smith     u_int8_t	pd_period;
450da8bb3a3SMike Smith     u_int8_t	pd_offset;
451da8bb3a3SMike Smith     u_int32_t	pd_config_size;
4524f492bfaSAlfred Perlstein } __packed;
453da8bb3a3SMike Smith 
454da8bb3a3SMike Smith struct mlx_core_cfg
455da8bb3a3SMike Smith {
456da8bb3a3SMike Smith     u_int8_t	cc_num_sys_drives;
457da8bb3a3SMike Smith     u_int8_t	cc_res1[3];
458da8bb3a3SMike Smith     struct mlx_sys_drv	cc_sys_drives[32];
459da8bb3a3SMike Smith     struct mlx_phys_drv cc_phys_drives[5 * 16];
4604f492bfaSAlfred Perlstein } __packed;
461da8bb3a3SMike Smith 
462da8bb3a3SMike Smith struct mlx_dcdb
463da8bb3a3SMike Smith {
464da8bb3a3SMike Smith     u_int8_t	dcdb_target:4;
465da8bb3a3SMike Smith     u_int8_t	dcdb_channel:4;
466da8bb3a3SMike Smith     u_int8_t	dcdb_flags;
467da8bb3a3SMike Smith #define MLX_DCDB_NO_DATA	0x00
468da8bb3a3SMike Smith #define MLX_DCDB_DATA_IN	0x01
469da8bb3a3SMike Smith #define MLX_DCDB_DATA_OUT	0x02
470da8bb3a3SMike Smith #define MLX_DCDB_EARLY_STATUS		(1<<2)
471da8bb3a3SMike Smith #define MLX_DCDB_TIMEOUT_10S	0x10
472da8bb3a3SMike Smith #define MLX_DCDB_TIMEOUT_60S	0x20
473da8bb3a3SMike Smith #define MLX_DCDB_TIMEOUT_20M	0x30
474da8bb3a3SMike Smith #define MLX_DCDB_TIMEOUT_24H	0x40
475da8bb3a3SMike Smith #define MLX_DCDB_NO_AUTO_SENSE	(1<<6)
476da8bb3a3SMike Smith #define MLX_DCDB_DISCONNECT	(1<<7)
477da8bb3a3SMike Smith     u_int16_t	dcdb_datasize;
478da8bb3a3SMike Smith     u_int32_t	dcdb_physaddr;
479da8bb3a3SMike Smith     u_int8_t	dcdb_cdb_length:4;
480da8bb3a3SMike Smith     u_int8_t	dcdb_datasize_high:4;
481da8bb3a3SMike Smith     u_int8_t	dcdb_sense_length;
482da8bb3a3SMike Smith     u_int8_t	dcdb_cdb[12];
483da8bb3a3SMike Smith     u_int8_t	dcdb_sense[64];
484da8bb3a3SMike Smith     u_int8_t	dcdb_status;
485da8bb3a3SMike Smith     u_int8_t	res1;
4864f492bfaSAlfred Perlstein } __packed;
487da8bb3a3SMike Smith 
488421f2f7dSMike Smith struct mlx_bbtable_entry
489421f2f7dSMike Smith {
490421f2f7dSMike Smith     u_int32_t	bbt_block_number;
491421f2f7dSMike Smith     u_int8_t	bbt_extent;
492421f2f7dSMike Smith     u_int8_t	res1;
493421f2f7dSMike Smith     u_int8_t	bbt_entry_type;
494421f2f7dSMike Smith     u_int8_t	bbt_system_drive:5;
495421f2f7dSMike Smith     u_int8_t	res2:3;
4964f492bfaSAlfred Perlstein } __packed;
497421f2f7dSMike Smith 
498da8bb3a3SMike Smith #ifdef _KERNEL
4994b006d7bSMike Smith /*
5004b006d7bSMike Smith  * Inlines to build various command structures
5014b006d7bSMike Smith  */
5024b006d7bSMike Smith static __inline void
mlx_make_type1(struct mlx_command * mc,u_int8_t code,u_int16_t f1,u_int32_t f2,u_int8_t f3,u_int32_t f4,u_int8_t f5)5034b006d7bSMike Smith mlx_make_type1(struct mlx_command *mc,
5044b006d7bSMike Smith 	       u_int8_t code,
5054b006d7bSMike Smith 	       u_int16_t f1,
5064b006d7bSMike Smith 	       u_int32_t f2,
5074b006d7bSMike Smith 	       u_int8_t f3,
5084b006d7bSMike Smith 	       u_int32_t f4,
5094b006d7bSMike Smith 	       u_int8_t f5)
5104b006d7bSMike Smith {
5114b006d7bSMike Smith     mc->mc_mailbox[0x0] = code;
5124b006d7bSMike Smith     mc->mc_mailbox[0x2] = f1 & 0xff;
5134b006d7bSMike Smith     mc->mc_mailbox[0x3] = (((f2 >> 24) & 0x3) << 6) | ((f1 >> 8) & 0x3f);
5144b006d7bSMike Smith     mc->mc_mailbox[0x4] = f2 & 0xff;
5154b006d7bSMike Smith     mc->mc_mailbox[0x5] = (f2 >> 8) & 0xff;
5164b006d7bSMike Smith     mc->mc_mailbox[0x6] = (f2 >> 16) & 0xff;
5174b006d7bSMike Smith     mc->mc_mailbox[0x7] = f3;
5184b006d7bSMike Smith     mc->mc_mailbox[0x8] = f4 & 0xff;
5194b006d7bSMike Smith     mc->mc_mailbox[0x9] = (f4 >> 8) & 0xff;
5204b006d7bSMike Smith     mc->mc_mailbox[0xa] = (f4 >> 16) & 0xff;
5214b006d7bSMike Smith     mc->mc_mailbox[0xb] = (f4 >> 24) & 0xff;
5224b006d7bSMike Smith     mc->mc_mailbox[0xc] = f5;
5234b006d7bSMike Smith }
5244b006d7bSMike Smith 
5254b006d7bSMike Smith static __inline void
mlx_make_type2(struct mlx_command * mc,u_int8_t code,u_int8_t f1,u_int8_t f2,u_int8_t f3,u_int8_t f4,u_int8_t f5,u_int8_t f6,u_int32_t f7,u_int8_t f8)5264b006d7bSMike Smith mlx_make_type2(struct mlx_command *mc,
5274b006d7bSMike Smith 	       u_int8_t code,
5284b006d7bSMike Smith 	       u_int8_t f1,
5294b006d7bSMike Smith 	       u_int8_t f2,
5304b006d7bSMike Smith 	       u_int8_t f3,
5314b006d7bSMike Smith 	       u_int8_t f4,
5324b006d7bSMike Smith 	       u_int8_t f5,
5334b006d7bSMike Smith 	       u_int8_t f6,
5344b006d7bSMike Smith 	       u_int32_t f7,
5354b006d7bSMike Smith 	       u_int8_t f8)
5364b006d7bSMike Smith {
5374b006d7bSMike Smith     mc->mc_mailbox[0x0] = code;
5384b006d7bSMike Smith     mc->mc_mailbox[0x2] = f1;
5394b006d7bSMike Smith     mc->mc_mailbox[0x3] = f2;
5404b006d7bSMike Smith     mc->mc_mailbox[0x4] = f3;
5414b006d7bSMike Smith     mc->mc_mailbox[0x5] = f4;
5424b006d7bSMike Smith     mc->mc_mailbox[0x6] = f5;
5434b006d7bSMike Smith     mc->mc_mailbox[0x7] = f6;
5444b006d7bSMike Smith     mc->mc_mailbox[0x8] = f7 & 0xff;
5454b006d7bSMike Smith     mc->mc_mailbox[0x9] = (f7 >> 8) & 0xff;
5464b006d7bSMike Smith     mc->mc_mailbox[0xa] = (f7 >> 16) & 0xff;
5474b006d7bSMike Smith     mc->mc_mailbox[0xb] = (f7 >> 24) & 0xff;
5484b006d7bSMike Smith     mc->mc_mailbox[0xc] = f8;
5494b006d7bSMike Smith }
5504b006d7bSMike Smith 
5514b006d7bSMike Smith static __inline void
mlx_make_type3(struct mlx_command * mc,u_int8_t code,u_int8_t f1,u_int8_t f2,u_int16_t f3,u_int8_t f4,u_int8_t f5,u_int32_t f6,u_int8_t f7)5524b006d7bSMike Smith mlx_make_type3(struct mlx_command *mc,
5534b006d7bSMike Smith 	       u_int8_t code,
5544b006d7bSMike Smith 	       u_int8_t f1,
5554b006d7bSMike Smith 	       u_int8_t f2,
5564b006d7bSMike Smith 	       u_int16_t f3,
5574b006d7bSMike Smith 	       u_int8_t f4,
5584b006d7bSMike Smith 	       u_int8_t f5,
5594b006d7bSMike Smith 	       u_int32_t f6,
5604b006d7bSMike Smith 	       u_int8_t f7)
5614b006d7bSMike Smith {
5624b006d7bSMike Smith     mc->mc_mailbox[0x0] = code;
5634b006d7bSMike Smith     mc->mc_mailbox[0x2] = f1;
5644b006d7bSMike Smith     mc->mc_mailbox[0x3] = f2;
5654b006d7bSMike Smith     mc->mc_mailbox[0x4] = f3 & 0xff;
5664b006d7bSMike Smith     mc->mc_mailbox[0x5] = (f3 >> 8) & 0xff;
5674b006d7bSMike Smith     mc->mc_mailbox[0x6] = f4;
5684b006d7bSMike Smith     mc->mc_mailbox[0x7] = f5;
5694b006d7bSMike Smith     mc->mc_mailbox[0x8] = f6 & 0xff;
5704b006d7bSMike Smith     mc->mc_mailbox[0x9] = (f6 >> 8) & 0xff;
5714b006d7bSMike Smith     mc->mc_mailbox[0xa] = (f6 >> 16) & 0xff;
5724b006d7bSMike Smith     mc->mc_mailbox[0xb] = (f6 >> 24) & 0xff;
5734b006d7bSMike Smith     mc->mc_mailbox[0xc] = f7;
5744b006d7bSMike Smith }
5754b006d7bSMike Smith 
5764b006d7bSMike Smith static __inline void
mlx_make_type4(struct mlx_command * mc,u_int8_t code,u_int16_t f1,u_int32_t f2,u_int32_t f3,u_int8_t f4)5774b006d7bSMike Smith mlx_make_type4(struct mlx_command *mc,
5784b006d7bSMike Smith 	       u_int8_t code,
5794b006d7bSMike Smith 	       u_int16_t f1,
5804b006d7bSMike Smith 	       u_int32_t f2,
5814b006d7bSMike Smith 	       u_int32_t f3,
5824b006d7bSMike Smith 	       u_int8_t f4)
5834b006d7bSMike Smith {
5844b006d7bSMike Smith     mc->mc_mailbox[0x0] = code;
5854b006d7bSMike Smith     mc->mc_mailbox[0x2] = f1 & 0xff;
5864b006d7bSMike Smith     mc->mc_mailbox[0x3] = (f1 >> 8) & 0xff;
5874b006d7bSMike Smith     mc->mc_mailbox[0x4] = f2 & 0xff;
5884b006d7bSMike Smith     mc->mc_mailbox[0x5] = (f2 >> 8) & 0xff;
5894b006d7bSMike Smith     mc->mc_mailbox[0x6] = (f2 >> 16) & 0xff;
5904b006d7bSMike Smith     mc->mc_mailbox[0x7] = (f2 >> 24) & 0xff;
5914b006d7bSMike Smith     mc->mc_mailbox[0x8] = f3 & 0xff;
5924b006d7bSMike Smith     mc->mc_mailbox[0x9] = (f3 >> 8) & 0xff;
5934b006d7bSMike Smith     mc->mc_mailbox[0xa] = (f3 >> 16) & 0xff;
5944b006d7bSMike Smith     mc->mc_mailbox[0xb] = (f3 >> 24) & 0xff;
5954b006d7bSMike Smith     mc->mc_mailbox[0xc] = f4;
5964b006d7bSMike Smith }
5974b006d7bSMike Smith 
5984b006d7bSMike Smith static __inline void
mlx_make_type5(struct mlx_command * mc,u_int8_t code,u_int8_t f1,u_int8_t f2,u_int32_t f3,u_int32_t f4,u_int8_t f5)5994b006d7bSMike Smith mlx_make_type5(struct mlx_command *mc,
6004b006d7bSMike Smith 	       u_int8_t code,
6014b006d7bSMike Smith 	       u_int8_t f1,
6024b006d7bSMike Smith 	       u_int8_t f2,
6034b006d7bSMike Smith 	       u_int32_t f3,
6044b006d7bSMike Smith 	       u_int32_t f4,
6054b006d7bSMike Smith 	       u_int8_t f5)
6064b006d7bSMike Smith {
6074b006d7bSMike Smith     mc->mc_mailbox[0x0] = code;
6084b006d7bSMike Smith     mc->mc_mailbox[0x2] = f1;
6094b006d7bSMike Smith     mc->mc_mailbox[0x3] = f2;
6104b006d7bSMike Smith     mc->mc_mailbox[0x4] = f3 & 0xff;
6114b006d7bSMike Smith     mc->mc_mailbox[0x5] = (f3 >> 8) & 0xff;
6124b006d7bSMike Smith     mc->mc_mailbox[0x6] = (f3 >> 16) & 0xff;
6134b006d7bSMike Smith     mc->mc_mailbox[0x7] = (f3 >> 24) & 0xff;
6144b006d7bSMike Smith     mc->mc_mailbox[0x8] = f4 & 0xff;
6154b006d7bSMike Smith     mc->mc_mailbox[0x9] = (f4 >> 8) & 0xff;
6164b006d7bSMike Smith     mc->mc_mailbox[0xa] = (f4 >> 16) & 0xff;
6174b006d7bSMike Smith     mc->mc_mailbox[0xb] = (f4 >> 24) & 0xff;
6184b006d7bSMike Smith     mc->mc_mailbox[0xc] = f5;
6194b006d7bSMike Smith }
620da8bb3a3SMike Smith 
621da8bb3a3SMike Smith #endif /* _KERNEL */
622