git: f3085b5d29cc - stable/13 - bhyve: add helper to fill a ACPI_GENERIC_ADDRESS

From: Corvin Köhne <corvink_at_FreeBSD.org>
Date: Mon, 05 Dec 2022 07:42:01 UTC
The branch stable/13 has been updated by corvink:

URL: https://cgit.FreeBSD.org/src/commit/?id=f3085b5d29ccb772acc678c7b2122506ac3d7923

commit f3085b5d29ccb772acc678c7b2122506ac3d7923
Author:     Corvin Köhne <corvink@FreeBSD.org>
AuthorDate: 2022-11-16 09:45:17 +0000
Commit:     Corvin Köhne <corvink@FreeBSD.org>
CommitDate: 2022-12-05 07:39:36 +0000

    bhyve: add helper to fill a ACPI_GENERIC_ADDRESS
    
    Reviewed by:            jhb
    Approved by:            manu (mentor)
    MFC after:              2 weeks
    Sponsored by:           Beckhoff Automation GmbH & Co. KG
    Differential Revision:  https://reviews.freebsd.org/D37407
    
    (cherry picked from commit 60277ad75ec905d25182368d1022f56f43b490d5)
---
 usr.sbin/bhyve/basl.c | 14 ++++++++++++++
 usr.sbin/bhyve/basl.h |  3 +++
 2 files changed, 17 insertions(+)

diff --git a/usr.sbin/bhyve/basl.c b/usr.sbin/bhyve/basl.c
index 9af1baed7dd7..afc8252cc0e2 100644
--- a/usr.sbin/bhyve/basl.c
+++ b/usr.sbin/bhyve/basl.c
@@ -122,6 +122,20 @@ basl_dump(const bool mem)
 	return (0);
 }
 
+void
+basl_fill_gas(ACPI_GENERIC_ADDRESS *const gas, const uint8_t space_id,
+    const uint8_t bit_width, const uint8_t bit_offset,
+    const uint8_t access_width, const uint64_t address)
+{
+	assert(gas != NULL);
+
+	gas->SpaceId = space_id;
+	gas->BitWidth = bit_width;
+	gas->BitOffset = bit_offset;
+	gas->AccessWidth = access_width;
+	gas->Address = htole64(address);
+}
+
 static int
 basl_finish_install_guest_tables(struct basl_table *const table)
 {
diff --git a/usr.sbin/bhyve/basl.h b/usr.sbin/bhyve/basl.h
index b634164c42de..e3f0621a1f69 100644
--- a/usr.sbin/bhyve/basl.h
+++ b/usr.sbin/bhyve/basl.h
@@ -37,6 +37,9 @@
 
 struct basl_table;
 
+void basl_fill_gas(ACPI_GENERIC_ADDRESS *gas, uint8_t space_id,
+    uint8_t bit_width, uint8_t bit_offset, uint8_t access_width,
+    uint64_t address);
 int basl_finish(void);
 int basl_init(void);
 int basl_table_add_checksum(struct basl_table *const table, const uint32_t off,