multi-process: create IOHUB object to handle irq
[qemu/ar7.git] / include / hw / remote / mpqemu-link.h
blob71d206f00e1d359a67f36ef9274d5adf7291112d
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"
18 #include "io/channel-socket.h"
19 #include "hw/remote/proxy.h"
21 #define REMOTE_MAX_FDS 8
23 #define MPQEMU_MSG_HDR_SIZE offsetof(MPQemuMsg, data.u64)
25 /**
26 * MPQemuCmd:
28 * MPQemuCmd enum type to specify the command to be executed on the remote
29 * device.
31 * This uses a private protocol between QEMU and the remote process. vfio-user
32 * protocol would supersede this in the future.
35 typedef enum {
36 MPQEMU_CMD_SYNC_SYSMEM,
37 MPQEMU_CMD_RET,
38 MPQEMU_CMD_PCI_CFGWRITE,
39 MPQEMU_CMD_PCI_CFGREAD,
40 MPQEMU_CMD_BAR_WRITE,
41 MPQEMU_CMD_BAR_READ,
42 MPQEMU_CMD_SET_IRQFD,
43 MPQEMU_CMD_MAX,
44 } MPQemuCmd;
46 typedef struct {
47 hwaddr gpas[REMOTE_MAX_FDS];
48 uint64_t sizes[REMOTE_MAX_FDS];
49 off_t offsets[REMOTE_MAX_FDS];
50 } SyncSysmemMsg;
52 typedef struct {
53 uint32_t addr;
54 uint32_t val;
55 int len;
56 } PciConfDataMsg;
58 typedef struct {
59 hwaddr addr;
60 uint64_t val;
61 unsigned size;
62 bool memory;
63 } BarAccessMsg;
65 /**
66 * MPQemuMsg:
67 * @cmd: The remote command
68 * @size: Size of the data to be shared
69 * @data: Structured data
70 * @fds: File descriptors to be shared with remote device
72 * MPQemuMsg Format of the message sent to the remote device from QEMU.
76 typedef struct {
77 int cmd;
78 size_t size;
80 union {
81 uint64_t u64;
82 PciConfDataMsg pci_conf_data;
83 SyncSysmemMsg sync_sysmem;
84 BarAccessMsg bar_access;
85 } data;
87 int fds[REMOTE_MAX_FDS];
88 int num_fds;
89 } MPQemuMsg;
91 bool mpqemu_msg_send(MPQemuMsg *msg, QIOChannel *ioc, Error **errp);
92 bool mpqemu_msg_recv(MPQemuMsg *msg, QIOChannel *ioc, Error **errp);
94 uint64_t mpqemu_msg_send_and_await_reply(MPQemuMsg *msg, PCIProxyDev *pdev,
95 Error **errp);
96 bool mpqemu_msg_valid(MPQemuMsg *msg);
98 #endif