Skip to content

Instantly share code, notes, and snippets.

@run
Created February 19, 2015 06:22
Show Gist options
  • Save run/73848de4b159539f4612 to your computer and use it in GitHub Desktop.
Save run/73848de4b159539f4612 to your computer and use it in GitHub Desktop.
#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