DMA驅動程式

2021-06-18 14:40:08 字數 1217 閱讀 3593

在單cpu系統中,cpu同一時間只能做一件事,為了提高效率引入了dma。

下面的**用dma方式實現兩塊記憶體之間的資料傳輸

大概步驟如下:

1. 把源,目的,長度告訴dma

2.設定dma引數

a. 位址(增,減,固定)

b. 啟動方式(手工或外部)

3. 啟動dma

static int s3c_dma_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg)

else

break;

}case mem_cpy_dma :

else

break;}}

return 0;

}static struct file_operations dma_fops = ;

static irqreturn_t s3c_dma_irq(int irq, void *devid)

static int s3c_dma_init(void)

/* 分配src, dst對應的緩衝區 */

src = dma_alloc_writecombine(null, buf_size, &src_phys, gfp_kernel);

if (null == src)

dst = dma_alloc_writecombine(null, buf_size, &dst_phys, gfp_kernel);

if (null == dst)

major = register_chrdev(0, "s3c_dma", &dma_fops);

/* 為了自動建立裝置節點 */

cls = class_create(this_module, "s3c_dma");

class_device_create(cls, null, mkdev(major, 0), null, "dma"); /* /dev/dma */

dma_regs = ioremap(dma3_base_addr, sizeof(struct s3c_dma_regs));

return 0;

}static void s3c_dma_exit(void)

module_init(s3c_dma_init);

module_exit(s3c_dma_exit);

module_license("gpl");

linux 驅動程式 高階字元驅動程式

ioctl方法 驅動程式的原型實現 int ioctl struct inode inode,struct file filp,unsigned int cmd,unsigned long arg ioctl 命令選擇 位段結構 number direction ioc read ioc write...

linux裝置驅動程式 字元裝置驅動程式

先留個 有一起學習驅動程式的加qq295699450 字元裝置驅動 這篇比較惱火。載入成功,但是讀不出來資料,有知道怎麼回事的,留個言,一起討論下 資料結構 struct scull mem struct scull dev dev 整個驅動程式 如下 include include include...

Linux裝置驅動程式 字元裝置驅動程式

1.檢視主裝置號,次裝置號 進入 dev目錄執行ls l,第四,五列分別為主次裝置號,10,180,1,5,這些是主裝置號,而60,63這些就是次裝置號 130 shell android dev ls l crw rw r system radio 10,60 1969 12 31 21 00 a...