From fb3c3f30792ed3831932ae81755b080e5aee6a1d Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Fri, 8 Oct 2010 23:08:34 -0400 Subject: android: Use __mmap2 in winsys/svga. --- src/gallium/winsys/svga/drm/vmw_screen_ioctl.c | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) (limited to 'src/gallium/winsys/svga/drm/vmw_screen_ioctl.c') diff --git a/src/gallium/winsys/svga/drm/vmw_screen_ioctl.c b/src/gallium/winsys/svga/drm/vmw_screen_ioctl.c index d92ba389d3..847f2c789b 100644 --- a/src/gallium/winsys/svga/drm/vmw_screen_ioctl.c +++ b/src/gallium/winsys/svga/drm/vmw_screen_ioctl.c @@ -46,6 +46,24 @@ #include #include +#ifdef PIPE_OS_ANDROID +extern void* __mmap2(void*, size_t, int, int, int, size_t); + +#define MMAP2_SHIFT 12 +static INLINE void* vmw_mmap(void *addr, size_t size, int prot, int flags, int fd, unsigned long long offset) +{ + if ( offset & ((1UL << MMAP2_SHIFT)-1) ) { + errno = EINVAL; + return MAP_FAILED; + } + + return __mmap2(addr, size, prot, flags, fd, (size_t)(offset >> MMAP2_SHIFT)); +} + +#else +#define vmw_mmap(addr, size, prot, flags, fd, offset) mmap(addr, size, prot, flags, fd, offset) +#endif + struct vmw_region { SVGAGuestPtr ptr; @@ -106,7 +124,7 @@ vmw_ioctl_fifo_map(struct vmw_winsys_screen *vws, VMW_FUNC; - map = mmap(NULL, getpagesize(), PROT_READ, MAP_SHARED, + map = vmw_mmap(NULL, getpagesize(), PROT_READ, MAP_SHARED, vws->ioctl.drm_fd, fifo_offset); if (map == MAP_FAILED) { @@ -388,7 +406,7 @@ vmw_ioctl_region_map(struct vmw_region *region) region->ptr.gmrId, region->ptr.offset); if (region->data == NULL) { - map = mmap(NULL, region->size, PROT_READ | PROT_WRITE, MAP_SHARED, + map = vmw_mmap(NULL, region->size, PROT_READ | PROT_WRITE, MAP_SHARED, region->drm_fd, region->map_handle); if (map == MAP_FAILED) { debug_printf("%s: Map failed.\n", __FUNCTION__); -- cgit v1.2.3