xref: /openbmc/qemu/hw/virtio/virtio-acpi.c (revision c4380f7b)
1 // SPDX-License-Identifier: GPL-2.0+
2 /*
3  * virtio ACPI Support
4  *
5  */
6 
7 #include "hw/virtio/virtio-acpi.h"
8 #include "hw/acpi/aml-build.h"
9 
10 void virtio_acpi_dsdt_add(Aml *scope, const hwaddr base, const hwaddr size,
11                           uint32_t mmio_irq, long int start_index, int num)
12 {
13     hwaddr virtio_base = base;
14     uint32_t irq = mmio_irq;
15     long int i;
16 
17     for (i = start_index; i < start_index + num; i++) {
18         Aml *dev = aml_device("VR%02u", (unsigned)i);
19         aml_append(dev, aml_name_decl("_HID", aml_string("LNRO0005")));
20         aml_append(dev, aml_name_decl("_UID", aml_int(i)));
21         aml_append(dev, aml_name_decl("_CCA", aml_int(1)));
22 
23         Aml *crs = aml_resource_template();
24         aml_append(crs, aml_memory32_fixed(virtio_base, size, AML_READ_WRITE));
25         aml_append(crs,
26                    aml_interrupt(AML_CONSUMER, AML_LEVEL, AML_ACTIVE_HIGH,
27                                  AML_EXCLUSIVE, &irq, 1));
28         aml_append(dev, aml_name_decl("_CRS", crs));
29         aml_append(scope, dev);
30         virtio_base += size;
31         irq++;
32     }
33 }
34