Lingfeng Yang | 88c170c | 2016-11-30 00:52:35 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2016 Google, Inc. |
| 3 | * |
| 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. |
| 7 | * |
| 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. |
| 12 | * |
| 13 | */ |
| 14 | |
| 15 | #ifndef ANDROID_INCLUDE_HARDWARE_GOLDFISH_DMA_H |
| 16 | #define ANDROID_INCLUDE_HARDWARE_GOLDFISH_DMA_H |
| 17 | |
Lingfeng Yang | e38d15c | 2018-09-24 16:24:01 -0700 | [diff] [blame] | 18 | #include <inttypes.h> |
Lingfeng Yang | 88c170c | 2016-11-30 00:52:35 +0000 | [diff] [blame] | 19 | |
| 20 | // userspace interface |
| 21 | struct goldfish_dma_context { |
Roman Kiryanov | 96a068f | 2018-06-13 17:05:05 -0700 | [diff] [blame] | 22 | uint64_t mapped_addr; |
| 23 | uint32_t size; |
| 24 | int32_t fd; |
Lingfeng Yang | 88c170c | 2016-11-30 00:52:35 +0000 | [diff] [blame] | 25 | }; |
| 26 | |
| 27 | int goldfish_dma_lock(struct goldfish_dma_context* cxt); |
| 28 | int goldfish_dma_unlock(struct goldfish_dma_context* cxt); |
| 29 | int goldfish_dma_create_region(uint32_t sz, struct goldfish_dma_context* res); |
| 30 | |
| 31 | void* goldfish_dma_map(struct goldfish_dma_context* cxt); |
| 32 | int goldfish_dma_unmap(struct goldfish_dma_context* cxt); |
| 33 | |
| 34 | void goldfish_dma_write(struct goldfish_dma_context* cxt, |
Roman Kiryanov | 96a068f | 2018-06-13 17:05:05 -0700 | [diff] [blame] | 35 | const void* to_write, |
Lingfeng Yang | 88c170c | 2016-11-30 00:52:35 +0000 | [diff] [blame] | 36 | uint32_t sz); |
| 37 | |
| 38 | void goldfish_dma_free(goldfish_dma_context* cxt); |
Roman Kiryanov | be1c0c2 | 2018-10-02 18:07:14 -0700 | [diff] [blame^] | 39 | uint64_t goldfish_dma_guest_paddr(const struct goldfish_dma_context* cxt); |
Lingfeng Yang | 88c170c | 2016-11-30 00:52:35 +0000 | [diff] [blame] | 40 | |
| 41 | #endif |