我正在尝试从物理地址读取。
printf函数的输出为空:“ value =”
我做错了什么?
int counter;
int fd;
char* mmap_res;
fd = open("/dev/mem", O_RDWR);
if (fd == -1)
{
printf("can not access /dev/mem\n" );
return -1;
}
mmap_res =
(char*)mmap(NULL, 4096, PROT_READ | PROT_WRITE,
MAP_SHARED, fd, 0x92000000);
for (counter = 0; counter < 10 ; counter++)
printf("value=%c\n",mmap_res[counter]);
if (mmap_res == MAP_FAILED)
{
printf("mmap failed\n" );
return -1;
}