Subject: is mmap on /dev/mem broken on sparc64?
To: None <port-sparc64@netbsd.org, current-users@netbsd.org>
From: Sean Davis <dive-nb@endersgame.net>
List: current-users
Date: 03/12/2005 16:57:00
Okay, I've tried about a million variations on this code... no luck with any
of them. Basically, I'm trying to mmap a specific region of memory with the
eventual goal of getting a ROM dump from an Adaptec 2940UW. But that is not
the problem. The problem is, even after I've gotten the offset of the card
ROM from pci_conf_read, I can't mmap() /dev/mem. I'm running at securelevel
1, which, according to the init manpage, means I should be able to mmap it
read-only. But, all mmap calls are giving me EINVAL. The code follows:


        if ((mem = open("/dev/mem", O_RDONLY))) {
                off_t offset;
                offset = pci_base + rom_base;
                printf("/dev/mem open as fd %d\n",mem);
                rom = mmap(NULL,0x20000,PROT_READ,MAP_SHARED,mem,offset);
                if (rom == MAP_FAILED)
                        printf("mmap failed: %s\n",strerror(errno));
                if (rom != (void *)0xffffffffffffffff) {
                        printf("mmap()'d ROM\n");
                        munmap(rom,0x20000);
                }
                close(mem);
        }

Any suggestions? or is mmap broken?

- Sean

--
 _
( ) ASCII Ribbon Campaign
 X
/ \ For Plain Text Email