summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChia-I Wu <olvaffe@gmail.com>2010-10-08 23:08:34 -0400
committerChia-I Wu <olvaffe@gmail.com>2011-03-16 20:18:39 +0800
commitfb3c3f30792ed3831932ae81755b080e5aee6a1d (patch)
treee3fe51e1d63951d668824f0870ab311bc2d4e772 /src
parentc60978b2e03e6c00896306e3faeb2a84916b494c (diff)
android: Use __mmap2 in winsys/svga.
Diffstat (limited to 'src')
-rw-r--r--src/gallium/winsys/svga/drm/vmw_screen_ioctl.c22
1 files changed, 20 insertions, 2 deletions
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 <errno.h>
#include <unistd.h>
+#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__);