Created
February 19, 2015 06:22
-
-
Save run/73848de4b159539f4612 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <sys/mman.h> | |
#include <sys/types.h> | |
#include <sys/stat.h> | |
#include <fcntl.h> | |
#include <stdio.h> | |
#define PAGE_SIZE (4 * 1024) | |
#define KERNEL_PHY_ADDR 0x77128000 | |
int main() | |
{ | |
char *buf; | |
int fd; | |
fd = open(“/dev/mem”,O_RDWR); | |
if (fd == -1) | |
perror(“open”); | |
buf = mmap(0, PAGE_SIZE, | |
PROT_READ|PROT_WRITE, MAP_SHARED, | |
fd, KERNEL_PHY_ADDR); | |
if (buf == MAP_FAILED) | |
perror(“mmap”); | |
puts(buf); | |
munmap(buf,PAGE_SIZE); | |
close(fd); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment