amd_iommu.c revision ac48dfe87039078897ed719af26744eca776508c
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#include <sys/x86_archext.h>
#include <sys/amd_iommu.h>
#include "amd_iommu_impl.h"
#include "amd_iommu_acpi.h"
#define AMD_IOMMU_MINOR2INST(x) (x)
#define AMD_IOMMU_INST2MINOR(x) (x)
#define AMD_IOMMU_NODETYPE "ddi_iommu"
#define AMD_IOMMU_MINOR_NAME "amd-iommu"
void **result);
static struct cb_ops amd_iommu_cb_ops = {
amd_iommu_open, /* cb_open */
amd_iommu_close, /* cb_close */
nodev, /* cb_strategy */
nodev, /* cb_print */
nodev, /* cb_dump */
nodev, /* cb_read */
nodev, /* cb_write */
amd_iommu_ioctl, /* cb_ioctl */
nodev, /* cb_devmap */
nodev, /* cb_mmap */
nodev, /* cb_segmap */
nochpoll, /* cb_chpoll */
ddi_prop_op, /* cb_prop_op */
NULL, /* cb_str */
CB_REV, /* cb_rev */
nodev, /* cb_aread */
nodev /* cb_awrite */
};
static struct dev_ops amd_iommu_dev_ops = {
DEVO_REV, /* devo_rev */
0, /* devo_refcnt */
amd_iommu_getinfo, /* devo_getinfo */
nulldev, /* devo_identify */
nulldev, /* devo_probe */
amd_iommu_attach, /* devo_attach */
amd_iommu_detach, /* devo_detach */
nodev, /* devo_reset */
&amd_iommu_cb_ops, /* devo_cb_ops */
NULL, /* devo_bus_ops */
nulldev, /* devo_power */
amd_iommu_quiesce, /* devo_quiesce */
};
"AMD IOMMU 0.1",
};
static struct modlinkage modlinkage = {
(void *)&modldrv,
};
const char *amd_iommu_modname = "amd_iommu";
static void *amd_iommu_statep;
int amd_iommu_64bit_bug;
int amd_iommu_unity_map;
int amd_iommu_no_unmap;
int amd_iommu_disable; /* disable IOMMU */
char *amd_iommu_disable_list; /* list of drivers bypassing IOMMU */
int
_init(void)
{
return (ENOTSUP);
sizeof (struct amd_iommu_state), 1);
if (error) {
return (error);
}
if (amd_iommu_acpi_init() != DDI_SUCCESS) {
if (amd_iommu_debug) {
}
return (ENOTSUP);
}
!= DDI_SUCCESS) {
if (amd_iommu_disable_list) {
}
return (EFAULT);
}
if (error) {
if (amd_iommu_disable_list) {
}
return (error);
}
error = 0;
#endif
return (error);
}
int
{
}
int
_fini(void)
{
int error;
if (error)
return (error);
if (amd_iommu_disable_list) {
}
return (0);
}
/*ARGSUSED*/
static int
{
struct amd_iommu_state *statep;
switch (cmd) {
case DDI_INFO_DEVT2DEVINFO:
if (statep) {
return (DDI_SUCCESS);
}
break;
case DDI_INFO_DEVT2INSTANCE:
return (DDI_SUCCESS);
}
return (DDI_FAILURE);
}
static int
{
struct amd_iommu_state *statep;
switch (cmd) {
case DDI_ATTACH:
!= DDI_SUCCESS) {
return (DDI_FAILURE);
}
return (DDI_FAILURE);
}
0) != DDI_SUCCESS) {
return (DDI_FAILURE);
}
if (amd_iommu_disable_list) {
" drivers:\n%s", amd_iommu_disable_list);
}
if (amd_iommu_disable) {
return (DDI_FAILURE);
}
return (DDI_SUCCESS);
case DDI_RESUME:
return (DDI_SUCCESS);
default:
return (DDI_FAILURE);
}
}
static int
{
struct amd_iommu_state *statep;
switch (cmd) {
case DDI_DETACH:
return (DDI_FAILURE);
}
return (DDI_FAILURE);
case DDI_SUSPEND:
return (DDI_SUCCESS);
default:
return (DDI_FAILURE);
}
}
/*ARGSUSED*/
static int
{
struct amd_iommu_state *statep;
const char *f = "amd_iommu_open";
if (instance < 0) {
f, instance);
return (ENXIO);
}
return (EINVAL);
}
return (EINVAL);
}
f, instance);
return (ENXIO);
}
return (0);
}
/*ARGSUSED*/
static int
{
struct amd_iommu_state *statep;
const char *f = "amd_iommu_close";
if (instance < 0) {
return (ENXIO);
}
return (EINVAL);
}
return (EINVAL);
}
f, instance);
return (ENXIO);
}
return (0);
}
/*ARGSUSED*/
static int
int *rvalp)
{
struct amd_iommu_state *statep;
const char *f = "amd_iommu_ioctl";
if (instance < 0) {
return (ENXIO);
}
return (EINVAL);
}
return (EINVAL);
}
f, instance);
return (ENXIO);
}
return (ENOTTY);
}
static int
{
struct amd_iommu_state *statep;
const char *f = "amd_iommu_quiesce";
f, instance);
return (DDI_FAILURE);
}
return (DDI_FAILURE);
}
return (DDI_SUCCESS);
}