phys_addr_t hal_tui_video_space_alloc(void) { phys_addr_t base; size_t size; ion_exynos_contig_heap_info(ION_EXYNOS_ID_VIDEO, &base, &size); if (size > TUI_TOTAL_ALLOC_SZ) #ifdef CONFIG_SOC_EXYNOS5433 g_sec_tuiMemPool.size = TUI_TOTAL_ALLOC_SZ; #else g_tuiMemPool.size = TUI_TOTAL_ALLOC_SZ; #endif else
uint32_t hal_tui_video_space_alloc(void) { uint32_t base; uint32_t size; ion_exynos_contig_heap_info(ION_EXYNOS_ID_VIDEO, &base, &size); if (size > TUI_TOTAL_ALLOC_SZ) g_sec_tuiMemPool.size = TUI_TOTAL_ALLOC_SZ; else g_sec_tuiMemPool.size = size; /* Align base address by 16MB */ base = ((base + (TUI_ALIGN_16MB_SZ-1))/TUI_ALIGN_16MB_SZ * TUI_ALIGN_16MB_SZ); g_sec_tuiMemPool.pa = base; return base; }
static int reset_reason_mem_probe(struct platform_device *pdev) { int i; u32 reasons; char buf[128]; phys_addr_t base = 0; size_t size = 0; int ret = -EINVAL; pr_debug("Entering :%s\n", __func__); if (ion_exynos_contig_heap_info(ION_EXYNOS_ID_RESET_REASON, &base, &size)) return -EINVAL; g_reset_reason_phy_addr = base; g_reset_reason_mem_size = size; /*check reset reason*/ reasons = __raw_readl(EXYNOS_PMU_RST_STAT); strlcpy(resetreason, "Last reset was: ", sizeof(resetreason)); for (i = 0; i < ARRAY_SIZE(hw_resetreason_flags); i++) { if (reasons & hw_resetreason_flags[i].mask) strlcat(resetreason, hw_resetreason_flags[i].str, sizeof(resetreason)); } snprintf(buf, sizeof(buf), " reset (RST_STAT=0x%x)\n", reasons); strlcat(resetreason, buf, sizeof(resetreason)); pr_info("%s", resetreason); /*Register record mem driver*/ if (!g_reset_reason_phy_addr || !g_reset_reason_mem_size) { ret = -ENOMEM; dev_err(&pdev->dev, "The memory address and size must be non-zero\n"); goto err_out; } resetinfoPtr = reset_reason_ram_vmap(g_reset_reason_phy_addr, g_reset_reason_mem_size); if (!resetinfoPtr) { ret = -EINVAL; dev_err(&pdev->dev, "Failed to map memory\n"); goto err_out; } if (resetinfoPtr->magic != RESET_REASON_MEM_MAGIC) { pr_info("%s The ram which record reasons was damaged\n", __func__); memset(resetinfoPtr, 0, sizeof(struct reset_info)); resetinfoPtr->magic = RESET_REASON_MEM_MAGIC; } /*inc reset reason, ignore software reset*/ for (i = 1; i < ARRAY_SIZE(hw_resetreason_flags); i++) { if (reasons & hw_resetreason_flags[i].mask) inc_reset_reason(hw_resetreason_flags[i].flag); } proc_create("reset_reason", S_IFREG | S_IRUGO, NULL, &proc_resetreason_operations); return 0; err_out: return ret; }
static long secmem_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) { struct secmem_info *info = filp->private_data; static int nbufs = 0; switch (cmd) { case SECMEM_IOC_GET_CHUNK_NUM: { nbufs = sizeof(secmem_regions) / sizeof(uint32_t); if (nbufs == 0) return -ENOMEM; if (copy_to_user((void __user *)arg, &nbufs, sizeof(int))) return -EFAULT; break; } case SECMEM_IOC_CHUNKINFO: { struct secchunk_info minfo; if (copy_from_user(&minfo, (void __user *)arg, sizeof(minfo))) return -EFAULT; memset(&minfo.name, 0, MAX_NAME_LEN); if (minfo.index < 0) return -EINVAL; if (minfo.index >= nbufs) { minfo.index = -1; /* No more memory region */ } else { if (ion_exynos_contig_heap_info(secmem_regions[minfo.index], &minfo.base, &minfo.size)) return -EINVAL; memcpy(minfo.name, secmem_regions_name[minfo.index], MAX_NAME_LEN); } if (copy_to_user((void __user *)arg, &minfo, sizeof(minfo))) return -EFAULT; break; } #if defined(CONFIG_ION) case SECMEM_IOC_GET_FD_PHYS_ADDR: { struct ion_client *client; struct secfd_info fd_info; struct ion_fd_data data; size_t len; if (copy_from_user(&fd_info, (int __user *)arg, sizeof(fd_info))) return -EFAULT; client = ion_client_create(ion_exynos, "DRM"); if (IS_ERR(client)) { pr_err("%s: Failed to get ion_client of DRM\n", __func__); return -ENOMEM; } data.fd = fd_info.fd; data.handle = ion_import_dma_buf(client, data.fd); pr_debug("%s: fd from user space = %d\n", __func__, fd_info.fd); if (IS_ERR(data.handle)) { pr_err("%s: Failed to get ion_handle of DRM\n", __func__); ion_client_destroy(client); return -ENOMEM; } if (ion_phys(client, data.handle, &fd_info.phys, &len)) { pr_err("%s: Failed to get phys. addr of DRM\n", __func__); ion_client_destroy(client); ion_free(client, data.handle); return -ENOMEM; } pr_debug("%s: physical addr from kernel space = 0x%08x\n", __func__, (unsigned int)fd_info.phys); ion_free(client, data.handle); ion_client_destroy(client); if (copy_to_user((void __user *)arg, &fd_info, sizeof(fd_info))) return -EFAULT; break; } #endif case SECMEM_IOC_GET_DRM_ONOFF: smp_rmb(); if (copy_to_user((void __user *)arg, &drm_onoff, sizeof(int))) return -EFAULT; break; case SECMEM_IOC_SET_DRM_ONOFF: { int ret, val = 0; if (copy_from_user(&val, (int __user *)arg, sizeof(int))) return -EFAULT; mutex_lock(&drm_lock); if ((info->drm_enabled && !val) || (!info->drm_enabled && val)) { /* * 1. if we enabled drm, then disable it * 2. if we don't already hdrm enabled, * try to enable it. */ ret = drm_enable_locked(info, val); if (ret < 0) pr_err("fail to lock/unlock drm status. lock = %d\n", val); } mutex_unlock(&drm_lock); break; } case SECMEM_IOC_GET_CRYPTO_LOCK: { break; } case SECMEM_IOC_RELEASE_CRYPTO_LOCK: { break; } case SECMEM_IOC_SET_TZPC: { #if !defined(CONFIG_SOC_EXYNOS5422) && !defined(CONFIG_SOC_EXYNOS5430) struct protect_info prot; if (copy_from_user(&prot, (void __user *)arg, sizeof(struct protect_info))) return -EFAULT; mutex_lock(&smc_lock); exynos_smc((uint32_t)(0x81000000), 0, prot.dev, prot.enable); mutex_unlock(&smc_lock); #endif break; } default: return -ENOTTY; } return 0; }