big commit
This commit is contained in:
@ -9,63 +9,51 @@
|
||||
#include <linux/slab.h>
|
||||
#include "mcctrl.h"
|
||||
|
||||
extern long __mcctrl_control(struct mcctrl_priv *, unsigned int, unsigned long);
|
||||
extern long __mcctrl_control(aal_os_t, unsigned int, unsigned long);
|
||||
extern int prepare_ikc_channels(aal_os_t os);
|
||||
|
||||
static int mcctrl_open(struct inode *inode, struct file *file)
|
||||
{
|
||||
struct mcctrl_priv *mcc_data;
|
||||
|
||||
mcc_data = kzalloc(sizeof(struct mcctrl_priv), GFP_KERNEL);
|
||||
if (!mcc_data) {
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
file->private_data = mcc_data;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int mcctrl_release(struct inode *inode, struct file *file)
|
||||
{
|
||||
struct mcctrl_priv *mcc_data = file->private_data;
|
||||
|
||||
if (mcc_data) {
|
||||
if (mcc_data->desc) {
|
||||
kfree(mcc_data->desc);
|
||||
}
|
||||
kfree(mcc_data);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static long mcctrl_ioctl(struct file *file, unsigned int request,
|
||||
static long mcctrl_ioctl(aal_os_t os, unsigned int request, void *priv,
|
||||
unsigned long arg)
|
||||
{
|
||||
struct mcctrl_priv *mcc_data = file->private_data;
|
||||
|
||||
return __mcctrl_control(mcc_data, request, arg);
|
||||
return __mcctrl_control(os, request, arg);
|
||||
}
|
||||
|
||||
static struct file_operations mcctrl_ops = {
|
||||
.open = mcctrl_open,
|
||||
.unlocked_ioctl = mcctrl_ioctl,
|
||||
.release = mcctrl_release,
|
||||
static struct aal_os_user_call_handler mcctrl_uchs[] = {
|
||||
{ .request = MCEXEC_UP_PREPARE_IMAGE, .func = mcctrl_ioctl },
|
||||
{ .request = MCEXEC_UP_LOAD_IMAGE, .func = mcctrl_ioctl },
|
||||
{ .request = MCEXEC_UP_START_IMAGE, .func = mcctrl_ioctl },
|
||||
{ .request = MCEXEC_UP_WAIT_SYSCALL, .func = mcctrl_ioctl },
|
||||
{ .request = MCEXEC_UP_RET_SYSCALL, .func = mcctrl_ioctl },
|
||||
{ .request = MCEXEC_UP_LOAD_SYSCALL, .func = mcctrl_ioctl },
|
||||
{ .request = MCEXEC_UP_PREPARE_DMA, .func = mcctrl_ioctl },
|
||||
};
|
||||
|
||||
static struct miscdevice mcctrl_dev = {
|
||||
.minor = MISC_DYNAMIC_MINOR,
|
||||
.name = "mcctrl",
|
||||
.fops = &mcctrl_ops,
|
||||
static struct aal_os_user_call mcctrl_uc = {
|
||||
.num_handlers = sizeof(mcctrl_uchs) / sizeof(mcctrl_uchs[0]),
|
||||
.handlers = mcctrl_uchs,
|
||||
};
|
||||
|
||||
static aal_os_t os;
|
||||
|
||||
static int __init mcctrl_init(void)
|
||||
{
|
||||
return misc_register(&mcctrl_dev);
|
||||
os = aal_host_find_os(0, NULL);
|
||||
if (!os) {
|
||||
printk("OS #0 not found.\n");
|
||||
return -ENOENT;
|
||||
}
|
||||
if (prepare_ikc_channels(os) != 0) {
|
||||
printk("Preparing syscall channels failed.\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
|
||||
return aal_os_register_user_call_handlers(os, &mcctrl_uc);
|
||||
}
|
||||
|
||||
static void __exit mcctrl_exit(void)
|
||||
{
|
||||
misc_deregister(&mcctrl_dev);
|
||||
aal_os_unregister_user_call_handlers(os, &mcctrl_uc);
|
||||
}
|
||||
|
||||
MODULE_LICENSE("GPL v2");
|
||||
|
||||
Reference in New Issue
Block a user