Changeset View
Changeset View
Standalone View
Standalone View
head/sbin/camcontrol/camcontrol.c
- This file is larger than 256 KB, so syntax highlighting is disabled by default.
Show First 20 Lines • Show All 184 Lines • ▼ Show 20 Lines | static struct camcontrol_opts option_table[] = { | ||||
{"load", CAM_CMD_STARTSTOP, CAM_ARG_START_UNIT | CAM_ARG_EJECT, NULL}, | {"load", CAM_CMD_STARTSTOP, CAM_ARG_START_UNIT | CAM_ARG_EJECT, NULL}, | ||||
{"eject", CAM_CMD_STARTSTOP, CAM_ARG_EJECT, NULL}, | {"eject", CAM_CMD_STARTSTOP, CAM_ARG_EJECT, NULL}, | ||||
{"reportluns", CAM_CMD_REPORTLUNS, CAM_ARG_NONE, "clr:"}, | {"reportluns", CAM_CMD_REPORTLUNS, CAM_ARG_NONE, "clr:"}, | ||||
{"readcapacity", CAM_CMD_READCAP, CAM_ARG_NONE, "bhHlNqs"}, | {"readcapacity", CAM_CMD_READCAP, CAM_ARG_NONE, "bhHlNqs"}, | ||||
{"reprobe", CAM_CMD_REPROBE, CAM_ARG_NONE, NULL}, | {"reprobe", CAM_CMD_REPROBE, CAM_ARG_NONE, NULL}, | ||||
{"rescan", CAM_CMD_RESCAN, CAM_ARG_NONE, NULL}, | {"rescan", CAM_CMD_RESCAN, CAM_ARG_NONE, NULL}, | ||||
{"reset", CAM_CMD_RESET, CAM_ARG_NONE, NULL}, | {"reset", CAM_CMD_RESET, CAM_ARG_NONE, NULL}, | ||||
{"cmd", CAM_CMD_SCSI_CMD, CAM_ARG_NONE, scsicmd_opts}, | {"cmd", CAM_CMD_SCSI_CMD, CAM_ARG_NONE, scsicmd_opts}, | ||||
{"mmcsdcmd", CAM_CMD_MMCSD_CMD, CAM_ARG_NONE, "c:a:f:Wb:l:41S:I"}, | {"mmcsdcmd", CAM_CMD_MMCSD_CMD, CAM_ARG_NONE, "c:a:F:f:Wb:l:41S:I"}, | ||||
{"command", CAM_CMD_SCSI_CMD, CAM_ARG_NONE, scsicmd_opts}, | {"command", CAM_CMD_SCSI_CMD, CAM_ARG_NONE, scsicmd_opts}, | ||||
{"smpcmd", CAM_CMD_SMP_CMD, CAM_ARG_NONE, "r:R:"}, | {"smpcmd", CAM_CMD_SMP_CMD, CAM_ARG_NONE, "r:R:"}, | ||||
{"smprg", CAM_CMD_SMP_RG, CAM_ARG_NONE, smprg_opts}, | {"smprg", CAM_CMD_SMP_RG, CAM_ARG_NONE, smprg_opts}, | ||||
{"smpreportgeneral", CAM_CMD_SMP_RG, CAM_ARG_NONE, smprg_opts}, | {"smpreportgeneral", CAM_CMD_SMP_RG, CAM_ARG_NONE, smprg_opts}, | ||||
{"smppc", CAM_CMD_SMP_PC, CAM_ARG_NONE, smppc_opts}, | {"smppc", CAM_CMD_SMP_PC, CAM_ARG_NONE, smppc_opts}, | ||||
{"smpphycontrol", CAM_CMD_SMP_PC, CAM_ARG_NONE, smppc_opts}, | {"smpphycontrol", CAM_CMD_SMP_PC, CAM_ARG_NONE, smppc_opts}, | ||||
{"smpplist", CAM_CMD_SMP_PHYLIST, CAM_ARG_NONE, smpphylist_opts}, | {"smpplist", CAM_CMD_SMP_PHYLIST, CAM_ARG_NONE, smpphylist_opts}, | ||||
{"smpphylist", CAM_CMD_SMP_PHYLIST, CAM_ARG_NONE, smpphylist_opts}, | {"smpphylist", CAM_CMD_SMP_PHYLIST, CAM_ARG_NONE, smpphylist_opts}, | ||||
▲ Show 20 Lines • Show All 7,626 Lines • ▼ Show 20 Lines | |||||
{ | { | ||||
int c, error = 0; | int c, error = 0; | ||||
union ccb *ccb; | union ccb *ccb; | ||||
int32_t mmc_opcode = 0, mmc_arg = 0; | int32_t mmc_opcode = 0, mmc_arg = 0; | ||||
int32_t mmc_flags = -1; | int32_t mmc_flags = -1; | ||||
int retval; | int retval; | ||||
int is_write = 0; | int is_write = 0; | ||||
int is_bw_4 = 0, is_bw_1 = 0; | int is_bw_4 = 0, is_bw_1 = 0; | ||||
int is_frequency = 0; | |||||
int is_highspeed = 0, is_stdspeed = 0; | int is_highspeed = 0, is_stdspeed = 0; | ||||
int is_info_request = 0; | int is_info_request = 0; | ||||
int flags = 0; | int flags = 0; | ||||
uint8_t mmc_data_byte = 0; | uint8_t mmc_data_byte = 0; | ||||
uint32_t mmc_frequency = 0; | |||||
/* For IO_RW_EXTENDED command */ | /* For IO_RW_EXTENDED command */ | ||||
uint8_t *mmc_data = NULL; | uint8_t *mmc_data = NULL; | ||||
struct mmc_data mmc_d; | struct mmc_data mmc_d; | ||||
int mmc_data_len = 0; | int mmc_data_len = 0; | ||||
/* | /* | ||||
* Note that at the moment we don't support sending SMP CCBs to | * Note that at the moment we don't support sending SMP CCBs to | ||||
Show All 20 Lines | case 'S': | ||||
if (!strcmp(optarg, "high")) | if (!strcmp(optarg, "high")) | ||||
is_highspeed = 1; | is_highspeed = 1; | ||||
else | else | ||||
is_stdspeed = 1; | is_stdspeed = 1; | ||||
break; | break; | ||||
case 'I': | case 'I': | ||||
is_info_request = 1; | is_info_request = 1; | ||||
break; | break; | ||||
case 'F': | |||||
is_frequency = 1; | |||||
mmc_frequency = strtol(optarg, NULL, 0); | |||||
break; | |||||
case 'c': | case 'c': | ||||
mmc_opcode = strtol(optarg, NULL, 0); | mmc_opcode = strtol(optarg, NULL, 0); | ||||
if (mmc_opcode < 0) { | if (mmc_opcode < 0) { | ||||
warnx("invalid MMC opcode %d", | warnx("invalid MMC opcode %d", | ||||
mmc_opcode); | mmc_opcode); | ||||
error = 1; | error = 1; | ||||
goto mmccmd_bailout; | goto mmccmd_bailout; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 89 Lines • ▼ Show 20 Lines | if (((retval = cam_send_ccb(device, ccb)) < 0) | ||||
warn("Error sending command"); | warn("Error sending command"); | ||||
} else { | } else { | ||||
printf("Parameters set OK\n"); | printf("Parameters set OK\n"); | ||||
} | } | ||||
cam_freeccb(ccb); | cam_freeccb(ccb); | ||||
return (retval); | return (retval); | ||||
} | } | ||||
if (is_frequency) { | |||||
struct ccb_trans_settings_mmc *cts; | |||||
ccb->ccb_h.func_code = XPT_SET_TRAN_SETTINGS; | |||||
ccb->ccb_h.flags = 0; | |||||
cts = &ccb->cts.proto_specific.mmc; | |||||
cts->ios.clock = mmc_frequency; | |||||
cts->ios_valid = MMC_CLK; | |||||
if (((retval = cam_send_ccb(device, ccb)) < 0) | |||||
|| ((ccb->ccb_h.status & CAM_STATUS_MASK) != CAM_REQ_CMP)) { | |||||
warn("Error sending command"); | |||||
} else { | |||||
printf("Parameters set OK\n"); | |||||
} | |||||
cam_freeccb(ccb); | |||||
return (retval); | |||||
} | |||||
// Switch bus speed instead of sending IO command | // Switch bus speed instead of sending IO command | ||||
if (is_stdspeed || is_highspeed) { | if (is_stdspeed || is_highspeed) { | ||||
struct ccb_trans_settings_mmc *cts; | struct ccb_trans_settings_mmc *cts; | ||||
ccb->ccb_h.func_code = XPT_SET_TRAN_SETTINGS; | ccb->ccb_h.func_code = XPT_SET_TRAN_SETTINGS; | ||||
ccb->ccb_h.flags = 0; | ccb->ccb_h.flags = 0; | ||||
cts = &ccb->cts.proto_specific.mmc; | cts = &ccb->cts.proto_specific.mmc; | ||||
cts->ios.timing = is_highspeed == 1 ? bus_timing_hs : bus_timing_normal; | cts->ios.timing = is_highspeed == 1 ? bus_timing_hs : bus_timing_normal; | ||||
cts->ios_valid = MMC_BT; | cts->ios_valid = MMC_BT; | ||||
Show All 17 Lines | if (((retval = cam_send_ccb(device, ccb)) < 0) | ||||
|| ((ccb->ccb_h.status & CAM_STATUS_MASK) != CAM_REQ_CMP)) { | || ((ccb->ccb_h.status & CAM_STATUS_MASK) != CAM_REQ_CMP)) { | ||||
warn("Error sending command"); | warn("Error sending command"); | ||||
return (retval); | return (retval); | ||||
} | } | ||||
printf("Host controller information\n"); | printf("Host controller information\n"); | ||||
printf("Host OCR: 0x%x\n", cts->host_ocr); | printf("Host OCR: 0x%x\n", cts->host_ocr); | ||||
printf("Min frequency: %u KHz\n", cts->host_f_min / 1000); | printf("Min frequency: %u KHz\n", cts->host_f_min / 1000); | ||||
printf("Max frequency: %u MHz\n", cts->host_f_max / 1000000); | printf("Max frequency: %u MHz\n", cts->host_f_max / 1000000); | ||||
printf("Supported bus width: "); | printf("Supported bus width:\n"); | ||||
if (cts->host_caps & MMC_CAP_4_BIT_DATA) | if (cts->host_caps & MMC_CAP_4_BIT_DATA) | ||||
printf(" 4 bit\n"); | printf(" 4 bit\n"); | ||||
if (cts->host_caps & MMC_CAP_8_BIT_DATA) | if (cts->host_caps & MMC_CAP_8_BIT_DATA) | ||||
printf(" 8 bit\n"); | printf(" 8 bit\n"); | ||||
printf("\nCurrent settings:\n"); | |||||
printf("Supported operating modes:\n"); | |||||
if (cts->host_caps & MMC_CAP_HSPEED) | |||||
printf(" Can do High Speed transfers\n"); | |||||
if (cts->host_caps & MMC_CAP_UHS_SDR12) | |||||
printf(" Can do UHS SDR12\n"); | |||||
if (cts->host_caps & MMC_CAP_UHS_SDR25) | |||||
printf(" Can do UHS SDR25\n"); | |||||
if (cts->host_caps & MMC_CAP_UHS_SDR50) | |||||
printf(" Can do UHS SDR50\n"); | |||||
if (cts->host_caps & MMC_CAP_UHS_SDR104) | |||||
printf(" Can do UHS SDR104\n"); | |||||
if (cts->host_caps & MMC_CAP_UHS_DDR50) | |||||
printf(" Can do UHS DDR50\n"); | |||||
if (cts->host_caps & MMC_CAP_MMC_DDR52_120) | |||||
printf(" Can do eMMC DDR52 at 1.2V\n"); | |||||
if (cts->host_caps & MMC_CAP_MMC_DDR52_180) | |||||
printf(" Can do eMMC DDR52 at 1.8V\n"); | |||||
if (cts->host_caps & MMC_CAP_MMC_HS200_120) | |||||
printf(" Can do eMMC HS200 at 1.2V\n"); | |||||
if (cts->host_caps & MMC_CAP_MMC_HS200_180) | |||||
printf(" Can do eMMC HS200 at 1.8V\n"); | |||||
if (cts->host_caps & MMC_CAP_MMC_HS400_120) | |||||
printf(" Can do eMMC HS400 at 1.2V\n"); | |||||
if (cts->host_caps & MMC_CAP_MMC_HS400_180) | |||||
printf(" Can do eMMC HS400 at 1.8V\n"); | |||||
printf("Supported VCCQ voltages:\n"); | |||||
if (cts->host_caps & MMC_CAP_SIGNALING_120) | |||||
printf(" 1.2V\n"); | |||||
if (cts->host_caps & MMC_CAP_SIGNALING_180) | |||||
printf(" 1.8V\n"); | |||||
if (cts->host_caps & MMC_CAP_SIGNALING_330) | |||||
printf(" 3.3V\n"); | |||||
printf("Current settings:\n"); | |||||
printf("Bus width: "); | printf(" Bus width: "); | ||||
switch (cts->ios.bus_width) { | switch (cts->ios.bus_width) { | ||||
case bus_width_1: | case bus_width_1: | ||||
printf("1 bit\n"); | printf("1 bit\n"); | ||||
break; | break; | ||||
case bus_width_4: | case bus_width_4: | ||||
printf("4 bit\n"); | printf("4 bit\n"); | ||||
break; | break; | ||||
case bus_width_8: | case bus_width_8: | ||||
printf("8 bit\n"); | printf("8 bit\n"); | ||||
break; | break; | ||||
} | } | ||||
printf("Freq: %d.%03d MHz%s\n", | printf(" Freq: %d.%03d MHz%s\n", | ||||
cts->ios.clock / 1000000, | cts->ios.clock / 1000000, | ||||
(cts->ios.clock / 1000) % 1000, | (cts->ios.clock / 1000) % 1000, | ||||
cts->ios.timing == bus_timing_hs ? "(high-speed timing)" : ""); | cts->ios.timing == bus_timing_hs ? " (high-speed timing)" : ""); | ||||
printf(" VCCQ: "); | |||||
switch (cts->ios.vccq) { | |||||
case vccq_330: | |||||
printf("3.3V\n"); | |||||
break; | |||||
case vccq_180: | |||||
printf("1.8V\n"); | |||||
break; | |||||
case vccq_120: | |||||
printf("1.2V\n"); | |||||
break; | |||||
} | |||||
return (0); | return (0); | ||||
} | } | ||||
printf("CMD %d arg %d flags %02x\n", mmc_opcode, mmc_arg, mmc_flags); | printf("CMD %d arg %d flags %02x\n", mmc_opcode, mmc_arg, mmc_flags); | ||||
if (mmc_data_len > 0) { | if (mmc_data_len > 0) { | ||||
flags |= CAM_DIR_IN; | flags |= CAM_DIR_IN; | ||||
mmc_data = malloc(mmc_data_len); | mmc_data = malloc(mmc_data_len); | ||||
▲ Show 20 Lines • Show All 2,554 Lines • Show Last 20 Lines |