int alloc_device_open(hw_module_t const* module, const char* name, hw_device_t** device) { alloc_device_t *dev; dev = new alloc_device_t; if (NULL == dev) { return -1; } ump_result ump_res = ump_open(); if (UMP_OK != ump_res) { LOGE("UMP open failed"); delete dev; return -1; } /* initialize our state here */ memset(dev, 0, sizeof(*dev)); /* initialize the procs */ dev->common.tag = HARDWARE_DEVICE_TAG; dev->common.version = 0; dev->common.module = const_cast<hw_module_t*>(module); dev->common.close = alloc_device_close; dev->alloc = alloc_device_alloc; dev->free = alloc_device_free; *device = &dev->common; return 0; }
Bool maliSetupExa(ScreenPtr pScreen, ExaDriverPtr exa) { ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; MaliPtr fPtr = MALIPTR(pScrn); if (NULL == exa) { return FALSE; } TRACE_ENTER(); exa->exa_major = 2; exa->exa_minor = 0; exa->memoryBase = fPtr->fbmem; exa->maxX = fPtr->fb_lcd_var.xres_virtual; exa->maxY = fPtr->fb_lcd_var.yres_virtual; exa->flags = EXA_OFFSCREEN_PIXMAPS | EXA_HANDLES_PIXMAPS | EXA_SUPPORTS_PREPARE_AUX; exa->offScreenBase = (fPtr->fb_lcd_fix.line_length * fPtr->fb_lcd_var.yres); exa->memorySize = fPtr->fb_lcd_fix.smem_len; exa->pixmapOffsetAlign = 4096; exa->pixmapPitchAlign = 8; MALI_EXA_FUNC(PrepareSolid); MALI_EXA_FUNC(Solid); MALI_EXA_FUNC(DoneSolid); MALI_EXA_FUNC(PrepareCopy); MALI_EXA_FUNC(Copy); MALI_EXA_FUNC(DoneCopy); MALI_EXA_FUNC(CheckComposite); MALI_EXA_FUNC(PrepareComposite); MALI_EXA_FUNC(Composite); MALI_EXA_FUNC(DoneComposite); MALI_EXA_FUNC(WaitMarker); MALI_EXA_FUNC(CreatePixmap); MALI_EXA_FUNC(DestroyPixmap); MALI_EXA_FUNC(ModifyPixmapHeader); MALI_EXA_FUNC(PixmapIsOffscreen); MALI_EXA_FUNC(PrepareAccess); MALI_EXA_FUNC(FinishAccess); if (UMP_OK != ump_open()) { ERROR_MSG("failed to open UMP subsystem"); TRACE_EXIT(); return FALSE; } INFO_MSG("Mali EXA driver is loaded successfully"); TRACE_EXIT(); return TRUE; }
int gralloc_backend_register(private_handle_t* hnd) { int retval = -EINVAL; switch (hnd->flags & (private_handle_t::PRIV_FLAGS_USES_UMP | private_handle_t::PRIV_FLAGS_USES_ION)) { case private_handle_t::PRIV_FLAGS_USES_UMP: if (!s_ump_is_open) { ump_result res = ump_open(); // MJOLL-4012: UMP implementation needs a ump_close() for each ump_open if (res != UMP_OK) { AERR("Failed to open UMP library with res=%d", res); } s_ump_is_open = 1; } if (s_ump_is_open) { hnd->ump_mem_handle = ump_handle_create_from_secure_id(hnd->ump_id); if (UMP_INVALID_MEMORY_HANDLE != (ump_handle)hnd->ump_mem_handle) { hnd->base = ump_mapped_pointer_get(hnd->ump_mem_handle); if (0 != hnd->base) { hnd->lockState = private_handle_t::LOCK_STATE_MAPPED; hnd->writeOwner = 0; hnd->lockState = 0; return 0; } else { AERR("Failed to map UMP handle %p", hnd->ump_mem_handle ); } ump_reference_release((ump_handle)hnd->ump_mem_handle); } else { AERR("Failed to create UMP handle %p", hnd->ump_mem_handle ); } } break; case private_handle_t::PRIV_FLAGS_USES_ION: AERR("Gralloc does not support DMA_BUF. Unable to map memory for handle %p", hnd ); break; } return retval; }
int alloc_device_open(hw_module_t const *module, const char */*name*/, hw_device_t **device) { alloc_device_t *dev; dev = new alloc_device_t; if (NULL == dev) { return -1; } #if GRALLOC_ARM_UMP_MODULE ump_result ump_res = ump_open(); if (UMP_OK != ump_res) { AERR("UMP open failed with %d", ump_res); delete dev; return -1; } #endif /* initialize our state here */ memset(dev, 0, sizeof(*dev)); /* initialize the procs */ dev->common.tag = HARDWARE_DEVICE_TAG; dev->common.version = 0; dev->common.module = const_cast<hw_module_t *>(module); dev->common.close = alloc_device_close; dev->alloc = alloc_device_alloc; dev->free = alloc_device_free; #if GRALLOC_ARM_DMA_BUF_MODULE private_module_t *m = reinterpret_cast<private_module_t *>(dev->common.module); m->ion_client = ion_open(); if (m->ion_client < 0) { AERR("ion_open failed with %s", strerror(errno)); delete dev; return -1; } #endif *device = &dev->common; return 0; }
Rk30MaliDRI2 *Rk30MaliDRI2_Init(ScreenPtr pScreen) { int drm_fd; DRI2InfoRec info; if (!xf86LoadSubModule(xf86Screens[pScreen->myNum], "dri2")) return FALSE; if ((drm_fd = drmOpen("mali_drm", NULL)) < 0) { ErrorF("Rk30MaliDRI2_Init: drmOpen failed!\n"); return FALSE; } if (ump_open() != UMP_OK) { drmClose(drm_fd); ErrorF("Rk30MaliDRI2_Init: ump_open() != UMP_OK\n"); return FALSE; } info.version = 3; info.driverName = "rk30-mali"; info.deviceName = "/dev/dri/card0"; info.fd = drm_fd; info.CreateBuffer = MaliDRI2CreateBuffer; info.DestroyBuffer = MaliDRI2DestroyBuffer; info.CopyRegion = MaliDRI2CopyRegion; if (!DRI2ScreenInit(pScreen, &info)) { drmClose(drm_fd); return NULL; } else { Rk30MaliDRI2 *private = calloc(1, sizeof(Rk30MaliDRI2)); private->drm_fd = drm_fd; return private; }
static int gralloc_register_buffer(gralloc_module_t const* module, buffer_handle_t handle) { int err = 0; int retval = -EINVAL; void *vaddr; if (private_handle_t::validate(handle) < 0) { ALOGE("Registering invalid buffer, returning error"); return -EINVAL; } /* if this handle was created in this process, then we keep it as is. */ private_handle_t* hnd = (private_handle_t*)handle; #ifdef USE_PARTIAL_FLUSH if (hnd->flags & private_handle_t::PRIV_FLAGS_USES_UMP) { private_handle_rect *psRect; private_handle_rect *psFRect; psRect = (private_handle_rect *)calloc(1, sizeof(private_handle_rect)); psRect->handle = (int)hnd->ump_id; psRect->stride = (int)hnd->stride; psFRect = find_last_rect((int)hnd->ump_id); psFRect->next = psRect; } #endif if (hnd->pid == getpid()) return 0; if (hnd->flags & private_handle_t::PRIV_FLAGS_USES_ION) err = gralloc_map(module, handle, &vaddr); pthread_mutex_lock(&s_map_lock); if (!s_ump_is_open) { ump_result res = ump_open(); /* TODO: Fix a ump_close() somewhere??? */ if (res != UMP_OK) { pthread_mutex_unlock(&s_map_lock); ALOGE("Failed to open UMP library"); return retval; } s_ump_is_open = 1; } if (hnd->flags & private_handle_t::PRIV_FLAGS_USES_UMP) { hnd->ump_mem_handle = (int)ump_handle_create_from_secure_id(hnd->ump_id); if (UMP_INVALID_MEMORY_HANDLE != (ump_handle)hnd->ump_mem_handle) { hnd->base = (int)ump_mapped_pointer_get((ump_handle)hnd->ump_mem_handle); if (0 != hnd->base) { hnd->lockState = private_handle_t::LOCK_STATE_MAPPED; hnd->writeOwner = 0; hnd->lockState = 0; pthread_mutex_unlock(&s_map_lock); return 0; } else { ALOGE("Failed to map UMP handle"); } ump_reference_release((ump_handle)hnd->ump_mem_handle); } else { ALOGE("Failed to create UMP handle"); } } else if (hnd->flags & private_handle_t::PRIV_FLAGS_USES_PMEM) { pthread_mutex_unlock(&s_map_lock); return 0; } else if (hnd->flags & private_handle_t::PRIV_FLAGS_USES_IOCTL) { void* vaddr = NULL; if (gMemfd == 0) { gMemfd = open(PFX_NODE_MEM, O_RDWR); if (gMemfd < 0) { ALOGE("%s:: %s exynos-mem open error\n", __func__, PFX_NODE_MEM); return false; } } gralloc_map(module, handle, &vaddr); pthread_mutex_unlock(&s_map_lock); return 0; } else if (hnd->flags & private_handle_t::PRIV_FLAGS_USES_ION) { hnd->ump_mem_handle = (int)ump_handle_create_from_secure_id(hnd->ump_id); if (UMP_INVALID_MEMORY_HANDLE != (ump_handle)hnd->ump_mem_handle) { vaddr = (void*)ump_mapped_pointer_get((ump_handle)hnd->ump_mem_handle); if (0 != vaddr) { hnd->lockState = private_handle_t::LOCK_STATE_MAPPED; hnd->writeOwner = 0; hnd->lockState = 0; pthread_mutex_unlock(&s_map_lock); return 0; } else { ALOGE("Failed to map UMP handle"); } ump_reference_release((ump_handle)hnd->ump_mem_handle); } else { ALOGE("Failed to create UMP handle"); } } else { ALOGE("registering non-UMP buffer not supported"); } pthread_mutex_unlock(&s_map_lock); return retval; }
static int gralloc_register_buffer(gralloc_module_t const *module, buffer_handle_t handle) { MALI_IGNORE(module); if (private_handle_t::validate(handle) < 0) { AERR("Registering invalid buffer 0x%p, returning error", handle); return -EINVAL; } // if this handle was created in this process, then we keep it as is. private_handle_t *hnd = (private_handle_t *)handle; int retval = -EINVAL; pthread_mutex_lock(&s_map_lock); #if GRALLOC_ARM_UMP_MODULE if (!s_ump_is_open) { ump_result res = ump_open(); // MJOLL-4012: UMP implementation needs a ump_close() for each ump_open if (res != UMP_OK) { pthread_mutex_unlock(&s_map_lock); AERR("Failed to open UMP library with res=%d", res); return retval; } s_ump_is_open = 1; } #endif hnd->pid = getpid(); if (hnd->flags & private_handle_t::PRIV_FLAGS_FRAMEBUFFER) { AERR("Can't register buffer 0x%p as it is a framebuffer", handle); } else if (hnd->flags & private_handle_t::PRIV_FLAGS_USES_UMP) { #if GRALLOC_ARM_UMP_MODULE hnd->ump_mem_handle = (int)ump_handle_create_from_secure_id(hnd->ump_id); if (UMP_INVALID_MEMORY_HANDLE != (ump_handle)hnd->ump_mem_handle) { hnd->base = ump_mapped_pointer_get((ump_handle)hnd->ump_mem_handle); if (0 != hnd->base) { hnd->lockState = private_handle_t::LOCK_STATE_MAPPED; hnd->writeOwner = 0; hnd->lockState = 0; pthread_mutex_unlock(&s_map_lock); return 0; } else { AERR("Failed to map UMP handle 0x%x", hnd->ump_mem_handle); } ump_reference_release((ump_handle)hnd->ump_mem_handle); } else { AERR("Failed to create UMP handle 0x%x", hnd->ump_mem_handle); } #else AERR("Gralloc does not support UMP. Unable to register UMP memory for handle 0x%p", hnd); #endif } else if (hnd->flags & private_handle_t::PRIV_FLAGS_USES_ION) { #if GRALLOC_ARM_DMA_BUF_MODULE int ret; unsigned char *mappedAddress; size_t size = hnd->size; hw_module_t *pmodule = NULL; private_module_t *m = NULL; if (hw_get_module(GRALLOC_HARDWARE_MODULE_ID, (const hw_module_t **)&pmodule) == 0) { m = reinterpret_cast<private_module_t *>(pmodule); } else { AERR("Could not get gralloc module for handle: 0x%p", hnd); retval = -errno; goto cleanup; } /* the test condition is set to m->ion_client <= 0 here, because: * 1) module structure are initialized to 0 if no initial value is applied * 2) a second user process should get a ion fd greater than 0. */ if (m->ion_client <= 0) { /* a second user process must obtain a client handle first via ion_open before it can obtain the shared ion buffer*/ m->ion_client = ion_open(); if (m->ion_client < 0) { AERR("Could not open ion device for handle: 0x%p", hnd); retval = -errno; goto cleanup; } } mappedAddress = (unsigned char *)mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED, hnd->share_fd, 0); if (MAP_FAILED == mappedAddress) { AERR("mmap( share_fd:%d ) failed with %s", hnd->share_fd, strerror(errno)); retval = -errno; goto cleanup; } hnd->base = mappedAddress + hnd->offset; pthread_mutex_unlock(&s_map_lock); return 0; #endif } else { AERR("registering non-UMP buffer not supported. flags = %d", hnd->flags); } cleanup: pthread_mutex_unlock(&s_map_lock); return retval; }
gboolean platform_alloc_eglimage (EGLDisplay display, EGLContext context, GLint format, GLint type, gint width, gint height, GLuint tex_id, EGLImageKHR * image, gpointer * image_platform_data) { fbdev_pixmap pixmap; pixmap.flags = FBDEV_PIXMAP_SUPPORTS_UMP; pixmap.width = width; pixmap.height = height; switch (format) { case GL_LUMINANCE: g_return_val_if_fail (type == GL_UNSIGNED_BYTE, FALSE); pixmap.red_size = 0; pixmap.green_size = 0; pixmap.blue_size = 0; pixmap.alpha_size = 0; pixmap.luminance_size = 8; break; case GL_LUMINANCE_ALPHA: g_return_val_if_fail (type == GL_UNSIGNED_BYTE, FALSE); pixmap.red_size = 0; pixmap.green_size = 0; pixmap.blue_size = 0; pixmap.alpha_size = 8; pixmap.luminance_size = 8; break; case GL_RGB: if (type == GL_UNSIGNED_BYTE) { pixmap.red_size = 8; pixmap.green_size = 8; pixmap.blue_size = 8; pixmap.alpha_size = 0; pixmap.luminance_size = 0; } else if (type == GL_UNSIGNED_SHORT_5_6_5) { pixmap.red_size = 5; pixmap.green_size = 6; pixmap.blue_size = 5; pixmap.alpha_size = 0; pixmap.luminance_size = 0; } else { g_return_val_if_reached (FALSE); } break; case GL_RGBA: g_return_val_if_fail (type == GL_UNSIGNED_BYTE, FALSE); pixmap.red_size = 8; pixmap.green_size = 8; pixmap.blue_size = 8; pixmap.alpha_size = 8; pixmap.luminance_size = 0; break; default: g_assert_not_reached (); return FALSE; } pixmap.buffer_size = pixmap.red_size + pixmap.green_size + pixmap.blue_size + pixmap.alpha_size + pixmap.luminance_size; pixmap.bytes_per_pixel = pixmap.buffer_size / 8; pixmap.format = 0; if (ump_open () != UMP_OK) { GST_ERROR ("Failed to open UMP"); return FALSE; } pixmap.data = ump_ref_drv_allocate (GST_ROUND_UP_4 (pixmap.width) * pixmap.height * pixmap.bytes_per_pixel, UMP_REF_DRV_CONSTRAINT_PHYSICALLY_LINEAR); if (pixmap.data == UMP_INVALID_MEMORY_HANDLE) { GST_ERROR ("Failed to allocate pixmap data via UMP"); ump_close (); return FALSE; } *image_platform_data = g_slice_dup (fbdev_pixmap, &pixmap); *image = eglCreateImageKHR (display, EGL_NO_CONTEXT, EGL_NATIVE_PIXMAP_KHR, (EGLClientBuffer) * image_platform_data, NULL); if (!image) { GST_ERROR ("Failed to create EGLImage for pixmap"); ump_reference_release ((ump_handle) pixmap.data); ump_close (); g_slice_free (fbdev_pixmap, *image_platform_data); return FALSE; } return TRUE; }
static int gralloc_register_buffer(gralloc_module_t const* module, buffer_handle_t handle) { if (private_handle_t::validate(handle) < 0) { LOGE("Registering invalid buffer, returning error"); return -EINVAL; } // if this handle was created in this process, then we keep it as is. private_handle_t* hnd = (private_handle_t*)handle; if (hnd->pid == getpid()) { return 0; } int retval = -EINVAL; pthread_mutex_lock(&s_map_lock); if (!s_ump_is_open) { ump_result res = ump_open(); // TODO: Fix a ump_close() somewhere??? if (res != UMP_OK) { pthread_mutex_unlock(&s_map_lock); LOGE("Failed to open UMP library"); return retval; } s_ump_is_open = 1; } if (hnd->flags & private_handle_t::PRIV_FLAGS_USES_UMP) { hnd->ump_mem_handle = (int)ump_handle_create_from_secure_id(hnd->ump_id); if (UMP_INVALID_MEMORY_HANDLE != (ump_handle)hnd->ump_mem_handle) { hnd->base = (int)ump_mapped_pointer_get((ump_handle)hnd->ump_mem_handle); if (0 != hnd->base) { hnd->lockState = private_handle_t::LOCK_STATE_MAPPED; hnd->writeOwner = 0; hnd->lockState = 0; pthread_mutex_unlock(&s_map_lock); return 0; } else { LOGE("Failed to map UMP handle"); } ump_reference_release((ump_handle)hnd->ump_mem_handle); } else { LOGE("Failed to create UMP handle"); } } else { LOGE("registering non-UMP buffer not supported"); } pthread_mutex_unlock(&s_map_lock); return retval; }
void Rk30MaliDRI2_Init(ScreenPtr pScreen) { int drm_fd; DRI2InfoRec info; ump_secure_id ump_id1, ump_id2; ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; FBDevPtr pMxv = FBDEVPTR(pScrn); Bool isOverlay = TRUE; #if DRI2INFOREC_VERSION >= 4 const char *driverNames[1]; #endif pMxv->Rk30Mali = NULL; if(pMxv->OvlHW == NULL){ xf86DrvMsg(pScreen->myNum, X_ERROR, "Rk30MaliDRI2_Init: Overlay not found!\n"); return; } OvlHWPtr overlay = pMxv->OvlHW; if (!xf86LoadKernelModule("ump")) xf86DrvMsg(pScreen->myNum, X_INFO, "can't load 'ump' kernel module\n"); if (!xf86LoadKernelModule("disp_ump")) xf86DrvMsg(pScreen->myNum, X_INFO, "can't load 'disp_ump' kernel module\n"); if (!xf86LoadKernelModule("mali")) xf86DrvMsg(pScreen->myNum, X_INFO, "can't load 'mali' kernel module\n"); if (!xf86LoadKernelModule("drm")) xf86DrvMsg(pScreen->myNum, X_INFO, "can't load 'drm' kernel module\n"); if (!xf86LoadKernelModule("mali_drm")) xf86DrvMsg(pScreen->myNum, X_INFO, "can't load 'mali_drm' kernel module\n"); if (!xf86LoadSubModule(xf86Screens[pScreen->myNum], "dri2")) return; if ((drm_fd = drmOpen("mali_drm", NULL)) < 0) { xf86DrvMsg(pScreen->myNum, X_ERROR, "Rk30MaliDRI2_Init: drmOpen failed!\n"); return; } if (ump_open() != UMP_OK) { xf86DrvMsg(pScreen->myNum, X_ERROR, "Rk30MaliDRI2_Init: ump_open() != UMP_OK\n"); goto err0; } if(!(pMxv->Rk30Mali = calloc(1, sizeof(Rk30MaliRec) ))){ xf86DrvMsg(pScreen->myNum, X_ERROR, "Rk30MaliDRI2_Init: Mem alloc failed!\n"); goto err0; } Rk30MaliPtr rk_3d = pMxv->Rk30Mali; rk_3d->PMemBuf = OvlAllocMemPg(pScrn, BUF_MEM); if(rk_3d->PMemBuf == NULL){ xf86DrvMsg(pScreen->myNum, X_INFO, "Alloc fb buf failed\n"); goto err1; } ump_id1 = rk_3d->PMemBuf->ump_fb_secure_id; if (ump_id1 == UMP_INVALID_SECURE_ID) { xf86DrvMsg(pScreen->myNum, X_INFO, "GET_UMP_SECURE_ID failed\n"); goto err1; } if (isOverlay){ xf86DrvMsg(pScreen->myNum, X_INFO, "HW overlay for 3D activated\n"); } else xf86DrvMsg(pScreen->myNum, X_INFO, "HW overlay for 3D not usable\n"); info.version = 3; info.driverName = "rk30-mali"; info.deviceName = "/dev/dri/card0"; info.fd = drm_fd; info.CreateBuffer = MaliDRI2CreateBuffer; info.DestroyBuffer = MaliDRI2DestroyBuffer; info.CopyRegion = MaliDRI2CopyRegion; /* #if DRI2INFOREC_VERSION >= 4 Bool USE_PAGEFLIP = TRUE; if (USE_PAGEFLIP) { info.version = 4; info.ScheduleSwap = MaliDRI2ScheduleSwap; info.GetMSC = NULL; info.ScheduleWaitMSC = NULL; info.numDrivers = 1; info.driverNames = driverNames; driverNames[0] = info.driverName; } #endif */ if (DRI2ScreenInit(pScreen, &info)){ /* Wrap the current DestroyWindow function */ rk_3d->DestroyWindow = pScreen->DestroyWindow; pScreen->DestroyWindow = DestroyWindow; /* Wrap the current PostValidateTree function */ // rk_3d->PostValidateTree = pScreen->PostValidateTree; // pScreen->PostValidateTree = PostValidateTree; /* Wrap the current GetImage function */ // rk_3d->GetImage = pScreen->GetImage; // pScreen->GetImage = GetImage; /* Wrap the current DestroyPixmap function */ rk_3d->DestroyPixmap = pScreen->DestroyPixmap; pScreen->DestroyPixmap = DestroyPixmap; rk_3d->ump_fb_secure_id1 = ump_id1; // rk_3d->ump_fb_secure_id2 = ump_id2; rk_3d->drm_fd = drm_fd; rk_3d->ovl_x = 0; rk_3d->ovl_y = 0; rk_3d->ovl_w = 0; rk_3d->ovl_h = 0; // rk_3d->lstatus = ST_INIT; // rk_3d->ovl_cr = FALSE; rk_3d->buf_back = NULL; rk_3d->OvlPg = ERRORL; return; } xf86DrvMsg(pScreen->myNum, X_ERROR, "Rk30MaliDRI2_Init: DRI2ScreenInit failed!\n"); err2: OvlFreeMemPg(pScrn, rk_3d->PMemBuf); err1: free(rk_3d); err0: drmClose(drm_fd); }
int main(int argc, char *argv[]) { int result = EXIT_FAILURE; if (UMP_OK == ump_open()) { const int SZ_4KB = 4096; const int alloc_size = 16 * SZ_4KB; const int resize_1 = 1 * SZ_4KB; const int resize_2 = -9 * SZ_4KB; #define NUM_ALLOCS 128 ump_handle h[NUM_ALLOCS]; int i; for (i = 0; i < NUM_ALLOCS; i++) { h[i] = UMP_INVALID_MEMORY_HANDLE; } for (i = 0; i < NUM_ALLOCS; i++) { u8 * p; h[i] = ump_allocate(alloc_size, UMP_PROT_CPU_RD | UMP_PROT_CPU_WR | UMP_HINT_CPU_RD | UMP_HINT_CPU_WR | UMP_PROT_W_RD | UMP_PROT_W_WR); if (UMP_INVALID_MEMORY_HANDLE == h[i]) { printf("Failed to allocate\n"); break; } p = ump_map(h[i], 0, alloc_size); if (NULL != p) { STDLIB_MEMSET(p, 0xFF, alloc_size); ump_cpu_msync_now(h[i], UMP_MSYNC_CLEAN, p, alloc_size); ump_unmap(h[i], p, alloc_size); } else { printf("Failed to map\n"); break; } } if (i == NUM_ALLOCS) { int resize_failure = 0; printf("%d allocations succeeded\n", NUM_ALLOCS); for (i = 0; i < NUM_ALLOCS; i++) { ump_secure_id check_id; check_id = ump_secure_id_get(h[i]); if (UMP_INVALID_SECURE_ID == check_id) { printf("Handle %d has an invalid secure id!\n", i); } else { int j; for (j = i + 1; j < NUM_ALLOCS; j++) { ump_secure_id id; id = ump_secure_id_get(h[j]); if (id == check_id) { printf("Duplicate IDs found for handles %d and %d, both have %u\n", i, j, id); } } } } printf("doing resize check\n"); for (i = 0; i < NUM_ALLOCS; i++) { u64 new_size; ump_resize_result res; res = ump_resize(h[i], resize_1, &new_size); if (UMP_RESIZE_OK != res) { printf("resize failed with error code 0x%08X\n", res); resize_failure++; } else { if (new_size != (alloc_size + resize_1)) { printf("Hmm, the new size isn't what I expected: %llu != %d\n", (unsigned long long)new_size, alloc_size + resize_1); resize_failure++; } else { int j; u8 * map; map = (u8*)ump_map(h[i], 0, new_size); if (NULL == map) { resize_failure++; /* record this as a resize failure */ break; } for (j = 0; j < alloc_size; j++) { if (map[j] != 0xFF) { printf("Expected 0xFF, have 0x%02X\n", map[j]); resize_failure++; } } for (j = alloc_size; j < new_size; j++) { if (map[j] != 0) { printf("Expected 0x00, have 0x%02X\n", map[j]); resize_failure++; } } ump_unmap(h[i], map, new_size); } res = ump_resize(h[i], resize_2, &new_size); if (UMP_RESIZE_OK != res) { printf("resize failed with error code 0x%08x\n", res); resize_failure++; } else { if (new_size != (alloc_size + resize_1 + resize_2)) { printf("Hmm, the new size isn't what I expected: %llu != %d\n", (unsigned long long)new_size, alloc_size + resize_1 + resize_2); resize_failure++; } else { int j; u8 * map; map = (u8*)ump_map(h[i], 0, new_size); if (NULL == map) { resize_failure++; break; } ump_cpu_msync_now(h[i], UMP_MSYNC_CLEAN_AND_INVALIDATE, map, new_size); for (j = 0; j < new_size; j++) { if (map[j] != 0xFF) { printf("expected 0xFF, have 0x%02X\n", map[j]); resize_failure++; } } ump_unmap(h[i], map, new_size); } } } } if (resize_failure) { printf("%d resize failures found\n", resize_failure); } else { printf("resize check OK\n"); result = EXIT_SUCCESS; } } for (i = 0; i < NUM_ALLOCS; i++) { ump_release(h[i]); } ump_close(); } return result; }