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
This commit is contained in:
parent
22a2e94f38
commit
e22f5ce2bf
@ -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,
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user