ACK: [PATCH][V2] acpi: lib: refactor table _init to a macro function
ivanhu
ivan.hu at canonical.com
Mon Dec 21 07:53:00 UTC 2020
On 12/18/20 10:04 AM, Alex Hung wrote:
> Signed-off-by: Alex Hung <alex.hung at canonical.com>
> ---
> src/acpi/aspt/aspt.c | 18 ++----------------
> src/acpi/bert/bert.c | 17 ++---------------
> src/acpi/bgrt/bgrt.c | 16 ++--------------
> src/acpi/cpep/cpep.c | 16 ++--------------
> src/acpi/csrt/csrt.c | 16 ++--------------
> src/acpi/dbgp/dbgp.c | 18 ++----------------
> src/acpi/dppt/dppt.c | 17 ++---------------
> src/acpi/drtm/drtm.c | 16 ++--------------
> src/acpi/ecdt/ecdt.c | 18 ++----------------
> src/acpi/einj/einj.c | 16 ++--------------
> src/acpi/erst/erst.c | 16 ++--------------
> src/acpi/facs/facs.c | 16 ++--------------
> src/acpi/fpdt/fpdt.c | 18 ++----------------
> src/acpi/hest/hest.c | 18 ++----------------
> src/acpi/hmat/hmat.c | 17 ++---------------
> src/acpi/iort/iort.c | 18 ++----------------
> src/acpi/lpit/lpit.c | 18 ++----------------
> src/acpi/mcfg/mcfg.c | 19 ++-----------------
> src/acpi/mchi/mchi.c | 18 ++----------------
> src/acpi/mpst/mpst.c | 17 ++---------------
> src/acpi/msct/msct.c | 16 ++--------------
> src/acpi/msdm/msdm.c | 18 ++----------------
> src/acpi/nfit/nfit.c | 16 ++--------------
> src/acpi/pcct/pcct.c | 17 ++---------------
> src/acpi/pdtt/pdtt.c | 17 ++---------------
> src/acpi/pmtt/pmtt.c | 17 ++---------------
> src/acpi/pptt/pptt.c | 17 ++---------------
> src/acpi/rasf/rasf.c | 17 ++---------------
> src/acpi/rsdt/rsdt.c | 16 ++--------------
> src/acpi/sbst/sbst.c | 16 ++--------------
> src/acpi/sdei/sdei.c | 17 ++---------------
> src/acpi/sdev/sdev.c | 17 ++---------------
> src/acpi/slic/slic.c | 18 ++----------------
> src/acpi/slit/slit.c | 18 ++----------------
> src/acpi/spmi/spmi.c | 18 ++----------------
> src/acpi/srat/srat.c | 18 ++----------------
> src/acpi/stao/stao.c | 18 ++----------------
> src/acpi/tcpa/tcpa.c | 17 ++---------------
> src/acpi/tpm2/tpm2.c | 17 ++---------------
> src/acpi/uefi/uefi.c | 16 ++--------------
> src/acpi/waet/waet.c | 17 ++---------------
> src/acpi/wdat/wdat.c | 18 ++----------------
> src/acpi/wpbt/wpbt.c | 16 ++--------------
> src/acpi/wsmt/wsmt.c | 16 ++--------------
> src/acpi/xenv/xenv.c | 17 ++---------------
> src/lib/include/fwts_acpi_tables.h | 8 ++++++++
> src/lib/src/fwts_acpi_tables.c | 17 +++++++++++++++++
> 47 files changed, 115 insertions(+), 678 deletions(-)
>
> diff --git a/src/acpi/aspt/aspt.c b/src/acpi/aspt/aspt.c
> index ca3fd268..bc2f3895 100644
> --- a/src/acpi/aspt/aspt.c
> +++ b/src/acpi/aspt/aspt.c
> @@ -27,21 +27,7 @@
> #include <string.h>
>
> static fwts_acpi_table_info *table;
> -
> -static int aspt_init(fwts_framework *fw)
> -{
> -
> - if (fwts_acpi_find_table(fw, "ASPT", 0, &table) != FWTS_OK) {
> - fwts_log_error(fw, "Cannot read ACPI tables.");
> - return FWTS_ERROR;
> - }
> - if (table == NULL || (table && table->length == 0)) {
> - fwts_log_error(fw, "ACPI ASPT table does not exist, skipping test");
> - return FWTS_SKIP;
> - }
> -
> - return FWTS_OK;
> -}
> +acpi_table_init(ASPT, &table)
>
> /*
> * ASPT Table
> @@ -101,7 +87,7 @@ static fwts_framework_minor_test aspt_tests[] = {
>
> static fwts_framework_ops aspt_ops = {
> .description = "ASPT Table test.",
> - .init = aspt_init,
> + .init = ASPT_init,
> .minor_tests = aspt_tests
> };
>
> diff --git a/src/acpi/bert/bert.c b/src/acpi/bert/bert.c
> index 5895f742..244f439a 100644
> --- a/src/acpi/bert/bert.c
> +++ b/src/acpi/bert/bert.c
> @@ -27,20 +27,7 @@
> #include <string.h>
>
> static fwts_acpi_table_info *table;
> -
> -static int bert_init(fwts_framework *fw)
> -{
> - if (fwts_acpi_find_table(fw, "BERT", 0, &table) != FWTS_OK) {
> - fwts_log_error(fw, "Cannot read ACPI tables.");
> - return FWTS_ERROR;
> - }
> - if (table == NULL || (table && table->length == 0)) {
> - fwts_log_error(fw, "ACPI BERT table does not exist, skipping test");
> - return FWTS_SKIP;
> - }
> -
> - return FWTS_OK;
> -}
> +acpi_table_init(BERT, &table)
>
> /*
> * For BERT refer to 18.3.1 Boot Error Record Table
> @@ -192,7 +179,7 @@ static fwts_framework_minor_test bert_tests[] = {
>
> static fwts_framework_ops bert_ops = {
> .description = "BERT Boot Error Record Table test.",
> - .init = bert_init,
> + .init = BERT_init,
> .minor_tests = bert_tests
> };
>
> diff --git a/src/acpi/bgrt/bgrt.c b/src/acpi/bgrt/bgrt.c
> index d988a85f..e15044ce 100644
> --- a/src/acpi/bgrt/bgrt.c
> +++ b/src/acpi/bgrt/bgrt.c
> @@ -28,19 +28,7 @@
> #include <ctype.h>
>
> static fwts_acpi_table_info *table;
> -
> -static int bgrt_init(fwts_framework *fw)
> -{
> - if (fwts_acpi_find_table(fw, "BGRT", 0, &table) != FWTS_OK) {
> - fwts_log_error(fw, "Cannot read ACPI tables.");
> - return FWTS_ERROR;
> - }
> - if (table == NULL || (table && table->length == 0)) {
> - fwts_log_error(fw, "ACPI BGRT table does not exist, skipping test");
> - return FWTS_SKIP;
> - }
> - return FWTS_OK;
> -}
> +acpi_table_init(BGRT, &table)
>
> /*
> * BGRT Boot Graphics Resource Table
> @@ -91,7 +79,7 @@ static fwts_framework_minor_test bgrt_tests[] = {
>
> static fwts_framework_ops bgrt_ops = {
> .description = "BGRT Boot Graphics Resource Table test.",
> - .init = bgrt_init,
> + .init = BGRT_init,
> .minor_tests = bgrt_tests
> };
>
> diff --git a/src/acpi/cpep/cpep.c b/src/acpi/cpep/cpep.c
> index ebd2beb3..dd03fb3b 100644
> --- a/src/acpi/cpep/cpep.c
> +++ b/src/acpi/cpep/cpep.c
> @@ -28,19 +28,7 @@
> #include <ctype.h>
>
> static fwts_acpi_table_info *table;
> -
> -static int cpep_init(fwts_framework *fw)
> -{
> - if (fwts_acpi_find_table(fw, "CPEP", 0, &table) != FWTS_OK) {
> - fwts_log_error(fw, "Cannot read ACPI tables.");
> - return FWTS_ERROR;
> - }
> - if (table == NULL || (table && table->length == 0)) {
> - fwts_log_error(fw, "ACPI CPEP table does not exist, skipping test");
> - return FWTS_SKIP;
> - }
> - return FWTS_OK;
> -}
> +acpi_table_init(CPEP, &table)
>
> /*
> * CPEP Corrected Platform Error Polling Table
> @@ -121,7 +109,7 @@ static fwts_framework_minor_test cpep_tests[] = {
>
> static fwts_framework_ops cpep_ops = {
> .description = "CPEP Corrected Platform Error Polling Table test.",
> - .init = cpep_init,
> + .init = CPEP_init,
> .minor_tests = cpep_tests
> };
>
> diff --git a/src/acpi/csrt/csrt.c b/src/acpi/csrt/csrt.c
> index 5d69feed..bb5c703c 100644
> --- a/src/acpi/csrt/csrt.c
> +++ b/src/acpi/csrt/csrt.c
> @@ -27,19 +27,7 @@
> #include <string.h>
>
> static fwts_acpi_table_info *table;
> -
> -static int csrt_init(fwts_framework *fw)
> -{
> - if (fwts_acpi_find_table(fw, "CSRT", 0, &table) != FWTS_OK) {
> - fwts_log_error(fw, "Cannot read ACPI tables.");
> - return FWTS_ERROR;
> - }
> - if (table == NULL || (table && table->length == 0)) {
> - fwts_log_error(fw, "ACPI CSRT table does not exist, skipping test");
> - return FWTS_SKIP;
> - }
> - return FWTS_OK;
> -}
> +acpi_table_init(CSRT, &table)
>
> /*
> * CSRT Core System Resource Table
> @@ -239,7 +227,7 @@ static fwts_framework_minor_test csrt_tests[] = {
>
> static fwts_framework_ops csrt_ops = {
> .description = "CSRT Core System Resource Table test.",
> - .init = csrt_init,
> + .init = CSRT_init,
> .minor_tests = csrt_tests
> };
>
> diff --git a/src/acpi/dbgp/dbgp.c b/src/acpi/dbgp/dbgp.c
> index fffa4762..e4db7790 100644
> --- a/src/acpi/dbgp/dbgp.c
> +++ b/src/acpi/dbgp/dbgp.c
> @@ -27,21 +27,7 @@
> #include <string.h>
>
> static fwts_acpi_table_info *table;
> -
> -static int dbgp_init(fwts_framework *fw)
> -{
> -
> - if (fwts_acpi_find_table(fw, "DBGP", 0, &table) != FWTS_OK) {
> - fwts_log_error(fw, "Cannot read ACPI tables.");
> - return FWTS_ERROR;
> - }
> - if (table == NULL || (table && table->length == 0)) {
> - fwts_log_error(fw, "ACPI DBGP table does not exist, skipping test");
> - return FWTS_SKIP;
> - }
> -
> - return FWTS_OK;
> -}
> +acpi_table_init(DBGP, &table)
>
> /*
> * DBGP Table
> @@ -127,7 +113,7 @@ static fwts_framework_minor_test dbgp_tests[] = {
>
> static fwts_framework_ops dbgp_ops = {
> .description = "DBGP (Debug Port) Table test.",
> - .init = dbgp_init,
> + .init = DBGP_init,
> .minor_tests = dbgp_tests
> };
>
> diff --git a/src/acpi/dppt/dppt.c b/src/acpi/dppt/dppt.c
> index 7ed53512..b181c178 100644
> --- a/src/acpi/dppt/dppt.c
> +++ b/src/acpi/dppt/dppt.c
> @@ -27,20 +27,7 @@
> #include <string.h>
>
> static fwts_acpi_table_info *table;
> -
> -static int dppt_init(fwts_framework *fw)
> -{
> - if (fwts_acpi_find_table(fw, "DPPT", 0, &table) != FWTS_OK) {
> - fwts_log_error(fw, "Cannot read ACPI tables");
> - return FWTS_ERROR;
> - }
> - if (table == NULL || (table && table->length == 0)) {
> - fwts_log_error(fw, "ACPI DPPT table does not exist, skipping test");
> - return FWTS_SKIP;
> - }
> -
> - return FWTS_OK;
> -}
> +acpi_table_init(DPPT, &table)
>
> static int dppt_test1(fwts_framework *fw)
> {
> @@ -64,7 +51,7 @@ static fwts_framework_minor_test dppt_tests[] = {
>
> static fwts_framework_ops dppt_ops = {
> .description = "DPPT DMA Protection Policy Table test",
> - .init = dppt_init,
> + .init = DPPT_init,
> .minor_tests = dppt_tests
> };
>
> diff --git a/src/acpi/drtm/drtm.c b/src/acpi/drtm/drtm.c
> index c587c364..b063fb8c 100644
> --- a/src/acpi/drtm/drtm.c
> +++ b/src/acpi/drtm/drtm.c
> @@ -28,19 +28,7 @@
> #include <ctype.h>
>
> static fwts_acpi_table_info *table;
> -
> -static int drtm_init(fwts_framework *fw)
> -{
> - if (fwts_acpi_find_table(fw, "DRTM", 0, &table) != FWTS_OK) {
> - fwts_log_error(fw, "Cannot read ACPI tables.");
> - return FWTS_ERROR;
> - }
> - if (table == NULL || (table && table->length == 0)) {
> - fwts_log_error(fw, "ACPI DRTM table does not exist, skipping test");
> - return FWTS_SKIP;
> - }
> - return FWTS_OK;
> -}
> +acpi_table_init(DRTM, &table)
>
> /*
> * DRTM D-RTM Resources Table
> @@ -153,7 +141,7 @@ static fwts_framework_minor_test drtm_tests[] = {
>
> static fwts_framework_ops drtm_ops = {
> .description = "DRTM D-RTM Resources Table test.",
> - .init = drtm_init,
> + .init = DRTM_init,
> .minor_tests = drtm_tests
> };
>
> diff --git a/src/acpi/ecdt/ecdt.c b/src/acpi/ecdt/ecdt.c
> index 4e001b5f..8110952e 100644
> --- a/src/acpi/ecdt/ecdt.c
> +++ b/src/acpi/ecdt/ecdt.c
> @@ -29,21 +29,7 @@
> #include "fwts_acpi_object_eval.h"
>
> static fwts_acpi_table_info *table;
> -
> -static int ecdt_init(fwts_framework *fw)
> -{
> -
> - if (fwts_acpi_find_table(fw, "ECDT", 0, &table) != FWTS_OK) {
> - fwts_log_error(fw, "Cannot read ACPI tables.");
> - return FWTS_ERROR;
> - }
> - if (table == NULL || (table && table->length == 0)) {
> - fwts_log_error(fw, "ACPI ECDT table does not exist, skipping test");
> - return FWTS_SKIP;
> - }
> -
> - return FWTS_OK;
> -}
> +acpi_table_init(ECDT, &table)
>
> /*
> * See ACPI 6.0, Section 5.2.15
> @@ -213,7 +199,7 @@ static fwts_framework_minor_test ecdt_tests[] = {
>
> static fwts_framework_ops ecdt_ops = {
> .description = "ECDT Embedded Controller Boot Resources Table test.",
> - .init = ecdt_init,
> + .init = ECDT_init,
> .minor_tests = ecdt_tests
> };
>
> diff --git a/src/acpi/einj/einj.c b/src/acpi/einj/einj.c
> index 02dd4e15..95220f65 100644
> --- a/src/acpi/einj/einj.c
> +++ b/src/acpi/einj/einj.c
> @@ -26,19 +26,7 @@
> #include <ctype.h>
>
> static fwts_acpi_table_info *table;
> -
> -static int einj_init(fwts_framework *fw)
> -{
> - if (fwts_acpi_find_table(fw, "EINJ", 0, &table) != FWTS_OK) {
> - fwts_log_error(fw, "Cannot read ACPI tables.");
> - return FWTS_ERROR;
> - }
> - if (table == NULL || (table && table->length == 0)) {
> - fwts_log_error(fw, "ACPI EINJ table does not exist, skipping test");
> - return FWTS_SKIP;
> - }
> - return FWTS_OK;
> -}
> +acpi_table_init(EINJ, &table)
>
> /*
> * EINJ Error Injection Table
> @@ -143,7 +131,7 @@ static fwts_framework_minor_test einj_tests[] = {
>
> static fwts_framework_ops einj_ops = {
> .description = "EINJ Error Injection Table test.",
> - .init = einj_init,
> + .init = EINJ_init,
> .minor_tests = einj_tests
> };
>
> diff --git a/src/acpi/erst/erst.c b/src/acpi/erst/erst.c
> index eb379e27..4dfafa9d 100644
> --- a/src/acpi/erst/erst.c
> +++ b/src/acpi/erst/erst.c
> @@ -27,19 +27,7 @@
> #include <string.h>
>
> static fwts_acpi_table_info *table;
> -
> -static int erst_init(fwts_framework *fw)
> -{
> - if (fwts_acpi_find_table(fw, "ERST", 0, &table) != FWTS_OK) {
> - fwts_log_error(fw, "Cannot read ACPI tables.");
> - return FWTS_ERROR;
> - }
> - if (table == NULL || (table && table->length == 0)) {
> - fwts_log_error(fw, "ACPI ERST table does not exist, skipping test");
> - return FWTS_SKIP;
> - }
> - return FWTS_OK;
> -}
> +acpi_table_init(ERST, &table)
>
> /*
> * ERST Extended System Description Table
> @@ -180,7 +168,7 @@ static fwts_framework_minor_test erst_tests[] = {
>
> static fwts_framework_ops erst_ops = {
> .description = "ERST Error Record Serialization Table test.",
> - .init = erst_init,
> + .init = ERST_init,
> .minor_tests = erst_tests
> };
>
> diff --git a/src/acpi/facs/facs.c b/src/acpi/facs/facs.c
> index 7dcffc3f..2d60d59f 100644
> --- a/src/acpi/facs/facs.c
> +++ b/src/acpi/facs/facs.c
> @@ -28,19 +28,7 @@
> #include <ctype.h>
>
> static fwts_acpi_table_info *table;
> -
> -static int facs_init(fwts_framework *fw)
> -{
> - if (fwts_acpi_find_table(fw, "FACS", 0, &table) != FWTS_OK) {
> - fwts_log_error(fw, "Cannot read ACPI tables.");
> - return FWTS_ERROR;
> - }
> - if (table == NULL || (table && table->length == 0)) {
> - fwts_log_error(fw, "ACPI FACS table does not exist, skipping test");
> - return FWTS_SKIP;
> - }
> - return FWTS_OK;
> -}
> +acpi_table_init(FACS, &table)
>
> /*
> * FACS Firmware ACPI Control Structure test
> @@ -157,7 +145,7 @@ static fwts_framework_minor_test facs_tests[] = {
>
> static fwts_framework_ops facs_ops = {
> .description = "FACS Firmware ACPI Control Structure test.",
> - .init = facs_init,
> + .init = FACS_init,
> .minor_tests = facs_tests
> };
>
> diff --git a/src/acpi/fpdt/fpdt.c b/src/acpi/fpdt/fpdt.c
> index a96341b2..8d73a351 100644
> --- a/src/acpi/fpdt/fpdt.c
> +++ b/src/acpi/fpdt/fpdt.c
> @@ -28,21 +28,7 @@
> #include <ctype.h>
>
> static fwts_acpi_table_info *table;
> -
> -static int fpdt_init(fwts_framework *fw)
> -{
> -
> - if (fwts_acpi_find_table(fw, "FPDT", 0, &table) != FWTS_OK) {
> - fwts_log_error(fw, "Cannot read ACPI tables.");
> - return FWTS_ERROR;
> - }
> - if (table == NULL || (table && table->length == 0)) {
> - fwts_log_error(fw, "ACPI FPDT table does not exist, skipping test");
> - return FWTS_SKIP;
> - }
> -
> - return FWTS_OK;
> -}
> +acpi_table_init(FPDT, &table)
>
> static void fpdt_rec_header_dump(
> fwts_framework *fw,
> @@ -219,7 +205,7 @@ static fwts_framework_minor_test fpdt_tests[] = {
>
> static fwts_framework_ops fpdt_ops = {
> .description = "FPDT Firmware Performance Data Table test.",
> - .init = fpdt_init,
> + .init = FPDT_init,
> .minor_tests = fpdt_tests
> };
>
> diff --git a/src/acpi/hest/hest.c b/src/acpi/hest/hest.c
> index 96314136..6961080d 100644
> --- a/src/acpi/hest/hest.c
> +++ b/src/acpi/hest/hest.c
> @@ -27,21 +27,7 @@
> #include <string.h>
>
> static fwts_acpi_table_info *table;
> -
> -static int hest_init(fwts_framework *fw)
> -{
> -
> - if (fwts_acpi_find_table(fw, "HEST", 0, &table) != FWTS_OK) {
> - fwts_log_error(fw, "Cannot read ACPI tables.");
> - return FWTS_ERROR;
> - }
> - if (table == NULL || (table && table->length == 0)) {
> - fwts_log_error(fw, "ACPI HEST table does not exist, skipping test");
> - return FWTS_SKIP;
> - }
> -
> - return FWTS_OK;
> -}
> +acpi_table_init(HEST, &table)
>
> /*
> * ACPI Section 18.3.2.1 IA-32 Architecture Machine Check Exception
> @@ -900,7 +886,7 @@ static fwts_framework_minor_test hest_tests[] = {
>
> static fwts_framework_ops hest_ops = {
> .description = "HEST Hardware Error Source Table test.",
> - .init = hest_init,
> + .init = HEST_init,
> .minor_tests = hest_tests
> };
>
> diff --git a/src/acpi/hmat/hmat.c b/src/acpi/hmat/hmat.c
> index dbfc3f6e..90765f59 100644
> --- a/src/acpi/hmat/hmat.c
> +++ b/src/acpi/hmat/hmat.c
> @@ -24,20 +24,7 @@
> #include <stdbool.h>
>
> static fwts_acpi_table_info *table;
> -
> -static int hmat_init(fwts_framework *fw)
> -{
> - if (fwts_acpi_find_table(fw, "HMAT", 0, &table) != FWTS_OK) {
> - fwts_log_error(fw, "Cannot load ACPI table");
> - return FWTS_ERROR;
> - }
> - if (table == NULL) {
> - fwts_log_error(fw, "ACPI HMAT table does not exist, skipping test");
> - return FWTS_SKIP;
> - }
> -
> - return FWTS_OK;
> -}
> +acpi_table_init(HMAT, &table)
>
> static void hmat_proximity_domain_test(fwts_framework *fw, const fwts_acpi_table_hmat_proximity_domain *entry, bool *passed)
> {
> @@ -231,7 +218,7 @@ static fwts_framework_minor_test hmat_tests[] = {
>
> static fwts_framework_ops hmat_ops = {
> .description = "HMAT Heterogeneous Memory Attribute Table test.",
> - .init = hmat_init,
> + .init = HMAT_init,
> .minor_tests = hmat_tests
> };
>
> diff --git a/src/acpi/iort/iort.c b/src/acpi/iort/iort.c
> index 03eba04d..e3857c32 100644
> --- a/src/acpi/iort/iort.c
> +++ b/src/acpi/iort/iort.c
> @@ -27,21 +27,7 @@
> #include <string.h>
>
> static fwts_acpi_table_info *table;
> -
> -static int iort_init(fwts_framework *fw)
> -{
> -
> - if (fwts_acpi_find_table(fw, "IORT", 0, &table) != FWTS_OK) {
> - fwts_log_error(fw, "Cannot read ACPI tables.");
> - return FWTS_ERROR;
> - }
> - if (table == NULL || (table && table->length == 0)) {
> - fwts_log_error(fw, "ACPI IORT table does not exist, skipping test");
> - return FWTS_SKIP;
> - }
> -
> - return FWTS_OK;
> -}
> +acpi_table_init(IORT, &table)
>
> /*
> * iort_node_dump()
> @@ -734,7 +720,7 @@ static fwts_framework_minor_test iort_tests[] = {
>
> static fwts_framework_ops iort_ops = {
> .description = "IORT IO Remapping Table test.",
> - .init = iort_init,
> + .init = IORT_init,
> .minor_tests = iort_tests
> };
>
> diff --git a/src/acpi/lpit/lpit.c b/src/acpi/lpit/lpit.c
> index 5b146f78..ce64e25e 100644
> --- a/src/acpi/lpit/lpit.c
> +++ b/src/acpi/lpit/lpit.c
> @@ -27,21 +27,7 @@
> #include <string.h>
>
> static fwts_acpi_table_info *table;
> -
> -static int lpit_init(fwts_framework *fw)
> -{
> -
> - if (fwts_acpi_find_table(fw, "LPIT", 0, &table) != FWTS_OK) {
> - fwts_log_error(fw, "Cannot read ACPI tables.");
> - return FWTS_ERROR;
> - }
> - if (table == NULL || (table && table->length == 0)) {
> - fwts_log_error(fw, "ACPI LPIT table does not exist, skipping test");
> - return FWTS_SKIP;
> - }
> -
> - return FWTS_OK;
> -}
> +acpi_table_init(LPIT, &table)
>
> static void lpit_check_type_0(
> fwts_framework *fw,
> @@ -231,7 +217,7 @@ static fwts_framework_minor_test lpit_tests[] = {
>
> static fwts_framework_ops lpit_ops = {
> .description = "LPIT Low Power Idle Table test.",
> - .init = lpit_init,
> + .init = LPIT_init,
> .minor_tests = lpit_tests
> };
>
> diff --git a/src/acpi/mcfg/mcfg.c b/src/acpi/mcfg/mcfg.c
> index 33a14e43..1301bafc 100644
> --- a/src/acpi/mcfg/mcfg.c
> +++ b/src/acpi/mcfg/mcfg.c
> @@ -29,6 +29,7 @@
>
> static fwts_list *memory_map_list;
> static fwts_acpi_table_info *mcfg_table;
> +acpi_table_init(MCFG, &mcfg_table)
>
> static int compare_config_space(
> fwts_framework *fw,
> @@ -99,22 +100,6 @@ static int compare_config_space(
> return FWTS_OK;
> }
>
> -static int mcfg_init(fwts_framework *fw)
> -{
> - if (fwts_acpi_find_table(fw, "MCFG", 0, &mcfg_table) != FWTS_OK) {
> - fwts_log_error(fw, "Cannot load ACPI table");
> - return FWTS_ERROR;
> - }
> - if (mcfg_table == NULL) {
> - fwts_log_error(fw,
> - "ACPI table MCFG not found. This table is "
> - "required to check for PCI Express*");
> - return FWTS_ERROR;
> - }
> -
> - return FWTS_OK;
> -}
> -
> static int mcfg_deinit(fwts_framework *fw)
> {
> FWTS_UNUSED(fw);
> @@ -262,7 +247,7 @@ static fwts_framework_minor_test mcfg_tests[] = {
>
> static fwts_framework_ops mcfg_ops = {
> .description = "MCFG PCI Express* memory mapped config space test.",
> - .init = mcfg_init,
> + .init = MCFG_init,
> .deinit = mcfg_deinit,
> .minor_tests = mcfg_tests
> };
> diff --git a/src/acpi/mchi/mchi.c b/src/acpi/mchi/mchi.c
> index 0f1fe085..666ec84e 100644
> --- a/src/acpi/mchi/mchi.c
> +++ b/src/acpi/mchi/mchi.c
> @@ -29,21 +29,7 @@
> #define DUMP_MCHI_TABLE (1) /* table is small and not used much, so dump it */
>
> static fwts_acpi_table_info *table;
> -
> -static int mchi_init(fwts_framework *fw)
> -{
> -
> - if (fwts_acpi_find_table(fw, "MCHI", 0, &table) != FWTS_OK) {
> - fwts_log_error(fw, "Cannot read ACPI tables.");
> - return FWTS_ERROR;
> - }
> - if (table == NULL || (table && table->length == 0)) {
> - fwts_log_error(fw, "ACPI MCHI table does not exist, skipping test");
> - return FWTS_SKIP;
> - }
> -
> - return FWTS_OK;
> -}
> +acpi_table_init(MCHI, &table)
>
> /*
> * MCHI Management Controller Host Interface Table
> @@ -225,7 +211,7 @@ static fwts_framework_minor_test mchi_tests[] = {
>
> static fwts_framework_ops mchi_ops = {
> .description = "MCHI Management Controller Host Interface Table test.",
> - .init = mchi_init,
> + .init = MCHI_init,
> .minor_tests = mchi_tests
> };
>
> diff --git a/src/acpi/mpst/mpst.c b/src/acpi/mpst/mpst.c
> index 4bfe3179..e366c918 100644
> --- a/src/acpi/mpst/mpst.c
> +++ b/src/acpi/mpst/mpst.c
> @@ -24,20 +24,7 @@
> #include <stdbool.h>
>
> static fwts_acpi_table_info *table;
> -
> -static int mpst_init(fwts_framework *fw)
> -{
> - if (fwts_acpi_find_table(fw, "MPST", 0, &table) != FWTS_OK) {
> - fwts_log_error(fw, "Cannot load ACPI table");
> - return FWTS_ERROR;
> - }
> - if (table == NULL) {
> - fwts_log_error(fw, "ACPI MPST table does not exist, skipping test");
> - return FWTS_SKIP;
> - }
> -
> - return FWTS_OK;
> -}
> +acpi_table_init(MPST, &table)
>
> static int mpst_test1(fwts_framework *fw)
> {
> @@ -197,7 +184,7 @@ static fwts_framework_minor_test mpst_tests[] = {
>
> static fwts_framework_ops mpst_ops = {
> .description = "MPST Memory Power State Table test.",
> - .init = mpst_init,
> + .init = MPST_init,
> .minor_tests = mpst_tests
> };
>
> diff --git a/src/acpi/msct/msct.c b/src/acpi/msct/msct.c
> index b0d50c4e..8e40b91c 100644
> --- a/src/acpi/msct/msct.c
> +++ b/src/acpi/msct/msct.c
> @@ -26,19 +26,7 @@
> #include <ctype.h>
>
> static fwts_acpi_table_info *table;
> -
> -static int msct_init(fwts_framework *fw)
> -{
> - if (fwts_acpi_find_table(fw, "MSCT", 0, &table) != FWTS_OK) {
> - fwts_log_error(fw, "Cannot read ACPI tables.");
> - return FWTS_ERROR;
> - }
> - if (table == NULL || (table && table->length == 0)) {
> - fwts_log_error(fw, "ACPI MSCT table does not exist, skipping test");
> - return FWTS_SKIP;
> - }
> - return FWTS_OK;
> -}
> +acpi_table_init(MSCT, &table)
>
> /*
> * MSCT Maximum System Characteristics Table
> @@ -127,7 +115,7 @@ static fwts_framework_minor_test msct_tests[] = {
>
> static fwts_framework_ops msct_ops = {
> .description = "MSCT Maximum System Characteristics Table test.",
> - .init = msct_init,
> + .init = MSCT_init,
> .minor_tests = msct_tests
> };
>
> diff --git a/src/acpi/msdm/msdm.c b/src/acpi/msdm/msdm.c
> index 96f7b77a..32af46a0 100644
> --- a/src/acpi/msdm/msdm.c
> +++ b/src/acpi/msdm/msdm.c
> @@ -28,21 +28,7 @@
> #include <ctype.h>
>
> static fwts_acpi_table_info *table;
> -
> -static int msdm_init(fwts_framework *fw)
> -{
> -
> - if (fwts_acpi_find_table(fw, "MSDM", 0, &table) != FWTS_OK) {
> - fwts_log_error(fw, "Cannot read ACPI tables.");
> - return FWTS_ERROR;
> - }
> - if (table == NULL || (table && table->length == 0)) {
> - fwts_log_error(fw, "ACPI MSDM table does not exist, skipping test");
> - return FWTS_SKIP;
> - }
> -
> - return FWTS_OK;
> -}
> +acpi_table_init(MSDM, &table)
>
> /*
> * Microsoft Data Management (MSDM) Table
> @@ -149,7 +135,7 @@ static fwts_framework_minor_test msdm_tests[] = {
>
> static fwts_framework_ops msdm_ops = {
> .description = "MSDM Microsoft Data Management Table test.",
> - .init = msdm_init,
> + .init = MSDM_init,
> .minor_tests = msdm_tests
> };
>
> diff --git a/src/acpi/nfit/nfit.c b/src/acpi/nfit/nfit.c
> index 809313ab..34c14e21 100644
> --- a/src/acpi/nfit/nfit.c
> +++ b/src/acpi/nfit/nfit.c
> @@ -56,6 +56,7 @@ static const uint8_t guid_virtual_device[4][16] = {
> };
>
> static fwts_acpi_table_info *nfit_table;
> +acpi_table_init(NFIT, &nfit_table)
>
> static bool check_length(fwts_framework *fw, const int actual, int min, const char *name)
> {
> @@ -111,19 +112,6 @@ static bool scan_nfit_smbios(fwts_framework *fw, int len, uint8_t *table)
> return true;
> }
>
> -static int nfit_init(fwts_framework *fw)
> -{
> - if (fwts_acpi_find_table(fw, "NFIT", 0, &nfit_table) != FWTS_OK) {
> - fwts_log_error(fw, "Cannot read ACPI tables.");
> - return FWTS_ERROR;
> - }
> - if (nfit_table == NULL || (nfit_table && nfit_table->length == 0)) {
> - fwts_log_error(fw, "ACPI NFIT table does not exist, skipping test");
> - return FWTS_SKIP;
> - }
> - return FWTS_OK;
> -}
> -
> /*
> * NFIT NVDIMM Firmware Interface Table
> */
> @@ -543,7 +531,7 @@ static fwts_framework_minor_test nfit_tests[] = {
>
> static fwts_framework_ops nfit_ops = {
> .description = "NFIT NVDIMM Firmware Interface Table test.",
> - .init = nfit_init,
> + .init = NFIT_init,
> .minor_tests = nfit_tests
> };
>
> diff --git a/src/acpi/pcct/pcct.c b/src/acpi/pcct/pcct.c
> index 544a28e5..2a4b4ab5 100644
> --- a/src/acpi/pcct/pcct.c
> +++ b/src/acpi/pcct/pcct.c
> @@ -24,20 +24,7 @@
> #include <stdbool.h>
>
> static fwts_acpi_table_info *table;
> -
> -static int pcct_init(fwts_framework *fw)
> -{
> - if (fwts_acpi_find_table(fw, "PCCT", 0, &table) != FWTS_OK) {
> - fwts_log_error(fw, "Cannot load ACPI table");
> - return FWTS_ERROR;
> - }
> - if (table == NULL) {
> - fwts_log_error(fw, "ACPI PCCT table does not exist, skipping test");
> - return FWTS_ERROR;
> - }
> -
> - return FWTS_OK;
> -}
> +acpi_table_init(PCCT, &table)
>
> static bool subspace_length_equal(fwts_framework *fw, uint8_t type, uint8_t type_size, uint8_t length)
> {
> @@ -315,7 +302,7 @@ static fwts_framework_minor_test pcct_tests[] = {
>
> static fwts_framework_ops pcct_ops = {
> .description = "PCCT Platform Communications Channel test.",
> - .init = pcct_init,
> + .init = PCCT_init,
> .minor_tests = pcct_tests
> };
>
> diff --git a/src/acpi/pdtt/pdtt.c b/src/acpi/pdtt/pdtt.c
> index da60612f..8fb929aa 100644
> --- a/src/acpi/pdtt/pdtt.c
> +++ b/src/acpi/pdtt/pdtt.c
> @@ -24,20 +24,7 @@
> #include <stdbool.h>
>
> static fwts_acpi_table_info *table;
> -
> -static int pdtt_init(fwts_framework *fw)
> -{
> - if (fwts_acpi_find_table(fw, "PDTT", 0, &table) != FWTS_OK) {
> - fwts_log_error(fw, "Cannot load ACPI table");
> - return FWTS_ERROR;
> - }
> - if (table == NULL) {
> - fwts_log_error(fw, "ACPI PDTT table does not exist, skipping test");
> - return FWTS_SKIP;
> - }
> -
> - return FWTS_OK;
> -}
> +acpi_table_init(PDTT, &table)
>
> static int pdtt_test1(fwts_framework *fw)
> {
> @@ -103,7 +90,7 @@ static fwts_framework_minor_test pdtt_tests[] = {
>
> static fwts_framework_ops pdtt_ops = {
> .description = "PDTT Platform Debug Trigger Table test.",
> - .init = pdtt_init,
> + .init = PDTT_init,
> .minor_tests = pdtt_tests
> };
>
> diff --git a/src/acpi/pmtt/pmtt.c b/src/acpi/pmtt/pmtt.c
> index 78c5156d..5f10a38d 100644
> --- a/src/acpi/pmtt/pmtt.c
> +++ b/src/acpi/pmtt/pmtt.c
> @@ -24,20 +24,7 @@
> #include <stdbool.h>
>
> static fwts_acpi_table_info *table;
> -
> -static int pmtt_init(fwts_framework *fw)
> -{
> - if (fwts_acpi_find_table(fw, "PMTT", 0, &table) != FWTS_OK) {
> - fwts_log_error(fw, "Cannot load ACPI table");
> - return FWTS_ERROR;
> - }
> - if (table == NULL) {
> - fwts_log_error(fw, "ACPI PMTT table does not exist, skipping test");
> - return FWTS_SKIP;
> - }
> -
> - return FWTS_OK;
> -}
> +acpi_table_init(PMTT, &table)
>
> static void pmtt_subtable_header_test(fwts_framework *fw, fwts_acpi_table_pmtt_header *entry, bool *passed)
> {
> @@ -222,7 +209,7 @@ static fwts_framework_minor_test pmtt_tests[] = {
>
> static fwts_framework_ops pmtt_ops = {
> .description = "PMTT Memory Topology Table test.",
> - .init = pmtt_init,
> + .init = PMTT_init,
> .minor_tests = pmtt_tests
> };
>
> diff --git a/src/acpi/pptt/pptt.c b/src/acpi/pptt/pptt.c
> index bf361dc0..8294445a 100644
> --- a/src/acpi/pptt/pptt.c
> +++ b/src/acpi/pptt/pptt.c
> @@ -24,20 +24,7 @@
> #include <stdbool.h>
>
> static fwts_acpi_table_info *table;
> -
> -static int pptt_init(fwts_framework *fw)
> -{
> - if (fwts_acpi_find_table(fw, "PPTT", 0, &table) != FWTS_OK) {
> - fwts_log_error(fw, "Cannot load ACPI table");
> - return FWTS_ERROR;
> - }
> - if (table == NULL) {
> - fwts_log_error(fw, "ACPI PPTT table does not exist, skipping test");
> - return FWTS_SKIP;
> - }
> -
> - return FWTS_OK;
> -}
> +acpi_table_init(PPTT, &table)
>
> static void pptt_processor_test(fwts_framework *fw, const fwts_acpi_table_pptt_processor *entry, uint8_t rev, bool *passed)
> {
> @@ -191,7 +178,7 @@ static fwts_framework_minor_test pptt_tests[] = {
>
> static fwts_framework_ops pptt_ops = {
> .description = "PPTT Processor Properties Topology Table test.",
> - .init = pptt_init,
> + .init = PPTT_init,
> .minor_tests = pptt_tests
> };
>
> diff --git a/src/acpi/rasf/rasf.c b/src/acpi/rasf/rasf.c
> index 99192cbc..90e34bb6 100644
> --- a/src/acpi/rasf/rasf.c
> +++ b/src/acpi/rasf/rasf.c
> @@ -27,20 +27,7 @@
> #include <string.h>
>
> static fwts_acpi_table_info *table;
> -
> -static int rasf_init(fwts_framework *fw)
> -{
> - if (fwts_acpi_find_table(fw, "RASF", 0, &table) != FWTS_OK) {
> - fwts_log_error(fw, "Cannot read ACPI tables");
> - return FWTS_ERROR;
> - }
> - if (table == NULL || (table && table->length == 0)) {
> - fwts_log_error(fw, "ACPI RASF table does not exist, skipping test");
> - return FWTS_SKIP;
> - }
> -
> - return FWTS_OK;
> -}
> +acpi_table_init(RASF, &table)
>
> static int rasf_test1(fwts_framework *fw)
> {
> @@ -73,7 +60,7 @@ static fwts_framework_minor_test rasf_tests[] = {
>
> static fwts_framework_ops rasf_ops = {
> .description = "RASF RAS Feature Table test",
> - .init = rasf_init,
> + .init = RASF_init,
> .minor_tests = rasf_tests
> };
>
> diff --git a/src/acpi/rsdt/rsdt.c b/src/acpi/rsdt/rsdt.c
> index 21162e59..c9b66713 100644
> --- a/src/acpi/rsdt/rsdt.c
> +++ b/src/acpi/rsdt/rsdt.c
> @@ -27,19 +27,7 @@
> #include <string.h>
>
> static fwts_acpi_table_info *table;
> -
> -static int rsdt_init(fwts_framework *fw)
> -{
> - if (fwts_acpi_find_table(fw, "RSDT", 0, &table) != FWTS_OK) {
> - fwts_log_error(fw, "Cannot read ACPI tables.");
> - return FWTS_ERROR;
> - }
> - if (table == NULL || (table && table->length == 0)) {
> - fwts_log_error(fw, "ACPI RSDT table does not exist, skipping test");
> - return FWTS_SKIP;
> - }
> - return FWTS_OK;
> -}
> +acpi_table_init(RSDT, &table)
>
> /*
> * RSDT Extended System Description Table
> @@ -78,7 +66,7 @@ static fwts_framework_minor_test rsdt_tests[] = {
>
> static fwts_framework_ops rsdt_ops = {
> .description = "RSDT Root System Description Table test.",
> - .init = rsdt_init,
> + .init = RSDT_init,
> .minor_tests = rsdt_tests
> };
>
> diff --git a/src/acpi/sbst/sbst.c b/src/acpi/sbst/sbst.c
> index 189bc77b..9f21549b 100644
> --- a/src/acpi/sbst/sbst.c
> +++ b/src/acpi/sbst/sbst.c
> @@ -27,19 +27,7 @@
> #include <string.h>
>
> static fwts_acpi_table_info *table;
> -
> -static int sbst_init(fwts_framework *fw)
> -{
> - if (fwts_acpi_find_table(fw, "SBST", 0, &table) != FWTS_OK) {
> - fwts_log_error(fw, "Cannot read ACPI tables.");
> - return FWTS_ERROR;
> - }
> - if (table == NULL || (table && table->length == 0)) {
> - fwts_log_error(fw, "ACPI SBST table does not exist, skipping test");
> - return FWTS_SKIP;
> - }
> - return FWTS_OK;
> -}
> +acpi_table_init(SBST,&table)
>
> /*
> * SBST Extended System Description Table
> @@ -88,7 +76,7 @@ static fwts_framework_minor_test sbst_tests[] = {
>
> static fwts_framework_ops sbst_ops = {
> .description = "SBST Smart Battery Specification Table test.",
> - .init = sbst_init,
> + .init = SBST_init,
> .minor_tests = sbst_tests
> };
>
> diff --git a/src/acpi/sdei/sdei.c b/src/acpi/sdei/sdei.c
> index 6713d635..2f9c76a1 100644
> --- a/src/acpi/sdei/sdei.c
> +++ b/src/acpi/sdei/sdei.c
> @@ -27,20 +27,7 @@
> #include <string.h>
>
> static fwts_acpi_table_info *table;
> -
> -static int sdei_init(fwts_framework *fw)
> -{
> - if (fwts_acpi_find_table(fw, "SDEI", 0, &table) != FWTS_OK) {
> - fwts_log_error(fw, "Cannot read ACPI tables");
> - return FWTS_ERROR;
> - }
> - if (table == NULL || (table && table->length == 0)) {
> - fwts_log_error(fw, "ACPI SDEI table does not exist, skipping test");
> - return FWTS_SKIP;
> - }
> -
> - return FWTS_OK;
> -}
> +acpi_table_init(SDEI, &table)
>
> static int sdei_test1(fwts_framework *fw)
> {
> @@ -77,7 +64,7 @@ static fwts_framework_minor_test sdei_tests[] = {
>
> static fwts_framework_ops sdei_ops = {
> .description = "SDEI Software Delegated Exception Interface Table test",
> - .init = sdei_init,
> + .init = SDEI_init,
> .minor_tests = sdei_tests
> };
>
> diff --git a/src/acpi/sdev/sdev.c b/src/acpi/sdev/sdev.c
> index bcb652ca..5c6856d2 100644
> --- a/src/acpi/sdev/sdev.c
> +++ b/src/acpi/sdev/sdev.c
> @@ -27,20 +27,7 @@
> #include <string.h>
>
> static fwts_acpi_table_info *table;
> -
> -static int sdev_init(fwts_framework *fw)
> -{
> - if (fwts_acpi_find_table(fw, "SDEV", 0, &table) != FWTS_OK) {
> - fwts_log_error(fw, "Cannot read ACPI tables");
> - return FWTS_ERROR;
> - }
> - if (table == NULL || (table && table->length == 0)) {
> - fwts_log_error(fw, "ACPI SDEV table does not exist, skipping test");
> - return FWTS_SKIP;
> - }
> -
> - return FWTS_OK;
> -}
> +acpi_table_init(SDEV, &table)
>
> static void sdev_acpi_namespace_device_test(fwts_framework *fw, const fwts_acpi_table_sdev_acpi *entry, bool *passed)
> {
> @@ -137,7 +124,7 @@ static fwts_framework_minor_test sdev_tests[] = {
>
> static fwts_framework_ops sdev_ops = {
> .description = "SDEV Secure Devices Table test",
> - .init = sdev_init,
> + .init = SDEV_init,
> .minor_tests = sdev_tests
> };
>
> diff --git a/src/acpi/slic/slic.c b/src/acpi/slic/slic.c
> index bc408616..89bdeadf 100644
> --- a/src/acpi/slic/slic.c
> +++ b/src/acpi/slic/slic.c
> @@ -29,21 +29,7 @@
> #define DUMP_SLIC (0) /* Disable this, just used it for debugging */
>
> static fwts_acpi_table_info *table;
> -
> -static int slic_init(fwts_framework *fw)
> -{
> -
> - if (fwts_acpi_find_table(fw, "SLIC", 0, &table) != FWTS_OK) {
> - fwts_log_error(fw, "Cannot read ACPI tables.");
> - return FWTS_ERROR;
> - }
> - if (table == NULL || (table && table->length == 0)) {
> - fwts_log_error(fw, "ACPI SLIC table does not exist, skipping test");
> - return FWTS_SKIP;
> - }
> -
> - return FWTS_OK;
> -}
> +acpi_table_init(SLIC, &table)
>
> /*
> * Software Licensing Description Table
> @@ -170,7 +156,7 @@ static fwts_framework_minor_test slic_tests[] = {
>
> static fwts_framework_ops slic_ops = {
> .description = "SLIC Software Licensing Description Table test.",
> - .init = slic_init,
> + .init = SLIC_init,
> .minor_tests = slic_tests
> };
>
> diff --git a/src/acpi/slit/slit.c b/src/acpi/slit/slit.c
> index 3b380142..cb2ddee3 100644
> --- a/src/acpi/slit/slit.c
> +++ b/src/acpi/slit/slit.c
> @@ -29,21 +29,7 @@
> #define INDEX(i, j) (((i) * slit->num_of_system_localities) + (j))
>
> static fwts_acpi_table_info *table;
> -
> -static int slit_init(fwts_framework *fw)
> -{
> -
> - if (fwts_acpi_find_table(fw, "SLIT", 0, &table) != FWTS_OK) {
> - fwts_log_error(fw, "Cannot read ACPI tables.");
> - return FWTS_ERROR;
> - }
> - if (table == NULL || (table && table->length == 0)) {
> - fwts_log_error(fw, "ACPI SLIT table does not exist, skipping test");
> - return FWTS_SKIP;
> - }
> -
> - return FWTS_OK;
> -}
> +acpi_table_init(SLIT, &table)
>
> /*
> * For SLIT System Locality Distance Information refer to
> @@ -178,7 +164,7 @@ static fwts_framework_minor_test slit_tests[] = {
>
> static fwts_framework_ops slit_ops = {
> .description = "SLIT System Locality Distance Information test.",
> - .init = slit_init,
> + .init = SLIT_init,
> .minor_tests = slit_tests
> };
>
> diff --git a/src/acpi/spmi/spmi.c b/src/acpi/spmi/spmi.c
> index 2dce7e06..d8ec8356 100644
> --- a/src/acpi/spmi/spmi.c
> +++ b/src/acpi/spmi/spmi.c
> @@ -27,21 +27,7 @@
> #include <string.h>
>
> static fwts_acpi_table_info *table;
> -
> -static int spmi_init(fwts_framework *fw)
> -{
> -
> - if (fwts_acpi_find_table(fw, "SPMI", 0, &table) != FWTS_OK) {
> - fwts_log_error(fw, "Cannot read ACPI tables.");
> - return FWTS_ERROR;
> - }
> - if (table == NULL || (table && table->length == 0)) {
> - fwts_log_error(fw, "ACPI SPMI table does not exist, skipping test");
> - return FWTS_SKIP;
> - }
> -
> - return FWTS_OK;
> -}
> +acpi_table_init(SPMI, &table)
>
> /*
> * SPMI Service Processor Management Interface Description Table
> @@ -218,7 +204,7 @@ static fwts_framework_minor_test spmi_tests[] = {
>
> static fwts_framework_ops spmi_ops = {
> .description = "SPMI Service Processor Management Interface Description Table test.",
> - .init = spmi_init,
> + .init = SPMI_init,
> .minor_tests = spmi_tests
> };
>
> diff --git a/src/acpi/srat/srat.c b/src/acpi/srat/srat.c
> index 135f7be2..1dd19eae 100644
> --- a/src/acpi/srat/srat.c
> +++ b/src/acpi/srat/srat.c
> @@ -27,21 +27,7 @@
> #include <string.h>
>
> static fwts_acpi_table_info *table;
> -
> -static int srat_init(fwts_framework *fw)
> -{
> -
> - if (fwts_acpi_find_table(fw, "SRAT", 0, &table) != FWTS_OK) {
> - fwts_log_error(fw, "Cannot read ACPI tables.");
> - return FWTS_ERROR;
> - }
> - if (table == NULL || (table && table->length == 0)) {
> - fwts_log_error(fw, "ACPI SRAT table does not exist, skipping test");
> - return FWTS_SKIP;
> - }
> -
> - return FWTS_OK;
> -}
> +acpi_table_init(SRAT, &table)
>
> static void srat_check_local_apic_sapic_affinity(
> fwts_framework *fw,
> @@ -417,7 +403,7 @@ static fwts_framework_minor_test srat_tests[] = {
>
> static fwts_framework_ops srat_ops = {
> .description = "SRAT System Resource Affinity Table test.",
> - .init = srat_init,
> + .init = SRAT_init,
> .minor_tests = srat_tests
> };
>
> diff --git a/src/acpi/stao/stao.c b/src/acpi/stao/stao.c
> index 72dbefce..9351fe50 100644
> --- a/src/acpi/stao/stao.c
> +++ b/src/acpi/stao/stao.c
> @@ -29,21 +29,7 @@
> #include "fwts_acpi_object_eval.h"
>
> static fwts_acpi_table_info *table;
> -
> -static int stao_init(fwts_framework *fw)
> -{
> -
> - if (fwts_acpi_find_table(fw, "STAO", 0, &table) != FWTS_OK) {
> - fwts_log_error(fw, "Cannot read ACPI tables.");
> - return FWTS_ERROR;
> - }
> - if (table == NULL || (table && table->length == 0)) {
> - fwts_log_error(fw, "ACPI STAO table does not exist, skipping test");
> - return FWTS_SKIP;
> - }
> -
> - return FWTS_OK;
> -}
> +acpi_table_init(STAO, &table)
>
> /*
> * Extract a STAO ACPI String from the raw buffer
> @@ -154,7 +140,7 @@ static fwts_framework_minor_test stao_tests[] = {
>
> static fwts_framework_ops stao_ops = {
> .description = "STAO Status Override Table test.",
> - .init = stao_init,
> + .init = STAO_init,
> .minor_tests = stao_tests
> };
>
> diff --git a/src/acpi/tcpa/tcpa.c b/src/acpi/tcpa/tcpa.c
> index f8d07b7e..5904858e 100644
> --- a/src/acpi/tcpa/tcpa.c
> +++ b/src/acpi/tcpa/tcpa.c
> @@ -24,20 +24,7 @@
> #include <stdbool.h>
>
> static fwts_acpi_table_info *table;
> -
> -static int tcpa_init(fwts_framework *fw)
> -{
> - if (fwts_acpi_find_table(fw, "TCPA", 0, &table) != FWTS_OK) {
> - fwts_log_error(fw, "Cannot load ACPI table");
> - return FWTS_ERROR;
> - }
> - if (table == NULL) {
> - fwts_log_error(fw, "ACPI TCPA table does not exist, skipping test");
> - return FWTS_SKIP;
> - }
> -
> - return FWTS_OK;
> -}
> +acpi_table_init(TCPA, &table)
>
> static int tcpa_client_test(fwts_framework *fw, fwts_acpi_table_tcpa *tcpa)
> {
> @@ -202,7 +189,7 @@ static fwts_framework_minor_test tcpa_tests[] = {
>
> static fwts_framework_ops tcpa_ops = {
> .description = "TCPA Trusted Computing Platform Alliance Capabilities Table test.",
> - .init = tcpa_init,
> + .init = TCPA_init,
> .minor_tests = tcpa_tests
> };
>
> diff --git a/src/acpi/tpm2/tpm2.c b/src/acpi/tpm2/tpm2.c
> index 56b35a1c..b746cbc7 100644
> --- a/src/acpi/tpm2/tpm2.c
> +++ b/src/acpi/tpm2/tpm2.c
> @@ -24,20 +24,7 @@
> #include <stdbool.h>
>
> static fwts_acpi_table_info *table;
> -
> -static int tpm2_init(fwts_framework *fw)
> -{
> - if (fwts_acpi_find_table(fw, "TPM2", 0, &table) != FWTS_OK) {
> - fwts_log_error(fw, "Cannot load ACPI table");
> - return FWTS_ERROR;
> - }
> - if (table == NULL) {
> - fwts_log_error(fw, "ACPI TPM2 table does not exist, skipping test");
> - return FWTS_SKIP;
> - }
> -
> - return FWTS_OK;
> -}
> +acpi_table_init(TPM2, &table)
>
> /*
> * TPM2 table
> @@ -106,7 +93,7 @@ static fwts_framework_minor_test tpm2_tests[] = {
>
> static fwts_framework_ops tpm2_ops = {
> .description = "TPM2 Trusted Platform Module 2 test.",
> - .init = tpm2_init,
> + .init = TPM2_init,
> .minor_tests = tpm2_tests
> };
>
> diff --git a/src/acpi/uefi/uefi.c b/src/acpi/uefi/uefi.c
> index d196d62e..f5c6641c 100644
> --- a/src/acpi/uefi/uefi.c
> +++ b/src/acpi/uefi/uefi.c
> @@ -28,19 +28,7 @@
> #include <ctype.h>
>
> static fwts_acpi_table_info *table;
> -
> -static int uefi_init(fwts_framework *fw)
> -{
> - if (fwts_acpi_find_table(fw, "UEFI", 0, &table) != FWTS_OK) {
> - fwts_log_error(fw, "Cannot read ACPI tables.");
> - return FWTS_ERROR;
> - }
> - if (table == NULL || (table && table->length == 0)) {
> - fwts_log_error(fw, "ACPI UEFI table does not exist, skipping test");
> - return FWTS_SKIP;
> - }
> - return FWTS_OK;
> -}
> +acpi_table_init(UEFI, &table)
>
> /*
> * UEFI ACPI DATA Table
> @@ -123,7 +111,7 @@ static fwts_framework_minor_test uefi_tests[] = {
>
> static fwts_framework_ops uefi_ops = {
> .description = "UEFI Data Table test.",
> - .init = uefi_init,
> + .init = UEFI_init,
> .minor_tests = uefi_tests
> };
>
> diff --git a/src/acpi/waet/waet.c b/src/acpi/waet/waet.c
> index 985138c5..d4a13c98 100644
> --- a/src/acpi/waet/waet.c
> +++ b/src/acpi/waet/waet.c
> @@ -30,20 +30,7 @@
> #include "fwts_acpi_object_eval.h"
>
> static fwts_acpi_table_info *table;
> -
> -static int waet_init(fwts_framework *fw)
> -{
> - if (fwts_acpi_find_table(fw, "WAET", 0, &table) != FWTS_OK) {
> - fwts_log_error(fw, "Cannot read ACPI tables.");
> - return FWTS_ERROR;
> - }
> - if (table == NULL || (table && table->length == 0)) {
> - fwts_log_error(fw, "ACPI WAET table does not exist, skipping test");
> - return FWTS_SKIP;
> - }
> -
> - return FWTS_OK;
> -}
> +acpi_table_init(WAET, &table)
>
> /*
> * WAET Windows ACPI Emulated Devices Table
> @@ -82,7 +69,7 @@ static fwts_framework_minor_test waet_tests[] = {
>
> static fwts_framework_ops waet_ops = {
> .description = "WAET Windows ACPI Emulated Devices Table test.",
> - .init = waet_init,
> + .init = WAET_init,
> .minor_tests = waet_tests
> };
>
> diff --git a/src/acpi/wdat/wdat.c b/src/acpi/wdat/wdat.c
> index 8149faa7..579dfd29 100644
> --- a/src/acpi/wdat/wdat.c
> +++ b/src/acpi/wdat/wdat.c
> @@ -31,21 +31,7 @@
> #define ACPI_DUMP (0) /* WDAT entries are long, so don't dump, too verbose */
>
> static fwts_acpi_table_info *table;
> -
> -static int wdat_init(fwts_framework *fw)
> -{
> -
> - if (fwts_acpi_find_table(fw, "WDAT", 0, &table) != FWTS_OK) {
> - fwts_log_error(fw, "Cannot read ACPI tables.");
> - return FWTS_ERROR;
> - }
> - if (table == NULL || (table && table->length == 0)) {
> - fwts_log_error(fw, "ACPI WDAT table does not exist, skipping test");
> - return FWTS_SKIP;
> - }
> -
> - return FWTS_OK;
> -}
> +acpi_table_init(WDAT, &table)
>
> /*
> * ACPI WDAT (Watchdog Action Table)
> @@ -213,7 +199,7 @@ static fwts_framework_minor_test wdat_tests[] = {
>
> static fwts_framework_ops wdat_ops = {
> .description = "WDAT Microsoft Hardware Watchdog Action Table test.",
> - .init = wdat_init,
> + .init = WDAT_init,
> .minor_tests = wdat_tests
> };
>
> diff --git a/src/acpi/wpbt/wpbt.c b/src/acpi/wpbt/wpbt.c
> index 00f45196..15ad2371 100644
> --- a/src/acpi/wpbt/wpbt.c
> +++ b/src/acpi/wpbt/wpbt.c
> @@ -28,19 +28,7 @@
> #include <ctype.h>
>
> static fwts_acpi_table_info *table;
> -
> -static int wpbt_init(fwts_framework *fw)
> -{
> - if (fwts_acpi_find_table(fw, "WPBT", 0, &table) != FWTS_OK) {
> - fwts_log_error(fw, "Cannot read ACPI tables.");
> - return FWTS_ERROR;
> - }
> - if (table == NULL || (table && table->length == 0)) {
> - fwts_log_error(fw, "ACPI WPBT table does not exist, skipping test");
> - return FWTS_SKIP;
> - }
> - return FWTS_OK;
> -}
> +acpi_table_init(WPBT, &table)
>
> /*
> * WPBT Windows Platform Binary Table
> @@ -99,7 +87,7 @@ static fwts_framework_minor_test wpbt_tests[] = {
>
> static fwts_framework_ops wpbt_ops = {
> .description = "WPBT Windows Platform Binary Table test.",
> - .init = wpbt_init,
> + .init = WPBT_init,
> .minor_tests = wpbt_tests
> };
>
> diff --git a/src/acpi/wsmt/wsmt.c b/src/acpi/wsmt/wsmt.c
> index b584af6b..bd26d2bd 100644
> --- a/src/acpi/wsmt/wsmt.c
> +++ b/src/acpi/wsmt/wsmt.c
> @@ -28,19 +28,7 @@
> #include <ctype.h>
>
> static fwts_acpi_table_info *table;
> -
> -static int wsmt_init(fwts_framework *fw)
> -{
> - if (fwts_acpi_find_table(fw, "WSMT", 0, &table) != FWTS_OK) {
> - fwts_log_error(fw, "Cannot read ACPI tables.");
> - return FWTS_ERROR;
> - }
> - if (table == NULL || (table && table->length == 0)) {
> - fwts_log_error(fw, "ACPI WSMT table does not exist, skipping test");
> - return FWTS_SKIP;
> - }
> - return FWTS_OK;
> -}
> +acpi_table_init(WSMT, &table)
>
> /*
> * WSMT Windows Platform Binary Table
> @@ -78,7 +66,7 @@ static fwts_framework_minor_test wsmt_tests[] = {
>
> static fwts_framework_ops wsmt_ops = {
> .description = "WSMT Windows SMM Security Mitigations Table test.",
> - .init = wsmt_init,
> + .init = WSMT_init,
> .minor_tests = wsmt_tests
> };
>
> diff --git a/src/acpi/xenv/xenv.c b/src/acpi/xenv/xenv.c
> index 6ac19ffd..012faac6 100644
> --- a/src/acpi/xenv/xenv.c
> +++ b/src/acpi/xenv/xenv.c
> @@ -24,20 +24,7 @@
> #include <inttypes.h>
>
> static fwts_acpi_table_info *table;
> -
> -static int xenv_init(fwts_framework *fw)
> -{
> - if (fwts_acpi_find_table(fw, "XENV", 0, &table) != FWTS_OK) {
> - fwts_log_error(fw, "Cannot load ACPI table");
> - return FWTS_ERROR;
> - }
> - if (table == NULL) {
> - fwts_log_error(fw, "ACPI XENV table does not exist, skipping test");
> - return FWTS_SKIP;
> - }
> -
> - return FWTS_OK;
> -}
> +acpi_table_init(XENV, &table)
>
> /*
> * Sanity check XENV table, see:
> @@ -86,7 +73,7 @@ static fwts_framework_minor_test xenv_tests[] = {
>
> static fwts_framework_ops xenv_check_ops = {
> .description = "XENV Xen Environment Table tests.",
> - .init = xenv_init,
> + .init = XENV_init,
> .minor_tests = xenv_tests
> };
>
> diff --git a/src/lib/include/fwts_acpi_tables.h b/src/lib/include/fwts_acpi_tables.h
> index 7125ba2c..1f95b74b 100644
> --- a/src/lib/include/fwts_acpi_tables.h
> +++ b/src/lib/include/fwts_acpi_tables.h
> @@ -43,6 +43,14 @@ typedef struct {
> fwts_acpi_table_provenance provenance;
> } fwts_acpi_table_info;
>
> +int acpi_table_generic_init(fwts_framework *fw, char *name, fwts_acpi_table_info **table);
> +
> +#define acpi_table_init(name, table) \
> +static int name ## _init (fwts_framework *fw) \
> +{ \
> + return acpi_table_generic_init(fw, # name, table); \
> +}
> +
> int fwts_acpi_load_tables(fwts_framework *fw);
> int fwts_acpi_free_tables(void);
>
> diff --git a/src/lib/src/fwts_acpi_tables.c b/src/lib/src/fwts_acpi_tables.c
> index 248f8ae1..af4736b3 100644
> --- a/src/lib/src/fwts_acpi_tables.c
> +++ b/src/lib/src/fwts_acpi_tables.c
> @@ -54,6 +54,23 @@ typedef enum {
>
> static acpi_table_load_state acpi_tables_loaded = ACPI_TABLES_NOT_LOADED;
>
> +/*
> + * acpi_table_generic_init()
> + * Generic ACPI table init function
> + */
> +int acpi_table_generic_init(fwts_framework *fw, char *name, fwts_acpi_table_info **table)
> +{
> + if (fwts_acpi_find_table(fw, name, 0, table) != FWTS_OK) {
> + fwts_log_error(fw, "Cannot read ACPI tables.");
> + return FWTS_ERROR;
> + }
> + if (*table == NULL || (*table)->length == 0) {
> + fwts_log_error(fw, "ACPI %s table does not exist, skipping test", name);
> + return FWTS_SKIP;
> + }
> + return FWTS_OK;
> +}
> +
> /*
> * fwts_acpi_find_rsdp_efi()
> * Get RSDP address from EFI if possible
>
Acked-by: Ivan Hu <ivan.hu at canonical.com>
More information about the fwts-devel
mailing list