Exemple #1
0
END_TEST

START_TEST (test_cleanup)
{
	ENABLE_STUB(bt_sock_unregister) = 1;
	cleanup_module();
	fail_unless(LAST_PRINTK("%s: L2CAP socket unregistration failed"),
		"Module cleanup failed");
	ENABLE_STUB(bt_sock_unregister) = 0;

	ENABLE_STUB(hci_unregister_proto) = 1;
	cleanup_module();
	fail_unless(LAST_PRINTK("%s: L2CAP protocol unregistration failed"),
		"Module cleanup failed");
	ENABLE_STUB(hci_unregister_proto) = 0;
}
Exemple #2
0
int main ()
{
  int            rval;
  int            size;
  struct file    my_file;
  char          *buffer; /* we do not model this buffer */
  struct inode   inode;
  unsigned int   count;
  unsigned char  random;

  int lock_held = 0; 

  dummy_major = register_chrdev (0, "dummy");
  inode.i_rdev = dummy_major << MINORBITS;

  init_module ();

  /* assign arbitrary values */
  my_file.f_mode = nondet_uint ();
  my_file.f_pos  = nondet_uint ();

  do
    {
      random = nondet_uchar ();
      __CPROVER_assume (0 <= random && random <= 3);

      switch (random)
	{
	case 1: 
	  rval = dummy_open (&inode, &my_file);
	  if (rval == 0)
	    lock_held = TRUE;
	  break;
	case 2:
	  __CPROVER_assume (lock_held);
	  count = dummy_read (&my_file, buffer, BUF_SIZE); 
	  break;
	case 3:
	  dummy_release (&inode, &my_file);
	  lock_held = FALSE;
	  break;
	default:
	  break;
	}
    }
  while (random || lock_held);

  cleanup_module ();
  unregister_chrdev (dummy_major, "dummy");

  return 0;
}
Exemple #3
0
/* someone asks us to die */
error_t trivfs_goaway(struct trivfs_control *cntl, int flags)
{
	const int protid_users = ports_count_class(cntl->protid_class);
	const int force = flags & FSYS_GOAWAY_FORCE;
	const int nosync = flags & FSYS_GOAWAY_NOSYNC;

	/* does our live have a meaning yet? */
	if(protid_users && !force) {
		/* yeah, have to toil a bit longer -> blow it off */
		ports_enable_class(cntl->protid_class);
		return EBUSY;
	}
	/* nope, that was it */
	if(!nosync)    /* we use a liberal interpretation of NOSYNC here */
		cleanup_module();    /* "...as though it never existed..." */
	exit(0);    /* "...now I will just say goodbye" */
}
Exemple #4
0
static int space_invader(void)
{
	int err;


	printk("Start space_invader\n");


	// Création de la tâche gérant le menu
	err =  rt_task_create (&menu_task, "menu", STACK_SIZE, 50, 0);
	if (err != 0) {
		printk("menu task creation failed: %d\n", err);
		goto fail;
	}

	printk("Task created\n");

	err = rt_task_start(&menu_task, menu, 0);
	if (err != 0) {
		printk("menu task start failed: %d\n", err);
		goto fail;
	}

	printk("Task started\n");

	err = rt_intr_enable(&isrDesc);

	printk("Intr enable\n");

	if (err != 0) {
		printk("rt-app: Could not enable I2C ISR\n");
		goto fail;
	}

	printk("rt-app: Enabled ISR\n");

	printk("End space_invader\n");
	return 0;

fail:
	cleanup_module();
	return -1;

}
Exemple #5
0
int main(void)
{
	int i;
        RT_TASK *task;

        if (!(task = rt_task_init(nam2num("CMNODE"), 0, 0, 0))) {
                printf("CANNOT INIT COMNODE TASK\n");
                exit(1);
        }

	init_module();
	for (i = 0; i < 7; i++) {
		rt_sem_wait(end_sem);
	}
	cleanup_module();
	rt_task_delete(task);

	exit(0);
}
Exemple #6
0
int main(int argc, char *argv[])
{
	mach_port_t bootstrap;
	struct trivfs_control *control;
	error_t err;

	argp_parse(&kgi_argp, argc, argv, 0, NULL, NULL);

	init_module();
	if(!display)
		error(3, 0, "No suitable display found... I'm bored, bye.");

	task_get_bootstrap_port(mach_task_self(), &bootstrap);
	if(bootstrap == MACH_PORT_NULL) {    /* not started as translator */
		printf("Init complete; press <return>.\n"); getchar();

		setmode();

		printf("setmode() complete; press <return>.\n"); getchar();

		draw_crap();

		printf("draw_crap() complete; press <return>.\n"); getchar();

		unsetmode();

		printf("unsetmode() complete; press <return>.\n"); getchar();

		cleanup_module();
		assert(!display);
		return 0;
	}

	err = trivfs_startup(bootstrap, 0, NULL, NULL, NULL, NULL, &control);
	mach_port_deallocate(mach_task_self(), bootstrap);
	if(err)
		error(2, err, "trivfs_startup");
	
	ports_manage_port_operations_one_thread(control->pi.bucket, kgi_demuxer, 0);
	return 0;    /* not reached */
}
Exemple #7
0
int pd_init (void)

{       int i;
	request_queue_t * q; 

	if (disable) return -1;
        if (devfs_register_blkdev(MAJOR_NR,name,&pd_fops)) {
                printk("%s: unable to get major number %d\n",
                        name,major);
                return -1;
        }
	q = BLK_DEFAULT_QUEUE(MAJOR_NR);
	blk_init_queue(q, DEVICE_REQUEST);
        read_ahead[MAJOR_NR] = 8;       /* 8 sector (4kB) read ahead */
        
	pd_gendisk.major = major;
	pd_gendisk.major_name = name;
	add_gendisk(&pd_gendisk);

	for(i=0;i<PD_DEVS;i++) pd_blocksizes[i] = 1024;
	blksize_size[MAJOR_NR] = pd_blocksizes;

	for(i=0;i<PD_DEVS;i++) pd_maxsectors[i] = cluster;
	max_sectors[MAJOR_NR] = pd_maxsectors;

	printk("%s: %s version %s, major %d, cluster %d, nice %d\n",
		name,name,PD_VERSION,major,cluster,nice);
	pd_init_units();
	pd_valid = 0;
	pd_gendisk.nr_real = pd_detect();
	pd_valid = 1;

#ifdef MODULE
        if (!pd_gendisk.nr_real) {
		cleanup_module();
		return -1;
	}
#endif
        return 0;
}
static int
click_modevent(module_t mod, int type, void *data)
{
	int ret;

	/* Load and unload the VFS part first */
	ret = vfs_modevent(mod, type, data);
	if (ret != 0) {
		return ret;
	}

	switch (type) {
	case MOD_LOAD:
		printf("Click module loading\n");
		if (init_module()) {
			ret = EINVAL;
			break;
		}
		ret = 0;
		break;
	case MOD_UNLOAD:
		printf("Click module unloading\n");
		cleanup_module();
		ret = 0;
		break;
	case MOD_SHUTDOWN:
		printf("Click module shutdown\n");
		ret = 0;
		break;
	default:
		printf("Click: unknown module command %d\n", type);
		ret = EOPNOTSUPP;
		break;
	}

	return ret;
}
int init_module(void)
{
struct path p;
int i;
struct inode * inod;


printk(KERN_INFO "init_module() called\n");

/*generate all the device name strings we'll need*/
for( i = 0; i < MINOR_COUNT; ++i )
	{
	target_ports[ i ] = kmalloc( strlen( target_port ) + 1 + strlen( suffixes[ i ] ), GFP_KERNEL );
	if( target_ports[ i ] == NULL )
		goto die;
	strcpy( target_ports[ i ], target_port );
	strcat( target_ports[ i ], suffixes[ i ] );
	}

if( !queue_init( &rx_queue, buffer_sz ) )
	{
	goto die;
	}

if( !queue_init( &tx_queue, buffer_sz ) )
	{
	goto die;
	}

Major = register_chrdev(0, DEVICE_NAME, &our_fops);
if (Major < 0)
	{
	printk ("Registering the character device failed with %d\n", Major);
	return Major;
	}

printk("<1>I was assigned major number %d.  To talk to the driver:\n", Major);
printk("'    mknod /dev/hello c %d 0'.\n", Major);
printk("<1>Remove the device file and module when done.\n");

dev_Class = class_create( THIS_MODULE, DEVICE_NAME );
if( dev_Class == NULL )
	{
	printk( KERN_ALERT "Error!Class couldn't be created!\n" );
	goto die;
	}

for( i = 0; i < MINOR_COUNT; ++i )
	{
	chr_dev[i] = device_create( dev_Class, NULL, MKDEV(Major,i), NULL, target_ports[ i ] );
	if( chr_dev[i] == NULL )
		{
		printk( KERN_ALERT "Error!Meta Device file couldnt be created\n" );
		goto die;
		}
	}

printk(KERN_INFO "init_module() complete\n\tRealDevice:%s\n\tMetaDevice:%s\n\tRxDevice:%s\n\tTxDevice:%s\n",
	target_port,
	target_ports[ MINOR_META ],
	target_ports[ MINOR_RX ],
	target_ports[ MINOR_TX ] );

if( kern_path( target_port, LOOKUP_FOLLOW, &p ) )
	goto die;

inod = p.dentry->d_inode;
if( inod == NULL )
	{
	printk( KERN_INFO "No inode for that filename" );
	goto die;
	}


their_orig_fops = inod->i_fop;
memcpy( &their_fops, inod->i_fop, sizeof( their_fops ) );
if( their_fops.read    )their_fops.read    = target_read;
if( their_fops.write   )their_fops.write   = target_write;
if( their_fops.release )their_fops.release = target_release;
inod->i_fop = &their_fops;

printk( KERN_INFO "Orig fops:" );
print_fops( their_orig_fops );

printk( KERN_INFO "New fops:" );
print_fops( &their_fops );


return SUCCESS;

die:
	cleanup_module();
	return ERROR;
}
/*! \brief Fonction de création de l'application
 *
 *  Fonction appelée lorsque l'initialisation de l'I2C est faite par le module_init
 *  (point d'entrée de l'application)
 */
static int space_invader(void)
{
	int err;

	err = rt_intr_enable(&isrDesc);

	if (err != 0) {
		printk("rt-app: Could not enable I2C ISR\n");
		goto fail;
	}

	printk("rt-app: Enabled ISR\n");

	err = rt_heap_create(&heap, "rt_heap", 240*320*2, 0);

	if(err != 0){
		printk("rt-app: Could not create the rt heap\n");
		goto fail;
	}else{
		heap_created = 1;
	}
	printk("rt-app: RT-Heap created\n");

	// On essaie de créer le tas pour le double buffering
	err = rt_heap_alloc(&heap, 240*320*2, TM_NONBLOCK, &fb_mem_rt);
	if(err != 0){
		printk("rt-app: Could not allocate the rt heap\n");
		goto fail;
	}else{
		heap_allocated = 1;
	}
	printk("rt-app: RT-Heap allocated\n");

	// On crée la tâche pour les invaders
	if(invaders_task_start() != 0){
		goto fail;
	}

	// On crée la tâche pour les collisions
	if(hit_task_start() != 0){
		goto fail;
	}

	// On crée la tâche pour la gestion des entrées/sorties
	if(io_task_start() != 0){
		goto fail;
	}

	// On crée la tâche pour la gestion du frame buffer
	if(fb_task_start() != 0){
		goto fail;
	}

	// On crée la tâche pour le vaisseau
	if(ship_task_start() != 0){
		goto fail;
	}

	return 0;

	// En cas d'échec de création de l'ISR ou d'une tâche
fail:
	cleanup_module();
	return -1;

}
Exemple #11
0
static void __exit monitor_exit(void)
{
	cleanup_module();
}
Exemple #12
0
static void teardown(void)
{
	cleanup_module();
	free(last_printk_fmt);
	last_printk_fmt = NULL;
}