static void vfio_probe_ati_bar2_quirk(VFIOPCIDevice *vdev, int nr)

{

    VFIOQuirk *quirk;

    VFIOConfigMirrorQuirk *mirror;



    /* Only enable on newer devices where BAR2 is 64bit */

    if (!vfio_pci_is(vdev, PCI_VENDOR_ID_ATI, PCI_ANY_ID) ||

        !vdev->has_vga || nr != 2 || !vdev->bars[2].mem64) {

        return;

    }



    quirk = g_malloc0(sizeof(*quirk));

    mirror = quirk->data = g_malloc0(sizeof(*mirror));

    mirror->mem = quirk->mem = g_malloc0(sizeof(MemoryRegion));

    quirk->nr_mem = 1;

    mirror->vdev = vdev;

    mirror->offset = 0x4000;

    mirror->bar = nr;



    memory_region_init_io(mirror->mem, OBJECT(vdev),

                          &vfio_generic_mirror_quirk, mirror,

                          "vfio-ati-bar2-4000-quirk", PCI_CONFIG_SPACE_SIZE);

    memory_region_add_subregion_overlap(&vdev->bars[nr].region.mem,

                                        mirror->offset, mirror->mem, 1);



    QLIST_INSERT_HEAD(&vdev->bars[nr].quirks, quirk, next);



    trace_vfio_quirk_ati_bar2_probe(vdev->vbasedev.name);

}

static void vfio_probe_ati_bar2_quirk(VFIOPCIDevice *vdev, int nr)

{

    VFIOQuirk *quirk;

    VFIOConfigMirrorQuirk *mirror;



    

    if (!vfio_pci_is(vdev, PCI_VENDOR_ID_ATI, PCI_ANY_ID) ||

        !vdev->has_vga || nr != 2 || !vdev->bars[2].mem64) {

        return;

    }



    quirk = g_malloc0(sizeof(*quirk));

    mirror = quirk->data = g_malloc0(sizeof(*mirror));

    mirror->mem = quirk->mem = g_malloc0(sizeof(MemoryRegion));

    quirk->nr_mem = 1;

    mirror->vdev = vdev;

    mirror->offset = 0x4000;

    mirror->bar = nr;



    memory_region_init_io(mirror->mem, OBJECT(vdev),

                          &vfio_generic_mirror_quirk, mirror,

                          "vfio-ati-bar2-4000-quirk", PCI_CONFIG_SPACE_SIZE);

    memory_region_add_subregion_overlap(&vdev->bars[nr].region.mem,

                                        mirror->offset, mirror->mem, 1);



    QLIST_INSERT_HEAD(&vdev->bars[nr].quirks, quirk, next);



    trace_vfio_quirk_ati_bar2_probe(vdev->vbasedev.name);

}

    mirror->mem = quirk->mem = g_malloc0(sizeof(MemoryRegion));     mirror->mem = quirk->mem = g_malloc0(sizeof(MemoryRegion));
static void FUNC_0(VFIOPCIDevice *VAR_0, int VAR_1)

{

    VFIOQuirk *quirk;

    VFIOConfigMirrorQuirk *mirror;



    

    if (!vfio_pci_is(VAR_0, PCI_VENDOR_ID_ATI, PCI_ANY_ID) ||

        !VAR_0->has_vga || VAR_1 != 2 || !VAR_0->bars[2].mem64) {

        return;

    }



    quirk = g_malloc0(sizeof(*quirk));

    mirror = quirk->data = g_malloc0(sizeof(*mirror));

    mirror->mem = quirk->mem = g_malloc0(sizeof(MemoryRegion));

    quirk->nr_mem = 1;

    mirror->VAR_0 = VAR_0;

    mirror->offset = 0x4000;

    mirror->bar = VAR_1;



    memory_region_init_io(mirror->mem, OBJECT(VAR_0),

                          &vfio_generic_mirror_quirk, mirror,

                          "vfio-ati-bar2-4000-quirk", PCI_CONFIG_SPACE_SIZE);

    memory_region_add_subregion_overlap(&VAR_0->bars[VAR_1].region.mem,

                                        mirror->offset, mirror->mem, 1);



    QLIST_INSERT_HEAD(&VAR_0->bars[VAR_1].quirks, quirk, next);



    trace_vfio_quirk_ati_bar2_probe(VAR_0->vbasedev.name);

}

static void FUNC_0(VFIOPCIDevice *VAR_0, int VAR_1)
{ VFIOQuirk *quirk; VFIOConfigMirrorQuirk *mirror; if (!vfio_pci_is(VAR_0, PCI_VENDOR_ID_ATI, PCI_ANY_ID) ||
!VAR_0->has_vga || VAR_1 != 2 || !VAR_0->bars[2].mem64) { return; } quirk = g_malloc0(sizeof(*quirk)); mirror = quirk->data = g_malloc0(sizeof(*mirror)); mirror->mem = quirk->mem = g_malloc0(sizeof(MemoryRegion)); quirk->nr_mem = 1; mirror->VAR_0 = VAR_0; mirror->offset = 0x4000; mirror->bar = VAR_1; memory_region_init_io(mirror->mem, OBJECT(VAR_0),
&vfio_generic_mirror_quirk, mirror,
"vfio-ati-bar2-4000-quirk", PCI_CONFIG_SPACE_SIZE); memory_region_add_subregion_overlap(&VAR_0->bars[VAR_1].region.mem,
mirror->offset, mirror->mem, 1); QLIST_INSERT_HEAD(&VAR_0->bars[VAR_1].quirks, quirk, next); trace_vfio_quirk_ati_bar2_probe(VAR_0->vbasedev.name); }