Changeset View
Changeset View
Standalone View
Standalone View
usr.sbin/ufdformat/scsi_util.h
/* | |||||
* 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 *); | |||||
void floppy_geom_scsi_to_fdc(struct fd_type *, | |||||
const struct flexible_disk_page *, | |||||
const struct format_capacity_descriptor *); | |||||
/* XXX: These two move to kernel headers eventually. */ | |||||
void scsi_format_unit_12(struct ccb_scsiio *, u_int32_t, | |||||
void (*)(struct cam_periph *, union ccb *), | |||||
u_int8_t, u_int8_t, u_int8_t, u_int16_t, u_int8_t *, u_int32_t, | |||||
u_int8_t, u_int32_t); | |||||
void scsi_read_format_capacities(struct ccb_scsiio *, u_int32_t, | |||||
void (*cbfcnp)(struct cam_periph *, union ccb *), | |||||
u_int8_t tag_action, u_int8_t, u_int8_t *, | |||||
u_int32_t, u_int8_t, u_int32_t); | |||||
void scsi_fillout_format_ufi_data(struct format_ufi_data *, | |||||
u_int8_t, u_int8_t, struct format_capacity_descriptor *); | |||||
int scsi_get_format_capacities(struct cam_device *, int, | |||||
int, u_int8_t *, u_int32_t); | |||||
int scsi_get_mode_sense(struct cam_device *, int, int, int, int, int, | |||||
u_int8_t *, int, int); | |||||
int scsi_get_inquiry(struct cam_device *, int, int, | |||||
struct scsi_inquiry_data *); | |||||
int scsi_get_flexible_disk_page(struct cam_device *, | |||||
struct flexible_disk_page *, int, int); | |||||
int scsi_format_track(struct cam_device *, union ccb *, | |||||
int, int, int head, struct format_capacity_descriptor *); | |||||
void scsi_verify(struct ccb_scsiio *, u_int32_t, | |||||
void (*)(struct cam_periph *, union ccb *), u_int8_t, | |||||
u_int8_t, u_int32_t, u_int16_t, u_int8_t, u_int32_t); | |||||
int scsi_verify_track(struct cam_device *, union ccb *, | |||||
int, int, int head, int); | |||||
void sfds_dump_supported_formats(struct supported_format_descriptors *); | |||||
void sfds_dump_desc(char *hdr, int, struct format_capacity_descriptor *); | |||||
/* 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 */ |