Example #1
0
void
gsm_reset (void)
{
    dp_reset();
    lsm_reset();
    fsmutil_free_all_shown_calls_ci_map();
}
Example #2
0
File: id_dp.c Project: B-Rich/simh
uint32 dpc (uint32 dev, uint32 op, uint32 dat)
{
uint32 f, t, u;
UNIT *uptr;
static uint8 good_cmd[8] = { 0, 1, 1, 1, 0, 0, 0, 0 };

switch (op) {                                           /* case IO op */

    case IO_ADR:                                        /* select */
        sch_adr (dp_dib.sch, dev);                      /* inform sel ch */
        return BY;                                      /* byte only */

    case IO_RD:                                         /* read data */
        if (dp_sta & STC_IDL)                           /* if idle */
            return GET_ROTATE (dp_rtime);               /* return sector */
        else dp_sta = dp_sta | STA_BSY;                 /* xfr? set busy */
        return dp_db;                                   /* return data */

    case IO_WD:                                         /* write data */
        if (DEBUG_PRS (dp_dev)) fprintf (sim_deb,
            ">>DPC WD = %02X, STA = %02X\n", dat, dp_sta);
        if (dp_sta & STC_IDL)                           /* idle? hdsc */
            dp_hdsc = dat & HS_MASK;
        else {                                          /* data xfer */
            dp_sta = dp_sta | STA_BSY;                  /* set busy */
            dp_db = dat & 0xFF;                         /* store data */
            }
        break;

    case IO_SS:                                         /* status */
        t = dp_sta & STC_MASK;                          /* get status */
        if (t & SETC_EX)                                /* test for EX */
            t = t | STA_EX;
        return t;

    case IO_OC:                                         /* command */
        if (DEBUG_PRS (dp_dev)) fprintf (sim_deb,
            ">>DPC OC = %02X, STA = %02X\n", dat, dp_sta);
        f = dat & CMC_MASK;                             /* get cmd */
        if (f & CMC_CLR) {                              /* clear? */
            dp_reset (&dp_dev);                         /* reset world */
            break;
            }
        u = (dp_svun - dp_dib.dno - o_DP0) / o_DP0;     /* get unit */
        uptr = dp_dev.units + u;                        /* ignore if busy */
        if (!(dp_sta & STC_IDL) || sim_is_active (uptr))
            break;
        dp_cmd = f;                                     /* save cmd */
        if (dp_cmd == CMC_WR)                           /* write: bsy=0 else */
            dp_sta = 0;
        else dp_sta = STA_BSY;                          /* bsy=1,idl,err=0 */
        dp_1st = 1;                                     /* xfr not started */
        dp_bptr = 0;                                    /* buffer empty */
        if (dp_svun & o_DPF)                            /* upper platter? */
            dp_plat = 1;
        else dp_plat = 0;                               /* no, lower */
        if (good_cmd[f])                                /* legal? sched */
            sim_activate (uptr, dp_rtime);
        break;
        }

return 0;
}
Example #3
0
static int
rmc_comm_attach(dev_info_t *dip, ddi_attach_cmd_t cmd)
{
	struct rmc_comm_state *rcs = NULL;
	sig_state_t *current_sgn_p;
	int instance;

	/*
	 * only allow one instance
	 */
	instance = ddi_get_instance(dip);
	if (instance != 0)
		return (DDI_FAILURE);

	switch (cmd) {
	default:
		return (DDI_FAILURE);

	case DDI_RESUME:
		if ((rcs = rmc_comm_getstate(dip, instance,
		    "rmc_comm_attach")) == NULL)
			return (DDI_FAILURE);	/* this "can't happen" */

		rmc_comm_hw_reset(rcs);
		rmc_comm_set_irq(rcs, B_TRUE);
		rcs->dip = dip;

		mutex_enter(&tod_lock);
		if (watchdog_enable && tod_ops.tod_set_watchdog_timer != NULL &&
		    watchdog_was_active) {
			(void) tod_ops.tod_set_watchdog_timer(0);
		}
		mutex_exit(&tod_lock);

		mutex_enter(rcs->dp_state.dp_mutex);
		dp_reset(rcs, INITIAL_SEQID, 1, 1);
		mutex_exit(rcs->dp_state.dp_mutex);

		current_sgn_p = (sig_state_t *)modgetsymvalue(
			"current_sgn", 0);
		if ((current_sgn_p != NULL) &&
			(current_sgn_p->state_t.sig != 0)) {
			CPU_SIGNATURE(current_sgn_p->state_t.sig,
				current_sgn_p->state_t.state,
				current_sgn_p->state_t.sub_state, -1);
		}
		return (DDI_SUCCESS);

	case DDI_ATTACH:
		break;
	}

	/*
	 *  Allocate the soft-state structure
	 */
	if (ddi_soft_state_zalloc(rmc_comm_statep, instance) != DDI_SUCCESS)
		return (DDI_FAILURE);
	if ((rcs = rmc_comm_getstate(dip, instance, "rmc_comm_attach")) ==
	    NULL) {
		rmc_comm_unattach(rcs, dip, instance, 0, 0, 0);
		return (DDI_FAILURE);
	}
	ddi_set_driver_private(dip, rcs);

	rcs->dip = NULL;

	/*
	 *  Set various options from .conf properties
	 */
	rcs->baud = ddi_prop_get_int(DDI_DEV_T_ANY, dip, DDI_PROP_DONTPASS,
	    "baud-rate", 0);
	rcs->debug = ddi_prop_get_int(DDI_DEV_T_ANY, dip, DDI_PROP_DONTPASS,
	    "debug", 0);

	/*
	 * the baud divisor factor tells us how to scale the result of
	 * the SIO_BAUD_TO_DIVISOR macro for platforms which do not
	 * use the standard 24MHz uart clock
	 */
	rcs->baud_divisor_factor = ddi_prop_get_int(DDI_DEV_T_ANY, dip,
	    DDI_PROP_DONTPASS, "baud-divisor-factor", SIO_BAUD_DIVISOR_MIN);

	/*
	 * try to be reasonable if the scale factor contains a silly value
	 */
	if ((rcs->baud_divisor_factor < SIO_BAUD_DIVISOR_MIN) ||
	    (rcs->baud_divisor_factor > SIO_BAUD_DIVISOR_MAX))
	    rcs->baud_divisor_factor = SIO_BAUD_DIVISOR_MIN;

	/*
	 * initialize serial device
	 */
	if (rmc_comm_serdev_init(rcs, dip) != 0) {
		rmc_comm_unattach(rcs, dip, instance, 0, 0, 0);
		return (DDI_FAILURE);
	}

	/*
	 * initialize data protocol
	 */
	rmc_comm_dp_init(rcs);

	/*
	 * initialize driver interface
	 */
	if (rmc_comm_drvintf_init(rcs) != 0) {
		rmc_comm_unattach(rcs, dip, instance, 0, 1, 1);
		return (DDI_FAILURE);
	}

	/*
	 *  Initialise devinfo-related fields
	 */
	rcs->majornum = ddi_driver_major(dip);
	rcs->instance = instance;
	rcs->dip = dip;

	/*
	 * enable interrupts now
	 */
	rmc_comm_set_irq(rcs, B_TRUE);

	/*
	 *  All done, report success
	 */
	ddi_report_dev(dip);
	mutex_enter(&rmc_comm_attach_lock);
	rcs->is_attached = B_TRUE;
	mutex_exit(&rmc_comm_attach_lock);
	return (DDI_SUCCESS);
}