target/arm/kvm: host cpu: Add support for sve<N> properties
[qemu/ar7.git] / plugins / plugin.h
blob5482168d797ab74cc40ce340b2160a01ba4a373f
1 /*
2 * Plugin Shared Internal Functions
4 * Copyright (C) 2019, Linaro
6 * License: GNU GPL, version 2 or later.
7 * See the COPYING file in the top-level directory.
9 * SPDX-License-Identifier: GPL-2.0-or-later
12 #ifndef _PLUGIN_INTERNAL_H_
13 #define _PLUGIN_INTERNAL_H_
15 #include <gmodule.h>
17 /* global state */
18 struct qemu_plugin_state {
19 QTAILQ_HEAD(, qemu_plugin_ctx) ctxs;
20 QLIST_HEAD(, qemu_plugin_cb) cb_lists[QEMU_PLUGIN_EV_MAX];
22 * Use the HT as a hash map by inserting k == v, which saves memory as
23 * documented by GLib. The parent struct is obtained with container_of().
25 GHashTable *id_ht;
27 * Use the HT as a hash map. Note that we could use a list here,
28 * but with the HT we avoid adding a field to CPUState.
30 GHashTable *cpu_ht;
31 DECLARE_BITMAP(mask, QEMU_PLUGIN_EV_MAX);
33 * @lock protects the struct as well as ctx->uninstalling.
34 * The lock must be acquired by all API ops.
35 * The lock is recursive, which greatly simplifies things, e.g.
36 * callback registration from qemu_plugin_vcpu_for_each().
38 QemuRecMutex lock;
40 * HT of callbacks invoked from helpers. All entries are freed when
41 * the code cache is flushed.
43 struct qht dyn_cb_arr_ht;
47 struct qemu_plugin_ctx {
48 GModule *handle;
49 qemu_plugin_id_t id;
50 struct qemu_plugin_cb *callbacks[QEMU_PLUGIN_EV_MAX];
51 QTAILQ_ENTRY(qemu_plugin_ctx) entry;
53 * keep a reference to @desc until uninstall, so that plugins do not have
54 * to strdup plugin args.
56 struct qemu_plugin_desc *desc;
57 bool installing;
58 bool uninstalling;
59 bool resetting;
62 struct qemu_plugin_ctx *plugin_id_to_ctx_locked(qemu_plugin_id_t id);
64 void plugin_register_inline_op(GArray **arr,
65 enum qemu_plugin_mem_rw rw,
66 enum qemu_plugin_op op, void *ptr,
67 uint64_t imm);
69 void plugin_reset_uninstall(qemu_plugin_id_t id,
70 qemu_plugin_simple_cb_t cb,
71 bool reset);
73 void plugin_register_cb(qemu_plugin_id_t id, enum qemu_plugin_event ev,
74 void *func);
76 void plugin_unregister_cb__locked(struct qemu_plugin_ctx *ctx,
77 enum qemu_plugin_event ev);
79 void
80 plugin_register_cb_udata(qemu_plugin_id_t id, enum qemu_plugin_event ev,
81 void *func, void *udata);
83 void
84 plugin_register_dyn_cb__udata(GArray **arr,
85 qemu_plugin_vcpu_udata_cb_t cb,
86 enum qemu_plugin_cb_flags flags, void *udata);
89 void plugin_register_vcpu_mem_cb(GArray **arr,
90 void *cb,
91 enum qemu_plugin_cb_flags flags,
92 enum qemu_plugin_mem_rw rw,
93 void *udata);
95 void exec_inline_op(struct qemu_plugin_dyn_cb *cb);
97 #endif /* _PLUGIN_INTERNAL_H_ */