[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v2 10/35] acpi: nvdimm_build_nfit: use acpi_init_table()/acpi_tab
From: |
Igor Mammedov |
Subject: |
[PATCH v2 10/35] acpi: nvdimm_build_nfit: use acpi_init_table()/acpi_table_composed() instead of build_header() |
Date: |
Thu, 8 Jul 2021 11:45:52 -0400 |
it replaces error-prone pointer arithmetic for build_header() API,
with 2 calls to start and finish table creation,
which hides offsets magic from API user.
Also since acpi_init_table() reserves space only for standard header
while previous acpi_data_push() reserved the header + 4 bytes field,
add 4 bytes 'Reserved' field into nvdimm_build_nfit() which didn't
have it.
Signed-off-by: Igor Mammedov <imammedo@redhat.com>
---
CC: xiaoguangrong.eric@gmail.com
---
hw/acpi/nvdimm.c | 42 +++++++++++++++++-------------------------
1 file changed, 17 insertions(+), 25 deletions(-)
diff --git a/hw/acpi/nvdimm.c b/hw/acpi/nvdimm.c
index e3d5fe1939..6a144b4542 100644
--- a/hw/acpi/nvdimm.c
+++ b/hw/acpi/nvdimm.c
@@ -44,22 +44,6 @@ static const uint8_t nvdimm_nfit_spa_uuid[] =
UUID_LE(0x66f0d379, 0xb4f3, 0x4074, 0xac, 0x43, 0x0d, 0x33,
0x18, 0xb7, 0x8c, 0xdb);
-/*
- * NVDIMM Firmware Interface Table
- * @signature: "NFIT"
- *
- * It provides information that allows OSPM to enumerate NVDIMM present in
- * the platform and associate system physical address ranges created by the
- * NVDIMMs.
- *
- * It is defined in ACPI 6.0: 5.2.25 NVDIMM Firmware Interface Table (NFIT)
- */
-struct NvdimmNfitHeader {
- ACPI_TABLE_HEADER_DEF
- uint32_t reserved;
-} QEMU_PACKED;
-typedef struct NvdimmNfitHeader NvdimmNfitHeader;
-
/*
* define NFIT structures according to ACPI 6.0: 5.2.25 NVDIMM Firmware
* Interface Table (NFIT).
@@ -401,25 +385,33 @@ void nvdimm_plug(NVDIMMState *state)
nvdimm_build_fit_buffer(state);
}
+/*
+ * NVDIMM Firmware Interface Table
+ * @signature: "NFIT"
+ *
+ * It provides information that allows OSPM to enumerate NVDIMM present in
+ * the platform and associate system physical address ranges created by the
+ * NVDIMMs.
+ *
+ * It is defined in ACPI 6.0: 5.2.25 NVDIMM Firmware Interface Table (NFIT)
+ */
+
static void nvdimm_build_nfit(NVDIMMState *state, GArray *table_offsets,
GArray *table_data, BIOSLinker *linker,
const char *oem_id, const char *oem_table_id)
{
NvdimmFitBuffer *fit_buf = &state->fit_buf;
- unsigned int header;
+ AcpiTable table = { .sig = "NFIT", .rev = 1,
+ .oem_id = oem_id, .oem_table_id = oem_table_id };
acpi_add_table(table_offsets, table_data);
- /* NFIT header. */
- header = table_data->len;
- acpi_data_push(table_data, sizeof(NvdimmNfitHeader));
+ acpi_init_table(&table, table_data);
+ /* Reserved */
+ build_append_int_noprefix(table_data, 0, 4);
/* NVDIMM device structures. */
g_array_append_vals(table_data, fit_buf->fit->data, fit_buf->fit->len);
-
- build_header(linker, table_data,
- (void *)(table_data->data + header), "NFIT",
- sizeof(NvdimmNfitHeader) + fit_buf->fit->len, 1, oem_id,
- oem_table_id);
+ acpi_table_composed(linker, &table);
}
#define NVDIMM_DSM_MEMORY_SIZE 4096
--
2.27.0
- [PATCH v2 00/35] acpi: refactor error prone build_header() and packed structures usage in ACPI tables, Igor Mammedov, 2021/07/08
- [PATCH v2 01/35] acpi: add helper routines to initialize ACPI tables, Igor Mammedov, 2021/07/08
- [PATCH v2 02/35] acpi: build_rsdt: use acpi_init_table()/acpi_table_composed() instead of build_header(), Igor Mammedov, 2021/07/08
- [PATCH v2 04/35] acpi: build_slit: use acpi_init_table()/acpi_table_composed() instead of build_header(), Igor Mammedov, 2021/07/08
- [PATCH v2 03/35] acpi: build_xsdt: use acpi_init_table()/acpi_table_composed() instead of build_header(), Igor Mammedov, 2021/07/08
- [PATCH v2 06/35] acpi: build_tpm2: use acpi_init_table()/acpi_table_composed() instead of build_header(), Igor Mammedov, 2021/07/08
- [PATCH v2 05/35] acpi: build_fadt: use acpi_init_table()/acpi_table_composed() instead of build_header(), Igor Mammedov, 2021/07/08
- [PATCH v2 08/35] acpi: build_mcfg: use acpi_init_table()/acpi_table_composed() instead of build_header(), Igor Mammedov, 2021/07/08
- [PATCH v2 09/35] acpi: build_hmat: use acpi_init_table()/acpi_table_composed() instead of build_header(), Igor Mammedov, 2021/07/08
- [PATCH v2 10/35] acpi: nvdimm_build_nfit: use acpi_init_table()/acpi_table_composed() instead of build_header(),
Igor Mammedov <=
- [PATCH v2 07/35] acpi: acpi_build_hest: use acpi_init_table()/acpi_table_composed() instead of build_header(), Igor Mammedov, 2021/07/08
- [PATCH v2 11/35] acpi: nvdimm_build_ssdt: use acpi_init_table()/acpi_table_composed() instead of build_header(), Igor Mammedov, 2021/07/08
- [PATCH v2 12/35] acpi: vmgenid_build_acpi: use acpi_init_table()/acpi_table_composed() instead of build_header(), Igor Mammedov, 2021/07/08
- [PATCH v2 14/35] acpi: build_hpet: use acpi_init_table()/acpi_table_composed() instead of build_header(), Igor Mammedov, 2021/07/08
- [PATCH v2 13/35] acpi: x86: build_dsdt: use acpi_init_table()/acpi_table_composed() instead of build_header(), Igor Mammedov, 2021/07/08
- [PATCH v2 16/35] acpi: arm/x86: build_srat: use acpi_init_table()/acpi_table_composed() instead of build_header(), Igor Mammedov, 2021/07/08
- [PATCH v2 15/35] acpi: build_tpm_tcpa: use acpi_init_table()/acpi_table_composed() instead of build_header(), Igor Mammedov, 2021/07/08
- [PATCH v2 18/35] acpi: build_dmar_q35: use acpi_init_table()/acpi_table_composed() instead of build_header(), Igor Mammedov, 2021/07/08
- [PATCH v2 17/35] acpi: use build_append_int_noprefix() API to compose SRAT table, Igor Mammedov, 2021/07/08
- [PATCH v2 19/35] acpi: build_waet: use acpi_init_table()/acpi_table_composed() instead of build_header(), Igor Mammedov, 2021/07/08