Linux下如何把IO空间映射到用户进程空间?
其实是个蛮简单的问题。在LDD3的第15章上有写(见“Remapping Specific I/O Regions”这一节)。不过当时作者选择了一个错误的做法:先把这块IO空间用ioremap映射到了内核空间,然后在用户进程访问被映射的地址所产 生的缺页中断里,用vmalloc_to_page得到page,返回给用户进程。
然而,vmalloc_to_page没法用在ioremap所得到的地址上,因为IO空间根本就没有对应的Page结构,返回的page指针自然是不对的。
正确的做法是在mmap函数里,使用remap_pfn_range函数。代码如下。注意要设置一下vma->vm_pgoff为你要map的io空间的物理地址对应的页。
static int filter_mmap(struct file *filp, struct vm_area_struct *vma)
{
vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
vma->vm_pgoff = ( (u32)map_start >> PAGE_SHIFT);
if (remap_pfn_range(vma,
vma->vm_start,
vma->vm_pgoff,
vma->vm_end-vma->vm_start,
vma->vm_page_prot))
return -EAGAIN;
return 0;
}
相关文档:
原文地址:http://wanping.blogbus.com/logs/28663569.html
1、时间戳转换为正常显示的时间格式
Freebsd
系统下:
转换命令为:
date -r 1112173761 或者:date -r 1112173761 +"%Y-%m-%d %T %z"(年月日的格式不一样)
Linux
系统下:
转换命令:date -d '1970-01-01 UTC 11121 ......
转自 http://blog.china-pub.com/more.asp?name=uniware&id=35478
在Linux下产生并调试core文件
先看看我用的是个什么机器:
$ uname -a
Linux dev 2.4.21-9.30AXsmp #1 SMP Wed May 26 23:37:09 EDT 2004 i686 i686 i386 GNU/Linux
再看看默认的一些参数,注意core file size是个0,程序 ......
引导:
如需获得对 vmlinux 和 zimage 之间区别的极好解释,请在 Alessandro Rubini 编写的“Kernel Configuration: dealing with the unexpected(Linux Magazine)的一文中找到“Booting your kernel”一节。
有关内核、映像和引导过程的更多信息,请阅读中央昆士兰大学(Central Queensland Universit ......
这是在实验室搭建局域网时的配置写在这里吧,等在回忆那段大学生活时还是很美好的!
环境:外网IP 202.206.249.186 子网掩码 255.255.255.0 默认网关 202.206.249.1
内网IP192.168.0.1 子网掩码 255 ......