微波EDA网,见证研发工程师的成长!
首页 > 硬件设计 > 嵌入式设计 > DMA操作驱动

DMA操作驱动

时间:11-21 来源:互联网 点击:

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

return 0;

}

static void s3c_dma_exit(void)

{

iounmap(dma_regs);

class_device_destroy(cls, MKDEV(major, 0));

class_destroy(cls);

unregister_chrdev(major, "s3c_dma");

dma_free_writecombine(NULL, BUF_SIZE, src, src_phys);

dma_free_writecombine(NULL, BUF_SIZE, dst, dst_phys);

free_irq(IRQ_DMA3, 1);

}

module_init(s3c_dma_init);

module_exit(s3c_dma_exit);

MODULE_LICENSE("GPL");

==================================================================

测试程序:

#include "stdio.h"

#include "sys/types.h"

#include "sys/stat.h"

#include "fcntl.h"

#include "sys/ioctl.h"

#include "string.h"

// ./dma_test nodma

// ./dma_test dma

//

#define MEM_CPY_NO_DMA 0

#define MEM_CPY_DMA 1

void print_usage(char *name)

{

printf("Usage:\n");

printf("%s \n", name);

}

int main(int argc, char **argv)

{

int fd;

if (argc != 2)

{

print_usage(argv[0]);

return -1;

}

fd = open("/dev/dma", O_RDWR);

if (fd < 0)

{

printf("cant open /dev/dma\n");

return -1;

}

if (strcmp(argv[1], "nodma") == 0)

{

while (1)

{

ioctl(fd, MEM_CPY_NO_DMA);

}

}

else if (strcmp(argv[1], "dma") == 0)

{

while (1)

{

ioctl(fd, MEM_CPY_DMA);

}

}

else

{

print_usage(argv[0]);

return -1;

}

return 0;

}


Copyright © 2017-2020 微波EDA网 版权所有

网站地图

Top