This is the physical memory address, if you want to read/write physical memory, you can open this file using fopen() for open(), and read/write it. For example, you can read/write SMRAM at 0xa0000
However, it cannot read /dev/mem mmap after 0x101000, but you could use mmap to solve this problem. please see article.
http://my.opera.com/yangguangxiang/blog/2008/02/17/dev-mem
在2.4,可以直接打开/dev/mem,然后读取。
在2.6,直接打开/dev/mem后,只可以读取前0x101000部分的内容(ubuntu)。大约是1MB加4KB。读取后面的内容将出现"open not permitted"错误。
解决的方法是使用mmap()。routine如下:
f = open("/dev/mem", O_RDONLY);
my_mem = mmap (0, 0x1000, PROT_READ, MAP_SHARED, f, 0x34f000);
if (my_mem == MAP_FAILED)
printf("map failed %s\n",strerror(errno));
通过my_mem就可以得到0x101000之后的内存内容了。
No comments:
Post a Comment