7d87efa8fdfb9453670f2832df666fdae8291a84jmcp * CDDL HEADER START
7d87efa8fdfb9453670f2832df666fdae8291a84jmcp * The contents of this file are subject to the terms of the
7d87efa8fdfb9453670f2832df666fdae8291a84jmcp * Common Development and Distribution License (the "License").
7d87efa8fdfb9453670f2832df666fdae8291a84jmcp * You may not use this file except in compliance with the License.
7d87efa8fdfb9453670f2832df666fdae8291a84jmcp * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
7d87efa8fdfb9453670f2832df666fdae8291a84jmcp * See the License for the specific language governing permissions
7d87efa8fdfb9453670f2832df666fdae8291a84jmcp * and limitations under the License.
7d87efa8fdfb9453670f2832df666fdae8291a84jmcp * When distributing Covered Code, include this CDDL HEADER in each
7d87efa8fdfb9453670f2832df666fdae8291a84jmcp * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
7d87efa8fdfb9453670f2832df666fdae8291a84jmcp * If applicable, add the following below this CDDL HEADER, with the
7d87efa8fdfb9453670f2832df666fdae8291a84jmcp * fields enclosed by brackets "[]" replaced with your own identifying
7d87efa8fdfb9453670f2832df666fdae8291a84jmcp * information: Portions Copyright [yyyy] [name of copyright owner]
7d87efa8fdfb9453670f2832df666fdae8291a84jmcp * CDDL HEADER END
7d87efa8fdfb9453670f2832df666fdae8291a84jmcp * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
7d87efa8fdfb9453670f2832df666fdae8291a84jmcp * Use is subject to license terms.
7d87efa8fdfb9453670f2832df666fdae8291a84jmcpstatic int amd_iommu_getinfo(dev_info_t *dip, ddi_info_cmd_t cmd, void *arg,
7d87efa8fdfb9453670f2832df666fdae8291a84jmcpstatic int amd_iommu_attach(dev_info_t *dip, ddi_attach_cmd_t cmd);
7d87efa8fdfb9453670f2832df666fdae8291a84jmcpstatic int amd_iommu_detach(dev_info_t *dip, ddi_detach_cmd_t cmd);
7d87efa8fdfb9453670f2832df666fdae8291a84jmcpstatic int amd_iommu_open(dev_t *devp, int flag, int otyp, cred_t *credp);
7d87efa8fdfb9453670f2832df666fdae8291a84jmcpstatic int amd_iommu_close(dev_t dev, int flag, int otyp, cred_t *credp);
7d87efa8fdfb9453670f2832df666fdae8291a84jmcpstatic int amd_iommu_ioctl(dev_t dev, int cmd, intptr_t arg, int mode,
7d87efa8fdfb9453670f2832df666fdae8291a84jmcp 0, /* devo_refcnt */
7d87efa8fdfb9453670f2832df666fdae8291a84jmcp "AMD IOMMU 0.1",
7d87efa8fdfb9453670f2832df666fdae8291a84jmcpchar *amd_iommu_disable_list; /* list of drivers bypassing IOMMU */
7d87efa8fdfb9453670f2832df666fdae8291a84jmcp cmn_err(CE_WARN, "%s: _init: failed to init soft state.",
7d87efa8fdfb9453670f2832df666fdae8291a84jmcp if (amd_iommu_page_table_hash_init(&amd_iommu_page_table_hash)
7d87efa8fdfb9453670f2832df666fdae8291a84jmcp cmn_err(CE_WARN, "%s: _init: Page table hash init failed.",
7d87efa8fdfb9453670f2832df666fdae8291a84jmcp amd_iommu_page_table_hash_fini(&amd_iommu_page_table_hash);
7d87efa8fdfb9453670f2832df666fdae8291a84jmcp amd_iommu_page_table_hash_fini(&amd_iommu_page_table_hash);
7d87efa8fdfb9453670f2832df666fdae8291a84jmcp return (0);
7d87efa8fdfb9453670f2832df666fdae8291a84jmcp/*ARGSUSED*/
7d87efa8fdfb9453670f2832df666fdae8291a84jmcpamd_iommu_getinfo(dev_info_t *dip, ddi_info_cmd_t cmd, void *arg, void **result)
7d87efa8fdfb9453670f2832df666fdae8291a84jmcp switch (cmd) {
7d87efa8fdfb9453670f2832df666fdae8291a84jmcp switch (cmd) {
7d87efa8fdfb9453670f2832df666fdae8291a84jmcp statep = ddi_get_soft_state(amd_iommu_statep, instance);
7d87efa8fdfb9453670f2832df666fdae8291a84jmcp if (ddi_create_minor_node(dip, AMD_IOMMU_MINOR_NAME, S_IFCHR,
7d87efa8fdfb9453670f2832df666fdae8291a84jmcp cmn_err(CE_NOTE, "AMD IOMMU disabled for the following"
7d87efa8fdfb9453670f2832df666fdae8291a84jmcp } else if (amd_iommu_setup(dip, statep) != DDI_SUCCESS) {
7d87efa8fdfb9453670f2832df666fdae8291a84jmcp switch (cmd) {
7d87efa8fdfb9453670f2832df666fdae8291a84jmcp statep = ddi_get_soft_state(amd_iommu_statep, instance);
7d87efa8fdfb9453670f2832df666fdae8291a84jmcp/*ARGSUSED*/
7d87efa8fdfb9453670f2832df666fdae8291a84jmcpamd_iommu_open(dev_t *devp, int flag, int otyp, cred_t *credp)
7d87efa8fdfb9453670f2832df666fdae8291a84jmcp const char *f = "amd_iommu_open";
7d87efa8fdfb9453670f2832df666fdae8291a84jmcp statep = ddi_get_soft_state(amd_iommu_statep, instance);
7d87efa8fdfb9453670f2832df666fdae8291a84jmcp cmn_err(CE_WARN, "%s: cannot get soft state: instance %d",
7d87efa8fdfb9453670f2832df666fdae8291a84jmcp return (0);
7d87efa8fdfb9453670f2832df666fdae8291a84jmcp/*ARGSUSED*/
7d87efa8fdfb9453670f2832df666fdae8291a84jmcpamd_iommu_close(dev_t dev, int flag, int otyp, cred_t *credp)
7d87efa8fdfb9453670f2832df666fdae8291a84jmcp const char *f = "amd_iommu_close";
7d87efa8fdfb9453670f2832df666fdae8291a84jmcp cmn_err(CE_WARN, "%s: invalid instance %d", f, instance);
7d87efa8fdfb9453670f2832df666fdae8291a84jmcp statep = ddi_get_soft_state(amd_iommu_statep, instance);
7d87efa8fdfb9453670f2832df666fdae8291a84jmcp cmn_err(CE_WARN, "%s: cannot get soft state: instance %d",
7d87efa8fdfb9453670f2832df666fdae8291a84jmcp return (0);
7d87efa8fdfb9453670f2832df666fdae8291a84jmcp/*ARGSUSED*/
7d87efa8fdfb9453670f2832df666fdae8291a84jmcpamd_iommu_ioctl(dev_t dev, int cmd, intptr_t arg, int mode, cred_t *credp,
7d87efa8fdfb9453670f2832df666fdae8291a84jmcp const char *f = "amd_iommu_ioctl";
7d87efa8fdfb9453670f2832df666fdae8291a84jmcp cmn_err(CE_WARN, "%s: invalid instance %d", f, instance);
7d87efa8fdfb9453670f2832df666fdae8291a84jmcp cmn_err(CE_WARN, "%s: FKIOCTL unsupported mode %d", f, mode);
7d87efa8fdfb9453670f2832df666fdae8291a84jmcp statep = ddi_get_soft_state(amd_iommu_statep, instance);
7d87efa8fdfb9453670f2832df666fdae8291a84jmcp cmn_err(CE_WARN, "%s: cannot get soft state: instance %d",
ac48dfe87039078897ed719af26744eca776508cVikram Hegde const char *f = "amd_iommu_quiesce";
ac48dfe87039078897ed719af26744eca776508cVikram Hegde statep = ddi_get_soft_state(amd_iommu_statep, instance);
ac48dfe87039078897ed719af26744eca776508cVikram Hegde cmn_err(CE_WARN, "%s: cannot get soft state: instance %d",
ac48dfe87039078897ed719af26744eca776508cVikram Hegde if (amd_iommu_teardown(dip, statep, AMD_IOMMU_QUIESCE) != DDI_SUCCESS) {
ac48dfe87039078897ed719af26744eca776508cVikram Hegde cmn_err(CE_WARN, "%s: Unable to quiesce AMD IOMMU "