summaryrefslogtreecommitdiff
path: root/src/arch
diff options
context:
space:
mode:
authorPatrick Rudolph <patrick.rudolph@9elements.com>2019-12-13 12:16:06 +0100
committerFelix Held <felix-coreboot@felixheld.de>2020-01-09 14:22:51 +0000
commitc83bab62b3657d97299c8368b6c610e4cbf994b6 (patch)
treef568d7f66b4a3491c6292040db29905111771de4 /src/arch
parent5c8ff794a8dcb0760c137d3b2dff1879a4a8dad6 (diff)
downloadcoreboot-c83bab62b3657d97299c8368b6c610e4cbf994b6.tar.xz
acpi: Be more ACPI compliant when generating _UID
* Add function to generate unique _UID using CRC32 * Add function to write the _UID based on a device's ACPI path ACPI devices that have the same _HID must use different _UID. Linux doesn't care about _UID if it's not used. Windows 10 verifies the ACPI code on boot and BSODs if two devices with the same _HID share the same _UID. Fixes BSOD seen on Windows 10. Change-Id: I47cd5396060d325f9ce338afced6af021e7ff2b4 Signed-off-by: Patrick Rudolph <patrick.rudolph@9elements.com> Reviewed-on: https://review.coreboot.org/c/coreboot/+/37695 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Philipp Deppenwiese <zaolin.daisuki@gmail.com>
Diffstat (limited to 'src/arch')
-rw-r--r--src/arch/x86/acpi_device.c22
-rw-r--r--src/arch/x86/include/arch/acpi_device.h2
2 files changed, 24 insertions, 0 deletions
diff --git a/src/arch/x86/acpi_device.c b/src/arch/x86/acpi_device.c
index 5c77953bc2..1d79170487 100644
--- a/src/arch/x86/acpi_device.c
+++ b/src/arch/x86/acpi_device.c
@@ -18,6 +18,8 @@
#include <device/device.h>
#include <device/path.h>
#include <stdlib.h>
+#include <crc_byte.h>
+
#if CONFIG(GENERIC_GPIO_LIB)
#include <gpio.h>
#endif
@@ -98,6 +100,19 @@ const char *acpi_device_hid(const struct device *dev)
return NULL;
}
+/*
+ * Generate unique ID based on the ACPI path.
+ * Collisions on the same _HID are possible but very unlikely.
+ */
+uint32_t acpi_device_uid(struct device *dev)
+{
+ const char *path = acpi_device_path(dev);
+ if (!path)
+ return 0;
+
+ return CRC(path, strlen(path), crc32_byte);
+}
+
/* Recursive function to find the root device and print a path from there */
static ssize_t acpi_device_path_fill(const struct device *dev, char *buf,
size_t buf_len, size_t cur)
@@ -192,6 +207,13 @@ int acpi_device_status(const struct device *dev)
return ACPI_STATUS_DEVICE_ALL_ON;
}
+
+/* Write the unique _UID based on ACPI device path. */
+void acpi_device_write_uid(struct device *dev)
+{
+ acpigen_write_name_integer("_UID", acpi_device_uid(dev));
+}
+
/* ACPI 6.1 section 6.4.3.6: Extended Interrupt Descriptor */
void acpi_device_write_interrupt(const struct acpi_irq *irq)
{
diff --git a/src/arch/x86/include/arch/acpi_device.h b/src/arch/x86/include/arch/acpi_device.h
index 382ef1546b..0a702c9329 100644
--- a/src/arch/x86/include/arch/acpi_device.h
+++ b/src/arch/x86/include/arch/acpi_device.h
@@ -62,10 +62,12 @@ struct acpi_dp {
struct device;
const char *acpi_device_name(const struct device *dev);
const char *acpi_device_hid(const struct device *dev);
+uint32_t acpi_device_uid(struct device *dev);
const char *acpi_device_path(const struct device *dev);
const char *acpi_device_scope(const struct device *dev);
const char *acpi_device_path_join(const struct device *dev, const char *name);
int acpi_device_status(const struct device *dev);
+void acpi_device_write_uid(struct device *dev);
/*
* ACPI Descriptor for extended Interrupt()