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
This commit is contained in:
parent
0860c27fe8
commit
2fb0f352b9
@ -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)
|
||||
|
@ -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,
|
||||
|
Loading…
Reference in New Issue
Block a user