ucode_drv.c revision 9c1d4953b1540f5c51deba9b9684ca504ee2f46f
/*
* 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 2010 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#include <sys/processor.h>
#include <sys/systeminfo.h>
#include <sys/x86_archext.h>
static dev_info_t *ucode_devi;
static uint32_t ucode_max_combined_size;
static kmutex_t ucode_update_lock;
/*ARGSUSED*/
static int
{
switch (cmd) {
case DDI_INFO_DEVT2DEVINFO:
case DDI_INFO_DEVT2INSTANCE:
break;
default:
return (DDI_FAILURE);
}
case UCODE_MINOR:
break;
default:
return (DDI_FAILURE);
}
if (cmd == DDI_INFO_DEVT2INSTANCE)
*result = 0;
else
*result = ucode_devi;
return (DDI_SUCCESS);
}
static int
{
switch (cmd) {
case DDI_RESUME:
return (DDI_SUCCESS);
case DDI_ATTACH:
ucode_devi = devi;
return (DDI_FAILURE);
}
return (DDI_SUCCESS);
default:
return (DDI_FAILURE);
}
}
static int
{
/*
* The power management and DR framework should never invoke this
* driver with DDI_SUSPEND because the ucode pseudo device does not
* have a reg property or hardware binding. However, we will return
* DDI_SUCCESS so that in the unlikely event that it does get
* called, the system will still suspend and resume.
*/
switch (cmd) {
case DDI_SUSPEND:
return (DDI_SUCCESS);
case DDI_DETACH:
ucode_devi = NULL;
return (DDI_SUCCESS);
default:
return (DDI_FAILURE);
}
}
/*ARGSUSED1*/
static int
{
}
/*ARGSUSED*/
static int
{
/*
* Make sure that the ucode ops pointer has been set up.
*/
if (!ucode)
return (EIO);
switch (cmd) {
case UCODE_GET_VERSION: {
int size;
STRUCT_INIT(h, mode);
if (ddi_copyin((void *)arg,
return (EFAULT);
return (EINVAL);
if (size == 0)
return (0);
return (EINVAL);
/* Can't rely on caller for kernel's buffer size. */
return (EINVAL);
}
return (EFAULT);
}
STRUCT_SIZE(h), mode))
return (EFAULT);
return (0);
}
case UCODE_UPDATE: {
int size;
/*
* Requires all privilege.
*/
return (EPERM);
STRUCT_INIT(h, mode);
mode))
return (EFAULT);
/*
* We allow the size of the combined microcode file to be up to
* ucode_max_combined_size. It is initialized to
* UCODE_MAX_COMBINED_SIZE, and can be patched if necessary.
*/
return (EINVAL);
return (EINVAL);
return (EFAULT);
}
STRUCT_SIZE(h), mode))
return (EFAULT);
return (0);
}
STRUCT_SIZE(h), mode))
return (EFAULT);
/*
* Even if rc is not EM_OK, it is a successful operation
* from ioctl()'s perspective. We return the detailed error
* code via the ucode_write_struct data structure.
*/
return (0);
}
default:
return (ENOTTY);
}
}
static struct cb_ops ucode_cb_ops = {
nulldev, /* close */
nodev, /* strategy */
nodev, /* print */
nodev, /* dump */
nodev, /* read */
nodev, /* write */
nodev, /* devmap */
nodev, /* mmap */
nodev, /* segmap */
nochpoll, /* poll */
NULL,
};
static struct dev_ops ucode_dv_ops = {
0,
nulldev, /* identify */
nulldev, /* probe */
nodev, /* reset */
(struct bus_ops *)0,
NULL, /* power */
ddi_quiesce_not_needed, /* quiesce */
};
"ucode driver",
};
static struct modlinkage modl = {
};
int
_init(void)
{
int rc;
return (rc);
return (0);
}
int
_fini(void)
{
int rc;
return (rc);
return (0);
}
int
{
}