Navigation Menu

Skip to content

Commit

Permalink
Date: Tue, 9 May 2006 23:01:49 -0400
Browse files Browse the repository at this point in the history
From: Mike Frysinger
Subject: [SDL] [patch] fall back to using MAP_PRIVATE with mmap() in fbcon dri

trying to use MAP_SHARED with mmap() on uClinux (aka non-mmu) hosts nowadays
will simply fail since the kernel disallows it ... falling back to using
MAP_PRIVATE on these hosts is acceptable ... as such, ive attached a patch
for the fbcon driver that will fall back to using MAP_PRIVATE if mmap() with
MAP_SHARED failed

going by a grep of MAP_SHARED, the only other drivers that utilize this flag
are video/wscons, video/ps2gs, and sound/dmaaudio ... i dont think these
would appear on a non-mmu host so the patch i wrote is restricted to just
SDL_fbvideo.c ...
-mike
  • Loading branch information
slouken committed May 10, 2006
1 parent 7aa11dd commit 2a8d225
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions src/video/fbcon/SDL_fbvideo.c
Expand Up @@ -149,6 +149,19 @@ static void FB_SavePalette(_THIS, struct fb_fix_screeninfo *finfo,
struct fb_var_screeninfo *vinfo);
static void FB_RestorePalette(_THIS);

/* Small wrapper for mmap() so we can play nicely with no-mmu hosts
* (non-mmu hosts disallow the MAP_SHARED flag) */

static void *do_mmap(void *start, size_t length, int prot, int flags, int fd, off_t offset)
{
void *ret;
ret = mmap(start, length, prot, flags, fd, offset);
if ( ret == (char *)-1 && (flags & MAP_SHARED) ) {
ret = mmap(start, length, prot,
(flags & ~MAP_SHARED) | MAP_PRIVATE, fd, offset);
}
}

/* FB driver bootstrap functions */

static int FB_Available(void)
Expand Down Expand Up @@ -535,7 +548,7 @@ static int FB_VideoInit(_THIS, SDL_PixelFormat *vformat)
mapped_offset = (((long)finfo.smem_start) -
(((long)finfo.smem_start)&~(PAGE_SIZE-1)));
mapped_memlen = finfo.smem_len+mapped_offset;
mapped_mem = mmap(NULL, mapped_memlen,
mapped_mem = do_mmap(NULL, mapped_memlen,
PROT_READ|PROT_WRITE, MAP_SHARED, console_fd, 0);
if ( mapped_mem == (char *)-1 ) {
SDL_SetError("Unable to memory map the video hardware");
Expand Down Expand Up @@ -579,7 +592,7 @@ static int FB_VideoInit(_THIS, SDL_PixelFormat *vformat)
ioctl(console_fd, FBIOPUT_VSCREENINFO, &vinfo);
if ( finfo.accel && finfo.mmio_len ) {
mapped_iolen = finfo.mmio_len;
mapped_io = mmap(NULL, mapped_iolen, PROT_READ|PROT_WRITE,
mapped_io = do_mmap(NULL, mapped_iolen, PROT_READ|PROT_WRITE,
MAP_SHARED, console_fd, mapped_memlen);
if ( mapped_io == (char *)-1 ) {
/* Hmm, failed to memory map I/O registers */
Expand Down

0 comments on commit 2a8d225

Please sign in to comment.