コード例 #1
0
ファイル: simmstat.c プロジェクト: mikess/illumos-gate
/* ARGSUSED */
static int
simmstat_detach(dev_info_t *devi, ddi_detach_cmd_t cmd)
{
    int instance;
    struct simmstat_soft_state *softsp;

    /* get the instance of this devi */
    instance = ddi_get_instance(devi);

    /* get the soft state pointer for this device node */
    softsp = ddi_get_soft_state(simmstatp, instance);

    switch (cmd) {
    case DDI_SUSPEND:
        return (DDI_SUCCESS);

    case DDI_DETACH:
        (void) fhc_bdlist_lock(softsp->board);
        if (fhc_bd_detachable(softsp->board))
            break;
        else
            fhc_bdlist_unlock();
    /* FALLTHROUGH */

    default:
        return (DDI_FAILURE);
    }

    fhc_bdlist_unlock();

    /* remove the kstat for this board */
    kstat_delete(softsp->simmstat_ksp);

    /* unmap the registers */
    ddi_unmap_regs(softsp->dip, 0,
                   (caddr_t *)&softsp->simmstat_base, 0, 0);

    /* free up the soft state */
    ddi_soft_state_free(simmstatp, instance);
    ddi_prop_remove_all(devi);

    return (DDI_SUCCESS);
}
コード例 #2
0
ファイル: ac_add.c プロジェクト: andreiw/polaris
int
ac_add_memory(ac_cfga_pkt_t *pkt)
{
	struct bd_list *board;
	struct ac_mem_info *mem_info;
	int force = pkt->cmd_cfga.force;
	int retval;

	board = fhc_bdlist_lock(pkt->softsp->board);
	if (board == NULL || board->ac_softsp == NULL) {
		fhc_bdlist_unlock();
		AC_ERR_SET(pkt, AC_ERR_BD);
		return (EINVAL);
	}
	ASSERT(pkt->softsp == board->ac_softsp);

	/* verify the board is of the correct type */
	switch (board->sc.type) {
	case CPU_BOARD:
	case MEM_BOARD:
		break;
	default:
		fhc_bdlist_unlock();
		AC_ERR_SET(pkt, AC_ERR_BD_TYPE);
		return (EINVAL);
	}

	/* verify the memory condition is acceptable */
	mem_info = &pkt->softsp->bank[pkt->bank];
	if (!MEM_BOARD_VISIBLE(board) || mem_info->busy ||
	    fhc_bd_busy(pkt->softsp->board) ||
	    mem_info->rstate != SYSC_CFGA_RSTATE_CONNECTED ||
	    mem_info->ostate != SYSC_CFGA_OSTATE_UNCONFIGURED ||
	    (!force && mem_info->condition != SYSC_CFGA_COND_OK)) {
		fhc_bdlist_unlock();
		AC_ERR_SET(pkt, AC_ERR_BD_STATE);
		return (EINVAL);
	}

	/*
	 * at this point, we have an available bank to add.
	 * mark it busy and initiate the add function.
	 */
	mem_info->busy = TRUE;
	fhc_bdlist_unlock();

	retval = ac_add_bank(board, pkt);

	/*
	 * We made it!  Update the status and get out of here.
	 */
	(void) fhc_bdlist_lock(-1);
	mem_info->busy = FALSE;
	if (retval == 0) {
		mem_info->ostate = SYSC_CFGA_OSTATE_CONFIGURED;
		mem_info->status_change = ddi_get_time();
	}

	fhc_bdlist_unlock();

	if (retval != 0) {
		return (retval);
	}
	return (DDI_SUCCESS);
}