git: 7263419f387d - main - bhyve: make basl_table_add_* functions public
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Mon, 21 Nov 2022 08:31:34 UTC
The branch main has been updated by corvink:
URL: https://cgit.FreeBSD.org/src/commit/?id=7263419f387db306340ed39fc058580872b64f3b
commit 7263419f387db306340ed39fc058580872b64f3b
Author: Corvin Köhne <corvink@FreeBSD.org>
AuthorDate: 2022-11-16 08:15:12 +0000
Commit: Corvin Köhne <corvink@FreeBSD.org>
CommitDate: 2022-11-21 08:27:50 +0000
bhyve: make basl_table_add_* functions public
The code will be more readable if we use struct definitions from ACPI-CA
to build ACPI tables. We can fill out the struct and append it to the
basl_table by using basl_table_append_bytes. After that, we have to
declare which checksums, length and pointers should be patched by basl.
That's done by the add_* functions.
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/D37405
---
usr.sbin/bhyve/basl.c | 14 +++++++++++---
usr.sbin/bhyve/basl.h | 7 +++++++
2 files changed, 18 insertions(+), 3 deletions(-)
diff --git a/usr.sbin/bhyve/basl.c b/usr.sbin/bhyve/basl.c
index 8c01f16895cd..e93d0e2e1a58 100644
--- a/usr.sbin/bhyve/basl.c
+++ b/usr.sbin/bhyve/basl.c
@@ -322,12 +322,14 @@ basl_init(void)
return (0);
}
-static int
+int
basl_table_add_checksum(struct basl_table *const table, const uint32_t off,
const uint32_t start, const uint32_t len)
{
struct basl_table_checksum *checksum;
+ assert(table != NULL);
+
checksum = calloc(1, sizeof(struct basl_table_checksum));
if (checksum == NULL) {
warnx("%s: failed to allocate checksum", __func__);
@@ -343,12 +345,15 @@ basl_table_add_checksum(struct basl_table *const table, const uint32_t off,
return (0);
}
-static int
+int
basl_table_add_length(struct basl_table *const table, const uint32_t off,
const uint8_t size)
{
struct basl_table_length *length;
+ assert(table != NULL);
+ assert(size == 4 || size == 8);
+
length = calloc(1, sizeof(struct basl_table_length));
if (length == NULL) {
warnx("%s: failed to allocate length", __func__);
@@ -363,13 +368,16 @@ basl_table_add_length(struct basl_table *const table, const uint32_t off,
return (0);
}
-static int
+int
basl_table_add_pointer(struct basl_table *const table,
const uint8_t src_signature[ACPI_NAMESEG_SIZE], const uint32_t off,
const uint8_t size)
{
struct basl_table_pointer *pointer;
+ assert(table != NULL);
+ assert(size == 4 || size == 8);
+
pointer = calloc(1, sizeof(struct basl_table_pointer));
if (pointer == NULL) {
warnx("%s: failed to allocate pointer", __func__);
diff --git a/usr.sbin/bhyve/basl.h b/usr.sbin/bhyve/basl.h
index eef252bd1248..3b61362d824f 100644
--- a/usr.sbin/bhyve/basl.h
+++ b/usr.sbin/bhyve/basl.h
@@ -42,6 +42,13 @@ struct basl_table;
int basl_finish(void);
int basl_init(void);
+int basl_table_add_checksum(struct basl_table *const table, const uint32_t off,
+ const uint32_t start, const uint32_t len);
+int basl_table_add_length(struct basl_table *const table, const uint32_t off,
+ const uint8_t size);
+int basl_table_add_pointer(struct basl_table *const table,
+ const uint8_t src_signature[ACPI_NAMESEG_SIZE], const uint32_t off,
+ const uint8_t size);
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,