コード例 #1
0
ファイル: shm.c プロジェクト: ArcEye/RTAI
int init_module (void)
{
	RTIME tick_period;
	RTIME now; 
#ifdef SHM_DEBUG
	int size = SHMSIZ ;
	unsigned long vaddr, paddr;
#endif
	shm = (int *)rtai_kmalloc(nam2num(SHMNAM), SHMSIZ);
	shm = (int *)rtai_kmalloc(nam2num(SHMNAM), SHMSIZ);
	shm = (int *)rtai_kmalloc(nam2num(SHMNAM), SHMSIZ);
	shm = (int *)rtai_kmalloc(nam2num(SHMNAM), SHMSIZ);
	if (shm == NULL)
		return -ENOMEM;
	memset(shm, 0, SHMSIZ);
#ifdef SHM_DEBUG
	/* Show physical addresses of */
	vaddr = (unsigned long)shm;
	while (size > 0)
	{
		paddr = kvirt_to_pa(vaddr);
		printk("vaddr=0x%lx paddr=0x%lx\n", vaddr, paddr); 
		vaddr += PAGE_SIZE;
		size -= PAGE_SIZE;
	}
#endif

	rt_task_init(&thread, fun, 0, STACK_SIZE, 0, 0, 0);
	tick_period = start_rt_timer(nano2count(TICK_PERIOD));
	now = rt_get_time();
	rt_task_make_periodic(&thread, now + tick_period, tick_period*PERIOD_COUNT);

	return 0;
}
コード例 #2
0
void* shm_handler(unsigned int srq, unsigned long arg) {
  switch (srq) {
  case CMD_RTAI_KMALLOC:
    do {
      struct rtai_kmalloc_desc *mem = (struct rtai_kmalloc_desc*)arg;
      return rtai_kmalloc(mem->name,mem->size);
    } while(0);
    break;
  case CMD_RTAI_KFREE:
    do {
      struct rtai_kfree_desc *mem = (struct rtai_kfree_desc*)arg;    
      rtai_kfree(mem->name);
      return 0;
    } while(0);    
    break;
  default:
    break;
  };
  return (void*)-EINVAL;
};