linux驱动开发前奏
1.驱动开发概述
驱动分类:
2.硬件访问技术
struct map_desc { unsigned long virtual; /* 映射后的虚拟地址 */ unsigned long pfn; /* 物理地址所在的页帧号 */ unsigned long length; /* 映射长度 */ unsigned int type; /* 映射的设备类型 */ };pfn:利用_phys_to_pfn(物理地址)可以计算出物理地址所在的物理页帧号
问题2:内核启动时,在什么地方完成自动映射?
static struct map_desc s3c_iodesc[] __initdata = { ... };里面保存的全是这种映射关系,目录下还有个初始化函数如下:
void __init s3c64xx_init_io(struct map_desc *mach_desc, int size) { unsigned long idcode; /* initialise the io descriptors we need for initialisation */ iotable_init(s3c_iodesc, ARRAY_SIZE(s3c_iodesc)); ... }内部调用iotable_init完成映射
寄存器读写
unsigned ioread8(void *addr) unsigned ioread16(void *addr) unsigned ioread32(void *addr) unsigned readb(address) unsigned readw(address) unsigned readw(address) unsigned readl(address)
void iowrite8(u8 value, void *addr) void iowrite16(u16 value, void *addr) void iowrite32(u32 value, void *addr) void writeb(unsigned value, address) void writew(unsigned value, address) void writel(unsigned value, address)
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。