Hi Oliver,

On Tue, Jan 27, 2026 at 11:02:52AM +0100, Oliver Steffen wrote:
Make the BIOS linker optional in acpi_table_end() and calculate the ACPI
table checksum directly if no linker is provided.

This makes it possible to call for example
acpi_build_madt() from outside the ACPI table builder context.

Signed-off-by: Oliver Steffen <[email protected]>
---
hw/acpi/aml-build.c | 29 +++++++++++++++++++++++++++--
1 file changed, 27 insertions(+), 2 deletions(-)

diff --git a/hw/acpi/aml-build.c b/hw/acpi/aml-build.c
index dad4cfcc7d..6a3650076f 100644
--- a/hw/acpi/aml-build.c
+++ b/hw/acpi/aml-build.c
@@ -1730,6 +1730,25 @@ void acpi_table_begin(AcpiTable *desc, GArray *array)
    build_append_int_noprefix(array, 1, 4); /* Creator Revision */
}

+static uint8_t calculate_acpi_checksum(const gchar *data, size_t len)
+{
+    size_t i;
+    uint8_t sum = 0;
+
+    for (i = 0; i < len; ++i) {
+        sum += (uint8_t)data[i];
+    }
+
+    return sum;
+}
+

In `hw/acpi/core.c` there is a `acpi_checksum` function that does exactly this. Can we reuse this to reduce code duplication? Currently that function is marked as static.

Thanks for all the work so far.

Luigi


Reply via email to