mirror of
https://github.com/qemu/qemu.git
synced 2026-07-08 17:46:10 +00:00
acpi: introduce WDAT table for GWDT
Add build_gwdt_wdat() to generate a Watchdog Action Table designed for SBSA Generic Watchdog Timer. Signed-off-by: Igor Mammedov <imammedo@redhat.com> Reviewed-by: Eric Auger <eric.auger@redhat.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com> Message-ID: <20260702145856.1539572-7-imammedo@redhat.com>
This commit is contained in:
committed by
Michael S. Tsirkin
parent
51011f7f36
commit
beadd272c1
@@ -31,11 +31,13 @@ acpi_ss.add(when: 'CONFIG_ACPI_ERST', if_true: files('erst.c'))
|
||||
acpi_ss.add(when: 'CONFIG_IPMI', if_true: files('ipmi.c'))
|
||||
stub_ss.add(files('ipmi-stub.c'))
|
||||
stub_ss.add(files('acpi-x86-stub.c'))
|
||||
acpi_ss.add(when: 'CONFIG_WDT_SBSA', if_true: files('wdat-gwdt.c'))
|
||||
if have_tpm
|
||||
acpi_ss.add(files('tpm.c'))
|
||||
endif
|
||||
stub_ss.add(files('acpi-stub.c', 'aml-build-stub.c', 'ghes-stub.c'))
|
||||
stub_ss.add(files('pci-bridge-stub.c'))
|
||||
stub_ss.add(files('wdat-gwdt-stub.c'))
|
||||
system_ss.add_all(when: 'CONFIG_ACPI', if_true: acpi_ss)
|
||||
system_ss.add(when: 'CONFIG_GHES_CPER', if_true: files('ghes_cper.c'))
|
||||
stub_ss.add(files('ghes_cper_stub.c'))
|
||||
|
||||
16
hw/acpi/wdat-gwdt-stub.c
Normal file
16
hw/acpi/wdat-gwdt-stub.c
Normal file
@@ -0,0 +1,16 @@
|
||||
/*
|
||||
* Copyright Red Hat, Inc. 2026
|
||||
* Author(s): Igor Mammedov <imammedo@redhat.com>
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-2.0-or-later
|
||||
*/
|
||||
|
||||
#include "qemu/osdep.h"
|
||||
#include "hw/acpi/wdat-gwdt.h"
|
||||
|
||||
void build_gwdt_wdat(GArray *table_data, BIOSLinker *linker, const char *oem_id,
|
||||
const char *oem_table_id, uint64_t rbase, uint64_t cbase,
|
||||
uint64_t freq)
|
||||
{
|
||||
g_assert_not_reached();
|
||||
}
|
||||
99
hw/acpi/wdat-gwdt.c
Normal file
99
hw/acpi/wdat-gwdt.c
Normal file
@@ -0,0 +1,99 @@
|
||||
/*
|
||||
* SBSA GWDT Watchdog Action Table (WDAT)
|
||||
*
|
||||
* Copyright Red Hat, Inc. 2026
|
||||
* Author(s): Igor Mammedov <imammedo@redhat.com>
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-2.0-or-later
|
||||
*/
|
||||
|
||||
#include "qemu/osdep.h"
|
||||
#include "hw/acpi/aml-build.h"
|
||||
#include "hw/acpi/wdat-gwdt.h"
|
||||
#include "hw/acpi/wdat.h"
|
||||
#include "hw/watchdog/sbsa_gwdt.h"
|
||||
|
||||
#define GWDT_REG(base, reg_offset, reg_width) { \
|
||||
.space_id = AML_AS_SYSTEM_MEMORY, \
|
||||
.address = base + reg_offset, .bit_width = reg_width, \
|
||||
.access_width = AML_DWORD_ACC };
|
||||
|
||||
/*
|
||||
* "Hardware Watchdog Timers Design Specification"
|
||||
* https://uefi.org/acpi 'Watchdog Action Table (WDAT)'
|
||||
*/
|
||||
void build_gwdt_wdat(GArray *table_data, BIOSLinker *linker, const char *oem_id,
|
||||
const char *oem_table_id, uint64_t rbase, uint64_t cbase,
|
||||
uint64_t freq)
|
||||
{
|
||||
AcpiTable table = { .sig = "WDAT", .rev = 1, .oem_id = oem_id,
|
||||
.oem_table_id = oem_table_id };
|
||||
|
||||
struct AcpiGenericAddress wrr = GWDT_REG(rbase, 0x0, 32);
|
||||
struct AcpiGenericAddress wor_l = GWDT_REG(cbase, SBSA_GWDT_WOR, 32);
|
||||
struct AcpiGenericAddress wcs = GWDT_REG(cbase, SBSA_GWDT_WCS, 32);
|
||||
|
||||
acpi_table_begin(&table, table_data);
|
||||
build_append_int_noprefix(table_data, 0x20, 4); /* Watchdog Header Length */
|
||||
/*
|
||||
* PCI location fields are set to 0xff to indicate
|
||||
* that the watchdog is not a PCI device.
|
||||
*/
|
||||
build_append_int_noprefix(table_data, 0xff, 2); /* PCI Segment */
|
||||
build_append_int_noprefix(table_data, 0xff, 1); /* PCI Bus Number */
|
||||
build_append_int_noprefix(table_data, 0xff, 1); /* PCI Device Number */
|
||||
build_append_int_noprefix(table_data, 0xff, 1); /* PCI Function Number */
|
||||
build_append_int_noprefix(table_data, 0, 3); /* Reserved */
|
||||
/*
|
||||
* WDAT spec: "The clock interval that the WDT uses must be
|
||||
* greater than or equal to 1 millisecond."
|
||||
*/
|
||||
g_assert(freq <= 1000);
|
||||
/* Timer Period, ms */
|
||||
build_append_int_noprefix(table_data, 1000 / freq, 4);
|
||||
/*
|
||||
* WDAT spec: "The time-out period before the WDT fires is recommended
|
||||
* to be at least 5 minutes."
|
||||
* Set max count to 10min and min count to 5sec.
|
||||
*/
|
||||
build_append_int_noprefix(table_data, 600 * freq, 4); /* Maximum Count */
|
||||
build_append_int_noprefix(table_data, 5 * freq, 4); /* Minimum Count */
|
||||
/*
|
||||
* WATCHDOG_ENABLED | WATCHDOG_STOPPED_IN_SLEEP_STATE
|
||||
*/
|
||||
build_append_int_noprefix(table_data, 0x81, 1); /* Watchdog Flags */
|
||||
build_append_int_noprefix(table_data, 0, 3); /* Reserved */
|
||||
/*
|
||||
* watchdog instruction entries
|
||||
*/
|
||||
build_append_int_noprefix(table_data, 8, 4);
|
||||
/* Action table: WCS (control/status) register actions */
|
||||
build_append_wdat_ins(table_data, WDAT_ACTION_QUERY_RUNNING_STATE,
|
||||
WDAT_INS_READ_VALUE,
|
||||
wcs, 0x1, 0x1);
|
||||
build_append_wdat_ins(table_data, WDAT_ACTION_SET_RUNNING_STATE,
|
||||
WDAT_INS_WRITE_VALUE | WDAT_INS_PRESERVE_REGISTER,
|
||||
wcs, 1, 0x00000001);
|
||||
build_append_wdat_ins(table_data, WDAT_ACTION_QUERY_STOPPED_STATE,
|
||||
WDAT_INS_READ_VALUE,
|
||||
wcs, 0x0, 0x00000001);
|
||||
build_append_wdat_ins(table_data, WDAT_ACTION_SET_STOPPED_STATE,
|
||||
WDAT_INS_WRITE_VALUE | WDAT_INS_PRESERVE_REGISTER,
|
||||
wcs, 0x0, 0x00000001);
|
||||
build_append_wdat_ins(table_data, WDAT_ACTION_QUERY_WATCHDOG_STATUS,
|
||||
WDAT_INS_READ_VALUE,
|
||||
wcs, 0x4, 0x00000004);
|
||||
/* WOR (offset) and WRR (refresh) register actions */
|
||||
build_append_wdat_ins(table_data, WDAT_ACTION_SET_COUNTDOWN_PERIOD,
|
||||
WDAT_INS_WRITE_COUNTDOWN,
|
||||
wor_l, 0, 0xffffffff);
|
||||
/* WRR: any write refreshes the watchdog, value is ignored */
|
||||
build_append_wdat_ins(table_data, WDAT_ACTION_RESET,
|
||||
WDAT_INS_WRITE_VALUE,
|
||||
wrr, 0x1, 0x1);
|
||||
build_append_wdat_ins(table_data, WDAT_ACTION_SET_WATCHDOG_STATUS,
|
||||
WDAT_INS_WRITE_VALUE | WDAT_INS_PRESERVE_REGISTER,
|
||||
wrr, 0x4, 0x4);
|
||||
|
||||
acpi_table_end(linker, &table);
|
||||
}
|
||||
19
include/hw/acpi/wdat-gwdt.h
Normal file
19
include/hw/acpi/wdat-gwdt.h
Normal file
@@ -0,0 +1,19 @@
|
||||
/*
|
||||
* GWDT Watchdog Action Table (WDAT) definition
|
||||
*
|
||||
* 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_GWDT_H
|
||||
#define QEMU_HW_ACPI_WDAT_GWDT_H
|
||||
|
||||
#include "hw/acpi/aml-build.h"
|
||||
#include "hw/watchdog/sbsa_gwdt.h"
|
||||
|
||||
void build_gwdt_wdat(GArray *table_data, BIOSLinker *linker, const char *oem_id,
|
||||
const char *oem_table_id, uint64_t rbase, uint64_t cbase,
|
||||
uint64_t freq);
|
||||
|
||||
#endif /* QEMU_HW_ACPI_WDAT_GWDT_H */
|
||||
Reference in New Issue
Block a user