PERFORCE change 167103 for review
Alexander Motin
mav at FreeBSD.org
Sat Aug 8 14:16:55 UTC 2009
http://perforce.freebsd.org/chv.cgi?CH=167103
Change 167103 by mav at mav_mavbook on 2009/08/08 14:16:31
Make identify command work for ATAPI devices.
Affected files ...
.. //depot/projects/scottl-camlock/src/sbin/camcontrol/camcontrol.c#15 edit
Differences ...
==== //depot/projects/scottl-camlock/src/sbin/camcontrol/camcontrol.c#15 (text+ko) ====
@@ -206,6 +206,7 @@
struct ccb_trans_settings *cts);
static void cpi_print(struct ccb_pathinq *cpi);
static int get_cpi(struct cam_device *device, struct ccb_pathinq *cpi);
+static int get_cgd(struct cam_device *device, struct ccb_getdev *cgd);
static int get_print_cts(struct cam_device *device, int user_settings,
int quiet, struct ccb_trans_settings *cts);
static int ratecontrol(struct cam_device *device, int retry_count,
@@ -1015,7 +1016,7 @@
((u_int64_t)parm->lba_size48_4 << 48);
printf("\n");
- printf("Protocol ");
+ printf("protocol ");
printf("ATA/ATAPI-%d", ata_version(parm->version_major));
if (parm->satacapabilities && parm->satacapabilities != 0xffff) {
if (parm->satacapabilities & ATA_SATA_GEN2)
@@ -1154,9 +1155,14 @@
{
union ccb *ccb;
struct ata_params *ident_buf;
+ struct ccb_getdev cgd;
u_int i, error = 0;
int16_t *ptr;
-
+
+ if (get_cgd(device, &cgd) != 0) {
+ warnx("couldn't get CGD");
+ return(1);
+ }
ccb = cam_getccb(device);
if (ccb == NULL) {
@@ -1185,10 +1191,10 @@
/*data_ptr*/(u_int8_t *)ptr,
/*dxfer_len*/sizeof(struct ata_params),
timeout ? timeout : 30 * 1000);
-// if (periph->path->device->protocol == PROTO_ATA)
+ if (cgd.protocol == PROTO_ATA)
ata_36bit_cmd(&ccb->ataio, ATA_ATA_IDENTIFY, 0, 0, 0);
-// else
-// ata_36bit_cmd(&ccb->ataio, ATA_ATAPI_IDENTIFY, 0, 0, 0);
+ else
+ ata_36bit_cmd(&ccb->ataio, ATA_ATAPI_IDENTIFY, 0, 0, 0);
/* Disable freezing the device queue */
ccb->ccb_h.flags |= CAM_DEV_QFRZDIS;
@@ -2621,46 +2627,71 @@
int retval = 0;
ccb = cam_getccb(device);
-
if (ccb == NULL) {
warnx("get_cpi: couldn't allocate CCB");
return(1);
}
-
bzero(&(&ccb->ccb_h)[1],
sizeof(struct ccb_pathinq) - sizeof(struct ccb_hdr));
-
ccb->ccb_h.func_code = XPT_PATH_INQ;
-
if (cam_send_ccb(device, ccb) < 0) {
warn("get_cpi: error sending Path Inquiry CCB");
-
if (arglist & CAM_ARG_VERBOSE)
cam_error_print(device, ccb, CAM_ESF_ALL,
CAM_EPF_ALL, stderr);
-
retval = 1;
-
goto get_cpi_bailout;
}
-
if ((ccb->ccb_h.status & CAM_STATUS_MASK) != CAM_REQ_CMP) {
-
if (arglist & CAM_ARG_VERBOSE)
cam_error_print(device, ccb, CAM_ESF_ALL,
CAM_EPF_ALL, stderr);
-
retval = 1;
-
goto get_cpi_bailout;
}
-
bcopy(&ccb->cpi, cpi, sizeof(struct ccb_pathinq));
get_cpi_bailout:
+ cam_freeccb(ccb);
+ return(retval);
+}
+/*
+ * Get a get device CCB for the specified device.
+ */
+static int
+get_cgd(struct cam_device *device, struct ccb_getdev *cgd)
+{
+ union ccb *ccb;
+ int retval = 0;
+
+ ccb = cam_getccb(device);
+ if (ccb == NULL) {
+ warnx("get_cgd: couldn't allocate CCB");
+ return(1);
+ }
+ bzero(&(&ccb->ccb_h)[1],
+ sizeof(struct ccb_pathinq) - sizeof(struct ccb_hdr));
+ ccb->ccb_h.func_code = XPT_GDEV_TYPE;
+ if (cam_send_ccb(device, ccb) < 0) {
+ warn("get_cgd: error sending Path Inquiry CCB");
+ if (arglist & CAM_ARG_VERBOSE)
+ cam_error_print(device, ccb, CAM_ESF_ALL,
+ CAM_EPF_ALL, stderr);
+ retval = 1;
+ goto get_cgd_bailout;
+ }
+ if ((ccb->ccb_h.status & CAM_STATUS_MASK) != CAM_REQ_CMP) {
+ if (arglist & CAM_ARG_VERBOSE)
+ cam_error_print(device, ccb, CAM_ESF_ALL,
+ CAM_EPF_ALL, stderr);
+ retval = 1;
+ goto get_cgd_bailout;
+ }
+ bcopy(&ccb->cgd, cgd, sizeof(struct ccb_getdev));
+
+get_cgd_bailout:
cam_freeccb(ccb);
-
return(retval);
}
More information about the p4-projects
mailing list