Subject: kern/113: mmap of /dev/vga returns EINVAL
To: None <gnats-admin>
From: None <randy%sierra%dsndata@tssi.com>
List: netbsd-bugs
Date: 02/07/1994 07:35:02
>Number:         113
>Category:       kern
>Synopsis:       mmapping /dev/vga returns EINVAL
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    gnats-admin (Kernel Bug People)
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Mon Feb  7 07:35:01 1994
>Originator:     Randy Terbush
>Organization:
zyzzyva
>Release:        current-020494
>Environment:
	486/66 VLB
	16MB RAM
	75MB Swap
	SCSI
	S3 928 Video
System: NetBSD sierra 0.9a SIERRABT#3 i386

>Description:
	Using mmap to map /dev/vga in XFree86 returns EINVAL
>How-To-Repeat:
	
#include <stdio.h>
#include <fcntl.h>
#include <errno.h>
#include <sys/types.h>
#include <sys/mman.h>


main()
{
    int fd;
    caddr_t base;

    if ((fd = open("/dev/vga", O_RDWR)) < 0)
    {
	printf("checkDevMem: warning: failed to open /dev/vga (%s)\n",
	       strerror(errno));
	printf("\tlinear fb access unavailable\n");

	return(fd);
    }

/* Try to map a page at the VGA address */
    printf("fd = %d\n", fd);

    base = (caddr_t)mmap((caddr_t)0, 4096, PROT_READ|PROT_WRITE,
			 MAP_FILE, fd, (off_t)0xA0000);

    printf("base = %d\n", base);

    close(fd);

    if (base == (caddr_t)-1)
    {
	printf("checkDevMem: warning: failed to mmap /dev/vga (%s)\n",
	       strerror(errno));
	printf("\tlinear fb access unavailable\n");

	return((int) base);
    }
 
    munmap((caddr_t)base, 4096);
    return;
}

>Fix:

>Audit-Trail:
>Unformatted:


------------------------------------------------------------------------------