git: 8897b562abbf - main - bhyve: add helper to append a basl table without a header
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Mon, 21 Nov 2022 08:31:35 UTC
The branch main has been updated by corvink:
URL: https://cgit.FreeBSD.org/src/commit/?id=8897b562abbf1dbc2d6c83d31ed673d5220c3da3
commit 8897b562abbf1dbc2d6c83d31ed673d5220c3da3
Author: Corvin Köhne <corvink@FreeBSD.org>
AuthorDate: 2022-11-16 08:31:29 +0000
Commit: Corvin Köhne <corvink@FreeBSD.org>
CommitDate: 2022-11-21 08:27:51 +0000
bhyve: add helper to append a basl table without a header
The common style for build an ACPI table will be:
1. basl_table_create
2. basl_table_append_header
3. setup an ACPI_TABLE_* struct
4. basl_table_append_bytes (without header)
Add a helper for the last step.
Reviewed by: jhb, markj
Approved by: manu (mentor)
MFC after: 2 weeks
Sponsored by: Beckhoff Automation GmbH & Co. KG
Differential Revision: https://reviews.freebsd.org/D37406
---
usr.sbin/bhyve/basl.c | 11 +++++++++++
usr.sbin/bhyve/basl.h | 3 +++
2 files changed, 14 insertions(+)
diff --git a/usr.sbin/bhyve/basl.c b/usr.sbin/bhyve/basl.c
index e93d0e2e1a58..716393caeebe 100644
--- a/usr.sbin/bhyve/basl.c
+++ b/usr.sbin/bhyve/basl.c
@@ -437,6 +437,17 @@ basl_table_append_checksum(struct basl_table *const table, const uint32_t start,
return (0);
}
+int
+basl_table_append_content(struct basl_table *table, void *data, uint32_t len)
+{
+ assert(data != NULL);
+ assert(len >= sizeof(ACPI_TABLE_HEADER));
+
+ return (basl_table_append_bytes(table,
+ (void *)((uintptr_t)(data) + sizeof(ACPI_TABLE_HEADER)),
+ len - sizeof(ACPI_TABLE_HEADER)));
+}
+
int
basl_table_append_gas(struct basl_table *const table, const uint8_t space_id,
const uint8_t bit_width, const uint8_t bit_offset,
diff --git a/usr.sbin/bhyve/basl.h b/usr.sbin/bhyve/basl.h
index 3b61362d824f..0fe4ef7c5e82 100644
--- a/usr.sbin/bhyve/basl.h
+++ b/usr.sbin/bhyve/basl.h
@@ -53,6 +53,9 @@ int basl_table_append_bytes(struct basl_table *table, const void *bytes,
uint32_t len);
int basl_table_append_checksum(struct basl_table *table, uint32_t start,
uint32_t len);
+/* Add an ACPI_TABLE_* to basl without its header. */
+int basl_table_append_content(struct basl_table *table, void *data,
+ uint32_t len);
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);