I have written a program that access memory in user space. It worked up to kernel version 1.2.13. But when I tried compiling the program under kernel 2.0.30 using Slackware 3.4 distribution, I get a map error 22. Does anybody have any suggestions to correct this?
This is the function I wrote to access the memory.
long *get_memspace() { int mem_fd; long *mem; long *gmem; long *start; if((mem_fd = open("/dev/mem",O_RDWR))<0) { printf("Can't open /dev/mem\n"); exit(-1); } if((mem = malloc(16384)) == NULL) { printf("Allocation error.\n"); exit(-1); }
mem = (unsigned char *)mmap((caddr_t)mem,16384,PROT_READ | PROT_WRITE, MAP_SHARED | MAP_FIXED, mem_fd,0xd0000);
if((long)mem <0) { printf("map error. %d\n",errno); exit(-1); } fprintf(stderr,"%lx\n",mem); return(mem); }
|