@@ -2580,8 +2580,8 @@ static void memwrite(int64_t addr, uint8List *bytes, CPUState *cpu,
MemTxResult r = address_space_write(&address_space_memory, addr,
MEMTXATTRS_UNSPECIFIED, buf, l);
if (r != MEMTX_OK) {
- error_setg(errp, "Invalid addr 0x%016" PRIx64 "/size %" PRId64
- " specified", addr, size);
+ error_setg(errp, "Invalid addr 0x%016" PRIx64 "/size %" PRIu32
+ " specified", addr, l);
return;
}
}
@@ -726,3 +726,33 @@ MemoryInfo *qmp_query_memory_size_summary(Error **errp)
return mem_info;
}
+
+void qmp_gpio_set(const char *path, bool has_gpio, const char *gpio,
+ bool has_number, int64_t number, bool value, Error **errp)
+{
+ DeviceState *dev;
+ qemu_irq irq;
+
+ dev = DEVICE(object_resolve_path(path, NULL));
+ if (!dev) {
+ error_set(errp, ERROR_CLASS_DEVICE_NOT_FOUND,
+ "Cannot find device '%s'", path);
+ return;
+ }
+
+ if (!has_gpio) {
+ gpio = NULL;
+ }
+ if (!has_number) {
+ number = 0;
+ }
+ irq = qdev_get_gpio_in_named(dev, gpio, number);
+ if (!irq) {
+ error_set(errp, ERROR_CLASS_GENERIC_ERROR,
+ "GPIO input '%s[%"PRId64"]' does not exists",
+ has_gpio ? gpio : "unnamed", number);
+ return;
+ }
+
+ qemu_set_irq(irq, value);
+}
@@ -3166,3 +3166,32 @@
{ 'command': 'pmemwrite',
'data': {'addr': 'int', 'bytes': ['uint8']}
}
+
+##
+# @gpio-set:
+#
+# @path: Path to the device.
+#
+# @gpio: Name of the GPIO will be unnamed-gpio if omitted.
+#
+# @number: Number of the GPIO line, 0 if omitted.
+#
+# @value: Value (boolean) to be set for the GPIO.
+#
+# Returns: nothing in case of success
+#
+# Since 4.1
+#
+# Example:
+#
+# -> { "execute": "gpio-set",
+# "arguments": { "path": "/machine/unattached/device[5]",
+# "gpio": "ssi-gpio-cs",
+# "number": 0,
+# "value": true } }
+# <- { "return": {} }
+#
+##
+{ 'command': 'gpio-set',
+ 'data': { 'path': 'str', '*gpio': 'str', '*number': 'int', 'value': 'bool' }
+}
This adds the "gpio-set" qmp command. Taking the device path, the gpio name and number, the command set the value (true or false) of the gpio. It works only on gpio input line. This is based on Frederic Konrad's work. Signed-off-by: Damien Hedde <damien.hedde@greensocs.com> --- cpus.c | 4 ++-- monitor/qmp-cmds.c | 30 ++++++++++++++++++++++++++++++ qapi/misc.json | 29 +++++++++++++++++++++++++++++ 3 files changed, 61 insertions(+), 2 deletions(-)