159138Smsmith/*-
259138Smsmith * Copyright (c) 1999 Michael Smith
359138Smsmith * All rights reserved.
459138Smsmith *
559138Smsmith * Redistribution and use in source and binary forms, with or without
659138Smsmith * modification, are permitted provided that the following conditions
759138Smsmith * are met:
859138Smsmith * 1. Redistributions of source code must retain the above copyright
959138Smsmith *    notice, this list of conditions and the following disclaimer.
1059138Smsmith * 2. Redistributions in binary form must reproduce the above copyright
1159138Smsmith *    notice, this list of conditions and the following disclaimer in the
1259138Smsmith *    documentation and/or other materials provided with the distribution.
1359138Smsmith *
1459138Smsmith * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
1559138Smsmith * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1659138Smsmith * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
1759138Smsmith * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
1859138Smsmith * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
1959138Smsmith * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2059138Smsmith * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2159138Smsmith * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2259138Smsmith * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2359138Smsmith * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2459138Smsmith * SUCH DAMAGE.
2559138Smsmith *
2659138Smsmith *	$FreeBSD$
2759138Smsmith */
2859138Smsmith
2959138Smsmith#include <sys/queue.h>
3059138Smsmith
31136057Sstefanf#define debug(fmt, args...)	printf("%s: " fmt "\n", __func__ , ##args)
3259138Smsmith
3359138Smsmithstruct mlxd_foreach_action
3459138Smsmith{
3559138Smsmith    void	(*func)(int unit, void *arg);
3659138Smsmith    void	*arg;
3759138Smsmith};
3859138Smsmith
3959138Smsmithextern void			mlx_foreach(void (*func)(int unit, void *arg), void *arg);
4059138Smsmithvoid				mlxd_foreach_ctrlr(int unit, void *arg);
4159138Smsmithextern void			mlxd_foreach(void (*func)(int unit, void *arg), void *arg);
4259138Smsmithextern int			mlxd_find_ctrlr(int unit, int *ctrlr, int *sysdrive);
4359138Smsmithextern void			mlx_perform(int unit, void (*func)(int fd, void *arg), void *arg);
4459138Smsmithextern void			mlx_command(int fd, void *arg);
4559138Smsmithextern int			mlx_enquiry(int unit, struct mlx_enquiry2 *enq);
4659138Smsmithextern int			mlx_read_configuration(int unit, struct mlx_core_cfg *cfg);
4759138Smsmithextern int			mlx_scsi_inquiry(int unit, int bus, int target, char **vendor, char **device, char **revision);
4859138Smsmithextern int			mlx_get_device_state(int fd, int channel, int target, struct mlx_phys_drv *drv);
4959138Smsmith
5059138Smsmithextern char 	*ctrlrpath(int unit);
5159138Smsmithextern char	*ctrlrname(int unit);
5259138Smsmithextern char	*drivepath(int unit);
5359138Smsmithextern char	*drivename(int unit);
5459138Smsmithextern int	ctrlrunit(char *str);
5559138Smsmithextern int	driveunit(char *str);
5659138Smsmith
5759138Smsmithextern void	mlx_print_phys_drv(struct mlx_phys_drv *drv, int channel, int target, char *prefix, int verbose);
5859138Smsmith
5959138Smsmithstruct conf_phys_drv
6059138Smsmith{
6160938Sjake    TAILQ_ENTRY(conf_phys_drv)	pd_link;
6259138Smsmith    int				pd_bus;
6359138Smsmith    int				pd_target;
6459138Smsmith    struct mlx_phys_drv		pd_drv;
6559138Smsmith};
6659138Smsmith
6759138Smsmithstruct conf_span
6859138Smsmith{
6960938Sjake    TAILQ_ENTRY(conf_span)	s_link;
7059138Smsmith    struct conf_phys_drv	*s_drvs[8];
7159138Smsmith    struct mlx_sys_drv_span	s_span;
7259138Smsmith};
7359138Smsmith
7459138Smsmithstruct conf_sys_drv
7559138Smsmith{
7660938Sjake    TAILQ_ENTRY(conf_sys_drv)	sd_link;
7759138Smsmith    struct conf_span		*sd_spans[4];
7859138Smsmith    struct mlx_sys_drv		sd_drv;
7959138Smsmith};
8059138Smsmith
8159138Smsmithstruct conf_config
8259138Smsmith{
8360938Sjake    TAILQ_HEAD(,conf_phys_drv)	cc_phys_drvs;
8460938Sjake    TAILQ_HEAD(,conf_span)	cc_spans;
8560938Sjake    TAILQ_HEAD(,conf_sys_drv)	cc_sys_drvs;
8659138Smsmith    struct conf_sys_drv		*cc_drives[32];
8759138Smsmith    struct mlx_core_cfg		cc_cfg;
8859138Smsmith};
8959138Smsmith
90