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