Statistics
| Branch: | Revision:

root / hw / misc / pci-testdev.c @ f487b677

History | View | Annotate | Download (8.8 kB)

1 22773d60 Michael S. Tsirkin
/*
2 22773d60 Michael S. Tsirkin
 * QEMU PCI test device
3 22773d60 Michael S. Tsirkin
 *
4 22773d60 Michael S. Tsirkin
 * Copyright (c) 2012 Red Hat Inc.
5 22773d60 Michael S. Tsirkin
 * Author: Michael S. Tsirkin <mst@redhat.com>
6 22773d60 Michael S. Tsirkin
 *
7 22773d60 Michael S. Tsirkin
 * This program is free software; you can redistribute it and/or modify
8 22773d60 Michael S. Tsirkin
 * it under the terms of the GNU General Public License as published by
9 22773d60 Michael S. Tsirkin
 * the Free Software Foundation; either version 2 of the License, or
10 22773d60 Michael S. Tsirkin
 * (at your option) any later version.
11 22773d60 Michael S. Tsirkin
 *
12 22773d60 Michael S. Tsirkin
 * This program is distributed in the hope that it will be useful,
13 22773d60 Michael S. Tsirkin
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 22773d60 Michael S. Tsirkin
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 22773d60 Michael S. Tsirkin
 * GNU General Public License for more details.
16 22773d60 Michael S. Tsirkin
 *
17 22773d60 Michael S. Tsirkin
 * You should have received a copy of the GNU General Public License along
18 22773d60 Michael S. Tsirkin
 * with this program; if not, see <http://www.gnu.org/licenses/>.
19 22773d60 Michael S. Tsirkin
 */
20 22773d60 Michael S. Tsirkin
#include "hw/hw.h"
21 22773d60 Michael S. Tsirkin
#include "hw/pci/pci.h"
22 22773d60 Michael S. Tsirkin
#include "qemu/event_notifier.h"
23 22773d60 Michael S. Tsirkin
#include "qemu/osdep.h"
24 22773d60 Michael S. Tsirkin
25 22773d60 Michael S. Tsirkin
typedef struct PCITestDevHdr {
26 22773d60 Michael S. Tsirkin
    uint8_t test;
27 22773d60 Michael S. Tsirkin
    uint8_t width;
28 22773d60 Michael S. Tsirkin
    uint8_t pad0[2];
29 22773d60 Michael S. Tsirkin
    uint32_t offset;
30 22773d60 Michael S. Tsirkin
    uint8_t data;
31 22773d60 Michael S. Tsirkin
    uint8_t pad1[3];
32 22773d60 Michael S. Tsirkin
    uint32_t count;
33 22773d60 Michael S. Tsirkin
    uint8_t name[];
34 22773d60 Michael S. Tsirkin
} PCITestDevHdr;
35 22773d60 Michael S. Tsirkin
36 22773d60 Michael S. Tsirkin
typedef struct IOTest {
37 22773d60 Michael S. Tsirkin
    MemoryRegion *mr;
38 22773d60 Michael S. Tsirkin
    EventNotifier notifier;
39 22773d60 Michael S. Tsirkin
    bool hasnotifier;
40 22773d60 Michael S. Tsirkin
    unsigned size;
41 22773d60 Michael S. Tsirkin
    bool match_data;
42 22773d60 Michael S. Tsirkin
    PCITestDevHdr *hdr;
43 22773d60 Michael S. Tsirkin
    unsigned bufsize;
44 22773d60 Michael S. Tsirkin
} IOTest;
45 22773d60 Michael S. Tsirkin
46 22773d60 Michael S. Tsirkin
#define IOTEST_DATAMATCH 0xFA
47 22773d60 Michael S. Tsirkin
#define IOTEST_NOMATCH   0xCE
48 22773d60 Michael S. Tsirkin
49 22773d60 Michael S. Tsirkin
#define IOTEST_IOSIZE 128
50 22773d60 Michael S. Tsirkin
#define IOTEST_MEMSIZE 2048
51 22773d60 Michael S. Tsirkin
52 22773d60 Michael S. Tsirkin
static const char *iotest_test[] = {
53 22773d60 Michael S. Tsirkin
    "no-eventfd",
54 22773d60 Michael S. Tsirkin
    "wildcard-eventfd",
55 22773d60 Michael S. Tsirkin
    "datamatch-eventfd"
56 22773d60 Michael S. Tsirkin
};
57 22773d60 Michael S. Tsirkin
58 22773d60 Michael S. Tsirkin
static const char *iotest_type[] = {
59 22773d60 Michael S. Tsirkin
    "mmio",
60 22773d60 Michael S. Tsirkin
    "portio"
61 22773d60 Michael S. Tsirkin
};
62 22773d60 Michael S. Tsirkin
63 22773d60 Michael S. Tsirkin
#define IOTEST_TEST(i) (iotest_test[((i) % ARRAY_SIZE(iotest_test))])
64 22773d60 Michael S. Tsirkin
#define IOTEST_TYPE(i) (iotest_type[((i) / ARRAY_SIZE(iotest_test))])
65 22773d60 Michael S. Tsirkin
#define IOTEST_MAX_TEST (ARRAY_SIZE(iotest_test))
66 22773d60 Michael S. Tsirkin
#define IOTEST_MAX_TYPE (ARRAY_SIZE(iotest_type))
67 22773d60 Michael S. Tsirkin
#define IOTEST_MAX (IOTEST_MAX_TEST * IOTEST_MAX_TYPE)
68 22773d60 Michael S. Tsirkin
69 22773d60 Michael S. Tsirkin
enum {
70 22773d60 Michael S. Tsirkin
    IOTEST_ACCESS_NAME,
71 22773d60 Michael S. Tsirkin
    IOTEST_ACCESS_DATA,
72 22773d60 Michael S. Tsirkin
    IOTEST_ACCESS_MAX,
73 22773d60 Michael S. Tsirkin
};
74 22773d60 Michael S. Tsirkin
75 22773d60 Michael S. Tsirkin
#define IOTEST_ACCESS_TYPE uint8_t
76 22773d60 Michael S. Tsirkin
#define IOTEST_ACCESS_WIDTH (sizeof(uint8_t))
77 22773d60 Michael S. Tsirkin
78 22773d60 Michael S. Tsirkin
typedef struct PCITestDevState {
79 22773d60 Michael S. Tsirkin
    PCIDevice dev;
80 22773d60 Michael S. Tsirkin
    MemoryRegion mmio;
81 22773d60 Michael S. Tsirkin
    MemoryRegion portio;
82 22773d60 Michael S. Tsirkin
    IOTest *tests;
83 22773d60 Michael S. Tsirkin
    int current;
84 22773d60 Michael S. Tsirkin
} PCITestDevState;
85 22773d60 Michael S. Tsirkin
86 22773d60 Michael S. Tsirkin
#define IOTEST_IS_MEM(i) (strcmp(IOTEST_TYPE(i), "portio"))
87 22773d60 Michael S. Tsirkin
#define IOTEST_REGION(d, i) (IOTEST_IS_MEM(i) ?  &(d)->mmio : &(d)->portio)
88 22773d60 Michael S. Tsirkin
#define IOTEST_SIZE(i) (IOTEST_IS_MEM(i) ? IOTEST_MEMSIZE : IOTEST_IOSIZE)
89 22773d60 Michael S. Tsirkin
#define IOTEST_PCI_BAR(i) (IOTEST_IS_MEM(i) ? PCI_BASE_ADDRESS_SPACE_MEMORY : \
90 22773d60 Michael S. Tsirkin
                           PCI_BASE_ADDRESS_SPACE_IO)
91 22773d60 Michael S. Tsirkin
92 22773d60 Michael S. Tsirkin
static int pci_testdev_start(IOTest *test)
93 22773d60 Michael S. Tsirkin
{
94 22773d60 Michael S. Tsirkin
    test->hdr->count = 0;
95 22773d60 Michael S. Tsirkin
    if (!test->hasnotifier) {
96 22773d60 Michael S. Tsirkin
        return 0;
97 22773d60 Michael S. Tsirkin
    }
98 22773d60 Michael S. Tsirkin
    event_notifier_test_and_clear(&test->notifier);
99 22773d60 Michael S. Tsirkin
    memory_region_add_eventfd(test->mr,
100 22773d60 Michael S. Tsirkin
                              le32_to_cpu(test->hdr->offset),
101 22773d60 Michael S. Tsirkin
                              test->size,
102 22773d60 Michael S. Tsirkin
                              test->match_data,
103 22773d60 Michael S. Tsirkin
                              test->hdr->data,
104 22773d60 Michael S. Tsirkin
                              &test->notifier);
105 22773d60 Michael S. Tsirkin
    return 0;
106 22773d60 Michael S. Tsirkin
}
107 22773d60 Michael S. Tsirkin
108 22773d60 Michael S. Tsirkin
static void pci_testdev_stop(IOTest *test)
109 22773d60 Michael S. Tsirkin
{
110 22773d60 Michael S. Tsirkin
    if (!test->hasnotifier) {
111 22773d60 Michael S. Tsirkin
        return;
112 22773d60 Michael S. Tsirkin
    }
113 22773d60 Michael S. Tsirkin
    memory_region_del_eventfd(test->mr,
114 22773d60 Michael S. Tsirkin
                              le32_to_cpu(test->hdr->offset),
115 22773d60 Michael S. Tsirkin
                              test->size,
116 22773d60 Michael S. Tsirkin
                              test->match_data,
117 22773d60 Michael S. Tsirkin
                              test->hdr->data,
118 22773d60 Michael S. Tsirkin
                              &test->notifier);
119 22773d60 Michael S. Tsirkin
}
120 22773d60 Michael S. Tsirkin
121 22773d60 Michael S. Tsirkin
static void
122 22773d60 Michael S. Tsirkin
pci_testdev_reset(PCITestDevState *d)
123 22773d60 Michael S. Tsirkin
{
124 22773d60 Michael S. Tsirkin
    if (d->current == -1) {
125 22773d60 Michael S. Tsirkin
        return;
126 22773d60 Michael S. Tsirkin
    }
127 22773d60 Michael S. Tsirkin
    pci_testdev_stop(&d->tests[d->current]);
128 22773d60 Michael S. Tsirkin
    d->current = -1;
129 22773d60 Michael S. Tsirkin
}
130 22773d60 Michael S. Tsirkin
131 22773d60 Michael S. Tsirkin
static void pci_testdev_inc(IOTest *test, unsigned inc)
132 22773d60 Michael S. Tsirkin
{
133 22773d60 Michael S. Tsirkin
    uint32_t c = le32_to_cpu(test->hdr->count);
134 22773d60 Michael S. Tsirkin
    test->hdr->count = cpu_to_le32(c + inc);
135 22773d60 Michael S. Tsirkin
}
136 22773d60 Michael S. Tsirkin
137 22773d60 Michael S. Tsirkin
static void
138 22773d60 Michael S. Tsirkin
pci_testdev_write(void *opaque, hwaddr addr, uint64_t val,
139 22773d60 Michael S. Tsirkin
                  unsigned size, int type)
140 22773d60 Michael S. Tsirkin
{
141 22773d60 Michael S. Tsirkin
    PCITestDevState *d = opaque;
142 22773d60 Michael S. Tsirkin
    IOTest *test;
143 22773d60 Michael S. Tsirkin
    int t, r;
144 22773d60 Michael S. Tsirkin
145 22773d60 Michael S. Tsirkin
    if (addr == offsetof(PCITestDevHdr, test)) {
146 22773d60 Michael S. Tsirkin
        pci_testdev_reset(d);
147 22773d60 Michael S. Tsirkin
        if (val >= IOTEST_MAX_TEST) {
148 22773d60 Michael S. Tsirkin
            return;
149 22773d60 Michael S. Tsirkin
        }
150 22773d60 Michael S. Tsirkin
        t = type * IOTEST_MAX_TEST + val;
151 22773d60 Michael S. Tsirkin
        r = pci_testdev_start(&d->tests[t]);
152 22773d60 Michael S. Tsirkin
        if (r < 0) {
153 22773d60 Michael S. Tsirkin
            return;
154 22773d60 Michael S. Tsirkin
        }
155 22773d60 Michael S. Tsirkin
        d->current = t;
156 22773d60 Michael S. Tsirkin
        return;
157 22773d60 Michael S. Tsirkin
    }
158 22773d60 Michael S. Tsirkin
    if (d->current < 0) {
159 22773d60 Michael S. Tsirkin
        return;
160 22773d60 Michael S. Tsirkin
    }
161 22773d60 Michael S. Tsirkin
    test = &d->tests[d->current];
162 22773d60 Michael S. Tsirkin
    if (addr != le32_to_cpu(test->hdr->offset)) {
163 22773d60 Michael S. Tsirkin
        return;
164 22773d60 Michael S. Tsirkin
    }
165 22773d60 Michael S. Tsirkin
    if (test->match_data && test->size != size) {
166 22773d60 Michael S. Tsirkin
        return;
167 22773d60 Michael S. Tsirkin
    }
168 22773d60 Michael S. Tsirkin
    if (test->match_data && val != test->hdr->data) {
169 22773d60 Michael S. Tsirkin
        return;
170 22773d60 Michael S. Tsirkin
    }
171 22773d60 Michael S. Tsirkin
    pci_testdev_inc(test, 1);
172 22773d60 Michael S. Tsirkin
}
173 22773d60 Michael S. Tsirkin
174 22773d60 Michael S. Tsirkin
static uint64_t
175 22773d60 Michael S. Tsirkin
pci_testdev_read(void *opaque, hwaddr addr, unsigned size)
176 22773d60 Michael S. Tsirkin
{
177 22773d60 Michael S. Tsirkin
    PCITestDevState *d = opaque;
178 22773d60 Michael S. Tsirkin
    const char *buf;
179 22773d60 Michael S. Tsirkin
    IOTest *test;
180 22773d60 Michael S. Tsirkin
    if (d->current < 0) {
181 22773d60 Michael S. Tsirkin
        return 0;
182 22773d60 Michael S. Tsirkin
    }
183 22773d60 Michael S. Tsirkin
    test = &d->tests[d->current];
184 22773d60 Michael S. Tsirkin
    buf = (const char *)test->hdr;
185 22773d60 Michael S. Tsirkin
    if (addr + size >= test->bufsize) {
186 22773d60 Michael S. Tsirkin
        return 0;
187 22773d60 Michael S. Tsirkin
    }
188 22773d60 Michael S. Tsirkin
    if (test->hasnotifier) {
189 22773d60 Michael S. Tsirkin
        event_notifier_test_and_clear(&test->notifier);
190 22773d60 Michael S. Tsirkin
    }
191 22773d60 Michael S. Tsirkin
    return buf[addr];
192 22773d60 Michael S. Tsirkin
}
193 22773d60 Michael S. Tsirkin
194 22773d60 Michael S. Tsirkin
static void
195 22773d60 Michael S. Tsirkin
pci_testdev_mmio_write(void *opaque, hwaddr addr, uint64_t val,
196 22773d60 Michael S. Tsirkin
                       unsigned size)
197 22773d60 Michael S. Tsirkin
{
198 22773d60 Michael S. Tsirkin
    pci_testdev_write(opaque, addr, val, size, 0);
199 22773d60 Michael S. Tsirkin
}
200 22773d60 Michael S. Tsirkin
201 22773d60 Michael S. Tsirkin
static void
202 22773d60 Michael S. Tsirkin
pci_testdev_pio_write(void *opaque, hwaddr addr, uint64_t val,
203 22773d60 Michael S. Tsirkin
                       unsigned size)
204 22773d60 Michael S. Tsirkin
{
205 22773d60 Michael S. Tsirkin
    pci_testdev_write(opaque, addr, val, size, 1);
206 22773d60 Michael S. Tsirkin
}
207 22773d60 Michael S. Tsirkin
208 22773d60 Michael S. Tsirkin
static const MemoryRegionOps pci_testdev_mmio_ops = {
209 22773d60 Michael S. Tsirkin
    .read = pci_testdev_read,
210 22773d60 Michael S. Tsirkin
    .write = pci_testdev_mmio_write,
211 22773d60 Michael S. Tsirkin
    .endianness = DEVICE_LITTLE_ENDIAN,
212 22773d60 Michael S. Tsirkin
    .impl = {
213 22773d60 Michael S. Tsirkin
        .min_access_size = 1,
214 22773d60 Michael S. Tsirkin
        .max_access_size = 1,
215 22773d60 Michael S. Tsirkin
    },
216 22773d60 Michael S. Tsirkin
};
217 22773d60 Michael S. Tsirkin
218 22773d60 Michael S. Tsirkin
static const MemoryRegionOps pci_testdev_pio_ops = {
219 22773d60 Michael S. Tsirkin
    .read = pci_testdev_read,
220 22773d60 Michael S. Tsirkin
    .write = pci_testdev_pio_write,
221 22773d60 Michael S. Tsirkin
    .endianness = DEVICE_LITTLE_ENDIAN,
222 22773d60 Michael S. Tsirkin
    .impl = {
223 22773d60 Michael S. Tsirkin
        .min_access_size = 1,
224 22773d60 Michael S. Tsirkin
        .max_access_size = 1,
225 22773d60 Michael S. Tsirkin
    },
226 22773d60 Michael S. Tsirkin
};
227 22773d60 Michael S. Tsirkin
228 22773d60 Michael S. Tsirkin
static int pci_testdev_init(PCIDevice *pci_dev)
229 22773d60 Michael S. Tsirkin
{
230 22773d60 Michael S. Tsirkin
    PCITestDevState *d = DO_UPCAST(PCITestDevState, dev, pci_dev);
231 22773d60 Michael S. Tsirkin
    uint8_t *pci_conf;
232 22773d60 Michael S. Tsirkin
    char *name;
233 22773d60 Michael S. Tsirkin
    int r, i;
234 22773d60 Michael S. Tsirkin
235 22773d60 Michael S. Tsirkin
    pci_conf = d->dev.config;
236 22773d60 Michael S. Tsirkin
237 22773d60 Michael S. Tsirkin
    pci_conf[PCI_INTERRUPT_PIN] = 0; /* no interrupt pin */
238 22773d60 Michael S. Tsirkin
239 22773d60 Michael S. Tsirkin
    memory_region_init_io(&d->mmio, &pci_testdev_mmio_ops, d,
240 22773d60 Michael S. Tsirkin
                          "pci-testdev-mmio", IOTEST_MEMSIZE * 2);
241 22773d60 Michael S. Tsirkin
    memory_region_init_io(&d->portio, &pci_testdev_pio_ops, d,
242 22773d60 Michael S. Tsirkin
                          "pci-testdev-portio", IOTEST_IOSIZE * 2);
243 22773d60 Michael S. Tsirkin
    pci_register_bar(&d->dev, 0, PCI_BASE_ADDRESS_SPACE_MEMORY, &d->mmio);
244 22773d60 Michael S. Tsirkin
    pci_register_bar(&d->dev, 1, PCI_BASE_ADDRESS_SPACE_IO, &d->portio);
245 22773d60 Michael S. Tsirkin
246 22773d60 Michael S. Tsirkin
    d->current = -1;
247 22773d60 Michael S. Tsirkin
    d->tests = g_malloc0(IOTEST_MAX * sizeof *d->tests);
248 22773d60 Michael S. Tsirkin
    for (i = 0; i < IOTEST_MAX; ++i) {
249 22773d60 Michael S. Tsirkin
        IOTest *test = &d->tests[i];
250 22773d60 Michael S. Tsirkin
        name = g_strdup_printf("%s-%s", IOTEST_TYPE(i), IOTEST_TEST(i));
251 22773d60 Michael S. Tsirkin
        test->bufsize = sizeof(PCITestDevHdr) + strlen(name) + 1;
252 22773d60 Michael S. Tsirkin
        test->hdr = g_malloc0(test->bufsize);
253 22773d60 Michael S. Tsirkin
        memcpy(test->hdr->name, name, strlen(name) + 1);
254 22773d60 Michael S. Tsirkin
        g_free(name);
255 22773d60 Michael S. Tsirkin
        test->hdr->offset = cpu_to_le32(IOTEST_SIZE(i) + i * IOTEST_ACCESS_WIDTH);
256 22773d60 Michael S. Tsirkin
        test->size = IOTEST_ACCESS_WIDTH;
257 22773d60 Michael S. Tsirkin
        test->match_data = strcmp(IOTEST_TEST(i), "wildcard-eventfd");
258 22773d60 Michael S. Tsirkin
        test->hdr->test = i;
259 22773d60 Michael S. Tsirkin
        test->hdr->data = test->match_data ? IOTEST_DATAMATCH : IOTEST_NOMATCH;
260 22773d60 Michael S. Tsirkin
        test->hdr->width = IOTEST_ACCESS_WIDTH;
261 22773d60 Michael S. Tsirkin
        test->mr = IOTEST_REGION(d, i);
262 22773d60 Michael S. Tsirkin
        if (!strcmp(IOTEST_TEST(i), "no-eventfd")) {
263 22773d60 Michael S. Tsirkin
            test->hasnotifier = false;
264 22773d60 Michael S. Tsirkin
            continue;
265 22773d60 Michael S. Tsirkin
        }
266 22773d60 Michael S. Tsirkin
        r = event_notifier_init(&test->notifier, 0);
267 22773d60 Michael S. Tsirkin
        assert(r >= 0);
268 22773d60 Michael S. Tsirkin
        test->hasnotifier = true;
269 22773d60 Michael S. Tsirkin
    }
270 22773d60 Michael S. Tsirkin
271 22773d60 Michael S. Tsirkin
    return 0;
272 22773d60 Michael S. Tsirkin
}
273 22773d60 Michael S. Tsirkin
274 22773d60 Michael S. Tsirkin
static void
275 22773d60 Michael S. Tsirkin
pci_testdev_uninit(PCIDevice *dev)
276 22773d60 Michael S. Tsirkin
{
277 22773d60 Michael S. Tsirkin
    PCITestDevState *d = DO_UPCAST(PCITestDevState, dev, dev);
278 22773d60 Michael S. Tsirkin
    int i;
279 22773d60 Michael S. Tsirkin
280 22773d60 Michael S. Tsirkin
    pci_testdev_reset(d);
281 22773d60 Michael S. Tsirkin
    for (i = 0; i < IOTEST_MAX; ++i) {
282 22773d60 Michael S. Tsirkin
        if (d->tests[i].hasnotifier) {
283 22773d60 Michael S. Tsirkin
            event_notifier_cleanup(&d->tests[i].notifier);
284 22773d60 Michael S. Tsirkin
        }
285 22773d60 Michael S. Tsirkin
        g_free(d->tests[i].hdr);
286 22773d60 Michael S. Tsirkin
    }
287 22773d60 Michael S. Tsirkin
    g_free(d->tests);
288 22773d60 Michael S. Tsirkin
    memory_region_destroy(&d->mmio);
289 22773d60 Michael S. Tsirkin
    memory_region_destroy(&d->portio);
290 22773d60 Michael S. Tsirkin
}
291 22773d60 Michael S. Tsirkin
292 22773d60 Michael S. Tsirkin
static void qdev_pci_testdev_reset(DeviceState *dev)
293 22773d60 Michael S. Tsirkin
{
294 22773d60 Michael S. Tsirkin
    PCITestDevState *d = DO_UPCAST(PCITestDevState, dev.qdev, dev);
295 22773d60 Michael S. Tsirkin
    pci_testdev_reset(d);
296 22773d60 Michael S. Tsirkin
}
297 22773d60 Michael S. Tsirkin
298 22773d60 Michael S. Tsirkin
static void pci_testdev_class_init(ObjectClass *klass, void *data)
299 22773d60 Michael S. Tsirkin
{
300 22773d60 Michael S. Tsirkin
    DeviceClass *dc = DEVICE_CLASS(klass);
301 22773d60 Michael S. Tsirkin
    PCIDeviceClass *k = PCI_DEVICE_CLASS(klass);
302 22773d60 Michael S. Tsirkin
303 22773d60 Michael S. Tsirkin
    k->init = pci_testdev_init;
304 22773d60 Michael S. Tsirkin
    k->exit = pci_testdev_uninit;
305 22773d60 Michael S. Tsirkin
    k->vendor_id = PCI_VENDOR_ID_REDHAT;
306 22773d60 Michael S. Tsirkin
    k->device_id = PCI_DEVICE_ID_REDHAT_TEST;
307 22773d60 Michael S. Tsirkin
    k->revision = 0x00;
308 22773d60 Michael S. Tsirkin
    k->class_id = PCI_CLASS_OTHERS;
309 22773d60 Michael S. Tsirkin
    dc->desc = "PCI Test Device";
310 22773d60 Michael S. Tsirkin
    dc->reset = qdev_pci_testdev_reset;
311 22773d60 Michael S. Tsirkin
}
312 22773d60 Michael S. Tsirkin
313 22773d60 Michael S. Tsirkin
static const TypeInfo pci_testdev_info = {
314 22773d60 Michael S. Tsirkin
    .name          = "pci-testdev",
315 22773d60 Michael S. Tsirkin
    .parent        = TYPE_PCI_DEVICE,
316 22773d60 Michael S. Tsirkin
    .instance_size = sizeof(PCITestDevState),
317 22773d60 Michael S. Tsirkin
    .class_init    = pci_testdev_class_init,
318 22773d60 Michael S. Tsirkin
};
319 22773d60 Michael S. Tsirkin
320 22773d60 Michael S. Tsirkin
static void pci_testdev_register_types(void)
321 22773d60 Michael S. Tsirkin
{
322 22773d60 Michael S. Tsirkin
    type_register_static(&pci_testdev_info);
323 22773d60 Michael S. Tsirkin
}
324 22773d60 Michael S. Tsirkin
325 22773d60 Michael S. Tsirkin
type_init(pci_testdev_register_types)