multi-process: setup memory manager for remote device
[qemu/ar7.git] / include / hw / remote / mpqemu-link.h
blob6ee5bc57512e4c59cbf759f47b189a434646f24a
1 /*
2 * Communication channel between QEMU and remote device process
4 * Copyright © 2018, 2021 Oracle and/or its affiliates.
6 * This work is licensed under the terms of the GNU GPL, version 2 or later.
7 * See the COPYING file in the top-level directory.
9 */
11 #ifndef MPQEMU_LINK_H
12 #define MPQEMU_LINK_H
14 #include "qom/object.h"
15 #include "qemu/thread.h"
16 #include "io/channel.h"
17 #include "exec/hwaddr.h"
19 #define REMOTE_MAX_FDS 8
21 #define MPQEMU_MSG_HDR_SIZE offsetof(MPQemuMsg, data.u64)
23 /**
24 * MPQemuCmd:
26 * MPQemuCmd enum type to specify the command to be executed on the remote
27 * device.
29 * This uses a private protocol between QEMU and the remote process. vfio-user
30 * protocol would supersede this in the future.
33 typedef enum {
34 MPQEMU_CMD_SYNC_SYSMEM,
35 MPQEMU_CMD_MAX,
36 } MPQemuCmd;
38 typedef struct {
39 hwaddr gpas[REMOTE_MAX_FDS];
40 uint64_t sizes[REMOTE_MAX_FDS];
41 off_t offsets[REMOTE_MAX_FDS];
42 } SyncSysmemMsg;
44 /**
45 * MPQemuMsg:
46 * @cmd: The remote command
47 * @size: Size of the data to be shared
48 * @data: Structured data
49 * @fds: File descriptors to be shared with remote device
51 * MPQemuMsg Format of the message sent to the remote device from QEMU.
55 typedef struct {
56 int cmd;
57 size_t size;
59 union {
60 uint64_t u64;
61 SyncSysmemMsg sync_sysmem;
62 } data;
64 int fds[REMOTE_MAX_FDS];
65 int num_fds;
66 } MPQemuMsg;
68 bool mpqemu_msg_send(MPQemuMsg *msg, QIOChannel *ioc, Error **errp);
69 bool mpqemu_msg_recv(MPQemuMsg *msg, QIOChannel *ioc, Error **errp);
71 bool mpqemu_msg_valid(MPQemuMsg *msg);
73 #endif