diff options
author | Ahmad Fatoum <ahmad@a3f.at> | 2019-12-04 15:07:20 +0100 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2019-12-09 11:39:13 +0100 |
commit | 9d2cc467bdccd01b2a6e23019a0f588969ff2a2e (patch) | |
tree | 256d3e6ccbfdab12e530c08b6f561a51c01a0891 /include | |
parent | d0c7fb0d030e282fda2708a4cd9d921cf7e10465 (diff) | |
download | barebox-9d2cc467bdccd01b2a6e23019a0f588969ff2a2e.tar.gz barebox-9d2cc467bdccd01b2a6e23019a0f588969ff2a2e.tar.xz |
bus: efi: add basic ACPI bus infrastructure
It makes sense to support some ACPI tables like the WDAT (Watchdog
Action Table) in barebox. To facilitate this add a ACPI bus and
the necessary bits to integrate ACPI tables into the barebox
device/driver model as devices. These devices are identified by the
four byte signature, which drivers can then match against and the
system description table (SDT) of the device is then available as a
device memory resource.
Even without drivers, with this patch, devinfo and md can now be used
to view the ACPI system description tables, which can be useful
during UEFI payload development.
Support for the ACPI Machine Language and ACPI 5.1 _DSD (Device
Specific Data) is not implemented.
Signed-off-by: Ahmad Fatoum <ahmad@a3f.at>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'include')
-rw-r--r-- | include/acpi.h | 73 |
1 files changed, 73 insertions, 0 deletions
diff --git a/include/acpi.h b/include/acpi.h new file mode 100644 index 0000000000..2d5fd3086a --- /dev/null +++ b/include/acpi.h @@ -0,0 +1,73 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (c) 2019 Ahmad Fatoum + */ + +#ifndef __ACPI_H_ +#define __ACPI_H_ + +#include <linux/types.h> +#include <driver.h> + +typedef char acpi_sig_t[4]; + +struct __packed acpi_rsdp { /* root system description pointer */ + char signature[8]; + u8 checksum; + u8 oem_id[6]; + u8 revision; + u32 rsdt_addr; +}; + +struct __packed acpi2_rsdp { /* root system description */ + struct acpi_rsdp acpi1; + u32 length; + u64 xsdt_addr; + u8 extended_checksum; + u8 reserved[3]; +}; + +struct __packed acpi_sdt { /* system description table header */ + acpi_sig_t signature; + u32 len; + u8 revision; + u8 checksum; + char oem_id[6]; + char oem_table_id[8]; + u32 oem_revision; + u32 creator_id; + u32 creator_revision; +}; + +struct __packed acpi_rsdt { /* system description table header */ + struct acpi_sdt sdt; + struct acpi_sdt * __aligned(8) entries[]; +}; + +struct acpi_driver { + struct driver_d driver; + acpi_sig_t signature; +}; + +extern struct bus_type acpi_bus; + +static inline struct acpi_driver *to_acpi_driver(struct driver_d *drv) +{ + return container_of(drv, struct acpi_driver, driver); +} + +#define device_acpi_driver(drv) \ + register_driver_macro(device, acpi, drv) + +static inline int acpi_driver_register(struct acpi_driver *acpidrv) +{ + acpidrv->driver.bus = &acpi_bus; + return register_driver(&acpidrv->driver); +} + +static inline int acpi_sigcmp(const acpi_sig_t sig_a, const acpi_sig_t sig_b) +{ + return memcmp(sig_a, sig_b, sizeof(acpi_sig_t)); +} + +#endif |