@@ -126,6 +126,7 @@ fwts_SOURCES = main.c \
acpi/pmtt/pmtt.c \
acpi/pptt/pptt.c \
acpi/rasf/rasf.c \
+ acpi/rgrt/rgrt.c \
acpi/rsdp/rsdp.c \
sbbr/rsdp/rsdp.c \
acpi/rsdt/rsdt.c \
new file mode 100644
@@ -0,0 +1,87 @@
+/*
+ * Copyright (C) 2022 Canonical
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+#include "fwts.h"
+
+#if defined(FWTS_HAS_ACPI)
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <unistd.h>
+#include <inttypes.h>
+#include <string.h>
+
+static fwts_acpi_table_info *table;
+acpi_table_init(RGRT, &table)
+
+static void rgrt_data_hexdump(fwts_framework *fw, uint8_t *data, size_t size)
+{
+ size_t i;
+
+ for (i = 0; i < size; i += 16) {
+ char buffer[128];
+ size_t left = size - i;
+
+ fwts_dump_raw_data(buffer, sizeof(buffer), data + i, i, left > 16 ? 16 : left);
+ fwts_log_info_verbatim(fw, " %s", buffer + 2);
+ }
+}
+
+static int rgrt_test1(fwts_framework *fw)
+{
+ bool passed = true;
+ fwts_acpi_table_rgrt *rgrt = (fwts_acpi_table_rgrt *)table->data;
+
+ if (!fwts_acpi_table_length(fw, "RGRT", table->length, sizeof(fwts_acpi_table_rgrt))) {
+ passed = false;
+ goto done;
+ }
+
+ fwts_log_info_verbatim(fw, "RGRT Regulatory Graphics Resource Table:");
+ fwts_log_info_simp_int(fw, " Version: ", rgrt->version);
+ fwts_log_info_simp_int(fw, " Image Type: ", rgrt->image_type);
+ fwts_log_info_simp_int(fw, " Reserved: ", rgrt->reserved);
+ fwts_log_info_verbatim(fw, " Image:");
+ rgrt_data_hexdump(fw, rgrt->image, table->length - sizeof(fwts_acpi_table_rgrt));
+
+ fwts_acpi_fixed_value(fw, LOG_LEVEL_MEDIUM, "RGRT", "Version", rgrt->version, 1, &passed);
+ fwts_acpi_fixed_value(fw, LOG_LEVEL_MEDIUM, "RGRT", "Image Type", rgrt->image_type, 1, &passed);
+ fwts_acpi_reserved_zero("RGRT", "Reserved", rgrt->reserved, &passed);
+
+ fwts_log_nl(fw);
+ if (passed)
+ fwts_passed(fw, "No issues found in RGRT table.");
+
+done:
+ return FWTS_OK;
+}
+
+static fwts_framework_minor_test rgrt_tests[] = {
+ { rgrt_test1, "Validate RGRT table." },
+ { NULL, NULL }
+};
+
+static fwts_framework_ops rgrt_ops = {
+ .description = "RGRT Regulatory Graphics Resource Table test",
+ .init = RGRT_init,
+ .minor_tests = rgrt_tests
+};
+
+FWTS_REGISTER("rgrt", &rgrt_ops, FWTS_TEST_ANYTIME, FWTS_FLAG_BATCH | FWTS_FLAG_ACPI)
+
+#endif
@@ -2286,4 +2286,16 @@ typedef struct {
fwts_acpi_table_svkl_key_structure key_struct[0];
} __attribute__ ((packed)) fwts_acpi_table_svkl;
+/*
+ * ACPI RGRT (Regulatory Graphics Resource Table)
+ * https://microsoft.github.io/mu/dyn/mu_plus/MsCorePkg/AcpiRGRT/feature_acpi_rgrt/
+ */
+typedef struct {
+ fwts_acpi_table_header header;
+ uint16_t version;
+ uint8_t image_type;
+ uint8_t reserved;
+ uint8_t image[0];
+} __attribute__ ((packed)) fwts_acpi_table_rgrt;
+
#endif
Signed-off-by: Ivan Hu <ivan.hu@canonical.com> --- src/Makefile.am | 1 + src/acpi/rgrt/rgrt.c | 87 +++++++++++++++++++++++++++++++++++++ src/lib/include/fwts_acpi.h | 12 +++++ 3 files changed, 100 insertions(+) create mode 100644 src/acpi/rgrt/rgrt.c