dp8393x: Always use 32-bit accesses
[qemu/ar7.git] / plugins / plugin.h
blob1aa29dcaddf20d762c59f8571f9bdf6610664934
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 #define QEMU_PLUGIN_MIN_VERSION 0
19 /* global state */
20 struct qemu_plugin_state {
21 QTAILQ_HEAD(, qemu_plugin_ctx) ctxs;
22 QLIST_HEAD(, qemu_plugin_cb) cb_lists[QEMU_PLUGIN_EV_MAX];
24 * Use the HT as a hash map by inserting k == v, which saves memory as
25 * documented by GLib. The parent struct is obtained with container_of().
27 GHashTable *id_ht;
29 * Use the HT as a hash map. Note that we could use a list here,
30 * but with the HT we avoid adding a field to CPUState.
32 GHashTable *cpu_ht;
33 DECLARE_BITMAP(mask, QEMU_PLUGIN_EV_MAX);
35 * @lock protects the struct as well as ctx->uninstalling.
36 * The lock must be acquired by all API ops.
37 * The lock is recursive, which greatly simplifies things, e.g.
38 * callback registration from qemu_plugin_vcpu_for_each().
40 QemuRecMutex lock;
42 * HT of callbacks invoked from helpers. All entries are freed when
43 * the code cache is flushed.
45 struct qht dyn_cb_arr_ht;
49 struct qemu_plugin_ctx {
50 GModule *handle;
51 qemu_plugin_id_t id;
52 struct qemu_plugin_cb *callbacks[QEMU_PLUGIN_EV_MAX];
53 QTAILQ_ENTRY(qemu_plugin_ctx) entry;
55 * keep a reference to @desc until uninstall, so that plugins do not have
56 * to strdup plugin args.
58 struct qemu_plugin_desc *desc;
59 bool installing;
60 bool uninstalling;
61 bool resetting;
64 struct qemu_plugin_ctx *plugin_id_to_ctx_locked(qemu_plugin_id_t id);
66 void plugin_register_inline_op(GArray **arr,
67 enum qemu_plugin_mem_rw rw,
68 enum qemu_plugin_op op, void *ptr,
69 uint64_t imm);
71 void plugin_reset_uninstall(qemu_plugin_id_t id,
72 qemu_plugin_simple_cb_t cb,
73 bool reset);
75 void plugin_register_cb(qemu_plugin_id_t id, enum qemu_plugin_event ev,
76 void *func);
78 void plugin_unregister_cb__locked(struct qemu_plugin_ctx *ctx,
79 enum qemu_plugin_event ev);
81 void
82 plugin_register_cb_udata(qemu_plugin_id_t id, enum qemu_plugin_event ev,
83 void *func, void *udata);
85 void
86 plugin_register_dyn_cb__udata(GArray **arr,
87 qemu_plugin_vcpu_udata_cb_t cb,
88 enum qemu_plugin_cb_flags flags, void *udata);
91 void plugin_register_vcpu_mem_cb(GArray **arr,
92 void *cb,
93 enum qemu_plugin_cb_flags flags,
94 enum qemu_plugin_mem_rw rw,
95 void *udata);
97 void exec_inline_op(struct qemu_plugin_dyn_cb *cb);
99 #endif /* _PLUGIN_INTERNAL_H_ */