From: Igor Mammedov <imammedo@redhat.com>
To: qemu-devel@nongnu.org
Cc: mst@redhat.com, anisinha@redhat.com, pbonzini@redhat.com,
peter.maydell@linaro.org, shannon.zhaosl@gmail.com,
philmd@linaro.org, zhao1.liu@intel.com, rad@semihalf.com,
leif.lindholm@oss.qualcomm.com, qemu-arm@nongnu.org
Subject: [PATCH v2 01/21] acpi: add API to build WDAT instructions
Date: Tue, 3 Mar 2026 10:25:12 +0100 [thread overview]
Message-ID: <20260303092532.2410177-2-imammedo@redhat.com> (raw)
In-Reply-To: <20260303092532.2410177-1-imammedo@redhat.com>
Add definitions for WDAT[1] actions/instructions
and build_append_wdat_ins() API to build table entries.
1)
"Hardware Watchdog Timers Design Specification"
https://uefi.org/acpi 'Watchdog Action Table (WDAT)'
Signed-off-by: Igor Mammedov <imammedo@redhat.com>
Reviewed-by: Ani Sinha <anisinha@redhat.com>
---
include/hw/acpi/wdat.h | 118 +++++++++++++++++++++++++++++++++++++++++
hw/acpi/aml-build.c | 14 +++++
2 files changed, 132 insertions(+)
create mode 100644 include/hw/acpi/wdat.h
diff --git a/include/hw/acpi/wdat.h b/include/hw/acpi/wdat.h
new file mode 100644
index 0000000000..89803eef4b
--- /dev/null
+++ b/include/hw/acpi/wdat.h
@@ -0,0 +1,118 @@
+/*
+ * Watchdog Action Table (WDAT) definitions
+ *
+ * Copyright Red Hat, Inc. 2026
+ * Author(s): Igor Mammedov <imammedo@redhat.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+#ifndef QEMU_HW_ACPI_WDAT_H
+#define QEMU_HW_ACPI_WDAT_H
+
+#include "hw/acpi/acpi-defs.h"
+
+/*
+ * Watchdog actions as described in
+ * "Hardware Watchdog Timers Design Specification"
+ * for link to spec see https://uefi.org/acpi
+ * 'Watchdog Action Table (WDAT)'
+ */
+typedef enum {
+ /*
+ * Restarts the watchdog timer's countdown. This action is
+ * required.
+ */
+ WDAT_ACTION_RESET = 0x1,
+ /*
+ * Returns the current countdown value of the watchdog hardware
+ * (in count intervals).
+ */
+ WDAT_ACTION_QUERY_CURRENT_COUNTDOWN_PERIOD = 0x4,
+ /*
+ * Returns the countdown value the watchdog hardware is
+ * configured to use when reset (in count intervals).
+ */
+ WDAT_ACTION_QUERY_COUNTDOWN_PERIOD = 0x5,
+ /*
+ * Sets the countdown value (in count intervals) to be used when
+ * the watchdog timer is reset. This action is required if
+ * WDAT_ACTION_RESET does not explicitly write a new
+ * countdown value to a register during a reset. Otherwise, this
+ * action is optional.
+ */
+ WDAT_ACTION_SET_COUNTDOWN_PERIOD = 0x6,
+ /*
+ * Determines if the watchdog hardware is currently in enabled/
+ * running state. The same result must occur when performed from
+ * both from enabled/stopped state and enabled/running state. If
+ * the watchdog hardware is disabled, results are indeterminate.
+ * This action is required.
+ */
+ WDAT_ACTION_QUERY_RUNNING_STATE = 0x8,
+ /*
+ * Starts the watchdog, if not already in running state. If the
+ * watchdog hardware is disabled, results are indeterminate.
+ * This action is required.
+ */
+ WDAT_ACTION_SET_RUNNING_STATE = 0x9,
+ /*
+ * Determines if the watchdog hardware is currently in enabled/
+ * stopped state. The same result must occur when performed from
+ * both the enabled/stopped state and enabled/running state. If
+ * the watchdog hardware is disabled, results are indeterminate.
+ * This action is required.
+ */
+ WDAT_ACTION_QUERY_STOPPED_STATE = 0xA,
+ /*
+ * Stops the watchdog, if not already in stopped state. If the
+ * watchdog hardware is disabled, results are indeterminate.
+ * This action is required.
+ */
+ WDAT_ACTION_SET_STOPPED_STATE = 0xB,
+ /*
+ * Determines if the watchdog hardware is configured to perform a
+ * reboot when the watchdog is fired.
+ */
+ WDAT_ACTION_QUERY_REBOOT = 0x10,
+ /*
+ * Configures the watchdog hardware to perform a reboot when it
+ * is fired.
+ */
+ WDAT_ACTION_SET_REBOOT = 0x11,
+ /*
+ * Determines if the watchdog hardware is configured to perform a
+ * system shutdown when fired.
+ */
+ WDAT_ACTION_QUERY_SHUTDOWN = 0x12,
+ /*
+ * Configures the watchdog hardware to perform a system shutdown
+ * when fired.
+ */
+ WDAT_ACTION_SET_SHUTDOWN = 0x13,
+ /*
+ * Determines if the current boot was caused by the watchdog
+ * firing. The boot status is required to be set if the watchdog
+ * fired and caused a reboot. It is recommended that the
+ * Watchdog Status be set if the watchdog fired and caused a
+ * shutdown. This action is required.
+ */
+ WDAT_ACTION_QUERY_WATCHDOG_STATUS = 0x20,
+ /*
+ * Sets the watchdog's boot status to the default value. This
+ * action is required.
+ */
+ WDAT_ACTION_SET_WATCHDOG_STATUS = 0x21,
+} WDATAction;
+
+#define WDAT_INS_READ_VALUE 0x0
+#define WDAT_INS_READ_COUNTDOWN 0x1
+#define WDAT_INS_WRITE_VALUE 0x2
+#define WDAT_INS_WRITE_COUNTDOWN 0x3
+#define WDAT_INS_PRESERVE_REGISTER 0x80
+
+void build_append_wdat_ins(GArray *table_data,
+ WDATAction action, uint8_t flags,
+ struct AcpiGenericAddress as,
+ uint32_t val, uint32_t mask);
+
+#endif /* QEMU_HW_ACPI_WDAT_H */
diff --git a/hw/acpi/aml-build.c b/hw/acpi/aml-build.c
index ea1c415b21..9f9ce28dcc 100644
--- a/hw/acpi/aml-build.c
+++ b/hw/acpi/aml-build.c
@@ -32,6 +32,7 @@
#include "hw/pci/pci_bus.h"
#include "hw/pci/pci_bridge.h"
#include "qemu/cutils.h"
+#include "hw/acpi/wdat.h"
static GArray *build_alloc_array(void)
{
@@ -2647,3 +2648,16 @@ Aml *aml_error_device(void)
return dev;
}
+
+void build_append_wdat_ins(GArray *table_data,
+ WDATAction action, uint8_t flags,
+ struct AcpiGenericAddress as,
+ uint32_t val, uint32_t mask)
+{
+ build_append_int_noprefix(table_data, action, 1); /* Watchdog Action */
+ build_append_int_noprefix(table_data, flags, 1); /* Instruction Flags */
+ build_append_int_noprefix(table_data, 0, 2); /* Reserved */
+ build_append_gas_from_struct(table_data, &as); /* Register Region */
+ build_append_int_noprefix(table_data, val, 4); /* Value */
+ build_append_int_noprefix(table_data, mask, 4); /* Mask */
+}
--
2.47.3
next prev parent reply other threads:[~2026-03-03 9:26 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-03 9:25 [PATCH v2 00/21] Introduce ACPI watchdog for Q35 and arm/virt boards Igor Mammedov
2026-03-03 9:25 ` Igor Mammedov [this message]
2026-05-13 15:23 ` [PATCH v2 01/21] acpi: add API to build WDAT instructions Zhao Liu
2026-03-03 9:25 ` [PATCH v2 02/21] x86: q35: add 'wdat' property Igor Mammedov
2026-05-13 14:58 ` Zhao Liu
2026-05-14 7:16 ` Ani Sinha
2026-03-03 9:25 ` [PATCH v2 03/21] x86: q35: generate WDAT ACPI table Igor Mammedov
2026-05-13 15:47 ` Zhao Liu
2026-05-13 15:28 ` Michael S. Tsirkin
2026-05-14 14:32 ` Igor Mammedov
2026-03-03 9:25 ` [PATCH v2 04/21] tests: acpi: x86/q35: whitelist new WDAT table Igor Mammedov
2026-05-13 15:48 ` Zhao Liu
2026-03-03 9:25 ` [PATCH v2 05/21] tests: acpi: x86/q35: add WDAT table test case Igor Mammedov
2026-05-13 15:49 ` Zhao Liu
2026-03-03 9:25 ` [PATCH v2 06/21] tests: acpi: x86/q35: update expected WDAT blob Igor Mammedov
2026-05-13 15:48 ` Zhao Liu
2026-03-03 9:25 ` [PATCH v2 07/21] arm: sbsa_gwdt: fixup default "clock-frequency" Igor Mammedov
2026-03-03 9:25 ` [PATCH v2 08/21] arm: add tracing events to sbsa_gwdt Igor Mammedov
2026-03-03 9:25 ` [PATCH v2 09/21] arm: virt: create sbsa_gwdt watchdog Igor Mammedov
2026-03-03 9:25 ` [PATCH v2 10/21] arm: sbsa_gwdt: add 'wdat' option Igor Mammedov
2026-03-03 9:25 ` [PATCH v2 11/21] arm: virt: add support for WDAT based watchdog Igor Mammedov
2026-03-03 9:25 ` [PATCH v2 12/21] tests: acpi: arm/virt: whitelist new WDAT table Igor Mammedov
2026-03-03 9:25 ` [PATCH v2 13/21] tests: acpi: arm/virt: add WDAT table test case Igor Mammedov
2026-03-03 9:25 ` [PATCH v2 14/21] tests: acpi: arm/virt: update expected WDAT blob Igor Mammedov
2026-03-03 9:25 ` [PATCH v2 15/21] tests: acpi: arm/virt: whitelist GTDT table Igor Mammedov
2026-03-03 9:25 ` [PATCH v2 16/21] tests: acpi: arm/virt: add GTDT watchdog table test case Igor Mammedov
2026-03-03 9:25 ` [PATCH v2 17/21] tests: acpi: arm/virt: update expected GTDT blob Igor Mammedov
2026-03-03 9:25 ` [PATCH v2 18/21] sbsa_gwdt: reduce code ident Igor Mammedov
2026-03-03 9:25 ` [PATCH v2 19/21] sbsa_gwdt: move all foo_REFRESH logic under REFRESH condition Igor Mammedov
2026-03-03 9:25 ` [PATCH v2 20/21] sbsa_gwdt: reschedule timer on direct WCV load Igor Mammedov
2026-03-03 9:25 ` [PATCH v2 21/21] sbsa_gwdt: limit compare_value to INT64_MAX Igor Mammedov
2026-04-28 14:12 ` [PATCH v2 00/21] Introduce ACPI watchdog for Q35 and arm/virt boards Igor Mammedov
2026-05-12 13:30 ` Igor Mammedov
2026-05-12 14:45 ` Ani Sinha
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260303092532.2410177-2-imammedo@redhat.com \
--to=imammedo@redhat.com \
--cc=anisinha@redhat.com \
--cc=leif.lindholm@oss.qualcomm.com \
--cc=mst@redhat.com \
--cc=pbonzini@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=philmd@linaro.org \
--cc=qemu-arm@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=rad@semihalf.com \
--cc=shannon.zhaosl@gmail.com \
--cc=zhao1.liu@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.