文档详情

LINUX资源如何映射到内核虚拟空间.pdf

发布:2017-08-30约9.84千字共11页下载文档
文本预览下载声明
LINUX I/O 资源如何映射到内核虚拟空间 (1) 系统启动初始化时iotable_init()---------------------------- - MACHINE_START(AT91SAM9261EK,ATMELAT91SAM9261) ············································ .map_io =at91sam9261_map_io, ············································ MACHINE_END-------------------------------------- void__init at91sam9261_map_io(void) { iotable_init(at91sam9261_io_desc,ARRAY_SIZE(at91sam9261_io_desc)); }-------------------------------------- /* * System peripheral registers mappedat virtual address. */ static struct map_descat91sam9261_io_desc[]__initdata ={ { .virtual =AT91C_VA_BASE_SYS, .pfn =__phys_to_pfn(AT91C_BASE_AIC), .length =SZ_4K, .type = MT_DEVICE }, { .virtual =AT91C_VA_BASE_EBI, .pfn =__phys_to_pfn(AT91C_BASE_EBI), .length =SZ_4K, .type = MT_DEVICE }, ··········································· ··· }; ./linux/include/asm-arm/map.h----------------------- struct map_desc { unsigned longvirtual; unsigned long pfn; unsigned long length; unsigned inttype;//标志位:domain、read、write、cache、buffer }; #define__phys_to_pfn(paddr) ((paddr) PAGE_SHIFT) #define__pfn_to_phys(pfn) ((pfn) PAGE_SHIFT)----------- --------------------------- iotable_init()函数 ./arch/arm/mm/mm-armv.c循环调用create_mapping()函数完成IO 的虚拟地址到物理地址的 映射。 (2) 系统启动后,在驱动中ioremap()---------------------------- ---------- static struct platform_device *smdk2410_devices[]__initdata ={ s3c_device_usb,//片上的各个设备 s3c_device_lcd,//下面以s3c_device_lcd 为例 s3c_device_wdt, s3c_device_i2c, s3c_device_iis, };-------------------------------------- struct platform_devices3c_device_lcd ={ .name =s3c2410-lcd,//此处设备的命名应和相应驱动程序命名一致以实现driver bind .id =-1,//-1表示不支持同类多个设备 .num_resources=ARRAY_SIZE(s3c_lcd_resource), .resource =s3c_lcd_resource, .de ={ .dma_mask =s3c_device_lcd_dmamask, .coherent_dma_mask =0xffffffffUL } }; ------------------------------------- /* LCDController */ static struct resources3c_lcd_resource[] ={//LCD 的两个资源[0] ={ .start =S3C2410_PA_LCD, .end =
显示全部
相似文档