Coverage Report

Created: 2026-11-20 08:13

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/qemu/hw/sd/sdhci-pci.c
Line
Count
Source
1
/*
2
 * SDHCI device on PCI
3
 *
4
 * This program is free software; you can redistribute it and/or modify it
5
 * under the terms of the GNU General Public License as published by the
6
 * Free Software Foundation; either version 2 of the License, or (at your
7
 * option) any later version.
8
 *
9
 * This program is distributed in the hope that it will be useful,
10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12
 * See the GNU General Public License for more details.
13
 *
14
 * You should have received a copy of the GNU General Public License along
15
 * with this program; if not, see <http://www.gnu.org/licenses/>.
16
 */
17
18
#include "qemu/osdep.h"
19
#include "qapi/error.h"
20
#include "qemu/module.h"
21
#include "hw/core/irq.h"
22
#include "hw/core/qdev-properties.h"
23
#include "hw/sd/sdhci.h"
24
#include "sdhci-internal.h"
25
26
static const Property sdhci_pci_properties[] = {
27
    DEFINE_SDHCI_COMMON_PROPERTIES(SDHCIState),
28
};
29
30
static void sdhci_pci_realize(PCIDevice *dev, Error **errp)
31
1
{
32
1
    ERRP_GUARD();
33
1
    SDHCIState *s = PCI_SDHCI(dev);
34
35
1
    sdhci_initfn(s);
36
1
    sdhci_common_realize(s, errp);
37
1
    if (*errp) {
38
0
        return;
39
0
    }
40
41
1
    dev->config[PCI_CLASS_PROG] = 0x01; /* Standard Host supported DMA */
42
1
    dev->config[PCI_INTERRUPT_PIN] = 0x01; /* interrupt pin A */
43
1
    s->irq = pci_allocate_irq(dev);
44
1
    s->dma_as = pci_get_address_space(dev);
45
1
    pci_register_bar(dev, 0, PCI_BASE_ADDRESS_SPACE_MEMORY, &s->iomem);
46
1
}
47
48
static void sdhci_pci_exit(PCIDevice *dev)
49
0
{
50
0
    SDHCIState *s = PCI_SDHCI(dev);
51
52
0
    qemu_free_irq(s->irq);
53
0
    sdhci_common_unrealize(s);
54
0
    sdhci_uninitfn(s);
55
0
}
56
57
static void sdhci_pci_class_init(ObjectClass *klass, const void *data)
58
63
{
59
63
    DeviceClass *dc = DEVICE_CLASS(klass);
60
63
    PCIDeviceClass *k = PCI_DEVICE_CLASS(klass);
61
62
63
    k->realize = sdhci_pci_realize;
63
63
    k->exit = sdhci_pci_exit;
64
63
    k->vendor_id = PCI_VENDOR_ID_REDHAT;
65
63
    k->device_id = PCI_DEVICE_ID_REDHAT_SDHCI;
66
63
    k->class_id = PCI_CLASS_SYSTEM_SDHCI;
67
63
    device_class_set_props(dc, sdhci_pci_properties);
68
69
63
    sdhci_common_class_init(klass, data);
70
63
}
71
72
static const TypeInfo sdhci_pci_types[] = {
73
    {
74
        .name           = TYPE_PCI_SDHCI,
75
        .parent         = TYPE_PCI_DEVICE,
76
        .instance_size  = sizeof(SDHCIState),
77
        .class_init     = sdhci_pci_class_init,
78
        .interfaces     = (const InterfaceInfo[]) {
79
            { INTERFACE_CONVENTIONAL_PCI_DEVICE },
80
            { },
81
        },
82
    },
83
};
84
85
DEFINE_TYPES(sdhci_pci_types)