git: c66bd4a5285c - stable/13 - bhyve: add basl support for int values
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Tue, 29 Nov 2022 13:58:01 UTC
The branch stable/13 has been updated by corvink: URL: https://cgit.FreeBSD.org/src/commit/?id=c66bd4a5285c4c2d64977d4e4c94079e0f8a4745 commit c66bd4a5285c4c2d64977d4e4c94079e0f8a4745 Author: Corvin Köhne <corvink@FreeBSD.org> AuthorDate: 2022-11-04 12:48:13 +0000 Commit: Corvin Köhne <corvink@FreeBSD.org> CommitDate: 2022-11-29 13:53:50 +0000 bhyve: add basl support for int values In upcoming commits, bhyve will build some ACPI tables by it's own. Therefore, it should be capable of appending int values to ACPI tables. 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/D36987 (cherry picked from commit e22f5ce2bf4c1a53a1551ae855f42d582eeda20e) --- usr.sbin/bhyve/basl.c | 23 +++++++++++++++++++++++ usr.sbin/bhyve/basl.h | 1 + 2 files changed, 24 insertions(+) diff --git a/usr.sbin/bhyve/basl.c b/usr.sbin/bhyve/basl.c index 655c6e509dc4..b3a561f51571 100644 --- a/usr.sbin/bhyve/basl.c +++ b/usr.sbin/bhyve/basl.c @@ -33,6 +33,17 @@ struct basl_table { static STAILQ_HEAD(basl_table_list, basl_table) basl_tables = STAILQ_HEAD_INITIALIZER( basl_tables); +static __inline void +basl_le_enc(void *pp, uint64_t val, size_t len) +{ + char buf[8]; + + assert(len <= 8); + + le64enc(buf, val); + memcpy(pp, buf, len); +} + static int basl_dump_table(const struct basl_table *const table, const bool mem) { @@ -145,6 +156,18 @@ basl_table_append_bytes(struct basl_table *const table, const void *const bytes, return (0); } +int +basl_table_append_int(struct basl_table *const table, const uint64_t val, + const uint8_t size) +{ + char buf[8]; + + assert(size <= sizeof(val)); + + basl_le_enc(buf, val, size); + return (basl_table_append_bytes(table, buf, size)); +} + int basl_table_create(struct basl_table **const table, struct vmctx *ctx, const uint8_t *const name, const uint32_t alignment, diff --git a/usr.sbin/bhyve/basl.h b/usr.sbin/bhyve/basl.h index f6809a473ff4..3ce33dea63e0 100644 --- a/usr.sbin/bhyve/basl.h +++ b/usr.sbin/bhyve/basl.h @@ -32,5 +32,6 @@ int basl_finish(void); int basl_init(void); int basl_table_append_bytes(struct basl_table *table, const void *bytes, uint32_t len); +int basl_table_append_int(struct basl_table *table, uint64_t val, uint8_t size); int basl_table_create(struct basl_table **table, struct vmctx *ctx, const uint8_t *name, uint32_t alignment, uint32_t off);