sabre.c 16.7 KB
Newer Older
P
pbrook 已提交
1
/*
M
Mark Cave-Ayland 已提交
2
 * QEMU Ultrasparc Sabre PCI host (PBM)
P
pbrook 已提交
3 4
 *
 * Copyright (c) 2006 Fabrice Bellard
5
 * Copyright (c) 2012,2013 Artyom Tarasenko
M
Mark Cave-Ayland 已提交
6
 * Copyright (c) 2018 Mark Cave-Ayland
7
 *
P
pbrook 已提交
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
 */
P
pbrook 已提交
26

P
Peter Maydell 已提交
27
#include "qemu/osdep.h"
28 29 30 31 32
#include "hw/sysbus.h"
#include "hw/pci/pci.h"
#include "hw/pci/pci_host.h"
#include "hw/pci/pci_bridge.h"
#include "hw/pci/pci_bus.h"
33
#include "hw/pci-bridge/simba.h"
M
Mark Cave-Ayland 已提交
34
#include "hw/pci-host/sabre.h"
35
#include "sysemu/sysemu.h"
36
#include "exec/address-spaces.h"
M
Mark Cave-Ayland 已提交
37
#include "qapi/error.h"
38
#include "qemu/log.h"
B
Fix APB  
blueswir1 已提交
39

M
Mark Cave-Ayland 已提交
40 41
/* debug sabre */
//#define DEBUG_SABRE
B
Fix APB  
blueswir1 已提交
42

M
Mark Cave-Ayland 已提交
43 44 45
#ifdef DEBUG_SABRE
#define SABRE_DPRINTF(fmt, ...) \
do { printf("sabre: " fmt , ## __VA_ARGS__); } while (0)
B
Fix APB  
blueswir1 已提交
46
#else
M
Mark Cave-Ayland 已提交
47
#define SABRE_DPRINTF(fmt, ...)
B
Fix APB  
blueswir1 已提交
48 49
#endif

B
Blue Swirl 已提交
50 51 52 53 54 55
/*
 * Chipset docs:
 * PBM: "UltraSPARC IIi User's Manual",
 * http://www.sun.com/processors/manuals/805-0087.pdf
 */

56 57 58
#define PBM_PCI_IMR_MASK    0x7fffffff
#define PBM_PCI_IMR_ENABLED 0x80000000

59 60 61 62 63
#define POR          (1U << 31)
#define SOFT_POR     (1U << 30)
#define SOFT_XIR     (1U << 29)
#define BTN_POR      (1U << 28)
#define BTN_XIR      (1U << 27)
64 65 66 67
#define RESET_MASK   0xf8000000
#define RESET_WCMASK 0x98000000
#define RESET_WMASK  0x60000000

68
#define NO_IRQ_REQUEST (MAX_IVEC + 1)
B
Blue Swirl 已提交
69

70
static inline void sabre_set_request(SabreState *s, unsigned int irq_num)
71
{
M
Mark Cave-Ayland 已提交
72
    SABRE_DPRINTF("%s: request irq %d\n", __func__, irq_num);
73 74 75 76 77

    s->irq_request = irq_num;
    qemu_set_irq(s->ivec_irqs[irq_num], 1);
}

78
static inline void sabre_check_irqs(SabreState *s)
79 80 81 82 83
{
    unsigned int i;

    /* Previous request is not acknowledged, resubmit */
    if (s->irq_request != NO_IRQ_REQUEST) {
84
        sabre_set_request(s, s->irq_request);
85 86 87 88 89 90 91 92 93
        return;
    }
    /* no request pending */
    if (s->pci_irq_in == 0ULL) {
        return;
    }
    for (i = 0; i < 32; i++) {
        if (s->pci_irq_in & (1ULL << i)) {
            if (s->pci_irq_map[i >> 2] & PBM_PCI_IMR_ENABLED) {
94
                sabre_set_request(s, i);
95 96 97 98 99 100 101
                return;
            }
        }
    }
    for (i = 32; i < 64; i++) {
        if (s->pci_irq_in & (1ULL << i)) {
            if (s->obio_irq_map[i - 32] & PBM_PCI_IMR_ENABLED) {
102
                sabre_set_request(s, i);
103 104 105 106 107 108
                break;
            }
        }
    }
}

109
static inline void sabre_clear_request(SabreState *s, unsigned int irq_num)
110
{
M
Mark Cave-Ayland 已提交
111
    SABRE_DPRINTF("%s: clear request irq %d\n", __func__, irq_num);
112 113 114
    qemu_set_irq(s->ivec_irqs[irq_num], 0);
    s->irq_request = NO_IRQ_REQUEST;
}
115

116
static AddressSpace *sabre_pci_dma_iommu(PCIBus *bus, void *opaque, int devfn)
117 118 119 120 121 122
{
    IOMMUState *is = opaque;

    return &is->iommu_as;
}

123
static void sabre_config_write(void *opaque, hwaddr addr,
A
Avi Kivity 已提交
124
                               uint64_t val, unsigned size)
P
pbrook 已提交
125
{
126
    SabreState *s = opaque;
127

M
Mark Cave-Ayland 已提交
128 129
    SABRE_DPRINTF("%s: addr " TARGET_FMT_plx " val %" PRIx64 "\n", __func__,
                  addr, val);
130 131 132 133 134 135 136

    switch (addr & 0xffff) {
    case 0x30 ... 0x4f: /* DMA error registers */
        /* XXX: not implemented yet */
        break;
    case 0xc00 ... 0xc3f: /* PCI interrupt control */
        if (addr & 4) {
137 138 139 140
            unsigned int ino = (addr & 0x3f) >> 3;
            s->pci_irq_map[ino] &= PBM_PCI_IMR_MASK;
            s->pci_irq_map[ino] |= val & ~PBM_PCI_IMR_MASK;
            if ((s->irq_request == ino) && !(val & ~PBM_PCI_IMR_MASK)) {
141
                sabre_clear_request(s, ino);
142
            }
143
            sabre_check_irqs(s);
144 145
        }
        break;
146
    case 0x1000 ... 0x107f: /* OBIO interrupt control */
B
Blue Swirl 已提交
147
        if (addr & 4) {
148 149 150 151 152
            unsigned int ino = ((addr & 0xff) >> 3);
            s->obio_irq_map[ino] &= PBM_PCI_IMR_MASK;
            s->obio_irq_map[ino] |= val & ~PBM_PCI_IMR_MASK;
            if ((s->irq_request == (ino | 0x20))
                 && !(val & ~PBM_PCI_IMR_MASK)) {
153
                sabre_clear_request(s, ino | 0x20);
154
            }
155
            sabre_check_irqs(s);
B
Blue Swirl 已提交
156 157
        }
        break;
158
    case 0x1400 ... 0x14ff: /* PCI interrupt clear */
159
        if (addr & 4) {
160 161
            unsigned int ino = (addr & 0xff) >> 5;
            if ((s->irq_request / 4)  == ino) {
162 163
                sabre_clear_request(s, s->irq_request);
                sabre_check_irqs(s);
164
            }
165 166 167 168
        }
        break;
    case 0x1800 ... 0x1860: /* OBIO interrupt clear */
        if (addr & 4) {
169 170
            unsigned int ino = ((addr & 0xff) >> 3) | 0x20;
            if (s->irq_request == ino) {
171 172
                sabre_clear_request(s, ino);
                sabre_check_irqs(s);
173
            }
174 175
        }
        break;
176 177 178 179 180 181 182 183 184
    case 0x2000 ... 0x202f: /* PCI control */
        s->pci_control[(addr & 0x3f) >> 2] = val;
        break;
    case 0xf020 ... 0xf027: /* Reset control */
        if (addr & 4) {
            val &= RESET_MASK;
            s->reset_control &= ~(val & RESET_WCMASK);
            s->reset_control |= val & RESET_WMASK;
            if (val & SOFT_POR) {
B
Blue Swirl 已提交
185
                s->nr_resets = 0;
186
                qemu_system_reset_request(SHUTDOWN_CAUSE_GUEST_RESET);
187
            } else if (val & SOFT_XIR) {
188
                qemu_system_reset_request(SHUTDOWN_CAUSE_GUEST_RESET);
189 190 191 192 193 194 195 196
            }
        }
        break;
    case 0x5000 ... 0x51cf: /* PIO/DMA diagnostics */
    case 0xa400 ... 0xa67f: /* IOMMU diagnostics */
    case 0xa800 ... 0xa80f: /* Interrupt diagnostics */
    case 0xf000 ... 0xf01f: /* FFB config, memory control */
        /* we don't care */
P
pbrook 已提交
197
    default:
B
blueswir1 已提交
198
        break;
P
pbrook 已提交
199 200 201
    }
}

202
static uint64_t sabre_config_read(void *opaque,
A
Avi Kivity 已提交
203
                                  hwaddr addr, unsigned size)
P
pbrook 已提交
204
{
205
    SabreState *s = opaque;
P
pbrook 已提交
206 207
    uint32_t val;

208 209 210 211 212 213 214 215 216 217 218 219
    switch (addr & 0xffff) {
    case 0x30 ... 0x4f: /* DMA error registers */
        val = 0;
        /* XXX: not implemented yet */
        break;
    case 0xc00 ... 0xc3f: /* PCI interrupt control */
        if (addr & 4) {
            val = s->pci_irq_map[(addr & 0x3f) >> 3];
        } else {
            val = 0;
        }
        break;
220
    case 0x1000 ... 0x107f: /* OBIO interrupt control */
B
Blue Swirl 已提交
221 222 223 224 225 226
        if (addr & 4) {
            val = s->obio_irq_map[(addr & 0xff) >> 3];
        } else {
            val = 0;
        }
        break;
227 228 229 230 231 232 233
    case 0x1080 ... 0x108f: /* PCI bus error */
        if (addr & 4) {
            val = s->pci_err_irq_map[(addr & 0xf) >> 3];
        } else {
            val = 0;
        }
        break;
234 235 236 237 238 239 240 241 242 243 244 245 246 247 248
    case 0x2000 ... 0x202f: /* PCI control */
        val = s->pci_control[(addr & 0x3f) >> 2];
        break;
    case 0xf020 ... 0xf027: /* Reset control */
        if (addr & 4) {
            val = s->reset_control;
        } else {
            val = 0;
        }
        break;
    case 0x5000 ... 0x51cf: /* PIO/DMA diagnostics */
    case 0xa400 ... 0xa67f: /* IOMMU diagnostics */
    case 0xa800 ... 0xa80f: /* Interrupt diagnostics */
    case 0xf000 ... 0xf01f: /* FFB config, memory control */
        /* we don't care */
P
pbrook 已提交
249
    default:
B
blueswir1 已提交
250 251
        val = 0;
        break;
P
pbrook 已提交
252
    }
M
Mark Cave-Ayland 已提交
253
    SABRE_DPRINTF("%s: addr " TARGET_FMT_plx " -> %x\n", __func__, addr, val);
254

P
pbrook 已提交
255 256 257
    return val;
}

258 259 260
static const MemoryRegionOps sabre_config_ops = {
    .read = sabre_config_read,
    .write = sabre_config_write,
261
    .endianness = DEVICE_BIG_ENDIAN,
P
pbrook 已提交
262 263
};

264 265
static void sabre_pci_config_write(void *opaque, hwaddr addr,
                                   uint64_t val, unsigned size)
266
{
267
    SabreState *s = opaque;
P
Paolo Bonzini 已提交
268
    PCIHostState *phb = PCI_HOST_BRIDGE(s);
269

M
Mark Cave-Ayland 已提交
270 271
    SABRE_DPRINTF("%s: addr " TARGET_FMT_plx " val %" PRIx64 "\n", __func__,
                  addr, val);
P
Paolo Bonzini 已提交
272
    pci_data_write(phb->bus, addr, val, size);
273 274
}

275 276
static uint64_t sabre_pci_config_read(void *opaque, hwaddr addr,
                                      unsigned size)
277 278
{
    uint32_t ret;
279
    SabreState *s = opaque;
P
Paolo Bonzini 已提交
280
    PCIHostState *phb = PCI_HOST_BRIDGE(s);
281

P
Paolo Bonzini 已提交
282
    ret = pci_data_read(phb->bus, addr, size);
M
Mark Cave-Ayland 已提交
283
    SABRE_DPRINTF("%s: addr " TARGET_FMT_plx " -> %x\n", __func__, addr, ret);
284 285 286
    return ret;
}

287 288
/* The sabre host has an IRQ line for each IRQ line of each slot.  */
static int pci_sabre_map_irq(PCIDevice *pci_dev, int irq_num)
P
pbrook 已提交
289
{
290 291
    /* Return the irq as swizzled by the PBM */
    return irq_num;
P
pbrook 已提交
292 293
}

294
static int pci_simbaA_map_irq(PCIDevice *pci_dev, int irq_num)
P
pbrook 已提交
295
{
296 297 298 299
    /* The on-board devices have fixed (legacy) OBIO intnos */
    switch (PCI_SLOT(pci_dev->devfn)) {
    case 1:
        /* Onboard NIC */
300
        return OBIO_NIC_IRQ;
301 302
    case 3:
        /* Onboard IDE */
303
        return OBIO_HDD_IRQ;
304 305 306
    default:
        /* Normal intno, fall through */
        break;
307 308
    }

309 310
    return ((PCI_SLOT(pci_dev->devfn) << 2) + irq_num) & 0x1f;
}
311

312
static int pci_simbaB_map_irq(PCIDevice *pci_dev, int irq_num)
313 314
{
    return (0x10 + (PCI_SLOT(pci_dev->devfn) << 2) + irq_num) & 0x1f;
315 316
}

317
static void pci_sabre_set_irq(void *opaque, int irq_num, int level)
318
{
319
    SabreState *s = opaque;
320

M
Mark Cave-Ayland 已提交
321
    SABRE_DPRINTF("%s: set irq_in %d level %d\n", __func__, irq_num, level);
P
pbrook 已提交
322
    /* PCI IRQ map onto the first 32 INO.  */
323
    if (irq_num < 32) {
324 325 326
        if (level) {
            s->pci_irq_in |= 1ULL << irq_num;
            if (s->pci_irq_map[irq_num >> 2] & PBM_PCI_IMR_ENABLED) {
327
                sabre_set_request(s, irq_num);
328
            }
B
Blue Swirl 已提交
329
        } else {
330
            s->pci_irq_in &= ~(1ULL << irq_num);
B
Blue Swirl 已提交
331 332
        }
    } else {
333 334
        /* OBIO IRQ map onto the next 32 INO.  */
        if (level) {
M
Mark Cave-Ayland 已提交
335 336
            SABRE_DPRINTF("%s: set irq %d level %d\n", __func__, irq_num,
                          level);
337 338 339
            s->pci_irq_in |= 1ULL << irq_num;
            if ((s->irq_request == NO_IRQ_REQUEST)
                && (s->obio_irq_map[irq_num - 32] & PBM_PCI_IMR_ENABLED)) {
340
                sabre_set_request(s, irq_num);
341
            }
342
        } else {
343
            s->pci_irq_in &= ~(1ULL << irq_num);
344 345
        }
    }
P
pbrook 已提交
346 347
}

348
static void sabre_reset(DeviceState *d)
B
Blue Swirl 已提交
349
{
350
    SabreState *s = SABRE_DEVICE(d);
351 352 353
    PCIDevice *pci_dev;
    unsigned int i;
    uint16_t cmd;
B
Blue Swirl 已提交
354

355 356 357
    for (i = 0; i < 8; i++) {
        s->pci_irq_map[i] &= PBM_PCI_IMR_MASK;
    }
358 359 360
    for (i = 0; i < 32; i++) {
        s->obio_irq_map[i] &= PBM_PCI_IMR_MASK;
    }
361

362 363 364
    s->irq_request = NO_IRQ_REQUEST;
    s->pci_irq_in = 0ULL;

B
Blue Swirl 已提交
365
    if (s->nr_resets++ == 0) {
366 367 368
        /* Power on reset */
        s->reset_control = POR;
    }
369 370 371 372 373 374 375 376 377

    /* As this is the busA PCI bridge which contains the on-board devices
     * attached to the ebus, ensure that we initially allow IO transactions
     * so that we get the early serial console until OpenBIOS can properly
     * configure the PCI bridge itself */
    pci_dev = PCI_DEVICE(s->bridgeA);
    cmd = pci_get_word(pci_dev->config + PCI_COMMAND);
    pci_set_word(pci_dev->config + PCI_COMMAND, cmd | PCI_COMMAND_IO);
    pci_bridge_update_mappings(PCI_BRIDGE(pci_dev));
378 379
}

A
Avi Kivity 已提交
380
static const MemoryRegionOps pci_config_ops = {
381 382
    .read = sabre_pci_config_read,
    .write = sabre_pci_config_write,
383
    .endianness = DEVICE_LITTLE_ENDIAN,
A
Avi Kivity 已提交
384 385
};

386
static void sabre_realize(DeviceState *dev, Error **errp)
387
{
388
    SabreState *s = SABRE_DEVICE(dev);
389 390
    PCIHostState *phb = PCI_HOST_BRIDGE(dev);
    SysBusDevice *sbd = SYS_BUS_DEVICE(s);
391
    PCIDevice *pci_dev;
P
pbrook 已提交
392

M
Mark Cave-Ayland 已提交
393
    /* sabre_config */
394
    sysbus_mmio_map(sbd, 0, s->special_base);
395
    /* PCI configuration space */
396
    sysbus_mmio_map(sbd, 1, s->special_base + 0x1000000ULL);
B
Blue Swirl 已提交
397
    /* pci_ioport */
398
    sysbus_mmio_map(sbd, 2, s->special_base + 0x2000000ULL);
399

400 401 402 403
    memory_region_init(&s->pci_mmio, OBJECT(s), "pci-mmio", 0x100000000ULL);
    memory_region_add_subregion(get_system_memory(), s->mem_base,
                                &s->pci_mmio);

404
    phb->bus = pci_register_root_bus(dev, "pci",
405
                                     pci_sabre_set_irq, pci_sabre_map_irq, s,
406 407 408
                                     &s->pci_mmio,
                                     &s->pci_ioport,
                                     0, 32, TYPE_PCI_BUS);
409

410
    pci_create_simple(phb->bus, 0, TYPE_SABRE_PCI_DEVICE);
411

412
    /* IOMMU */
M
Mark Cave-Ayland 已提交
413
    memory_region_add_subregion_overlap(&s->sabre_config, 0x200,
M
Mark Cave-Ayland 已提交
414
                    sysbus_mmio_get_region(SYS_BUS_DEVICE(s->iommu), 0), 1);
415
    pci_setup_iommu(phb->bus, sabre_pci_dma_iommu, s->iommu);
416

B
Blue Swirl 已提交
417
    /* APB secondary busses */
P
Paolo Bonzini 已提交
418
    pci_dev = pci_create_multifunction(phb->bus, PCI_DEVFN(1, 0), true,
419
                                       TYPE_SIMBA_PCI_BRIDGE);
420
    s->bridgeB = PCI_BRIDGE(pci_dev);
421
    pci_bridge_map_irq(s->bridgeB, "pciB", pci_simbaB_map_irq);
422 423
    qdev_init_nofail(&pci_dev->qdev);

P
Paolo Bonzini 已提交
424
    pci_dev = pci_create_multifunction(phb->bus, PCI_DEVFN(1, 1), true,
425
                                       TYPE_SIMBA_PCI_BRIDGE);
426
    s->bridgeA = PCI_BRIDGE(pci_dev);
427
    pci_bridge_map_irq(s->bridgeA, "pciA", pci_simbaA_map_irq);
428
    qdev_init_nofail(&pci_dev->qdev);
429 430
}

431
static void sabre_init(Object *obj)
432
{
433
    SabreState *s = SABRE_DEVICE(obj);
434
    SysBusDevice *sbd = SYS_BUS_DEVICE(obj);
435
    unsigned int i;
B
Blue Swirl 已提交
436

437 438 439
    for (i = 0; i < 8; i++) {
        s->pci_irq_map[i] = (0x1f << 6) | (i << 2);
    }
440 441 442
    for (i = 0; i < 2; i++) {
        s->pci_err_irq_map[i] = (0x1f << 6) | 0x30;
    }
443 444 445
    for (i = 0; i < 32; i++) {
        s->obio_irq_map[i] = ((0x1f << 6) | 0x20) + i;
    }
446
    qdev_init_gpio_in_named(DEVICE(s), pci_sabre_set_irq, "pbm-irq", MAX_IVEC);
447
    qdev_init_gpio_out_named(DEVICE(s), s->ivec_irqs, "ivec-irq", MAX_IVEC);
448 449
    s->irq_request = NO_IRQ_REQUEST;
    s->pci_irq_in = 0ULL;
450

M
Mark Cave-Ayland 已提交
451 452 453 454 455 456
    /* IOMMU */
    object_property_add_link(obj, "iommu", TYPE_SUN4U_IOMMU,
                             (Object **) &s->iommu,
                             qdev_prop_allow_set_link_before_realize,
                             0, NULL);

M
Mark Cave-Ayland 已提交
457 458 459
    /* sabre_config */
    memory_region_init_io(&s->sabre_config, OBJECT(s), &sabre_config_ops, s,
                          "sabre-config", 0x10000);
460
    /* at region 0 */
M
Mark Cave-Ayland 已提交
461
    sysbus_init_mmio(sbd, &s->sabre_config);
462

463
    memory_region_init_io(&s->pci_config, OBJECT(s), &pci_config_ops, s,
M
Mark Cave-Ayland 已提交
464
                          "sabre-pci-config", 0x1000000);
465
    /* at region 1 */
M
Mark Cave-Ayland 已提交
466
    sysbus_init_mmio(sbd, &s->pci_config);
467 468

    /* pci_ioport */
M
Mark Cave-Ayland 已提交
469 470
    memory_region_init(&s->pci_ioport, OBJECT(s), "sabre-pci-ioport",
                       0x1000000);
471

472
    /* at region 2 */
M
Mark Cave-Ayland 已提交
473
    sysbus_init_mmio(sbd, &s->pci_ioport);
B
Blue Swirl 已提交
474
}
P
pbrook 已提交
475

476
static void sabre_pci_realize(PCIDevice *d, Error **errp)
B
Blue Swirl 已提交
477
{
478 479 480 481 482
    pci_set_word(d->config + PCI_COMMAND,
                 PCI_COMMAND_MEMORY | PCI_COMMAND_MASTER);
    pci_set_word(d->config + PCI_STATUS,
                 PCI_STATUS_FAST_BACK | PCI_STATUS_66MHZ |
                 PCI_STATUS_DEVSEL_MEDIUM);
B
Blue Swirl 已提交
483
}
P
pbrook 已提交
484

485
static void sabre_pci_class_init(ObjectClass *klass, void *data)
486 487
{
    PCIDeviceClass *k = PCI_DEVICE_CLASS(klass);
488
    DeviceClass *dc = DEVICE_CLASS(klass);
489

490
    k->realize = sabre_pci_realize;
491 492 493
    k->vendor_id = PCI_VENDOR_ID_SUN;
    k->device_id = PCI_DEVICE_ID_SUN_SABRE;
    k->class_id = PCI_CLASS_BRIDGE_HOST;
494 495 496 497
    /*
     * PCI-facing part of the host bridge, not usable without the
     * host-facing part, which can't be device_add'ed, yet.
     */
498
    dc->user_creatable = false;
499 500
}

501
static const TypeInfo sabre_pci_info = {
502
    .name          = TYPE_SABRE_PCI_DEVICE,
503
    .parent        = TYPE_PCI_DEVICE,
504
    .instance_size = sizeof(SabrePCIState),
505
    .class_init    = sabre_pci_class_init,
506 507 508 509
    .interfaces = (InterfaceInfo[]) {
        { INTERFACE_CONVENTIONAL_PCI_DEVICE },
        { },
    },
B
Blue Swirl 已提交
510 511
};

512
static Property sabre_properties[] = {
513 514
    DEFINE_PROP_UINT64("special-base", SabreState, special_base, 0),
    DEFINE_PROP_UINT64("mem-base", SabreState, mem_base, 0),
515 516 517
    DEFINE_PROP_END_OF_LIST(),
};

518
static void sabre_class_init(ObjectClass *klass, void *data)
519
{
520
    DeviceClass *dc = DEVICE_CLASS(klass);
521

522 523 524
    dc->realize = sabre_realize;
    dc->reset = sabre_reset;
    dc->props = sabre_properties;
M
Mark Cave-Ayland 已提交
525
    set_bit(DEVICE_CATEGORY_BRIDGE, dc->categories);
526 527
}

528
static const TypeInfo sabre_info = {
529
    .name          = TYPE_SABRE,
P
Paolo Bonzini 已提交
530
    .parent        = TYPE_PCI_HOST_BRIDGE,
531
    .instance_size = sizeof(SabreState),
532 533
    .instance_init = sabre_init,
    .class_init    = sabre_class_init,
534
};
535

536
static void sabre_register_types(void)
B
Blue Swirl 已提交
537
{
538
    type_register_static(&sabre_info);
539
    type_register_static(&sabre_pci_info);
P
pbrook 已提交
540
}
B
Blue Swirl 已提交
541

542
type_init(sabre_register_types)