support builtin-x86 and builtin-mic

This commit is contained in:
shirasawa
2013-01-06 15:45:17 +09:00
parent 884bd5db82
commit 9818e199f6
17 changed files with 380 additions and 142 deletions

View File

@@ -9,9 +9,14 @@
#include <linux/slab.h>
#include "mcctrl.h"
#define OS_MAX_MINOR 64
extern long __mcctrl_control(ihk_os_t, unsigned int, unsigned long);
extern int prepare_ikc_channels(ihk_os_t os);
extern void destroy_ikc_channels(ihk_os_t os);
#ifndef DO_USER_MODE
extern void mcctrl_syscall_init(void);
#endif
static long mcctrl_ioctl(ihk_os_t os, unsigned int request, void *priv,
unsigned long arg)
@@ -30,33 +35,70 @@ static struct ihk_os_user_call_handler mcctrl_uchs[] = {
{ .request = MCEXEC_UP_FREE_DMA, .func = mcctrl_ioctl },
};
static struct ihk_os_user_call mcctrl_uc = {
static struct ihk_os_user_call mcctrl_uc_proto = {
.num_handlers = sizeof(mcctrl_uchs) / sizeof(mcctrl_uchs[0]),
.handlers = mcctrl_uchs,
};
static ihk_os_t os;
static struct ihk_os_user_call mcctrl_uc[OS_MAX_MINOR];
static ihk_os_t os[OS_MAX_MINOR];
static int __init mcctrl_init(void)
{
os = ihk_host_find_os(0, NULL);
if (!os) {
printk("OS #0 not found.\n");
return -ENOENT;
int i;
int rc;
rc = -ENOENT;
for(i = 0; i < OS_MAX_MINOR; i++){
os[i] = ihk_host_find_os(i, NULL);
if (os[i]) {
printk("OS #%d found.\n", i);
rc = 0;
}
}
if (prepare_ikc_channels(os) != 0) {
printk("Preparing syscall channels failed.\n");
return -EINVAL;
if(rc){
printk("OS not found.\n");
return rc;
}
return ihk_os_register_user_call_handlers(os, &mcctrl_uc);
for(i = 0; i < OS_MAX_MINOR; i++){
if (os[i]) {
if (prepare_ikc_channels(os[i]) != 0) {
printk("Preparing syscall channels failed.\n");
os[i] = NULL;
}
}
}
#ifndef DO_USER_MODE
mcctrl_syscall_init();
#endif
for(i = 0; i < OS_MAX_MINOR; i++){
if (os[i]) {
memcpy(mcctrl_uc + i, &mcctrl_uc_proto, sizeof mcctrl_uc_proto);
rc = ihk_os_register_user_call_handlers(os[i], mcctrl_uc + i);
if(rc < 0){
destroy_ikc_channels(os[i]);
os[i] = NULL;
}
}
}
return 0;
}
static void __exit mcctrl_exit(void)
{
int i;
printk("mcctrl: unregistered.\n");
ihk_os_unregister_user_call_handlers(os, &mcctrl_uc);
destroy_ikc_channels(os);
for(i = 0; i < OS_MAX_MINOR; i++){
if(os[i]){
ihk_os_unregister_user_call_handlers(os[i], mcctrl_uc + i);
destroy_ikc_channels(os[i]);
}
}
}
MODULE_LICENSE("GPL v2");