int main (int argc, char *argv[]) { int err; /* Bind to a shared heap which has been created elsewhere, either in kernel or user-space. Here we cannot wait and the heap must be available at once, since the caller is not a Xenomai-enabled thread. The heap should have been created with the H_SHARED mode set. */ err = rt_heap_bind(&heap_desc,"SomeShmName",TM_NONBLOCK); if (err) fail(); /* Get the address of the shared memory segment. The "size" and "timeout" arguments are unused here. */ rt_heap_alloc(&heap_desc,0,TM_NONBLOCK,&shared_mem); /* ... */ }
/*! \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; }