src/video/fbcon/SDL_fbvideo.c
branchSDL-1.2
changeset 3917 8a3a0f1179f3
parent 1837 6987e947c77a
child 3923 0dd8bdf173e2
equal deleted inserted replaced
3916:16f7767f9580 3917:8a3a0f1179f3
   147 /* Internal palette functions */
   147 /* Internal palette functions */
   148 static void FB_SavePalette(_THIS, struct fb_fix_screeninfo *finfo,
   148 static void FB_SavePalette(_THIS, struct fb_fix_screeninfo *finfo,
   149                                   struct fb_var_screeninfo *vinfo);
   149                                   struct fb_var_screeninfo *vinfo);
   150 static void FB_RestorePalette(_THIS);
   150 static void FB_RestorePalette(_THIS);
   151 
   151 
       
   152 static int SDL_getpagesize(void)
       
   153 {
       
   154 #ifdef HAVE_GETPAGESIZE
       
   155 	return getpagesize();
       
   156 #elif defined(PAGE_SIZE)
       
   157 	return PAGE_SIZE;
       
   158 #else
       
   159 #error Can not determine system page size.
       
   160 	return 4096;  /* this is what it USED to be in Linux... */
       
   161 #endif
       
   162 }
       
   163 
       
   164 
   152 /* Small wrapper for mmap() so we can play nicely with no-mmu hosts
   165 /* Small wrapper for mmap() so we can play nicely with no-mmu hosts
   153  * (non-mmu hosts disallow the MAP_SHARED flag) */
   166  * (non-mmu hosts disallow the MAP_SHARED flag) */
   154 
   167 
   155 static void *do_mmap(void *start, size_t length, int prot, int flags, int fd, off_t offset)
   168 static void *do_mmap(void *start, size_t length, int prot, int flags, int fd, off_t offset)
   156 {
   169 {
   464 	}
   477 	}
   465 }
   478 }
   466 
   479 
   467 static int FB_VideoInit(_THIS, SDL_PixelFormat *vformat)
   480 static int FB_VideoInit(_THIS, SDL_PixelFormat *vformat)
   468 {
   481 {
       
   482 	const int pagesize = SDL_getpagesize();
   469 	struct fb_fix_screeninfo finfo;
   483 	struct fb_fix_screeninfo finfo;
   470 	struct fb_var_screeninfo vinfo;
   484 	struct fb_var_screeninfo vinfo;
   471 	int i, j;
   485 	int i, j;
   472 	int current_index;
   486 	int current_index;
   473 	unsigned int current_w;
   487 	unsigned int current_w;
   545 		}
   559 		}
   546 	}
   560 	}
   547 
   561 
   548 	/* Memory map the device, compensating for buggy PPC mmap() */
   562 	/* Memory map the device, compensating for buggy PPC mmap() */
   549 	mapped_offset = (((long)finfo.smem_start) -
   563 	mapped_offset = (((long)finfo.smem_start) -
   550 	                (((long)finfo.smem_start)&~(PAGE_SIZE-1)));
   564 	                (((long)finfo.smem_start)&~(pagesize-1)));
   551 	mapped_memlen = finfo.smem_len+mapped_offset;
   565 	mapped_memlen = finfo.smem_len+mapped_offset;
   552 	mapped_mem = do_mmap(NULL, mapped_memlen,
   566 	mapped_mem = do_mmap(NULL, mapped_memlen,
   553 	                  PROT_READ|PROT_WRITE, MAP_SHARED, console_fd, 0);
   567 	                  PROT_READ|PROT_WRITE, MAP_SHARED, console_fd, 0);
   554 	if ( mapped_mem == (char *)-1 ) {
   568 	if ( mapped_mem == (char *)-1 ) {
   555 		SDL_SetError("Unable to memory map the video hardware");
   569 		SDL_SetError("Unable to memory map the video hardware");