Linux uio用户态编程

参考

The Userspace I/O HOWTO

实现

地址和大小是驱动中填入的,可由sysfs获取,在mapX中,mmap的偏移为pagesize的整数倍,

#define UIO_DEV 	"/dev/uio0"
#define UIO_ADDR 	"/sys/class/uio/uio0/maps/map0/addr"
#define UIO_SIZE 	"/sys/class/uio/uio0/maps/map0/size"
#define UIO_ADDR1 	"/sys/class/uio/uio0/maps/map1/addr"
#define UIO_SIZE1	"/sys/class/uio/uio0/maps/map1/size"

access_address = mmap(NULL, uio_size, PROT_READ | PROT_WRITE,
	MAP_SHARED, uio_fd, 0);
access_address_1 = mmap(NULL, uio_size_1, PROT_READ | PROT_WRITE,
	MAP_SHARED, uio_fd, getpagesize());

你可能感兴趣的:(linux应用开发)