Lines Matching defs:hp
361 static int dr_copyin_iocmd(dr_handle_t *hp);
362 static int dr_copyout_iocmd(dr_handle_t *hp);
363 static int dr_copyout_errs(dr_handle_t *hp);
364 static int dr_pre_op(dr_handle_t *hp);
365 static int dr_post_op(dr_handle_t *hp);
366 static int dr_exec_op(dr_handle_t *hp);
367 static void dr_assign_board(dr_handle_t *hp);
368 static void dr_unassign_board(dr_handle_t *hp);
369 static void dr_connect(dr_handle_t *hp);
370 static int dr_disconnect(dr_handle_t *hp);
371 static void dr_dev_configure(dr_handle_t *hp);
372 static void dr_dev_release(dr_handle_t *hp);
373 static int dr_dev_unconfigure(dr_handle_t *hp);
374 static void dr_dev_cancel(dr_handle_t *hp);
375 static int dr_dev_status(dr_handle_t *hp);
376 static int dr_get_ncm(dr_handle_t *hp);
377 static int dr_pt_ioctl(dr_handle_t *hp);
378 static void dr_poweron_board(dr_handle_t *hp);
379 static void dr_poweroff_board(dr_handle_t *hp);
380 static void dr_test_board(dr_handle_t *hp);
564 dr_handle_t *hp;
593 hp = GETSTRUCT(dr_handle_t, 1);
594 hp->h_bd = &softsp->boards[bd];
595 hp->h_err = NULL;
596 hp->h_dev = getminor(dev);
597 hp->h_cmd = cmd;
598 hp->h_mode = mode;
599 hp->h_iap = (sbd_ioctl_arg_t *)arg;
602 rv = dr_copyin_iocmd(hp);
604 FREESTRUCT(hp, dr_handle_t, 1);
609 if (hp->h_sbdcmd.cmd_cm.c_id.c_name[0] != '\0') {
610 hp->h_sbdcmd.cmd_cm.c_id.c_type =
611 dr_dev_type_to_nt(hp->h_sbdcmd.cmd_cm.c_id.c_name);
615 hp->h_sbdcmd.cmd_cm.c_id.c_name,
616 hp->h_sbdcmd.cmd_cm.c_id.c_type);
623 hp->h_devset = dr_dev2devset(&hp->h_sbdcmd.cmd_cm.c_id);
625 switch (hp->h_cmd) {
633 mutex_enter(&hp->h_bd->b_lock);
643 rv = DEVSET_IN_SET(hp->h_devset, SBD_COMP_MEM, DEVSET_ANYUNIT);
651 rv = dr_pre_op(hp);
653 rv = dr_exec_op(hp);
655 rv = dr_post_op(hp);
660 if (hp->h_err != NULL)
661 if (!(rv = dr_copyout_errs(hp)))
665 switch (hp->h_cmd) {
680 (void) drmach_log_sysevent(hp->h_bd->b_num, "",
685 mutex_exit(&hp->h_bd->b_lock);
689 if (hp->h_opts.size != 0)
690 FREESTRUCT(hp->h_opts.copts, char, hp->h_opts.size);
692 FREESTRUCT(hp, dr_handle_t, 1);
886 dr_copyin_iocmd(dr_handle_t *hp)
889 sbd_cmd_t *scp = &hp->h_sbdcmd;
891 if (hp->h_iap == NULL)
897 if (ddi_model_convert_from(hp->h_mode & FMODELS) == DDI_MODEL_ILP32) {
902 if (ddi_copyin((void *)hp->h_iap, (void *)&scmd32,
903 sizeof (sbd_cmd32_t), hp->h_mode)) {
917 switch (hp->h_cmd) {
929 if (ddi_copyin((void *)hp->h_iap, (void *)scp,
930 sizeof (sbd_cmd_t), hp->h_mode) != 0) {
936 if ((hp->h_opts.size = scp->cmd_cm.c_len) != 0) {
937 hp->h_opts.copts = GETSTRUCT(char, scp->cmd_cm.c_len + 1);
938 ++hp->h_opts.size;
940 (void *)hp->h_opts.copts,
941 scp->cmd_cm.c_len, hp->h_mode) != 0) {
950 dr_copyout_iocmd(dr_handle_t *hp)
953 sbd_cmd_t *scp = &hp->h_sbdcmd;
955 if (hp->h_iap == NULL)
959 if (ddi_model_convert_from(hp->h_mode & FMODELS) == DDI_MODEL_ILP32) {
971 switch (hp->h_cmd) {
979 if (ddi_copyout((void *)&scmd32, (void *)hp->h_iap,
980 sizeof (sbd_cmd32_t), hp->h_mode)) {
988 if (ddi_copyout((void *)scp, (void *)hp->h_iap,
989 sizeof (sbd_cmd_t), hp->h_mode) != 0) {
999 dr_copyout_errs(dr_handle_t *hp)
1003 if (hp->h_err == NULL)
1006 if (hp->h_err->e_code) {
1008 f, hp->h_err->e_code, hp->h_err->e_rsc);
1012 if (ddi_model_convert_from(hp->h_mode & FMODELS) == DDI_MODEL_ILP32) {
1017 serr32p->e_code = hp->h_err->e_code;
1018 bcopy(&hp->h_err->e_rsc[0], &serr32p->e_rsc[0],
1021 (void *)&((sbd_ioctl_arg32_t *)hp->h_iap)->i_err,
1022 sizeof (sbd_error32_t), hp->h_mode)) {
1030 if (ddi_copyout((void *)hp->h_err,
1031 (void *)&hp->h_iap->i_err,
1032 sizeof (sbd_error_t), hp->h_mode)) {
1038 sbd_err_clear(&hp->h_err);
1049 dr_pre_op(dr_handle_t *hp)
1054 dr_board_t *bp = hp->h_bd;
1055 dr_handle_t *shp = hp;
1058 cmd = hp->h_cmd;
1063 hp->h_err = drmach_pre_op(cmd, bp->b_id, &hp->h_opts);
1064 if (hp->h_err != NULL) {
1086 dr_op_err(CE_IGNORE, hp, ESBD_INVAL, NULL);
1094 dr_op_err(CE_IGNORE, hp,
1115 dr_post_op(dr_handle_t *hp)
1119 dr_board_t *bp = hp->h_bd;
1122 cmd = hp->h_cmd;
1127 ASSERT(hp->h_err == NULL);
1129 hp->h_err = drmach_post_op(cmd, bp->b_id, &hp->h_opts);
1130 if (hp->h_err != NULL) {
1153 dr_exec_op(dr_handle_t *hp)
1159 ASSERT(hp->h_err == NULL);
1161 switch (hp->h_cmd) {
1163 dr_assign_board(hp);
1167 dr_unassign_board(hp);
1171 dr_poweroff_board(hp);
1175 dr_poweron_board(hp);
1179 dr_test_board(hp);
1183 dr_connect(hp);
1187 dr_dev_configure(hp);
1191 dr_dev_release(hp);
1192 if (hp->h_err == NULL)
1193 rv = dr_dev_unconfigure(hp);
1195 dr_dev_cancel(hp);
1199 rv = dr_disconnect(hp);
1203 rv = dr_dev_status(hp);
1207 hp->h_sbdcmd.cmd_getncm.g_ncm = dr_get_ncm(hp);
1208 rv = dr_copyout_iocmd(hp);
1212 rv = dr_pt_ioctl(hp);
1218 f, hp->h_cmd);
1222 if (hp->h_err != NULL) {
1230 dr_assign_board(dr_handle_t *hp)
1232 dr_board_t *bp = hp->h_bd;
1234 hp->h_err = drmach_board_assign(bp->b_num, &bp->b_id);
1235 if (hp->h_err == NULL) {
1241 dr_unassign_board(dr_handle_t *hp)
1243 dr_board_t *bp = hp->h_bd;
1255 hp->h_err = drmach_board_unassign(bp->b_id);
1256 if (hp->h_err == NULL) {
1268 dr_poweron_board(dr_handle_t *hp)
1270 dr_board_t *bp = hp->h_bd;
1272 hp->h_err = drmach_board_poweron(bp->b_id);
1276 dr_poweroff_board(dr_handle_t *hp)
1278 dr_board_t *bp = hp->h_bd;
1280 hp->h_err = drmach_board_poweroff(bp->b_id);
1284 dr_test_board(dr_handle_t *hp)
1286 dr_board_t *bp = hp->h_bd;
1287 hp->h_err = drmach_board_test(bp->b_id, &hp->h_opts,
1288 dr_cmd_flags(hp) & SBD_FLAG_FORCE);
1346 dr_connect(dr_handle_t *hp)
1348 dr_board_t *bp = hp->h_bd;
1362 hp->h_err = drmach_board_connect(bp->b_id, &hp->h_opts);
1363 if (hp->h_err)
1366 hp->h_err = dr_init_devlists(bp);
1367 if (hp->h_err)
1370 dr_op_err(CE_WARN, hp, ESBD_EMPTY_BD, bp->b_path);
1380 dr_disconnect(dr_handle_t *hp)
1384 dr_board_t *bp = hp->h_bd;
1393 devset = hp->h_devset & DR_DEVS_PRESENT(bp) &
1397 dr_op_err(CE_IGNORE, hp, ESBD_EMPTY_BD, bp->b_path);
1414 hp->h_err = drmach_board_disconnect(bp->b_id, &hp->h_opts);
1433 DRERR_SET_C(&hp->h_err, &cp->sbc_cm.sbdev_error);
1448 DRERR_SET_C(&hp->h_err, &mp->sbm_cm.sbdev_error);
1463 DRERR_SET_C(&hp->h_err, &ip->sbi_cm.sbdev_error);
1467 if (hp->h_err) {
1477 if ((hp->h_err->e_code == ESTC_MBXRPLY) ||
1478 (hp->h_err->e_code == ESTC_MBXRQST) ||
1479 (hp->h_err->e_code == ESTC_SMS_ERR_UNRECOVERABLE) ||
1480 (hp->h_err->e_code == ESTC_SMS_ERR_RECOVERABLE) ||
1481 (hp->h_err->e_code == ESTC_DEPROBE) ||
1482 (hp->h_err->e_code == EOPL_DEPROBE)) {
1501 if ((hp->h_err->e_code == ESTC_MBXRQST) ||
1502 (hp->h_err->e_code == ESTC_SMS_ERR_RECOVERABLE) ||
1503 (hp->h_err->e_code == ESTC_DEPROBE) ||
1504 (hp->h_err->e_code == EOPL_DEPROBE)) {
1522 if (hp->h_err == NULL && DR_DEVS_PRESENT(bp) == 0) {
1529 hp->h_err = drmach_board_deprobe(bp->b_id);
1531 if (hp->h_err == NULL) {
1582 dr_dev_make_list(dr_handle_t *hp, sbd_comp_type_t type, int present_only,
1585 dr_board_t *bp = hp->h_bd;
1616 uset = DEVSET_GET_UNITSET(hp->h_devset, type);
1667 dr_dev_clean_up(dr_handle_t *hp, dr_common_unit_t **list, int devnum)
1677 if (hp->h_err == NULL) {
1681 hp->h_err = cp->sbdev_error;
1704 dr_dev_walk(dr_handle_t *hp, sbd_comp_type_t type, int present_only,
1713 dr_dev_make_list(hp, type, present_only, &devlist, &devnum);
1717 rv = (*pre_op)(hp, devlist, devnum);
1722 (*op)(hp, devlist[n]);
1724 rv = (*post_op)(hp, devlist, devnum);
1726 (*board_op)(hp, devlist, devnum);
1730 dr_dev_clean_up(hp, devlist, devnum);
1736 dr_dev_noop(dr_handle_t *hp, dr_common_unit_t **devlist, int devnum)
1742 dr_attach_update_state(dr_handle_t *hp,
1745 dr_board_t *bp = hp->h_bd;
1778 hp->h_bd->b_ostate = SBD_STAT_CONFIGURED;
1779 hp->h_bd->b_rstate = SBD_STAT_CONNECTED;
1780 hp->h_bd->b_cond = SBD_COND_OK;
1781 hp->h_bd->b_busy = 0;
1782 (void) drv_getparm(TIME, (void *)&hp->h_bd->b_time);
1788 hp->h_bd->b_rstate = SBD_STAT_CONNECTED;
1789 hp->h_bd->b_ostate = SBD_STAT_CONFIGURED;
1790 (void) drv_getparm(TIME, (void *)&hp->h_bd->b_time);
1801 hp->h_bd->b_rstate = SBD_STAT_CONNECTED;
1802 hp->h_bd->b_ostate = SBD_STAT_CONFIGURED;
1803 hp->h_bd->b_cond = SBD_COND_OK;
1804 hp->h_bd->b_busy = 0;
1805 (void) drv_getparm(TIME, (void *)&hp->h_bd->b_time);
1815 dr_dev_configure(dr_handle_t *hp)
1819 rv = dr_dev_walk(hp, SBD_COMP_CPU, 1,
1826 rv = dr_dev_walk(hp, SBD_COMP_MEM, 1,
1834 (void) dr_dev_walk(hp, SBD_COMP_IO, 1,
1843 dr_release_update_state(dr_handle_t *hp,
1849 dr_board_t *bp = hp->h_bd;
1858 hp->h_bd->b_busy = 1;
1880 dr_release_done(dr_handle_t *hp, dr_common_unit_t *cp)
1882 _NOTE(ARGUNUSED(hp))
1891 ASSERT(bp == hp->h_bd);
1925 dr_dev_release_mem(dr_handle_t *hp, dr_common_unit_t *dv)
1928 dr_release_done(hp, dv);
1932 dr_dev_release(dr_handle_t *hp)
1936 hp->h_bd->b_busy = 1;
1938 rv = dr_dev_walk(hp, SBD_COMP_CPU, 0,
1945 rv = dr_dev_walk(hp, SBD_COMP_MEM, 0,
1953 rv = dr_dev_walk(hp, SBD_COMP_IO, 0,
1962 hp->h_bd->b_busy = 0;
1967 dr_detach_update_state(dr_handle_t *hp,
1970 dr_board_t *bp = hp->h_bd;
2002 hp->h_bd->b_ostate = SBD_STAT_UNCONFIGURED;
2003 (void) drv_getparm(TIME, (void *)&hp->h_bd->b_time);
2011 (void) drv_getparm(TIME, (void *)&hp->h_bd->b_time);
2014 if ((hp->h_devset & DR_DEVS_UNATTACHED(bp)) == hp->h_devset)
2015 hp->h_bd->b_busy = 0;
2020 dr_dev_unconfigure(dr_handle_t *hp)
2022 dr_board_t *bp = hp->h_bd;
2037 (void) dr_dev_walk(hp, SBD_COMP_IO, 0,
2045 (void) dr_dev_walk(hp, SBD_COMP_CPU, 0,
2051 (void) dr_dev_walk(hp, SBD_COMP_MEM, 0,
2061 dr_dev_cancel(dr_handle_t *hp)
2065 dr_board_t *bp = hp->h_bd;
2074 devset = hp->h_devset & DR_DEVS_RELEASED(bp);
2137 hp->h_bd->b_ostate = SBD_STAT_CONFIGURED;
2138 hp->h_bd->b_busy = 0;
2139 (void) drv_getparm(TIME, (void *)&hp->h_bd->b_time);
2144 dr_dev_status(dr_handle_t *hp)
2163 mode = hp->h_mode;
2164 shp = hp;
2166 bp = hp->h_bd;
2183 if (hp->h_sbdcmd.cmd_cm.c_id.c_type == SBD_COMP_NONE) {
2184 if (dr_cmd_flags(hp) & SBD_FLAG_ALLCMP) {
2216 pbsz = (int)hp->h_sbdcmd.cmd_stat.s_nbytes;
2254 DRERR_SET_C(&hp->h_err, &err);
2294 if ((nstat = dr_cpu_status(hp, devset, devstatp)) > 0) {
2300 if ((nstat = dr_mem_status(hp, devset, devstatp)) > 0) {
2306 if ((nstat = dr_io_status(hp, devset, devstatp)) > 0) {
2332 DR_OP_INTERNAL_ERROR(hp);
2340 DR_OP_INTERNAL_ERROR(hp);
2439 hp->h_sbdcmd.cmd_stat.s_statp, pbsz, mode) != 0) {
2449 if (ddi_copyout((void *)dstatp, hp->h_sbdcmd.cmd_stat.s_statp,
2468 dr_get_ncm(dr_handle_t *hp)
2474 devset = DR_DEVS_PRESENT(hp->h_bd);
2475 if (hp->h_sbdcmd.cmd_cm.c_id.c_type != SBD_COMP_NONE)
2476 devset &= DEVSET(hp->h_sbdcmd.cmd_cm.c_id.c_type,
2805 dr_op_err(int ce, dr_handle_t *hp, int code, char *fmt, ...)
2817 DRERR_SET_C(&hp->h_err, &err);
3037 dr_pt_try_drmach(dr_handle_t *hp)
3039 dr_board_t *bp = hp->h_bd;
3040 sbd_comp_id_t *comp_id = &hp->h_sbdcmd.cmd_cm.c_id;
3050 dr_op_err(CE_IGNORE, hp, ESBD_INVAL, comp_id->c_name);
3060 if (hp->h_err == NULL)
3061 hp->h_err = drmach_passthru(id, &hp->h_opts);
3063 return (hp->h_err == NULL ? 0 : -1);
3067 dr_pt_ioctl(dr_handle_t *hp)
3077 sz = hp->h_opts.size;
3078 copts = hp->h_opts.copts;
3094 rv = (*pt_arr[cmd].pt_func)(hp);
3096 rv = dr_pt_try_drmach(hp);
3359 dr_cmd_flags(dr_handle_t *hp)
3361 return (hp->h_sbdcmd.cmd_cm.c_flags);