2 * Copyright (C) 2016 Google, Inc.
4 * This software is licensed under the terms of the GNU General Public
5 * License version 2, as published by the Free Software Foundation, and
6 * may be copied, distributed, and modified under those terms.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
15 #ifndef ANDROID_INCLUDE_HARDWARE_GOLDFISH_DMA_H
16 #define ANDROID_INCLUDE_HARDWARE_GOLDFISH_DMA_H
19 #include <linux/ioctl.h>
20 #include <linux/types.h>
21 #include <sys/cdefs.h>
25 /* There is an ioctl associated with goldfish dma driver.
26 * Make it conflict with ioctls that are not likely to be used
28 * 'G' 00-3F drivers/misc/sgi-gru/grulib.h conflict!
29 * 'G' 00-0F linux/gigaset_dev.h conflict!
31 #define GOLDFISH_DMA_IOC_MAGIC 'G'
33 #define GOLDFISH_DMA_IOC_LOCK _IOWR(GOLDFISH_DMA_IOC_MAGIC, 0, struct goldfish_dma_ioctl_info)
34 #define GOLDFISH_DMA_IOC_UNLOCK _IOWR(GOLDFISH_DMA_IOC_MAGIC, 1, struct goldfish_dma_ioctl_info)
35 #define GOLDFISH_DMA_IOC_GETOFF _IOWR(GOLDFISH_DMA_IOC_MAGIC, 2, struct goldfish_dma_ioctl_info)
36 #define GOLDFISH_DMA_IOC_CREATE_REGION _IOWR(GOLDFISH_DMA_IOC_MAGIC, 3, struct goldfish_dma_ioctl_info)
38 struct goldfish_dma_ioctl_info {
43 // userspace interface
44 struct goldfish_dma_context {
47 uint64_t sz; // size of reservation
50 int goldfish_dma_lock(struct goldfish_dma_context* cxt);
51 int goldfish_dma_unlock(struct goldfish_dma_context* cxt);
52 int goldfish_dma_create_region(uint32_t sz, struct goldfish_dma_context* res);
54 void* goldfish_dma_map(struct goldfish_dma_context* cxt);
55 int goldfish_dma_unmap(struct goldfish_dma_context* cxt);
57 void goldfish_dma_write(struct goldfish_dma_context* cxt,
61 void goldfish_dma_free(goldfish_dma_context* cxt);
62 uint64_t goldfish_dma_guest_paddr(struct goldfish_dma_context* cxt);