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