Changeset View
Changeset View
Standalone View
Standalone View
head/sys/cam/mmc/mmc_da.c
Show First 20 Lines • Show All 1,189 Lines • ▼ Show 20 Lines | sdda_get_host_caps(struct cam_periph *periph, union ccb *ccb) | ||||
ccb->ccb_h.cbfcnp = NULL; | ccb->ccb_h.cbfcnp = NULL; | ||||
xpt_action(ccb); | xpt_action(ccb); | ||||
if (ccb->ccb_h.status != CAM_REQ_CMP) | if (ccb->ccb_h.status != CAM_REQ_CMP) | ||||
panic("Cannot get host caps"); | panic("Cannot get host caps"); | ||||
return (cts->host_caps); | return (cts->host_caps); | ||||
} | } | ||||
static uint32_t | |||||
sdda_get_max_data(struct cam_periph *periph, union ccb *ccb) | |||||
{ | |||||
struct ccb_trans_settings_mmc *cts; | |||||
cts = &ccb->cts.proto_specific.mmc; | |||||
memset(cts, 0, sizeof(struct ccb_trans_settings_mmc)); | |||||
ccb->ccb_h.func_code = XPT_GET_TRAN_SETTINGS; | |||||
ccb->ccb_h.flags = CAM_DIR_NONE; | |||||
ccb->ccb_h.retry_count = 0; | |||||
ccb->ccb_h.timeout = 100; | |||||
ccb->ccb_h.cbfcnp = NULL; | |||||
xpt_action(ccb); | |||||
if (ccb->ccb_h.status != CAM_REQ_CMP) | |||||
panic("Cannot get host max data"); | |||||
KASSERT(cts->host_max_data != 0, ("host_max_data == 0?!")); | |||||
return (cts->host_max_data); | |||||
} | |||||
static void | static void | ||||
sdda_start_init(void *context, union ccb *start_ccb) | sdda_start_init(void *context, union ccb *start_ccb) | ||||
{ | { | ||||
struct cam_periph *periph = (struct cam_periph *)context; | struct cam_periph *periph = (struct cam_periph *)context; | ||||
struct ccb_trans_settings_mmc *cts; | struct ccb_trans_settings_mmc *cts; | ||||
uint32_t host_caps; | uint32_t host_caps; | ||||
uint32_t sec_count; | uint32_t sec_count; | ||||
int err; | int err; | ||||
▲ Show 20 Lines • Show All 209 Lines • ▼ Show 20 Lines | |||||
static void | static void | ||||
sdda_add_part(struct cam_periph *periph, u_int type, const char *name, | sdda_add_part(struct cam_periph *periph, u_int type, const char *name, | ||||
u_int cnt, off_t media_size, bool ro) | u_int cnt, off_t media_size, bool ro) | ||||
{ | { | ||||
struct sdda_softc *sc = (struct sdda_softc *)periph->softc; | struct sdda_softc *sc = (struct sdda_softc *)periph->softc; | ||||
struct sdda_part *part; | struct sdda_part *part; | ||||
struct ccb_pathinq cpi; | struct ccb_pathinq cpi; | ||||
u_int maxio; | |||||
CAM_DEBUG(periph->path, CAM_DEBUG_PERIPH, | CAM_DEBUG(periph->path, CAM_DEBUG_PERIPH, | ||||
("Partition type '%s', size %ju %s\n", | ("Partition type '%s', size %ju %s\n", | ||||
part_type(type), | part_type(type), | ||||
media_size, | media_size, | ||||
ro ? "(read-only)" : "")); | ro ? "(read-only)" : "")); | ||||
part = sc->part[type] = malloc(sizeof(*part), M_DEVBUF, | part = sc->part[type] = malloc(sizeof(*part), M_DEVBUF, | ||||
▲ Show 20 Lines • Show All 42 Lines • ▼ Show 20 Lines | sdda_add_part(struct cam_periph *periph, u_int type, const char *name, | ||||
part->disk->d_open = sddaopen; | part->disk->d_open = sddaopen; | ||||
part->disk->d_close = sddaclose; | part->disk->d_close = sddaclose; | ||||
part->disk->d_strategy = sddastrategy; | part->disk->d_strategy = sddastrategy; | ||||
part->disk->d_getattr = sddagetattr; | part->disk->d_getattr = sddagetattr; | ||||
// sc->disk->d_dump = sddadump; | // sc->disk->d_dump = sddadump; | ||||
part->disk->d_gone = sddadiskgonecb; | part->disk->d_gone = sddadiskgonecb; | ||||
part->disk->d_name = part->name; | part->disk->d_name = part->name; | ||||
part->disk->d_drv1 = part; | part->disk->d_drv1 = part; | ||||
maxio = cpi.maxio; /* Honor max I/O size of SIM */ | part->disk->d_maxsize = | ||||
if (maxio == 0) | MIN(MAXPHYS, sdda_get_max_data(periph, | ||||
maxio = DFLTPHYS; /* traditional default */ | (union ccb *)&cpi) * mmc_get_sector_size(periph)); | ||||
else if (maxio > MAXPHYS) | |||||
maxio = MAXPHYS; /* for safety */ | |||||
part->disk->d_maxsize = maxio; | |||||
part->disk->d_unit = cnt; | part->disk->d_unit = cnt; | ||||
part->disk->d_flags = 0; | part->disk->d_flags = 0; | ||||
strlcpy(part->disk->d_descr, sc->card_id_string, | strlcpy(part->disk->d_descr, sc->card_id_string, | ||||
MIN(sizeof(part->disk->d_descr), sizeof(sc->card_id_string))); | MIN(sizeof(part->disk->d_descr), sizeof(sc->card_id_string))); | ||||
strlcpy(part->disk->d_ident, sc->card_sn_string, | strlcpy(part->disk->d_ident, sc->card_sn_string, | ||||
MIN(sizeof(part->disk->d_ident), sizeof(sc->card_sn_string))); | MIN(sizeof(part->disk->d_ident), sizeof(sc->card_sn_string))); | ||||
part->disk->d_hba_vendor = cpi.hba_vendor; | part->disk->d_hba_vendor = cpi.hba_vendor; | ||||
part->disk->d_hba_device = cpi.hba_device; | part->disk->d_hba_device = cpi.hba_device; | ||||
▲ Show 20 Lines • Show All 405 Lines • Show Last 20 Lines |