Tux
Communication
Mailing lists
Documentation
User Manual
Target board info.
Target chip info.
Support
Linux support
Bugzilla
Downloads
STLinux
Updates
Search
Google


The web
stlinux.com
Distribution Guide
STMicroelectronics DMA API
ST Logo
  Contents   Next
	unsigned long flags= 	  
				STM_DMA_SETUP_CONTEXT_TASK 
				| DIM_1_x_1
				| MODE_SH_COMPATIBILITY;
	
	unsigned long xfer_bytes =4096;
	void* src_buff = kmalloc(xfer_bytes,GFP_KERNEL);
	void * dst_buff = kmalloc(xfer_bytes,GFP_KERNEL);

	int ch_num = request_dma(0,__FUNCTION__);

	if(!ch_num ==0)
		return -ENODEV;
	
	if(src_buff){	
		memset(src_buff,0x4,xfer_bytes);
		
		dma_cache_wback(&src_buff[0],sizeof(u32)*xfer_bytes);	
		dma_cache_wback(&dst_buff[0],sizeof(u32)*xfer_bytes);	

			
		dma_configure_channel(ch_num,flags);
		dma_xfer(ch_num,
				virt_to_phys((void*)src_buff),
				virt_to_phys((void*)dst_buff)
				,xfer_bytes,
				MODE_SH_COMPATIBILITY);
		dma_wait_for_completion(ch_num);

		if(memcmp((void*)src_buff,(void*)dst_buff,xfer_bytes)!=0){
			dump_srcbuff(src_buff,xfer_bytes);
			dump_dstbuff(dst_buff,xfer_bytes);
			panic(" memory does not compare\n");
		}			
		printk("woken up from DMA  -  TEST OK\n");
		kfree((void*)src_buff);
		kfree((void*)dst_buff);
		free_dma(ch_num);
		
		return 0;	
	}
	return -ENOMEM;