On Tue, 20 Jun 2000, David S. Miller wrote:
> Date: Tue, 20 Jun 2000 12:09:16 +0200 (CEST)
> From: Francis Galiegue <fg@mandrakesoft.com>
>
> All is in the subject...
>
> What kernel, and what is trying to mmap it (the X server I presume)?
>
Kernel is 2.2.16, and trying to mmap() from a custom application. The following
code works for ALL machines except the Ultra5 with the ATI framebuffer, and I
don't know why...
#include <stdio.h>
#include <fcntl.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/mman.h>
#include <sys/ioctl.h>
#include <linux/fb.h>
#define croak(x) do {\
perror(x);\
exit(1);\
} while (0)
int main(void) {
int fd;
char *foo;
struct fb_fix_screeninfo x;
struct fb_var_screeninfo v;
size_t screensize;
fd = open("/dev/fb0", O_RDWR);
if (fd == -1)
croak("open failed");
if (ioctl(fd, FBIOGET_VSCREENINFO, &v))
croak("ioctl FBIOGET_VSCREENINFO failed");
if (ioctl(fd, FBIOGET_FSCREENINFO, &x))
croak("ioctl FBIOGET_FSCREENINFO failed");
screensize = v.xres * v.yres * v.bits_per_pixel / 8;
foo = mmap(x.mmio_start, screensize, PROT_WRITE, MAP_SHARED, fd, 0);
if (foo == MAP_FAILED)
croak("mmap failed");
fprintf(stderr,"Success\n");
memset(foo, 0xaa, screensize);
sleep(5);
munmap(foo, screensize);
close(fd);
return 0;
}
-- fg"You can tune a filesystem but you can't tuna fish" (HP/UX' tunefs manpage)
- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/
This archive was generated by hypermail 2b29 : Fri Jun 23 2000 - 21:00:19 EST