diff --git a/usr.sbin/bhyve/basl.h b/usr.sbin/bhyve/basl.h --- a/usr.sbin/bhyve/basl.h +++ b/usr.sbin/bhyve/basl.h @@ -33,5 +33,6 @@ int basl_init(); 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[QEMU_FWCFG_MAX_NAME], uint32_t alignment, uint32_t off); diff --git a/usr.sbin/bhyve/basl.c b/usr.sbin/bhyve/basl.c --- a/usr.sbin/bhyve/basl.c +++ b/usr.sbin/bhyve/basl.c @@ -168,6 +168,18 @@ return (0); } +int +basl_table_append_int(struct basl_table *const table, const uint64_t val, + const uint8_t size) +{ + if (size > sizeof(val)) { + return (EINVAL); + } + + const uint64_t val_le = htole64(val); + return (basl_table_append_bytes(table, &val_le, size)); +} + int basl_table_create(struct basl_table **const table, struct vmctx *ctx, const uint8_t name[QEMU_FWCFG_MAX_NAME], const uint32_t alignment,