/* * Copyright (c) 2004 by Bruce M. Simpson. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * * $FreeBSD$ */ #ifndef _SCSI_UTIL_H #define _SCSI_UTIL_H /* XXX: Push to ufdformat.c */ #define UFI_MODE_SENSE_LEN 10 #define UFI_MODE_SENSE_TIMEOUT 5 /* * 12-byte FORMAT_UNIT command. Only used by UFI and SFF8077i devices. * XXX: Push to kernel headers? */ struct scsi_format_unit_12 { uint8_t opcode; uint8_t byte2; /* Assignments as for 6-byte FORMAT UNIT */ #define FUFI_ALL_TRACKS 0xFF /* Format the entire unit */ #define FUFI_SIDE_LOWER 0x0 /* Lower LBA */ #define FUFI_SIDE_UPPER 0x1 /* Higher LBA */ #define FUFI_SIDE_ALL FUFI_SIDE_LOWER uint8_t track; uint8_t interleave[2]; uint8_t unused00[2]; uint8_t param_len[2]; uint8_t unused01[3]; }; struct format_ufi_data { struct format_defect_list_header fdh; struct format_capacity_descriptor fcd; }; struct supported_format_descriptors { struct format_capacity_list_header fh; struct format_capacity_descriptor fdcurrmax; struct format_capacity_descriptor fdsupp[4]; }; void dump_flexible_geometry(struct flexible_disk_page *flex); void floppy_geom_scsi_to_fdc(struct fd_type *fdt, const struct flexible_disk_page *flexpage, const struct format_capacity_descriptor *fcd); /* XXX: These two move to kernel headers eventually. */ void scsi_format_unit_12(struct ccb_scsiio *csio, u_int32_t retries, void (*cbfcnp)(struct cam_periph *, union ccb *), u_int8_t tag_action, u_int8_t byte2, u_int8_t track, u_int16_t interleave, u_int8_t *param_buf, u_int32_t param_len, u_int8_t sense_len, u_int32_t timeout); void scsi_read_format_capacities(struct ccb_scsiio *csio, u_int32_t retries, void (*cbfcnp)(struct cam_periph *, union ccb *), u_int8_t tag_action, u_int8_t byte2, u_int8_t *fmt_buf, u_int32_t fmt_len, u_int8_t sense_len, u_int32_t timeout); void scsi_fillout_format_ufi_data(struct format_ufi_data *ufid, u_int8_t track, u_int8_t side, struct format_capacity_descriptor *cap); int scsi_get_format_capacities(struct cam_device *device, int retry_count, int timeout, u_int8_t *fmt_buf, u_int32_t fmt_len); int scsi_get_mode_sense(struct cam_device *device, int mode_page, int page_control, int dbd, int retry_count, int timeout, u_int8_t *data, int datalen, int min_mode_cmd_size); int scsi_get_inquiry(struct cam_device *device, int retry_count, int timeout, struct scsi_inquiry_data *inq_buf); int scsi_get_flexible_disk_page(struct cam_device *cam_dev, struct flexible_disk_page *page_data, int min_mode_cmd_size, int mode_cmd_timeout); void sfds_dump_supported_formats(struct supported_format_descriptors *sfds); void sfds_dump_desc(char *hdr, int dump_code_type, struct format_capacity_descriptor *pfd); /* Macros for working with mode pages. */ #define MODE_PAGE_HEADER_6(mh)\ (struct scsi_mode_page_header *)find_mode_page_6(mh) #define MODE_PAGE_HEADER_10(mh)\ (struct scsi_mode_page_header *)find_mode_page_10(mh) #define MODE_PAGE_DATA(mph)\ (u_int8_t *)(mph) + sizeof(struct scsi_mode_page_header) #endif /* _SCSI_UTIL_H */