diff options
Diffstat (limited to 'src/arch/x86/acpigen.c')
-rw-r--r-- | src/arch/x86/acpigen.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/src/arch/x86/acpigen.c b/src/arch/x86/acpigen.c index 26fe08fa87..715c38b598 100644 --- a/src/arch/x86/acpigen.c +++ b/src/arch/x86/acpigen.c @@ -17,6 +17,8 @@ #include <assert.h> #include <console/console.h> #include <device/device.h> +#include <device/pci_def.h> +#include <device/pci_type.h> static char *gencurrent; @@ -1840,3 +1842,25 @@ void acpigen_resource_qword(u16 res_type, u16 gen_flags, u16 type_flags, acpigen_emit_qword(translation); acpigen_emit_qword(length); } + +void acpigen_write_ADR(uint64_t adr) +{ + acpigen_write_name_qword("_ADR", adr); +} + +void acpigen_write_ADR_pci_devfn(pci_devfn_t devfn) +{ + /* + * _ADR for PCI Bus is encoded as follows: + * [63:32] - unused + * [31:16] - device # + * [15:0] - function # + */ + acpigen_write_ADR(PCI_SLOT(devfn) << 16 | PCI_FUNC(devfn)); +} + +void acpigen_write_ADR_pci_device(const struct device *dev) +{ + assert(dev->path.type == DEVICE_PATH_PCI); + acpigen_write_ADR_pci_devfn(dev->path.pci.devfn); +} |