git: eb8931d77cee - stable/13 - bhyve: add helper func to add acpi resources
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Tue, 28 Feb 2023 10:14:08 UTC
The branch stable/13 has been updated by corvink:
URL: https://cgit.FreeBSD.org/src/commit/?id=eb8931d77cee0af57578159297f95571a2d723f8
commit eb8931d77cee0af57578159297f95571a2d723f8
Author: Corvin Köhne <corvink@FreeBSD.org>
AuthorDate: 2021-10-07 13:57:01 +0000
Commit: Corvin Köhne <corvink@FreeBSD.org>
CommitDate: 2023-02-28 10:04:33 +0000
bhyve: add helper func to add acpi resources
These helper function can be used to assign acpi resources to an
acpi_device.
Reviewed by: markj
MFC after: 1 week
Sponsored by: Beckhoff Automation GmbH & Co. KG
Differential Revision: https://reviews.freebsd.org/D38328
(cherry picked from commit 13a1df5b85e992570f45248bfe9d581dc182b755)
---
usr.sbin/bhyve/acpi_device.c | 45 ++++++++++++++++++++++++++++++++++++++++++++
usr.sbin/bhyve/acpi_device.h | 5 +++++
2 files changed, 50 insertions(+)
diff --git a/usr.sbin/bhyve/acpi_device.c b/usr.sbin/bhyve/acpi_device.c
index 66d50de814fd..402e32faa93a 100644
--- a/usr.sbin/bhyve/acpi_device.c
+++ b/usr.sbin/bhyve/acpi_device.c
@@ -90,3 +90,48 @@ acpi_device_destroy(struct acpi_device *const dev)
free(__DECONST(void *, dev->name));
free(dev);
}
+
+int
+acpi_device_add_res_fixed_ioport(struct acpi_device *const dev,
+ const UINT16 port, const UINT8 length)
+{
+ if (dev == NULL) {
+ return (EINVAL);
+ }
+
+ struct acpi_resource_list_entry *const res = calloc(1, sizeof(*res));
+ if (res == NULL) {
+ return (ENOMEM);
+ }
+
+ res->type = ACPI_RESOURCE_TYPE_FIXED_IO;
+ res->data.FixedIo.Address = port;
+ res->data.FixedIo.AddressLength = length;
+
+ SLIST_INSERT_HEAD(&dev->crs, res, chain);
+
+ return (0);
+}
+
+int
+acpi_device_add_res_fixed_memory32(struct acpi_device *const dev,
+ const UINT8 write_protected, const UINT32 address, const UINT32 length)
+{
+ if (dev == NULL) {
+ return (EINVAL);
+ }
+
+ struct acpi_resource_list_entry *const res = calloc(1, sizeof(*res));
+ if (res == NULL) {
+ return (ENOMEM);
+ }
+
+ res->type = ACPI_RESOURCE_TYPE_FIXED_MEMORY32;
+ res->data.FixedMemory32.WriteProtect = write_protected;
+ res->data.FixedMemory32.Address = address;
+ res->data.FixedMemory32.AddressLength = length;
+
+ SLIST_INSERT_HEAD(&dev->crs, res, chain);
+
+ return (0);
+}
diff --git a/usr.sbin/bhyve/acpi_device.h b/usr.sbin/bhyve/acpi_device.h
index 1728acd4cdcd..d9618d7e0a43 100644
--- a/usr.sbin/bhyve/acpi_device.h
+++ b/usr.sbin/bhyve/acpi_device.h
@@ -29,3 +29,8 @@ struct acpi_device;
int acpi_device_create(struct acpi_device **const new_dev,
struct vmctx *const vm_ctx, const char *const name, const char *const hid);
void acpi_device_destroy(struct acpi_device *const dev);
+
+int acpi_device_add_res_fixed_ioport(struct acpi_device *const dev,
+ const UINT16 port, UINT8 length);
+int acpi_device_add_res_fixed_memory32(struct acpi_device *const dev,
+ const UINT8 write_protected, const UINT32 address, const UINT32 length);