]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - usr.sbin/bhyve/basl.h
bhyve: build DSDT table by basl
[FreeBSD/FreeBSD.git] / usr.sbin / bhyve / basl.h
1 /*-
2  * SPDX-License-Identifier: BSD-2-Clause
3  *
4  * Copyright (c) 2022 Beckhoff Automation GmbH & Co. KG
5  */
6
7 #pragma once
8
9 #include <contrib/dev/acpica/include/acpi.h>
10
11 #define ACPI_GAS_ACCESS_WIDTH_LEGACY 0
12 #define ACPI_GAS_ACCESS_WIDTH_UNDEFINED 0
13 #define ACPI_GAS_ACCESS_WIDTH_BYTE 1
14 #define ACPI_GAS_ACCESS_WIDTH_WORD 2
15 #define ACPI_GAS_ACCESS_WIDTH_DWORD 3
16 #define ACPI_GAS_ACCESS_WIDTH_QWORD 4
17
18 #define BHYVE_ACPI_BASE 0xf2400
19
20 #define BASL_TABLE_ALIGNMENT 0x10
21 #define BASL_TABLE_ALIGNMENT_FACS 0x40
22
23 #define BASL_TABLE_CHECKSUM_LEN_FULL_TABLE (-1)
24
25 #define BASL_EXEC(x)                                                         \
26         do {                                                                 \
27                 const int error = (x);                                       \
28                 if (error) {                                                 \
29                         warnc(error,                                         \
30                             "BASL failed @ %s:%d\n    Failed to execute %s", \
31                             __func__, __LINE__, #x);                         \
32                         return (error);                                      \
33                 }                                                            \
34         } while (0)
35
36 #define QEMU_FWCFG_MAX_NAME 56
37
38 struct basl_table;
39
40 int basl_finish(void);
41 int basl_init(void);
42 int basl_table_append_bytes(struct basl_table *table, const void *bytes,
43     uint32_t len);
44 int basl_table_append_checksum(struct basl_table *table, uint32_t start,
45     uint32_t len);
46 int basl_table_append_gas(struct basl_table *table, uint8_t space_id,
47     uint8_t bit_width, uint8_t bit_offset, uint8_t access_width,
48     uint64_t address);
49 int basl_table_append_header(struct basl_table *table,
50     const uint8_t signature[ACPI_NAMESEG_SIZE], uint8_t revision,
51     uint32_t oem_revision);
52 int basl_table_append_int(struct basl_table *table, uint64_t val, uint8_t size);
53 int basl_table_append_length(struct basl_table *table, uint8_t size);
54 int basl_table_append_pointer(struct basl_table *table,
55     const uint8_t src_signature[ACPI_NAMESEG_SIZE], uint8_t size);
56 int basl_table_create(struct basl_table **table, struct vmctx *ctx,
57     const uint8_t *name, uint32_t alignment, uint32_t off);