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