Example #1
0
static void __init setup_vector(void)
{
    int i;
    unsigned long *ramvec, *ramvec_p;
    const h8300_vector *trap_entry;

    ramvec = get_vector_address();
    if (ramvec == NULL)
        panic("interrupt vector serup failed.");
    else
        pr_debug("virtual vector at 0x%p\n", ramvec);

    /* create redirect table */
    ramvec_p = ramvec;
    trap_entry = trap_table;
    for (i = 0; i < NR_IRQS; i++) {
        if (i < 12) {
            if (*trap_entry)
                *ramvec_p = VECTOR(*trap_entry);
            ramvec_p++;
            trap_entry++;
        } else
            *ramvec_p++ = REDIRECT(_interrupt_entry);
    }
    _interrupt_redirect_table = ramvec;
}
Example #2
0
void __init init_IRQ(void)
{
#if defined(CONFIG_RAMKERNEL)
	int i;
	unsigned long *ramvec,*ramvec_p;
	const unsigned long *trap_entry;
	const int *saved_vector;

	ramvec = get_vector_address();
	if (ramvec == NULL)
		panic("interrupt vector serup failed.");
	else
		printk(KERN_INFO "virtual vector at 0x%08lx\n",(unsigned long)ramvec);

	/* create redirect table */
	ramvec_p = ramvec;
	trap_entry = h8300_trap_table;
	saved_vector = h8300_saved_vectors;
	for ( i = 0; i < NR_IRQS; i++) {
		if (i == *saved_vector) {
			ramvec_p++;
			saved_vector++;
		} else {
			if ( i < NR_TRAPS ) {
				if (*trap_entry)
					*ramvec_p = VECTOR(*trap_entry);
				ramvec_p++;
				trap_entry++;
			} else
				*ramvec_p++ = REDIRECT(interrupt_entry);
		}
	}
	interrupt_redirect_table = ramvec;
#ifdef DUMP_VECTOR
	ramvec_p = ramvec;
	for (i = 0; i < NR_IRQS; i++) {
		if ((i % 8) == 0)
			printk(KERN_DEBUG "\n%p: ",ramvec_p);
		printk(KERN_DEBUG "%p ",*ramvec_p);
		ramvec_p++;
	}
	printk(KERN_DEBUG "\n");
#endif
#endif
}
Example #3
0
void __init init_IRQ(void)
{
#if defined(CONFIG_RAMKERNEL)
	int i;
	unsigned long *ramvec,*ramvec_p;
	unsigned long break_vec;

	ramvec = get_vector_address();
	if (ramvec == NULL)
		panic("interrupt vector serup failed.");
	else
		printk("virtual vector at 0x%08lx\n",(unsigned long)ramvec);

#if defined(CONFIG_GDB_DEBUG)
	/* save orignal break vector */
	break_vec = ramvec[TRAP3_VEC];
#else
	break_vec = VECTOR(trace_break);
#endif

	/* create redirect table */
	for (ramvec_p = ramvec, i = 0; i < NR_IRQS; i++)
		*ramvec_p++ = REDIRECT(interrupt_entry);

	/* set special vector */
	ramvec[TRAP0_VEC] = VECTOR(system_call);
	ramvec[TRAP3_VEC] = break_vec;
	interrupt_redirect_table = ramvec;
#ifdef DUMP_VECTOR
	ramvec_p = ramvec;
	for (i = 0; i < NR_IRQS; i++) {
		if ((i % 8) == 0)
			printk("\n%p: ",ramvec_p);
		printk("%p ",*ramvec_p);
		ramvec_p++;
	}
	printk("\n");
#endif
#endif
}
/*
 * This is the implementation of "unlocked_ioctl" file operation for this character device.
 * Two ioctls have been defined IOCTL_SET_VECTOR and IOCTL_REMOVE, and corresponding 
 * actions as defined on the top has been done.
 *
 * Mutex lock has been used before accessing the task structure of the current process' task 
 * structure, to make sure that nobody else changes its contents at the same time.
 *
 */
static long device_ioctl(struct file *file,	/* ditto */
		 unsigned int ioctl_num,	/* number and param for ioctl */
		 unsigned long ioctl_param)
{
	int ret;
	char  *temp;
	char *vector_name;
	struct syscall_vector* sys_vec;

	mutex_lock(&mut_lock);

	ret = 0;
	vector_name = NULL;
	sys_vec = NULL;
	temp = (char *)ioctl_param;
	vector_name = kmalloc(MAX_VECTOR_NAME_LEN, GFP_KERNEL);
        if(vector_name == NULL) {
                ret = -ENOMEM;
                goto out;
        }
        if (IS_ERR(vector_name)) {
                ret = PTR_ERR(vector_name);
                goto out;
        }

	/* 
	 * Switch according to the ioctl called 
	 */
	switch (ioctl_num) {
	case IOCTL_SET_VECTOR:
		try_module_get(THIS_MODULE);
		ret = copy_from_user(vector_name, temp, MAX_VECTOR_NAME_LEN);
		if(ret < 0) {
			ret = -1;
			goto out;
		}
		printk(KERN_INFO " VECTOR_NAME_RECEIVED is: %s", vector_name);

		sys_vec = (struct syscall_vector *)get_vector_address(vector_name);
		if(sys_vec == NULL) {
			ret = -EINVAL;
		}
		else {
			// printk(KERN_INFO " VECTOR ADDRESS RECEIVED is: %ld", (unsigned long)sys_vec);
			ret = add_to_task_structure(sys_vec);
		}
		if(ret < 0) {
			module_put(THIS_MODULE);
		}
		break;
	case IOCTL_REMOVE:
		ret = copy_from_user(vector_name, temp, MAX_VECTOR_NAME_LEN);
		if(ret < 0) {
			ret = -1;
			goto out;
		}
		// printk(KERN_INFO " VECTOR_NAME_RECEIVED is: %s", vector_name);

		ret = reduce_ref_count(vector_name);
		if(ret < 0) {
			ret = -EINVAL;
		}
		remove_from_task_struct();	
		module_put(THIS_MODULE);
		break;

	default:
		ret = -1;
		break;
	}
out:
	kfree(vector_name);
	mutex_unlock(&mut_lock);
	return (long)ret;
}