mike@BUCASB.BU.EDU (08/25/89)
I simulated the Sun Server bug in a short bit of code. I got identical behavior to real thing. Eric if you are maintaining X11R3 here, please fix. A description of the bug follows in detail for the athena people. This concerns a bug I discovered in X11R3 Sun Server Code. The problems concern the interactions in the initialization of a frame buffer using /dev/bwtwo0 for an X server. The problem concerns the interaction between the routines ../server/ddx/sun/{sunInit.c,sunBW.c}.and the fix is described below. The bug bug was detected on a Sun386i/150 with 4MB of memory. The routine sunOpenFrameBuffer in sunInit.c opens the appropriate frame buffer and does a FBIOGTYPE ioctl correctly returning the frame buffer description in the structure fbType. However, when memory is mapped to the frame buffer in the following mmap calls reference is not made the appropriate value returned by the ioctl telling the size of the frame buffer , fbtype.fb_size, but the reference is made to values defined in system include files <sundev/bw2reg.h> in particular to BW2_FBSIZE, and BW2_FBSIZE_HIRES indirectly referenced through sizeof(<variable>) where <variable> is defined by a typedef in terms of the above quantities. Although this turns out to be fine for large screen devices, for small screen devices (namely my 386i/150's), the initial mmap of the frame buffer returns with the error message, "Mapping BW2: No such device or address", because the frame buffer for the small screen is significantly smaller than the amount of memory which one is requesting to map. The fix is to use the quantity returned by the FBIOGTYPE ioctl, fbType.fb_size or if necessary some integral multiple in machine pages in subsequent mmap calls. Enclosed is a small piece of code which simulates the action of the Xsun server. Thanks to Phil Budne (budd@bu-it.bu.edu), for help in testing the server. This code generates the no error message on large screen devices but fails on small screen (1024 X 768) devices. -mike -----------------------------test routine------------------------------ # include <stdio.h> # include <sys/ioctl.h> # include <sun/fbio.h> # include <sundev/bw2reg.h> # include <sys/types.h> # include <sys/mman.h> # include <fcntl.h> # include <errno.h> # define Error perror typedef struct bw2 { u_char image[BW2_FBSIZE]; /* Pixel buffer */ } BW2, BW2Rec, *BW2Ptr; main() { extern caddr_t mmap(); int fd; BW2Ptr fbptr = NULL; struct fbtype fb; fd = open( "/dev/fb", O_RDWR, 0 ); # define P(f) printf("f: %d\n", fb.fb_/**/f) ioctl( fd, FBIOGTYPE, &fb ); P(type); P(height); P(width); P(depth); P(cmsize); P(size); fbptr = (BW2Ptr) mmap((caddr_t) 0, sizeof(BW2), PROT_READ | PROT_WRITE, MAP_SHARED | _MAP_NEW, fd, (off_t) 0); if ((int) fbptr == -1) { Error("mapping BW2"); (void) close(fd); } } ------------------------------------------------------------------------- Michael Cohen ---- Center for Adaptive Systems Boston University (617-353-7857) Email: mike@bucasb.bu.edu Smail: Michael Cohen Center for Adaptive System Department of Mathematics, Boston University 111 Cummington Street Boston, Mass 02215