Deleted Added
full compact
scsi_da.c (276825) scsi_da.c (276835)
1/*-
2 * Implementation of SCSI Direct Access Peripheral driver for CAM.
3 *
4 * Copyright (c) 1997 Justin T. Gibbs.
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions

--- 13 unchanged lines hidden (view full) ---

22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 * SUCH DAMAGE.
27 */
28
29#include <sys/cdefs.h>
1/*-
2 * Implementation of SCSI Direct Access Peripheral driver for CAM.
3 *
4 * Copyright (c) 1997 Justin T. Gibbs.
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions

--- 13 unchanged lines hidden (view full) ---

22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 * SUCH DAMAGE.
27 */
28
29#include <sys/cdefs.h>
30__FBSDID("$FreeBSD: head/sys/cam/scsi/scsi_da.c 276825 2015-01-08 15:10:25Z hselasky $");
30__FBSDID("$FreeBSD: head/sys/cam/scsi/scsi_da.c 276835 2015-01-08 16:58:40Z ken $");
31
32#include <sys/param.h>
33
34#ifdef _KERNEL
35#include <sys/systm.h>
36#include <sys/kernel.h>
37#include <sys/bio.h>
38#include <sys/sysctl.h>

--- 3828 unchanged lines hidden (view full) ---

3867 xpt_release_ccb(ccb);
3868 cam_periph_unlock(periph);
3869 }
3870}
3871
3872#else /* !_KERNEL */
3873
3874/*
31
32#include <sys/param.h>
33
34#ifdef _KERNEL
35#include <sys/systm.h>
36#include <sys/kernel.h>
37#include <sys/bio.h>
38#include <sys/sysctl.h>

--- 3828 unchanged lines hidden (view full) ---

3867 xpt_release_ccb(ccb);
3868 cam_periph_unlock(periph);
3869 }
3870}
3871
3872#else /* !_KERNEL */
3873
3874/*
3875 * XXX This is only left out of the kernel build to silence warnings. If,
3876 * for some reason this function is used in the kernel, the ifdefs should
3877 * be moved so it is included both in the kernel and userland.
3875 * XXX These are only left out of the kernel build to silence warnings. If,
3876 * for some reason these functions are used in the kernel, the ifdefs should
3877 * be moved so they are included both in the kernel and userland.
3878 */
3879void
3880scsi_format_unit(struct ccb_scsiio *csio, u_int32_t retries,
3881 void (*cbfcnp)(struct cam_periph *, union ccb *),
3882 u_int8_t tag_action, u_int8_t byte2, u_int16_t ileave,
3883 u_int8_t *data_ptr, u_int32_t dxfer_len, u_int8_t sense_len,
3884 u_int32_t timeout)
3885{

--- 12 unchanged lines hidden (view full) ---

3898 data_ptr,
3899 dxfer_len,
3900 sense_len,
3901 sizeof(*scsi_cmd),
3902 timeout);
3903}
3904
3905void
3878 */
3879void
3880scsi_format_unit(struct ccb_scsiio *csio, u_int32_t retries,
3881 void (*cbfcnp)(struct cam_periph *, union ccb *),
3882 u_int8_t tag_action, u_int8_t byte2, u_int16_t ileave,
3883 u_int8_t *data_ptr, u_int32_t dxfer_len, u_int8_t sense_len,
3884 u_int32_t timeout)
3885{

--- 12 unchanged lines hidden (view full) ---

3898 data_ptr,
3899 dxfer_len,
3900 sense_len,
3901 sizeof(*scsi_cmd),
3902 timeout);
3903}
3904
3905void
3906scsi_read_defects(struct ccb_scsiio *csio, uint32_t retries,
3907 void (*cbfcnp)(struct cam_periph *, union ccb *),
3908 uint8_t tag_action, uint8_t list_format,
3909 uint32_t addr_desc_index, uint8_t *data_ptr,
3910 uint32_t dxfer_len, int minimum_cmd_size,
3911 uint8_t sense_len, uint32_t timeout)
3912{
3913 uint8_t cdb_len;
3914
3915 /*
3916 * These conditions allow using the 10 byte command. Otherwise we
3917 * need to use the 12 byte command.
3918 */
3919 if ((minimum_cmd_size <= 10)
3920 && (addr_desc_index == 0)
3921 && (dxfer_len <= SRDD10_MAX_LENGTH)) {
3922 struct scsi_read_defect_data_10 *cdb10;
3923
3924 cdb10 = (struct scsi_read_defect_data_10 *)
3925 &csio->cdb_io.cdb_bytes;
3926
3927 cdb_len = sizeof(*cdb10);
3928 bzero(cdb10, cdb_len);
3929 cdb10->opcode = READ_DEFECT_DATA_10;
3930 cdb10->format = list_format;
3931 scsi_ulto2b(dxfer_len, cdb10->alloc_length);
3932 } else {
3933 struct scsi_read_defect_data_12 *cdb12;
3934
3935 cdb12 = (struct scsi_read_defect_data_12 *)
3936 &csio->cdb_io.cdb_bytes;
3937
3938 cdb_len = sizeof(*cdb12);
3939 bzero(cdb12, cdb_len);
3940 cdb12->opcode = READ_DEFECT_DATA_12;
3941 cdb12->format = list_format;
3942 scsi_ulto4b(dxfer_len, cdb12->alloc_length);
3943 scsi_ulto4b(addr_desc_index, cdb12->address_descriptor_index);
3944 }
3945
3946 cam_fill_csio(csio,
3947 retries,
3948 cbfcnp,
3949 /*flags*/ CAM_DIR_IN,
3950 tag_action,
3951 data_ptr,
3952 dxfer_len,
3953 sense_len,
3954 cdb_len,
3955 timeout);
3956}
3957
3958void
3906scsi_sanitize(struct ccb_scsiio *csio, u_int32_t retries,
3907 void (*cbfcnp)(struct cam_periph *, union ccb *),
3908 u_int8_t tag_action, u_int8_t byte2, u_int16_t control,
3909 u_int8_t *data_ptr, u_int32_t dxfer_len, u_int8_t sense_len,
3910 u_int32_t timeout)
3911{
3912 struct scsi_sanitize *scsi_cmd;
3913

--- 19 unchanged lines hidden ---
3959scsi_sanitize(struct ccb_scsiio *csio, u_int32_t retries,
3960 void (*cbfcnp)(struct cam_periph *, union ccb *),
3961 u_int8_t tag_action, u_int8_t byte2, u_int16_t control,
3962 u_int8_t *data_ptr, u_int32_t dxfer_len, u_int8_t sense_len,
3963 u_int32_t timeout)
3964{
3965 struct scsi_sanitize *scsi_cmd;
3966

--- 19 unchanged lines hidden ---