The HyperNews Linux KHG Discussion Pages

Question: Map Error 22 on kernel 2.0.30

Forum: User-space device drivers
Keywords: mmap map error 22
Date: Thu, 07 May 1998 06:36:09 GMT
From: Ivan <galysh@juno.nrl.navy.mil>

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);
}

Ivan galysh@juno.nrl.navy.mil