+
+ /* Map the GEM buffer for copy in/out to the simulator. */
+ struct drm_mode_map_dumb map = {
+ .handle = handle,
+ };
+ int ret = drmIoctl(fd, DRM_IOCTL_MODE_MAP_DUMB, &map);
+ if (ret) {
+ fprintf(stderr, "Failed to get MMAP offset: %d\n",
+ errno);
+ abort();
+ }
+ sim_bo->gem_vaddr = mmap(NULL, obj->base.size,
+ PROT_READ | PROT_WRITE, MAP_SHARED,
+ fd, map.offset);
+ if (sim_bo->gem_vaddr == MAP_FAILED) {
+ fprintf(stderr, "mmap of bo %d (offset 0x%016llx, size %d) failed\n",
+ handle, (long long)map.offset, (int)obj->base.size);
+ abort();
+ }