Date: Tue, 9 May 2006 23:01:49 -0400
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 --HG-- extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%401757
This commit is contained in:
parent
4ff931d2b7
commit
24dd26200f
1 changed files with 15 additions and 2 deletions
|
@ -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)
|
||||
|
@ -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");
|
||||
|
@ -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 */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue