• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2023 Google
3  * SPDX-License-Identifier: MIT
4  */
5 
6 #pragma once
7 
8 #include <inttypes.h>
9 #include <stddef.h>
10 
11 typedef int address_space_handle_t;
12 
13 enum AddressSpaceSubdeviceType {
14     NoSubdevice = -1,
15     Graphics = 0,
16     Media = 1,
17     HostMemoryAllocator = 5,
18     SharedSlotsHostMemoryAllocator = 6,
19     VirtioGpuGraphics = 10,
20 };
21 
22 // We also expose the ping info struct that is shared between host and guest.
23 struct address_space_ping {
24     uint64_t offset;
25     uint64_t size;
26     uint64_t metadata;
27     uint32_t resourceId;
28     uint32_t wait_fd;
29     uint32_t wait_flags;
30     uint32_t direction;
31 };
32 
33 // typedef/struct to abstract over goldfish vs virtio-gpu implementations
34 typedef address_space_handle_t (*address_space_open_t)(void);
35 typedef void (*address_space_close_t)(address_space_handle_t);
36 
37 typedef bool (*address_space_allocate_t)(
38     address_space_handle_t, size_t size, uint64_t* phys_addr, uint64_t* offset);
39 typedef bool (*address_space_free_t)(
40     address_space_handle_t, uint64_t offset);
41 
42 typedef bool (*address_space_claim_shared_t)(
43     address_space_handle_t, uint64_t offset, uint64_t size);
44 typedef bool (*address_space_unclaim_shared_t)(
45     address_space_handle_t, uint64_t offset);
46 
47 // pgoff is the offset into the page to return in the result
48 typedef void* (*address_space_map_t)(
49     address_space_handle_t, uint64_t offset, uint64_t size, uint64_t pgoff);
50 typedef void (*address_space_unmap_t)(void* ptr, uint64_t size);
51 
52 typedef bool (*address_space_set_subdevice_type_t)(
53     address_space_handle_t, AddressSpaceSubdeviceType type, address_space_handle_t*);
54 typedef bool (*address_space_ping_t)(
55     address_space_handle_t, struct address_space_ping*);
56 
57 struct address_space_ops {
58     address_space_open_t open;
59     address_space_close_t close;
60     address_space_claim_shared_t claim_shared;
61     address_space_unclaim_shared_t unclaim_shared;
62     address_space_map_t map;
63     address_space_unmap_t unmap;
64     address_space_set_subdevice_type_t set_subdevice_type;
65     address_space_ping_t ping;
66 };
67