Home | History | Annotate | Line # | Download | only in mmcformat
      1  1.1  reinoud /* $NetBSD: uscsilib.h,v 1.1 2008/05/14 16:49:48 reinoud Exp $	*/
      2  1.1  reinoud 
      3  1.1  reinoud /*-
      4  1.1  reinoud  * Copyright (c) 1998 The NetBSD Foundation, Inc.
      5  1.1  reinoud  * All rights reserved.
      6  1.1  reinoud  *
      7  1.1  reinoud  * This code is derived from software contributed to The NetBSD Foundation
      8  1.1  reinoud  * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility,
      9  1.1  reinoud  * NASA Ames Research Center.
     10  1.1  reinoud  *
     11  1.1  reinoud  * Redistribution and use in source and binary forms, with or without
     12  1.1  reinoud  * modification, are permitted provided that the following conditions
     13  1.1  reinoud  * are met:
     14  1.1  reinoud  * 1. Redistributions of source code must retain the above copyright
     15  1.1  reinoud  *    notice, this list of conditions and the following disclaimer.
     16  1.1  reinoud  * 2. Redistributions in binary form must reproduce the above copyright
     17  1.1  reinoud  *    notice, this list of conditions and the following disclaimer in the
     18  1.1  reinoud  *    documentation and/or other materials provided with the distribution.
     19  1.1  reinoud  *
     20  1.1  reinoud  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     21  1.1  reinoud  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     22  1.1  reinoud  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     23  1.1  reinoud  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     24  1.1  reinoud  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     25  1.1  reinoud  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     26  1.1  reinoud  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     27  1.1  reinoud  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     28  1.1  reinoud  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     29  1.1  reinoud  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     30  1.1  reinoud  * POSSIBILITY OF SUCH DAMAGE.
     31  1.1  reinoud  *
     32  1.1  reinoud  * Small changes made by Reinoud Zandijk <reinoud (at) netbsd.org>
     33  1.1  reinoud  *
     34  1.1  reinoud  */
     35  1.1  reinoud 
     36  1.1  reinoud #ifndef _SCSILIB_H_
     37  1.1  reinoud #define _SCSILIB_H_
     38  1.1  reinoud 
     39  1.1  reinoud 
     40  1.1  reinoud #define SCSI_CMD_LEN  12
     41  1.1  reinoud typedef unsigned char scsicmd[SCSI_CMD_LEN];
     42  1.1  reinoud 
     43  1.1  reinoud #include "defs.h"
     44  1.1  reinoud #include "uscsilib_machdep.h"
     45  1.1  reinoud extern	int uscsilib_verbose;
     46  1.1  reinoud 
     47  1.1  reinoud 
     48  1.1  reinoud /*
     49  1.1  reinoud  * Unified structure copied and modified from NetBSD's <sys/scsiio.h> for ease
     50  1.1  reinoud  */
     51  1.1  reinoud 
     52  1.1  reinoud struct  uscsi_addr {
     53  1.1  reinoud 	int type;	/* bus type */
     54  1.1  reinoud #define USCSI_TYPE_SCSI  0
     55  1.1  reinoud #define USCSI_TYPE_ATAPI 1
     56  1.1  reinoud 	union {
     57  1.1  reinoud 		struct {
     58  1.1  reinoud 			int scbus;  /* -1 if wildcard */
     59  1.1  reinoud 			int target; /* -1 if wildcard */
     60  1.1  reinoud 			int lun;    /* -1 if wildcard */
     61  1.1  reinoud 		} scsi;
     62  1.1  reinoud 		struct {
     63  1.1  reinoud 			int atbus;  /* -1 if wildcard */
     64  1.1  reinoud 			int drive;  /* -1 if wildcard */
     65  1.1  reinoud 		} atapi;
     66  1.1  reinoud 	} addr;
     67  1.1  reinoud };
     68  1.1  reinoud 
     69  1.1  reinoud 
     70  1.1  reinoud struct uscsi_sense {
     71  1.1  reinoud 	int asc;		/* Additional sense code */
     72  1.1  reinoud 	int ascq;		/* Additional sense code quality */
     73  1.1  reinoud 	int skey_valid;		/* sense key valid */
     74  1.1  reinoud 	int sense_key;		/* sense key; interpret on (asc, ascq) pair */
     75  1.1  reinoud };
     76  1.1  reinoud 
     77  1.1  reinoud 
     78  1.1  reinoud struct uscsi_dev {
     79  1.1  reinoud 	char	*dev_name;
     80  1.1  reinoud 	int	 fhandle;
     81  1.1  reinoud 	void	*devhandle;	/* for if a fhandle is not enough */
     82  1.1  reinoud };
     83  1.1  reinoud 
     84  1.1  reinoud 
     85  1.1  reinoud /* uscsi_sense.c */
     86  1.1  reinoud extern char *uscsi_decode_sense(void *sinfo, int flag);
     87  1.1  reinoud extern void  uscsi_print_sense(const char *name, u_char *req_cmd,
     88  1.1  reinoud 	int req_cmdlen, u_char *req_sense, int req_senselen_used,
     89  1.1  reinoud 	int verbosity);
     90  1.1  reinoud 
     91  1.1  reinoud 
     92  1.1  reinoud /* scsi_subr.c */
     93  1.1  reinoud extern int  uscsi_open(struct uscsi_dev *);
     94  1.1  reinoud extern int  uscsi_close(struct uscsi_dev *);
     95  1.1  reinoud extern int  uscsi_command(int flags, struct uscsi_dev *disc,
     96  1.1  reinoud 	void *cmd, size_t cmdlen, void *data, size_t datalen,
     97  1.1  reinoud 	uint32_t timeout, struct uscsi_sense *uscsi_sense);
     98  1.1  reinoud extern int  uscsi_check_for_scsi(struct uscsi_dev *);
     99  1.1  reinoud extern int  uscsi_identify(struct uscsi_dev *, struct uscsi_addr *saddr);
    100  1.1  reinoud 
    101  1.1  reinoud extern int  uscsi_mode_sense(struct uscsi_dev *, u_int8_t, u_int8_t,
    102  1.1  reinoud 	void *, size_t);
    103  1.1  reinoud extern int  uscsi_mode_select(struct uscsi_dev *, u_int8_t, void *, size_t);
    104  1.1  reinoud extern int  uscsi_request_sense(struct uscsi_dev *, void *, size_t);
    105  1.1  reinoud 
    106  1.1  reinoud 
    107  1.1  reinoud #endif	/* _SCSILIB_H_ */
    108  1.1  reinoud 
    109