am cd8b953e: Merge changes I2d3fef08,Idb828aa4,Ica764b1f,I9ae8887b,I376fad86,I4d00a9dd
* commit 'cd8b953ede50f68dff5ea049e72aee130dc4a3cb': libion: update to latest uapi header libion: return -errno from ion_close libion: add include for size_t libion: add NULL checks libion: clean up whitespace libion: move ion.h into local include directory
This commit is contained in:
commit
c4f4e5e255
8 changed files with 686 additions and 289 deletions
|
|
@ -5,11 +5,14 @@ LOCAL_SRC_FILES := ion.c
|
||||||
LOCAL_MODULE := libion
|
LOCAL_MODULE := libion
|
||||||
LOCAL_MODULE_TAGS := optional
|
LOCAL_MODULE_TAGS := optional
|
||||||
LOCAL_SHARED_LIBRARIES := liblog
|
LOCAL_SHARED_LIBRARIES := liblog
|
||||||
|
LOCAL_C_INCLUDES := $(LOCAL_PATH)/include $(LOCAL_PATH)/kernel-headers
|
||||||
|
LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH)/include $(LOCAL_PATH)/kernel-headers
|
||||||
include $(BUILD_SHARED_LIBRARY)
|
include $(BUILD_SHARED_LIBRARY)
|
||||||
|
|
||||||
include $(CLEAR_VARS)
|
include $(CLEAR_VARS)
|
||||||
LOCAL_SRC_FILES := ion.c ion_test.c
|
LOCAL_SRC_FILES := ion.c ion_test.c
|
||||||
LOCAL_MODULE := iontest
|
LOCAL_MODULE := iontest
|
||||||
LOCAL_MODULE_TAGS := optional tests
|
LOCAL_MODULE_TAGS := optional tests
|
||||||
|
LOCAL_C_INCLUDES := $(LOCAL_PATH)/include $(LOCAL_PATH)/kernel-headers
|
||||||
LOCAL_SHARED_LIBRARIES := liblog
|
LOCAL_SHARED_LIBRARIES := liblog
|
||||||
include $(BUILD_EXECUTABLE)
|
include $(BUILD_EXECUTABLE)
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,7 @@
|
||||||
#ifndef __SYS_CORE_ION_H
|
#ifndef __SYS_CORE_ION_H
|
||||||
#define __SYS_CORE_ION_H
|
#define __SYS_CORE_ION_H
|
||||||
|
|
||||||
|
#include <sys/types.h>
|
||||||
#include <linux/ion.h>
|
#include <linux/ion.h>
|
||||||
|
|
||||||
__BEGIN_DECLS
|
__BEGIN_DECLS
|
||||||
|
|
@ -30,9 +31,9 @@ struct ion_handle;
|
||||||
int ion_open();
|
int ion_open();
|
||||||
int ion_close(int fd);
|
int ion_close(int fd);
|
||||||
int ion_alloc(int fd, size_t len, size_t align, unsigned int heap_mask,
|
int ion_alloc(int fd, size_t len, size_t align, unsigned int heap_mask,
|
||||||
unsigned int flags, ion_user_handle_t *handle);
|
unsigned int flags, ion_user_handle_t *handle);
|
||||||
int ion_alloc_fd(int fd, size_t len, size_t align, unsigned int heap_mask,
|
int ion_alloc_fd(int fd, size_t len, size_t align, unsigned int heap_mask,
|
||||||
unsigned int flags, int *handle_fd);
|
unsigned int flags, int *handle_fd);
|
||||||
int ion_sync_fd(int fd, int handle_fd);
|
int ion_sync_fd(int fd, int handle_fd);
|
||||||
int ion_free(int fd, ion_user_handle_t handle);
|
int ion_free(int fd, ion_user_handle_t handle);
|
||||||
int ion_map(int fd, ion_user_handle_t handle, size_t length, int prot,
|
int ion_map(int fd, ion_user_handle_t handle, size_t length, int prot,
|
||||||
164
libion/ion.c
164
libion/ion.c
|
|
@ -32,119 +32,139 @@
|
||||||
|
|
||||||
int ion_open()
|
int ion_open()
|
||||||
{
|
{
|
||||||
int fd = open("/dev/ion", O_RDWR);
|
int fd = open("/dev/ion", O_RDWR);
|
||||||
if (fd < 0)
|
if (fd < 0)
|
||||||
ALOGE("open /dev/ion failed!\n");
|
ALOGE("open /dev/ion failed!\n");
|
||||||
return fd;
|
return fd;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ion_close(int fd)
|
int ion_close(int fd)
|
||||||
{
|
{
|
||||||
return close(fd);
|
int ret = close(fd);
|
||||||
|
if (ret < 0)
|
||||||
|
return -errno;
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int ion_ioctl(int fd, int req, void *arg)
|
static int ion_ioctl(int fd, int req, void *arg)
|
||||||
{
|
{
|
||||||
int ret = ioctl(fd, req, arg);
|
int ret = ioctl(fd, req, arg);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
ALOGE("ioctl %x failed with code %d: %s\n", req,
|
ALOGE("ioctl %x failed with code %d: %s\n", req,
|
||||||
ret, strerror(errno));
|
ret, strerror(errno));
|
||||||
return -errno;
|
return -errno;
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ion_alloc(int fd, size_t len, size_t align, unsigned int heap_mask,
|
int ion_alloc(int fd, size_t len, size_t align, unsigned int heap_mask,
|
||||||
unsigned int flags, ion_user_handle_t *handle)
|
unsigned int flags, ion_user_handle_t *handle)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
struct ion_allocation_data data = {
|
struct ion_allocation_data data = {
|
||||||
.len = len,
|
.len = len,
|
||||||
.align = align,
|
.align = align,
|
||||||
.heap_id_mask = heap_mask,
|
.heap_id_mask = heap_mask,
|
||||||
.flags = flags,
|
.flags = flags,
|
||||||
};
|
};
|
||||||
|
|
||||||
ret = ion_ioctl(fd, ION_IOC_ALLOC, &data);
|
if (handle == NULL)
|
||||||
if (ret < 0)
|
return -EINVAL;
|
||||||
return ret;
|
|
||||||
*handle = data.handle;
|
ret = ion_ioctl(fd, ION_IOC_ALLOC, &data);
|
||||||
|
if (ret < 0)
|
||||||
return ret;
|
return ret;
|
||||||
|
*handle = data.handle;
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ion_free(int fd, ion_user_handle_t handle)
|
int ion_free(int fd, ion_user_handle_t handle)
|
||||||
{
|
{
|
||||||
struct ion_handle_data data = {
|
struct ion_handle_data data = {
|
||||||
.handle = handle,
|
.handle = handle,
|
||||||
};
|
};
|
||||||
return ion_ioctl(fd, ION_IOC_FREE, &data);
|
return ion_ioctl(fd, ION_IOC_FREE, &data);
|
||||||
}
|
}
|
||||||
|
|
||||||
int ion_map(int fd, ion_user_handle_t handle, size_t length, int prot,
|
int ion_map(int fd, ion_user_handle_t handle, size_t length, int prot,
|
||||||
int flags, off_t offset, unsigned char **ptr, int *map_fd)
|
int flags, off_t offset, unsigned char **ptr, int *map_fd)
|
||||||
{
|
{
|
||||||
struct ion_fd_data data = {
|
int ret;
|
||||||
.handle = handle,
|
struct ion_fd_data data = {
|
||||||
};
|
.handle = handle,
|
||||||
|
};
|
||||||
|
|
||||||
int ret = ion_ioctl(fd, ION_IOC_MAP, &data);
|
if (map_fd == NULL)
|
||||||
if (ret < 0)
|
return -EINVAL;
|
||||||
return ret;
|
if (ptr == NULL)
|
||||||
*map_fd = data.fd;
|
return -EINVAL;
|
||||||
if (*map_fd < 0) {
|
|
||||||
ALOGE("map ioctl returned negative fd\n");
|
ret = ion_ioctl(fd, ION_IOC_MAP, &data);
|
||||||
return -EINVAL;
|
if (ret < 0)
|
||||||
}
|
|
||||||
*ptr = mmap(NULL, length, prot, flags, *map_fd, offset);
|
|
||||||
if (*ptr == MAP_FAILED) {
|
|
||||||
ALOGE("mmap failed: %s\n", strerror(errno));
|
|
||||||
return -errno;
|
|
||||||
}
|
|
||||||
return ret;
|
return ret;
|
||||||
|
*map_fd = data.fd;
|
||||||
|
if (*map_fd < 0) {
|
||||||
|
ALOGE("map ioctl returned negative fd\n");
|
||||||
|
return -EINVAL;
|
||||||
|
}
|
||||||
|
*ptr = mmap(NULL, length, prot, flags, *map_fd, offset);
|
||||||
|
if (*ptr == MAP_FAILED) {
|
||||||
|
ALOGE("mmap failed: %s\n", strerror(errno));
|
||||||
|
return -errno;
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ion_share(int fd, ion_user_handle_t handle, int *share_fd)
|
int ion_share(int fd, ion_user_handle_t handle, int *share_fd)
|
||||||
{
|
{
|
||||||
int map_fd;
|
int map_fd;
|
||||||
struct ion_fd_data data = {
|
int ret;
|
||||||
.handle = handle,
|
struct ion_fd_data data = {
|
||||||
};
|
.handle = handle,
|
||||||
|
};
|
||||||
|
|
||||||
int ret = ion_ioctl(fd, ION_IOC_SHARE, &data);
|
if (share_fd == NULL)
|
||||||
if (ret < 0)
|
return -EINVAL;
|
||||||
return ret;
|
|
||||||
*share_fd = data.fd;
|
ret = ion_ioctl(fd, ION_IOC_SHARE, &data);
|
||||||
if (*share_fd < 0) {
|
if (ret < 0)
|
||||||
ALOGE("share ioctl returned negative fd\n");
|
|
||||||
return -EINVAL;
|
|
||||||
}
|
|
||||||
return ret;
|
return ret;
|
||||||
|
*share_fd = data.fd;
|
||||||
|
if (*share_fd < 0) {
|
||||||
|
ALOGE("share ioctl returned negative fd\n");
|
||||||
|
return -EINVAL;
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ion_alloc_fd(int fd, size_t len, size_t align, unsigned int heap_mask,
|
int ion_alloc_fd(int fd, size_t len, size_t align, unsigned int heap_mask,
|
||||||
unsigned int flags, int *handle_fd) {
|
unsigned int flags, int *handle_fd) {
|
||||||
ion_user_handle_t handle;
|
ion_user_handle_t handle;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
ret = ion_alloc(fd, len, align, heap_mask, flags, &handle);
|
ret = ion_alloc(fd, len, align, heap_mask, flags, &handle);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
return ret;
|
return ret;
|
||||||
ret = ion_share(fd, handle, handle_fd);
|
ret = ion_share(fd, handle, handle_fd);
|
||||||
ion_free(fd, handle);
|
ion_free(fd, handle);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ion_import(int fd, int share_fd, ion_user_handle_t *handle)
|
int ion_import(int fd, int share_fd, ion_user_handle_t *handle)
|
||||||
{
|
{
|
||||||
struct ion_fd_data data = {
|
int ret;
|
||||||
.fd = share_fd,
|
struct ion_fd_data data = {
|
||||||
};
|
.fd = share_fd,
|
||||||
|
};
|
||||||
|
|
||||||
int ret = ion_ioctl(fd, ION_IOC_IMPORT, &data);
|
if (handle == NULL)
|
||||||
if (ret < 0)
|
return -EINVAL;
|
||||||
return ret;
|
|
||||||
*handle = data.handle;
|
ret = ion_ioctl(fd, ION_IOC_IMPORT, &data);
|
||||||
|
if (ret < 0)
|
||||||
return ret;
|
return ret;
|
||||||
|
*handle = data.handle;
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ion_sync_fd(int fd, int handle_fd)
|
int ion_sync_fd(int fd, int handle_fd)
|
||||||
|
|
|
||||||
|
|
@ -24,254 +24,248 @@ size_t stride;
|
||||||
|
|
||||||
int _ion_alloc_test(int *fd, ion_user_handle_t *handle)
|
int _ion_alloc_test(int *fd, ion_user_handle_t *handle)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
*fd = ion_open();
|
*fd = ion_open();
|
||||||
if (*fd < 0)
|
if (*fd < 0)
|
||||||
return *fd;
|
return *fd;
|
||||||
|
|
||||||
ret = ion_alloc(*fd, len, align, heap_mask, alloc_flags, handle);
|
ret = ion_alloc(*fd, len, align, heap_mask, alloc_flags, handle);
|
||||||
|
|
||||||
if (ret)
|
if (ret)
|
||||||
printf("%s failed: %s\n", __func__, strerror(ret));
|
printf("%s failed: %s\n", __func__, strerror(ret));
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ion_alloc_test()
|
void ion_alloc_test()
|
||||||
{
|
{
|
||||||
int fd, ret;
|
int fd, ret;
|
||||||
ion_user_handle_t handle;
|
ion_user_handle_t handle;
|
||||||
|
|
||||||
if(_ion_alloc_test(&fd, &handle))
|
if(_ion_alloc_test(&fd, &handle))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
ret = ion_free(fd, handle);
|
ret = ion_free(fd, handle);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
printf("%s failed: %s %p\n", __func__, strerror(ret), handle);
|
printf("%s failed: %s %p\n", __func__, strerror(ret), handle);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ion_close(fd);
|
ion_close(fd);
|
||||||
printf("ion alloc test: passed\n");
|
printf("ion alloc test: passed\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
void ion_map_test()
|
void ion_map_test()
|
||||||
{
|
{
|
||||||
int fd, map_fd, ret;
|
int fd, map_fd, ret;
|
||||||
size_t i;
|
size_t i;
|
||||||
ion_user_handle_t handle;
|
ion_user_handle_t handle;
|
||||||
unsigned char *ptr;
|
unsigned char *ptr;
|
||||||
|
|
||||||
if(_ion_alloc_test(&fd, &handle))
|
if(_ion_alloc_test(&fd, &handle))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
ret = ion_map(fd, handle, len, prot, map_flags, 0, &ptr, &map_fd);
|
ret = ion_map(fd, handle, len, prot, map_flags, 0, &ptr, &map_fd);
|
||||||
if (ret)
|
if (ret)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for (i = 0; i < len; i++) {
|
for (i = 0; i < len; i++) {
|
||||||
ptr[i] = (unsigned char)i;
|
ptr[i] = (unsigned char)i;
|
||||||
}
|
}
|
||||||
for (i = 0; i < len; i++)
|
for (i = 0; i < len; i++)
|
||||||
if (ptr[i] != (unsigned char)i)
|
if (ptr[i] != (unsigned char)i)
|
||||||
printf("%s failed wrote %zu read %d from mapped "
|
printf("%s failed wrote %zu read %d from mapped "
|
||||||
"memory\n", __func__, i, ptr[i]);
|
"memory\n", __func__, i, ptr[i]);
|
||||||
/* clean up properly */
|
/* clean up properly */
|
||||||
ret = ion_free(fd, handle);
|
ret = ion_free(fd, handle);
|
||||||
ion_close(fd);
|
ion_close(fd);
|
||||||
munmap(ptr, len);
|
munmap(ptr, len);
|
||||||
close(map_fd);
|
close(map_fd);
|
||||||
|
|
||||||
_ion_alloc_test(&fd, &handle);
|
_ion_alloc_test(&fd, &handle);
|
||||||
close(fd);
|
close(fd);
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
munmap(ptr, len);
|
munmap(ptr, len);
|
||||||
close(map_fd);
|
close(map_fd);
|
||||||
ion_close(fd);
|
ion_close(fd);
|
||||||
|
|
||||||
_ion_alloc_test(len, align, flags, &fd, &handle);
|
_ion_alloc_test(len, align, flags, &fd, &handle);
|
||||||
close(map_fd);
|
close(map_fd);
|
||||||
ret = ion_map(fd, handle, len, prot, flags, 0, &ptr, &map_fd);
|
ret = ion_map(fd, handle, len, prot, flags, 0, &ptr, &map_fd);
|
||||||
/* don't clean up */
|
/* don't clean up */
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void ion_share_test()
|
void ion_share_test()
|
||||||
|
|
||||||
{
|
{
|
||||||
ion_user_handle_t handle;
|
ion_user_handle_t handle;
|
||||||
int sd[2];
|
int sd[2];
|
||||||
int num_fd = 1;
|
int num_fd = 1;
|
||||||
struct iovec count_vec = {
|
struct iovec count_vec = {
|
||||||
.iov_base = &num_fd,
|
.iov_base = &num_fd,
|
||||||
.iov_len = sizeof num_fd,
|
.iov_len = sizeof num_fd,
|
||||||
};
|
};
|
||||||
char buf[CMSG_SPACE(sizeof(int))];
|
char buf[CMSG_SPACE(sizeof(int))];
|
||||||
socketpair(AF_UNIX, SOCK_STREAM, 0, sd);
|
socketpair(AF_UNIX, SOCK_STREAM, 0, sd);
|
||||||
if (fork()) {
|
if (fork()) {
|
||||||
struct msghdr msg = {
|
struct msghdr msg = {
|
||||||
.msg_control = buf,
|
.msg_control = buf,
|
||||||
.msg_controllen = sizeof buf,
|
.msg_controllen = sizeof buf,
|
||||||
.msg_iov = &count_vec,
|
.msg_iov = &count_vec,
|
||||||
.msg_iovlen = 1,
|
.msg_iovlen = 1,
|
||||||
};
|
};
|
||||||
|
|
||||||
struct cmsghdr *cmsg;
|
struct cmsghdr *cmsg;
|
||||||
int fd, share_fd, ret;
|
int fd, share_fd, ret;
|
||||||
char *ptr;
|
char *ptr;
|
||||||
/* parent */
|
/* parent */
|
||||||
if(_ion_alloc_test(&fd, &handle))
|
if(_ion_alloc_test(&fd, &handle))
|
||||||
return;
|
return;
|
||||||
ret = ion_share(fd, handle, &share_fd);
|
ret = ion_share(fd, handle, &share_fd);
|
||||||
if (ret)
|
if (ret)
|
||||||
printf("share failed %s\n", strerror(errno));
|
printf("share failed %s\n", strerror(errno));
|
||||||
ptr = mmap(NULL, len, prot, map_flags, share_fd, 0);
|
ptr = mmap(NULL, len, prot, map_flags, share_fd, 0);
|
||||||
if (ptr == MAP_FAILED) {
|
if (ptr == MAP_FAILED) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
strcpy(ptr, "master");
|
strcpy(ptr, "master");
|
||||||
cmsg = CMSG_FIRSTHDR(&msg);
|
cmsg = CMSG_FIRSTHDR(&msg);
|
||||||
cmsg->cmsg_level = SOL_SOCKET;
|
cmsg->cmsg_level = SOL_SOCKET;
|
||||||
cmsg->cmsg_type = SCM_RIGHTS;
|
cmsg->cmsg_type = SCM_RIGHTS;
|
||||||
cmsg->cmsg_len = CMSG_LEN(sizeof(int));
|
cmsg->cmsg_len = CMSG_LEN(sizeof(int));
|
||||||
*(int *)CMSG_DATA(cmsg) = share_fd;
|
*(int *)CMSG_DATA(cmsg) = share_fd;
|
||||||
/* send the fd */
|
/* send the fd */
|
||||||
printf("master? [%10s] should be [master]\n", ptr);
|
printf("master? [%10s] should be [master]\n", ptr);
|
||||||
printf("master sending msg 1\n");
|
printf("master sending msg 1\n");
|
||||||
sendmsg(sd[0], &msg, 0);
|
sendmsg(sd[0], &msg, 0);
|
||||||
if (recvmsg(sd[0], &msg, 0) < 0)
|
if (recvmsg(sd[0], &msg, 0) < 0)
|
||||||
perror("master recv msg 2");
|
perror("master recv msg 2");
|
||||||
printf("master? [%10s] should be [child]\n", ptr);
|
printf("master? [%10s] should be [child]\n", ptr);
|
||||||
|
|
||||||
/* send ping */
|
/* send ping */
|
||||||
sendmsg(sd[0], &msg, 0);
|
sendmsg(sd[0], &msg, 0);
|
||||||
printf("master->master? [%10s]\n", ptr);
|
printf("master->master? [%10s]\n", ptr);
|
||||||
if (recvmsg(sd[0], &msg, 0) < 0)
|
if (recvmsg(sd[0], &msg, 0) < 0)
|
||||||
perror("master recv 1");
|
perror("master recv 1");
|
||||||
} else {
|
} else {
|
||||||
struct msghdr msg;
|
struct msghdr msg;
|
||||||
struct cmsghdr *cmsg;
|
struct cmsghdr *cmsg;
|
||||||
char* ptr;
|
char* ptr;
|
||||||
int fd, recv_fd;
|
int fd, recv_fd;
|
||||||
char* child_buf[100];
|
char* child_buf[100];
|
||||||
/* child */
|
/* child */
|
||||||
struct iovec count_vec = {
|
struct iovec count_vec = {
|
||||||
.iov_base = child_buf,
|
.iov_base = child_buf,
|
||||||
.iov_len = sizeof child_buf,
|
.iov_len = sizeof child_buf,
|
||||||
};
|
};
|
||||||
|
|
||||||
struct msghdr child_msg = {
|
struct msghdr child_msg = {
|
||||||
.msg_control = buf,
|
.msg_control = buf,
|
||||||
.msg_controllen = sizeof buf,
|
.msg_controllen = sizeof buf,
|
||||||
.msg_iov = &count_vec,
|
.msg_iov = &count_vec,
|
||||||
.msg_iovlen = 1,
|
.msg_iovlen = 1,
|
||||||
};
|
};
|
||||||
|
|
||||||
if (recvmsg(sd[1], &child_msg, 0) < 0)
|
if (recvmsg(sd[1], &child_msg, 0) < 0)
|
||||||
perror("child recv msg 1");
|
perror("child recv msg 1");
|
||||||
cmsg = CMSG_FIRSTHDR(&child_msg);
|
cmsg = CMSG_FIRSTHDR(&child_msg);
|
||||||
if (cmsg == NULL) {
|
if (cmsg == NULL) {
|
||||||
printf("no cmsg rcvd in child");
|
printf("no cmsg rcvd in child");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
recv_fd = *(int*)CMSG_DATA(cmsg);
|
recv_fd = *(int*)CMSG_DATA(cmsg);
|
||||||
if (recv_fd < 0) {
|
if (recv_fd < 0) {
|
||||||
printf("could not get recv_fd from socket");
|
printf("could not get recv_fd from socket");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
printf("child %d\n", recv_fd);
|
printf("child %d\n", recv_fd);
|
||||||
fd = ion_open();
|
fd = ion_open();
|
||||||
ptr = mmap(NULL, len, prot, map_flags, recv_fd, 0);
|
ptr = mmap(NULL, len, prot, map_flags, recv_fd, 0);
|
||||||
if (ptr == MAP_FAILED) {
|
if (ptr == MAP_FAILED) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
printf("child? [%10s] should be [master]\n", ptr);
|
printf("child? [%10s] should be [master]\n", ptr);
|
||||||
strcpy(ptr, "child");
|
strcpy(ptr, "child");
|
||||||
printf("child sending msg 2\n");
|
printf("child sending msg 2\n");
|
||||||
sendmsg(sd[1], &child_msg, 0);
|
sendmsg(sd[1], &child_msg, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char* argv[]) {
|
int main(int argc, char* argv[]) {
|
||||||
int c;
|
int c;
|
||||||
enum tests {
|
enum tests {
|
||||||
ALLOC_TEST = 0, MAP_TEST, SHARE_TEST,
|
ALLOC_TEST = 0, MAP_TEST, SHARE_TEST,
|
||||||
};
|
};
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
static struct option opts[] = {
|
static struct option opts[] = {
|
||||||
{"alloc", no_argument, 0, 'a'},
|
{"alloc", no_argument, 0, 'a'},
|
||||||
{"alloc_flags", required_argument, 0, 'f'},
|
{"alloc_flags", required_argument, 0, 'f'},
|
||||||
{"heap_mask", required_argument, 0, 'h'},
|
{"heap_mask", required_argument, 0, 'h'},
|
||||||
{"map", no_argument, 0, 'm'},
|
{"map", no_argument, 0, 'm'},
|
||||||
{"share", no_argument, 0, 's'},
|
{"share", no_argument, 0, 's'},
|
||||||
{"len", required_argument, 0, 'l'},
|
{"len", required_argument, 0, 'l'},
|
||||||
{"align", required_argument, 0, 'g'},
|
{"align", required_argument, 0, 'g'},
|
||||||
{"map_flags", required_argument, 0, 'z'},
|
{"map_flags", required_argument, 0, 'z'},
|
||||||
{"prot", required_argument, 0, 'p'},
|
{"prot", required_argument, 0, 'p'},
|
||||||
};
|
};
|
||||||
int i = 0;
|
int i = 0;
|
||||||
c = getopt_long(argc, argv, "af:h:l:mr:st", opts, &i);
|
c = getopt_long(argc, argv, "af:h:l:mr:st", opts, &i);
|
||||||
if (c == -1)
|
if (c == -1)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
switch (c) {
|
switch (c) {
|
||||||
case 'l':
|
case 'l':
|
||||||
len = atol(optarg);
|
len = atol(optarg);
|
||||||
break;
|
break;
|
||||||
case 'g':
|
case 'g':
|
||||||
align = atol(optarg);
|
align = atol(optarg);
|
||||||
break;
|
break;
|
||||||
case 'z':
|
case 'z':
|
||||||
map_flags = 0;
|
map_flags = 0;
|
||||||
map_flags |= strstr(optarg, "PROT_EXEC") ?
|
map_flags |= strstr(optarg, "PROT_EXEC") ? PROT_EXEC : 0;
|
||||||
PROT_EXEC : 0;
|
map_flags |= strstr(optarg, "PROT_READ") ? PROT_READ: 0;
|
||||||
map_flags |= strstr(optarg, "PROT_READ") ?
|
map_flags |= strstr(optarg, "PROT_WRITE") ? PROT_WRITE: 0;
|
||||||
PROT_READ: 0;
|
map_flags |= strstr(optarg, "PROT_NONE") ? PROT_NONE: 0;
|
||||||
map_flags |= strstr(optarg, "PROT_WRITE") ?
|
break;
|
||||||
PROT_WRITE: 0;
|
case 'p':
|
||||||
map_flags |= strstr(optarg, "PROT_NONE") ?
|
prot = 0;
|
||||||
PROT_NONE: 0;
|
prot |= strstr(optarg, "MAP_PRIVATE") ? MAP_PRIVATE : 0;
|
||||||
break;
|
prot |= strstr(optarg, "MAP_SHARED") ? MAP_PRIVATE : 0;
|
||||||
case 'p':
|
break;
|
||||||
prot = 0;
|
case 'f':
|
||||||
prot |= strstr(optarg, "MAP_PRIVATE") ?
|
alloc_flags = atol(optarg);
|
||||||
MAP_PRIVATE : 0;
|
break;
|
||||||
prot |= strstr(optarg, "MAP_SHARED") ?
|
case 'h':
|
||||||
MAP_PRIVATE : 0;
|
heap_mask = atol(optarg);
|
||||||
break;
|
break;
|
||||||
case 'f':
|
case 'a':
|
||||||
alloc_flags = atol(optarg);
|
test = ALLOC_TEST;
|
||||||
break;
|
break;
|
||||||
case 'h':
|
case 'm':
|
||||||
heap_mask = atol(optarg);
|
test = MAP_TEST;
|
||||||
break;
|
break;
|
||||||
case 'a':
|
case 's':
|
||||||
test = ALLOC_TEST;
|
test = SHARE_TEST;
|
||||||
break;
|
break;
|
||||||
case 'm':
|
}
|
||||||
test = MAP_TEST;
|
}
|
||||||
break;
|
printf("test %d, len %zu, align %zu, map_flags %d, prot %d, heap_mask %d,"
|
||||||
case 's':
|
" alloc_flags %d\n", test, len, align, map_flags, prot,
|
||||||
test = SHARE_TEST;
|
heap_mask, alloc_flags);
|
||||||
break;
|
switch (test) {
|
||||||
}
|
case ALLOC_TEST:
|
||||||
}
|
ion_alloc_test();
|
||||||
printf("test %d, len %zu, align %zu, map_flags %d, prot %d, heap_mask %d,"
|
break;
|
||||||
" alloc_flags %d\n", test, len, align, map_flags, prot,
|
case MAP_TEST:
|
||||||
heap_mask, alloc_flags);
|
ion_map_test();
|
||||||
switch (test) {
|
break;
|
||||||
case ALLOC_TEST:
|
case SHARE_TEST:
|
||||||
ion_alloc_test();
|
ion_share_test();
|
||||||
break;
|
break;
|
||||||
case MAP_TEST:
|
default:
|
||||||
ion_map_test();
|
printf("must specify a test (alloc, map, share)\n");
|
||||||
break;
|
}
|
||||||
case SHARE_TEST:
|
return 0;
|
||||||
ion_share_test();
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
printf("must specify a test (alloc, map, share)\n");
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
78
libion/kernel-headers/linux/ion.h
Normal file
78
libion/kernel-headers/linux/ion.h
Normal file
|
|
@ -0,0 +1,78 @@
|
||||||
|
/****************************************************************************
|
||||||
|
****************************************************************************
|
||||||
|
***
|
||||||
|
*** This header was automatically generated from a Linux kernel header
|
||||||
|
*** of the same name, to make information necessary for userspace to
|
||||||
|
*** call into the kernel available to libc. It contains only constants,
|
||||||
|
*** structures, and macros generated from the original header, and thus,
|
||||||
|
*** contains no copyrightable information.
|
||||||
|
***
|
||||||
|
*** To edit the content of this header, modify the corresponding
|
||||||
|
*** source file (e.g. under external/kernel-headers/original/) then
|
||||||
|
*** run bionic/libc/kernel/tools/update_all.py
|
||||||
|
***
|
||||||
|
*** Any manual change here will be lost the next time this script will
|
||||||
|
*** be run. You've been warned!
|
||||||
|
***
|
||||||
|
****************************************************************************
|
||||||
|
****************************************************************************/
|
||||||
|
#ifndef _UAPI_LINUX_ION_H
|
||||||
|
#define _UAPI_LINUX_ION_H
|
||||||
|
#include <linux/ioctl.h>
|
||||||
|
#include <linux/types.h>
|
||||||
|
/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
|
||||||
|
typedef int ion_user_handle_t;
|
||||||
|
enum ion_heap_type {
|
||||||
|
ION_HEAP_TYPE_SYSTEM,
|
||||||
|
ION_HEAP_TYPE_SYSTEM_CONTIG,
|
||||||
|
/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
|
||||||
|
ION_HEAP_TYPE_CARVEOUT,
|
||||||
|
ION_HEAP_TYPE_CHUNK,
|
||||||
|
ION_HEAP_TYPE_DMA,
|
||||||
|
ION_HEAP_TYPE_CUSTOM,
|
||||||
|
/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
|
||||||
|
ION_NUM_HEAPS = 16,
|
||||||
|
};
|
||||||
|
#define ION_HEAP_SYSTEM_MASK (1 << ION_HEAP_TYPE_SYSTEM)
|
||||||
|
#define ION_HEAP_SYSTEM_CONTIG_MASK (1 << ION_HEAP_TYPE_SYSTEM_CONTIG)
|
||||||
|
/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
|
||||||
|
#define ION_HEAP_CARVEOUT_MASK (1 << ION_HEAP_TYPE_CARVEOUT)
|
||||||
|
#define ION_HEAP_TYPE_DMA_MASK (1 << ION_HEAP_TYPE_DMA)
|
||||||
|
#define ION_NUM_HEAP_IDS sizeof(unsigned int) * 8
|
||||||
|
#define ION_FLAG_CACHED 1
|
||||||
|
/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
|
||||||
|
#define ION_FLAG_CACHED_NEEDS_SYNC 2
|
||||||
|
struct ion_allocation_data {
|
||||||
|
size_t len;
|
||||||
|
size_t align;
|
||||||
|
/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
|
||||||
|
unsigned int heap_id_mask;
|
||||||
|
unsigned int flags;
|
||||||
|
ion_user_handle_t handle;
|
||||||
|
};
|
||||||
|
/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
|
||||||
|
struct ion_fd_data {
|
||||||
|
ion_user_handle_t handle;
|
||||||
|
int fd;
|
||||||
|
};
|
||||||
|
/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
|
||||||
|
struct ion_handle_data {
|
||||||
|
ion_user_handle_t handle;
|
||||||
|
};
|
||||||
|
struct ion_custom_data {
|
||||||
|
/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
|
||||||
|
unsigned int cmd;
|
||||||
|
unsigned long arg;
|
||||||
|
};
|
||||||
|
#define ION_IOC_MAGIC 'I'
|
||||||
|
/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
|
||||||
|
#define ION_IOC_ALLOC _IOWR(ION_IOC_MAGIC, 0, struct ion_allocation_data)
|
||||||
|
#define ION_IOC_FREE _IOWR(ION_IOC_MAGIC, 1, struct ion_handle_data)
|
||||||
|
#define ION_IOC_MAP _IOWR(ION_IOC_MAGIC, 2, struct ion_fd_data)
|
||||||
|
#define ION_IOC_SHARE _IOWR(ION_IOC_MAGIC, 4, struct ion_fd_data)
|
||||||
|
/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
|
||||||
|
#define ION_IOC_IMPORT _IOWR(ION_IOC_MAGIC, 5, struct ion_fd_data)
|
||||||
|
#define ION_IOC_SYNC _IOWR(ION_IOC_MAGIC, 7, struct ion_fd_data)
|
||||||
|
#define ION_IOC_CUSTOM _IOWR(ION_IOC_MAGIC, 6, struct ion_custom_data)
|
||||||
|
#endif
|
||||||
|
/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
|
||||||
36
libion/kernel-headers/linux/ion_test.h
Normal file
36
libion/kernel-headers/linux/ion_test.h
Normal file
|
|
@ -0,0 +1,36 @@
|
||||||
|
/****************************************************************************
|
||||||
|
****************************************************************************
|
||||||
|
***
|
||||||
|
*** This header was automatically generated from a Linux kernel header
|
||||||
|
*** of the same name, to make information necessary for userspace to
|
||||||
|
*** call into the kernel available to libc. It contains only constants,
|
||||||
|
*** structures, and macros generated from the original header, and thus,
|
||||||
|
*** contains no copyrightable information.
|
||||||
|
***
|
||||||
|
*** To edit the content of this header, modify the corresponding
|
||||||
|
*** source file (e.g. under external/kernel-headers/original/) then
|
||||||
|
*** run bionic/libc/kernel/tools/update_all.py
|
||||||
|
***
|
||||||
|
*** Any manual change here will be lost the next time this script will
|
||||||
|
*** be run. You've been warned!
|
||||||
|
***
|
||||||
|
****************************************************************************
|
||||||
|
****************************************************************************/
|
||||||
|
#ifndef _UAPI_LINUX_ION_TEST_H
|
||||||
|
#define _UAPI_LINUX_ION_TEST_H
|
||||||
|
#include <linux/ioctl.h>
|
||||||
|
#include <linux/types.h>
|
||||||
|
/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
|
||||||
|
struct ion_test_rw_data {
|
||||||
|
__u64 ptr;
|
||||||
|
__u64 offset;
|
||||||
|
__u64 size;
|
||||||
|
/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
|
||||||
|
int write;
|
||||||
|
};
|
||||||
|
#define ION_IOC_MAGIC 'I'
|
||||||
|
#define ION_IOC_TEST_SET_FD _IO(ION_IOC_MAGIC, 0xf0)
|
||||||
|
/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
|
||||||
|
#define ION_IOC_TEST_DMA_MAPPING _IOW(ION_IOC_MAGIC, 0xf1, struct ion_test_rw_data)
|
||||||
|
#define ION_IOC_TEST_KERNEL_MAPPING _IOW(ION_IOC_MAGIC, 0xf2, struct ion_test_rw_data)
|
||||||
|
#endif
|
||||||
196
libion/original-kernel-headers/linux/ion.h
Normal file
196
libion/original-kernel-headers/linux/ion.h
Normal file
|
|
@ -0,0 +1,196 @@
|
||||||
|
/*
|
||||||
|
* drivers/staging/android/uapi/ion.h
|
||||||
|
*
|
||||||
|
* Copyright (C) 2011 Google, Inc.
|
||||||
|
*
|
||||||
|
* This software is licensed under the terms of the GNU General Public
|
||||||
|
* License version 2, as published by the Free Software Foundation, and
|
||||||
|
* may be copied, distributed, and modified under those terms.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _UAPI_LINUX_ION_H
|
||||||
|
#define _UAPI_LINUX_ION_H
|
||||||
|
|
||||||
|
#include <linux/ioctl.h>
|
||||||
|
#include <linux/types.h>
|
||||||
|
|
||||||
|
typedef int ion_user_handle_t;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* enum ion_heap_types - list of all possible types of heaps
|
||||||
|
* @ION_HEAP_TYPE_SYSTEM: memory allocated via vmalloc
|
||||||
|
* @ION_HEAP_TYPE_SYSTEM_CONTIG: memory allocated via kmalloc
|
||||||
|
* @ION_HEAP_TYPE_CARVEOUT: memory allocated from a prereserved
|
||||||
|
* carveout heap, allocations are physically
|
||||||
|
* contiguous
|
||||||
|
* @ION_HEAP_TYPE_DMA: memory allocated via DMA API
|
||||||
|
* @ION_NUM_HEAPS: helper for iterating over heaps, a bit mask
|
||||||
|
* is used to identify the heaps, so only 32
|
||||||
|
* total heap types are supported
|
||||||
|
*/
|
||||||
|
enum ion_heap_type {
|
||||||
|
ION_HEAP_TYPE_SYSTEM,
|
||||||
|
ION_HEAP_TYPE_SYSTEM_CONTIG,
|
||||||
|
ION_HEAP_TYPE_CARVEOUT,
|
||||||
|
ION_HEAP_TYPE_CHUNK,
|
||||||
|
ION_HEAP_TYPE_DMA,
|
||||||
|
ION_HEAP_TYPE_CUSTOM, /* must be last so device specific heaps always
|
||||||
|
are at the end of this enum */
|
||||||
|
ION_NUM_HEAPS = 16,
|
||||||
|
};
|
||||||
|
|
||||||
|
#define ION_HEAP_SYSTEM_MASK (1 << ION_HEAP_TYPE_SYSTEM)
|
||||||
|
#define ION_HEAP_SYSTEM_CONTIG_MASK (1 << ION_HEAP_TYPE_SYSTEM_CONTIG)
|
||||||
|
#define ION_HEAP_CARVEOUT_MASK (1 << ION_HEAP_TYPE_CARVEOUT)
|
||||||
|
#define ION_HEAP_TYPE_DMA_MASK (1 << ION_HEAP_TYPE_DMA)
|
||||||
|
|
||||||
|
#define ION_NUM_HEAP_IDS sizeof(unsigned int) * 8
|
||||||
|
|
||||||
|
/**
|
||||||
|
* allocation flags - the lower 16 bits are used by core ion, the upper 16
|
||||||
|
* bits are reserved for use by the heaps themselves.
|
||||||
|
*/
|
||||||
|
#define ION_FLAG_CACHED 1 /* mappings of this buffer should be
|
||||||
|
cached, ion will do cache
|
||||||
|
maintenance when the buffer is
|
||||||
|
mapped for dma */
|
||||||
|
#define ION_FLAG_CACHED_NEEDS_SYNC 2 /* mappings of this buffer will created
|
||||||
|
at mmap time, if this is set
|
||||||
|
caches must be managed manually */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* DOC: Ion Userspace API
|
||||||
|
*
|
||||||
|
* create a client by opening /dev/ion
|
||||||
|
* most operations handled via following ioctls
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* struct ion_allocation_data - metadata passed from userspace for allocations
|
||||||
|
* @len: size of the allocation
|
||||||
|
* @align: required alignment of the allocation
|
||||||
|
* @heap_id_mask: mask of heap ids to allocate from
|
||||||
|
* @flags: flags passed to heap
|
||||||
|
* @handle: pointer that will be populated with a cookie to use to
|
||||||
|
* refer to this allocation
|
||||||
|
*
|
||||||
|
* Provided by userspace as an argument to the ioctl
|
||||||
|
*/
|
||||||
|
struct ion_allocation_data {
|
||||||
|
size_t len;
|
||||||
|
size_t align;
|
||||||
|
unsigned int heap_id_mask;
|
||||||
|
unsigned int flags;
|
||||||
|
ion_user_handle_t handle;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* struct ion_fd_data - metadata passed to/from userspace for a handle/fd pair
|
||||||
|
* @handle: a handle
|
||||||
|
* @fd: a file descriptor representing that handle
|
||||||
|
*
|
||||||
|
* For ION_IOC_SHARE or ION_IOC_MAP userspace populates the handle field with
|
||||||
|
* the handle returned from ion alloc, and the kernel returns the file
|
||||||
|
* descriptor to share or map in the fd field. For ION_IOC_IMPORT, userspace
|
||||||
|
* provides the file descriptor and the kernel returns the handle.
|
||||||
|
*/
|
||||||
|
struct ion_fd_data {
|
||||||
|
ion_user_handle_t handle;
|
||||||
|
int fd;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* struct ion_handle_data - a handle passed to/from the kernel
|
||||||
|
* @handle: a handle
|
||||||
|
*/
|
||||||
|
struct ion_handle_data {
|
||||||
|
ion_user_handle_t handle;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* struct ion_custom_data - metadata passed to/from userspace for a custom ioctl
|
||||||
|
* @cmd: the custom ioctl function to call
|
||||||
|
* @arg: additional data to pass to the custom ioctl, typically a user
|
||||||
|
* pointer to a predefined structure
|
||||||
|
*
|
||||||
|
* This works just like the regular cmd and arg fields of an ioctl.
|
||||||
|
*/
|
||||||
|
struct ion_custom_data {
|
||||||
|
unsigned int cmd;
|
||||||
|
unsigned long arg;
|
||||||
|
};
|
||||||
|
|
||||||
|
#define ION_IOC_MAGIC 'I'
|
||||||
|
|
||||||
|
/**
|
||||||
|
* DOC: ION_IOC_ALLOC - allocate memory
|
||||||
|
*
|
||||||
|
* Takes an ion_allocation_data struct and returns it with the handle field
|
||||||
|
* populated with the opaque handle for the allocation.
|
||||||
|
*/
|
||||||
|
#define ION_IOC_ALLOC _IOWR(ION_IOC_MAGIC, 0, \
|
||||||
|
struct ion_allocation_data)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* DOC: ION_IOC_FREE - free memory
|
||||||
|
*
|
||||||
|
* Takes an ion_handle_data struct and frees the handle.
|
||||||
|
*/
|
||||||
|
#define ION_IOC_FREE _IOWR(ION_IOC_MAGIC, 1, struct ion_handle_data)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* DOC: ION_IOC_MAP - get a file descriptor to mmap
|
||||||
|
*
|
||||||
|
* Takes an ion_fd_data struct with the handle field populated with a valid
|
||||||
|
* opaque handle. Returns the struct with the fd field set to a file
|
||||||
|
* descriptor open in the current address space. This file descriptor
|
||||||
|
* can then be used as an argument to mmap.
|
||||||
|
*/
|
||||||
|
#define ION_IOC_MAP _IOWR(ION_IOC_MAGIC, 2, struct ion_fd_data)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* DOC: ION_IOC_SHARE - creates a file descriptor to use to share an allocation
|
||||||
|
*
|
||||||
|
* Takes an ion_fd_data struct with the handle field populated with a valid
|
||||||
|
* opaque handle. Returns the struct with the fd field set to a file
|
||||||
|
* descriptor open in the current address space. This file descriptor
|
||||||
|
* can then be passed to another process. The corresponding opaque handle can
|
||||||
|
* be retrieved via ION_IOC_IMPORT.
|
||||||
|
*/
|
||||||
|
#define ION_IOC_SHARE _IOWR(ION_IOC_MAGIC, 4, struct ion_fd_data)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* DOC: ION_IOC_IMPORT - imports a shared file descriptor
|
||||||
|
*
|
||||||
|
* Takes an ion_fd_data struct with the fd field populated with a valid file
|
||||||
|
* descriptor obtained from ION_IOC_SHARE and returns the struct with the handle
|
||||||
|
* filed set to the corresponding opaque handle.
|
||||||
|
*/
|
||||||
|
#define ION_IOC_IMPORT _IOWR(ION_IOC_MAGIC, 5, struct ion_fd_data)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* DOC: ION_IOC_SYNC - syncs a shared file descriptors to memory
|
||||||
|
*
|
||||||
|
* Deprecated in favor of using the dma_buf api's correctly (syncing
|
||||||
|
* will happend automatically when the buffer is mapped to a device).
|
||||||
|
* If necessary should be used after touching a cached buffer from the cpu,
|
||||||
|
* this will make the buffer in memory coherent.
|
||||||
|
*/
|
||||||
|
#define ION_IOC_SYNC _IOWR(ION_IOC_MAGIC, 7, struct ion_fd_data)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* DOC: ION_IOC_CUSTOM - call architecture specific ion ioctl
|
||||||
|
*
|
||||||
|
* Takes the argument of the architecture specific ioctl to call and
|
||||||
|
* passes appropriate userdata for that ioctl
|
||||||
|
*/
|
||||||
|
#define ION_IOC_CUSTOM _IOWR(ION_IOC_MAGIC, 6, struct ion_custom_data)
|
||||||
|
|
||||||
|
#endif /* _UAPI_LINUX_ION_H */
|
||||||
69
libion/original-kernel-headers/linux/ion_test.h
Normal file
69
libion/original-kernel-headers/linux/ion_test.h
Normal file
|
|
@ -0,0 +1,69 @@
|
||||||
|
/*
|
||||||
|
* drivers/staging/android/uapi/ion.h
|
||||||
|
*
|
||||||
|
* Copyright (C) 2011 Google, Inc.
|
||||||
|
*
|
||||||
|
* This software is licensed under the terms of the GNU General Public
|
||||||
|
* License version 2, as published by the Free Software Foundation, and
|
||||||
|
* may be copied, distributed, and modified under those terms.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _UAPI_LINUX_ION_TEST_H
|
||||||
|
#define _UAPI_LINUX_ION_TEST_H
|
||||||
|
|
||||||
|
#include <linux/ioctl.h>
|
||||||
|
#include <linux/types.h>
|
||||||
|
|
||||||
|
/**
|
||||||
|
* struct ion_test_rw_data - metadata passed to the kernel to read handle
|
||||||
|
* @ptr: a pointer to an area at least as large as size
|
||||||
|
* @offset: offset into the ion buffer to start reading
|
||||||
|
* @size: size to read or write
|
||||||
|
* @write: 1 to write, 0 to read
|
||||||
|
*/
|
||||||
|
struct ion_test_rw_data {
|
||||||
|
__u64 ptr;
|
||||||
|
__u64 offset;
|
||||||
|
__u64 size;
|
||||||
|
int write;
|
||||||
|
};
|
||||||
|
|
||||||
|
#define ION_IOC_MAGIC 'I'
|
||||||
|
|
||||||
|
/**
|
||||||
|
* DOC: ION_IOC_TEST_SET_DMA_BUF - attach a dma buf to the test driver
|
||||||
|
*
|
||||||
|
* Attaches a dma buf fd to the test driver. Passing a second fd or -1 will
|
||||||
|
* release the first fd.
|
||||||
|
*/
|
||||||
|
#define ION_IOC_TEST_SET_FD \
|
||||||
|
_IO(ION_IOC_MAGIC, 0xf0)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* DOC: ION_IOC_TEST_DMA_MAPPING - read or write memory from a handle as DMA
|
||||||
|
*
|
||||||
|
* Reads or writes the memory from a handle using an uncached mapping. Can be
|
||||||
|
* used by unit tests to emulate a DMA engine as close as possible. Only
|
||||||
|
* expected to be used for debugging and testing, may not always be available.
|
||||||
|
*/
|
||||||
|
#define ION_IOC_TEST_DMA_MAPPING \
|
||||||
|
_IOW(ION_IOC_MAGIC, 0xf1, struct ion_test_rw_data)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* DOC: ION_IOC_TEST_KERNEL_MAPPING - read or write memory from a handle
|
||||||
|
*
|
||||||
|
* Reads or writes the memory from a handle using a kernel mapping. Can be
|
||||||
|
* used by unit tests to test heap map_kernel functions. Only expected to be
|
||||||
|
* used for debugging and testing, may not always be available.
|
||||||
|
*/
|
||||||
|
#define ION_IOC_TEST_KERNEL_MAPPING \
|
||||||
|
_IOW(ION_IOC_MAGIC, 0xf2, struct ion_test_rw_data)
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* _UAPI_LINUX_ION_H */
|
||||||
Loading…
Add table
Reference in a new issue