git: 2fb0f352b977 - main - bhyve: add basl support for common table header
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Wed, 16 Nov 2022 11:47:53 UTC
The branch main has been updated by corvink: URL: https://cgit.FreeBSD.org/src/commit/?id=2fb0f352b977aeb34650081e51454b0b637c5ace commit 2fb0f352b977aeb34650081e51454b0b637c5ace Author: Corvin Köhne <corvink@FreeBSD.org> AuthorDate: 2022-04-06 09:10:40 +0000 Commit: Corvin Köhne <corvink@FreeBSD.org> CommitDate: 2022-11-16 11:42:19 +0000 bhyve: add basl support for common table header Most ACPI tables are using the same header. Make it easy to create this header by creating a function for it. Reviewed by: jhb, markj (older version) Approved by: manu (mentor) MFC after: 2 weeks Sponsored by: Beckhoff Automation GmbH & Co. KG Differential Revision: https://reviews.freebsd.org/D36992 --- usr.sbin/bhyve/basl.c | 36 ++++++++++++++++++++++++++++++++++++ usr.sbin/bhyve/basl.h | 3 +++ 2 files changed, 39 insertions(+) diff --git a/usr.sbin/bhyve/basl.c b/usr.sbin/bhyve/basl.c index 1da0a7028f57..e8724b857381 100644 --- a/usr.sbin/bhyve/basl.c +++ b/usr.sbin/bhyve/basl.c @@ -446,6 +446,42 @@ basl_table_append_gas(struct basl_table *const table, const uint8_t space_id, return (basl_table_append_bytes(table, &gas_le, sizeof(gas_le))); } +int +basl_table_append_header(struct basl_table *const table, + const uint8_t signature[ACPI_NAMESEG_SIZE], const uint8_t revision, + const uint32_t oem_revision) +{ + ACPI_TABLE_HEADER header_le; + /* + 1 is required for the null terminator */ + char oem_table_id[ACPI_OEM_TABLE_ID_SIZE + 1]; + + assert(table != NULL); + assert(table->len == 0); + + memcpy(header_le.Signature, signature, ACPI_NAMESEG_SIZE); + header_le.Length = 0; /* patched by basl_finish */ + header_le.Revision = revision; + header_le.Checksum = 0; /* patched by basl_finish */ + memcpy(header_le.OemId, "BHYVE ", ACPI_OEM_ID_SIZE); + snprintf(oem_table_id, ACPI_OEM_TABLE_ID_SIZE, "BV%.4s ", signature); + memcpy(header_le.OemTableId, oem_table_id, + sizeof(header_le.OemTableId)); + header_le.OemRevision = htole32(oem_revision); + memcpy(header_le.AslCompilerId, "BASL", ACPI_NAMESEG_SIZE); + header_le.AslCompilerRevision = htole32(0x20220504); + + BASL_EXEC( + basl_table_append_bytes(table, &header_le, sizeof(header_le))); + + BASL_EXEC(basl_table_add_length(table, + offsetof(ACPI_TABLE_HEADER, Length), sizeof(header_le.Length))); + BASL_EXEC(basl_table_add_checksum(table, + offsetof(ACPI_TABLE_HEADER, Checksum), 0, + BASL_TABLE_CHECKSUM_LEN_FULL_TABLE)); + + return (0); +} + int basl_table_append_int(struct basl_table *const table, const uint64_t val, const uint8_t size) diff --git a/usr.sbin/bhyve/basl.h b/usr.sbin/bhyve/basl.h index 978b2722acf9..aab4a16a63f5 100644 --- a/usr.sbin/bhyve/basl.h +++ b/usr.sbin/bhyve/basl.h @@ -46,6 +46,9 @@ int basl_table_append_checksum(struct basl_table *table, uint32_t start, int basl_table_append_gas(struct basl_table *table, uint8_t space_id, uint8_t bit_width, uint8_t bit_offset, uint8_t access_width, uint64_t address); +int basl_table_append_header(struct basl_table *table, + const uint8_t signature[ACPI_NAMESEG_SIZE], uint8_t revision, + uint32_t oem_revision); int basl_table_append_int(struct basl_table *table, uint64_t val, uint8_t size); int basl_table_append_length(struct basl_table *table, uint8_t size); int basl_table_append_pointer(struct basl_table *table,