📄 drm_ioc32.c
字号:
if (__get_user(s32.count, &stats->count)) return -EFAULT; for (i = 0; i < 15; ++i) if (__get_user(s32.data[i].value, &stats->data[i].value) || __get_user(s32.data[i].type, &stats->data[i].type)) return -EFAULT; if (copy_to_user(argp, &s32, sizeof(s32))) return -EFAULT; return 0;}typedef struct drm_buf_desc32 { int count; /**< Number of buffers of this size */ int size; /**< Size in bytes */ int low_mark; /**< Low water mark */ int high_mark; /**< High water mark */ int flags; u32 agp_start; /**< Start address in the AGP aperture */} drm_buf_desc32_t;static int compat_drm_addbufs(struct file *file, unsigned int cmd, unsigned long arg){ drm_buf_desc32_t __user *argp = (void __user *)arg; drm_buf_desc_t __user *buf; int err; unsigned long agp_start; buf = compat_alloc_user_space(sizeof(*buf)); if (!access_ok(VERIFY_WRITE, buf, sizeof(*buf)) || !access_ok(VERIFY_WRITE, argp, sizeof(*argp))) return -EFAULT; if (__copy_in_user(buf, argp, offsetof(drm_buf_desc32_t, agp_start)) || __get_user(agp_start, &argp->agp_start) || __put_user(agp_start, &buf->agp_start)) return -EFAULT; err = drm_ioctl(file->f_dentry->d_inode, file, DRM_IOCTL_ADD_BUFS, (unsigned long)buf); if (err) return err; if (__copy_in_user(argp, buf, offsetof(drm_buf_desc32_t, agp_start)) || __get_user(agp_start, &buf->agp_start) || __put_user(agp_start, &argp->agp_start)) return -EFAULT; return 0;}static int compat_drm_markbufs(struct file *file, unsigned int cmd, unsigned long arg){ drm_buf_desc32_t b32; drm_buf_desc32_t __user *argp = (void __user *)arg; drm_buf_desc_t __user *buf; if (copy_from_user(&b32, argp, sizeof(b32))) return -EFAULT; buf = compat_alloc_user_space(sizeof(*buf)); if (!access_ok(VERIFY_WRITE, buf, sizeof(*buf))) return -EFAULT; if (__put_user(b32.size, &buf->size) || __put_user(b32.low_mark, &buf->low_mark) || __put_user(b32.high_mark, &buf->high_mark)) return -EFAULT; return drm_ioctl(file->f_dentry->d_inode, file, DRM_IOCTL_MARK_BUFS, (unsigned long)buf);}typedef struct drm_buf_info32 { int count; /**< Entries in list */ u32 list;} drm_buf_info32_t;static int compat_drm_infobufs(struct file *file, unsigned int cmd, unsigned long arg){ drm_buf_info32_t req32; drm_buf_info32_t __user *argp = (void __user *)arg; drm_buf_desc32_t __user *to; drm_buf_info_t __user *request; drm_buf_desc_t __user *list; size_t nbytes; int i, err; int count, actual; if (copy_from_user(&req32, argp, sizeof(req32))) return -EFAULT; count = req32.count; to = (drm_buf_desc32_t __user *) (unsigned long)req32.list; if (count < 0) count = 0; if (count > 0 && !access_ok(VERIFY_WRITE, to, count * sizeof(drm_buf_desc32_t))) return -EFAULT; nbytes = sizeof(*request) + count * sizeof(drm_buf_desc_t); request = compat_alloc_user_space(nbytes); if (!access_ok(VERIFY_WRITE, request, nbytes)) return -EFAULT; list = (drm_buf_desc_t *) (request + 1); if (__put_user(count, &request->count) || __put_user(list, &request->list)) return -EFAULT; err = drm_ioctl(file->f_dentry->d_inode, file, DRM_IOCTL_INFO_BUFS, (unsigned long)request); if (err) return err; if (__get_user(actual, &request->count)) return -EFAULT; if (count >= actual) for (i = 0; i < actual; ++i) if (__copy_in_user(&to[i], &list[i], offsetof(drm_buf_desc_t, flags))) return -EFAULT; if (__put_user(actual, &argp->count)) return -EFAULT; return 0;}typedef struct drm_buf_pub32 { int idx; /**< Index into the master buffer list */ int total; /**< Buffer size */ int used; /**< Amount of buffer in use (for DMA) */ u32 address; /**< Address of buffer */} drm_buf_pub32_t;typedef struct drm_buf_map32 { int count; /**< Length of the buffer list */ u32 virtual; /**< Mmap'd area in user-virtual */ u32 list; /**< Buffer information */} drm_buf_map32_t;static int compat_drm_mapbufs(struct file *file, unsigned int cmd, unsigned long arg){ drm_buf_map32_t __user *argp = (void __user *)arg; drm_buf_map32_t req32; drm_buf_pub32_t __user *list32; drm_buf_map_t __user *request; drm_buf_pub_t __user *list; int i, err; int count, actual; size_t nbytes; void __user *addr; if (copy_from_user(&req32, argp, sizeof(req32))) return -EFAULT; count = req32.count; list32 = (void __user *)(unsigned long)req32.list; if (count < 0) return -EINVAL; nbytes = sizeof(*request) + count * sizeof(drm_buf_pub_t); request = compat_alloc_user_space(nbytes); if (!access_ok(VERIFY_WRITE, request, nbytes)) return -EFAULT; list = (drm_buf_pub_t *) (request + 1); if (__put_user(count, &request->count) || __put_user(list, &request->list)) return -EFAULT; err = drm_ioctl(file->f_dentry->d_inode, file, DRM_IOCTL_MAP_BUFS, (unsigned long)request); if (err) return err; if (__get_user(actual, &request->count)) return -EFAULT; if (count >= actual) for (i = 0; i < actual; ++i) if (__copy_in_user(&list32[i], &list[i], offsetof(drm_buf_pub_t, address)) || __get_user(addr, &list[i].address) || __put_user((unsigned long)addr, &list32[i].address)) return -EFAULT; if (__put_user(actual, &argp->count) || __get_user(addr, &request->virtual) || __put_user((unsigned long)addr, &argp->virtual)) return -EFAULT; return 0;}typedef struct drm_buf_free32 { int count; u32 list;} drm_buf_free32_t;static int compat_drm_freebufs(struct file *file, unsigned int cmd, unsigned long arg){ drm_buf_free32_t req32; drm_buf_free_t __user *request; drm_buf_free32_t __user *argp = (void __user *)arg; if (copy_from_user(&req32, argp, sizeof(req32))) return -EFAULT; request = compat_alloc_user_space(sizeof(*request)); if (!access_ok(VERIFY_WRITE, request, sizeof(*request))) return -EFAULT; if (__put_user(req32.count, &request->count) || __put_user((int __user *)(unsigned long)req32.list, &request->list)) return -EFAULT; return drm_ioctl(file->f_dentry->d_inode, file, DRM_IOCTL_FREE_BUFS, (unsigned long)request);}typedef struct drm_ctx_priv_map32 { unsigned int ctx_id; /**< Context requesting private mapping */ u32 handle; /**< Handle of map */} drm_ctx_priv_map32_t;static int compat_drm_setsareactx(struct file *file, unsigned int cmd, unsigned long arg){ drm_ctx_priv_map32_t req32; drm_ctx_priv_map_t __user *request; drm_ctx_priv_map32_t __user *argp = (void __user *)arg; if (copy_from_user(&req32, argp, sizeof(req32))) return -EFAULT; request = compat_alloc_user_space(sizeof(*request)); if (!access_ok(VERIFY_WRITE, request, sizeof(*request))) return -EFAULT; if (__put_user(req32.ctx_id, &request->ctx_id) || __put_user((void *)(unsigned long)req32.handle, &request->handle)) return -EFAULT; return drm_ioctl(file->f_dentry->d_inode, file, DRM_IOCTL_SET_SAREA_CTX, (unsigned long)request);}static int compat_drm_getsareactx(struct file *file, unsigned int cmd, unsigned long arg){ drm_ctx_priv_map_t __user *request; drm_ctx_priv_map32_t __user *argp = (void __user *)arg; int err; unsigned int ctx_id; void *handle; if (!access_ok(VERIFY_WRITE, argp, sizeof(*argp)) || __get_user(ctx_id, &argp->ctx_id)) return -EFAULT; request = compat_alloc_user_space(sizeof(*request)); if (!access_ok(VERIFY_WRITE, request, sizeof(*request))) return -EFAULT; if (__put_user(ctx_id, &request->ctx_id)) return -EFAULT; err = drm_ioctl(file->f_dentry->d_inode, file, DRM_IOCTL_GET_SAREA_CTX, (unsigned long)request); if (err) return err; if (__get_user(handle, &request->handle) || __put_user((unsigned long)handle, &argp->handle)) return -EFAULT; return 0;}typedef struct drm_ctx_res32 { int count; u32 contexts;} drm_ctx_res32_t;static int compat_drm_resctx(struct file *file, unsigned int cmd, unsigned long arg){ drm_ctx_res32_t __user *argp = (void __user *)arg; drm_ctx_res32_t res32; drm_ctx_res_t __user *res; int err; if (copy_from_user(&res32, argp, sizeof(res32))) return -EFAULT; res = compat_alloc_user_space(sizeof(*res)); if (!access_ok(VERIFY_WRITE, res, sizeof(*res))) return -EFAULT; if (__put_user(res32.count, &res->count) || __put_user((drm_ctx_t __user *) (unsigned long)res32.contexts, &res->contexts)) return -EFAULT; err = drm_ioctl(file->f_dentry->d_inode, file, DRM_IOCTL_RES_CTX, (unsigned long)res); if (err) return err; if (__get_user(res32.count, &res->count) || __put_user(res32.count, &argp->count)) return -EFAULT; return 0;}typedef struct drm_dma32 { int context; /**< Context handle */ int send_count; /**< Number of buffers to send */ u32 send_indices; /**< List of handles to buffers */ u32 send_sizes; /**< Lengths of data to send */ drm_dma_flags_t flags; /**< Flags */ int request_count; /**< Number of buffers requested */ int request_size; /**< Desired size for buffers */ u32 request_indices; /**< Buffer information */ u32 request_sizes; int granted_count; /**< Number of buffers granted */} drm_dma32_t;static int compat_drm_dma(struct file *file, unsigned int cmd, unsigned long arg){ drm_dma32_t d32; drm_dma32_t __user *argp = (void __user *)arg; drm_dma_t __user *d; int err; if (copy_from_user(&d32, argp, sizeof(d32))) return -EFAULT; d = compat_alloc_user_space(sizeof(*d)); if (!access_ok(VERIFY_WRITE, d, sizeof(*d))) return -EFAULT; if (__put_user(d32.context, &d->context) || __put_user(d32.send_count, &d->send_count) || __put_user((int __user *)(unsigned long)d32.send_indices, &d->send_indices) || __put_user((int __user *)(unsigned long)d32.send_sizes, &d->send_sizes) || __put_user(d32.flags, &d->flags) || __put_user(d32.request_count, &d->request_count) || __put_user((int __user *)(unsigned long)d32.request_indices,
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -