Statistics
| Branch: | Revision:

root / hw / dec_pci.c @ a75b3e0f

History | View | Annotate | Download (4.6 kB)

1 e1c6bbab Blue Swirl
/*
2 e1c6bbab Blue Swirl
 * QEMU DEC 21154 PCI bridge
3 e1c6bbab Blue Swirl
 *
4 e1c6bbab Blue Swirl
 * Copyright (c) 2006-2007 Fabrice Bellard
5 e1c6bbab Blue Swirl
 * Copyright (c) 2007 Jocelyn Mayer
6 e1c6bbab Blue Swirl
 *
7 e1c6bbab Blue Swirl
 * Permission is hereby granted, free of charge, to any person obtaining a copy
8 e1c6bbab Blue Swirl
 * of this software and associated documentation files (the "Software"), to deal
9 e1c6bbab Blue Swirl
 * in the Software without restriction, including without limitation the rights
10 e1c6bbab Blue Swirl
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 e1c6bbab Blue Swirl
 * copies of the Software, and to permit persons to whom the Software is
12 e1c6bbab Blue Swirl
 * furnished to do so, subject to the following conditions:
13 e1c6bbab Blue Swirl
 *
14 e1c6bbab Blue Swirl
 * The above copyright notice and this permission notice shall be included in
15 e1c6bbab Blue Swirl
 * all copies or substantial portions of the Software.
16 e1c6bbab Blue Swirl
 *
17 e1c6bbab Blue Swirl
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 e1c6bbab Blue Swirl
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 e1c6bbab Blue Swirl
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20 e1c6bbab Blue Swirl
 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 e1c6bbab Blue Swirl
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 e1c6bbab Blue Swirl
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23 e1c6bbab Blue Swirl
 * THE SOFTWARE.
24 e1c6bbab Blue Swirl
 */
25 e1c6bbab Blue Swirl
26 d55380bb Blue Swirl
#include "dec_pci.h"
27 e1c6bbab Blue Swirl
#include "sysbus.h"
28 e1c6bbab Blue Swirl
#include "pci.h"
29 e1c6bbab Blue Swirl
#include "pci_host.h"
30 783753fd Isaku Yamahata
#include "pci_bridge.h"
31 68f79994 Isaku Yamahata
#include "pci_internals.h"
32 e1c6bbab Blue Swirl
33 e1c6bbab Blue Swirl
/* debug DEC */
34 e1c6bbab Blue Swirl
//#define DEBUG_DEC
35 e1c6bbab Blue Swirl
36 e1c6bbab Blue Swirl
#ifdef DEBUG_DEC
37 e1c6bbab Blue Swirl
#define DEC_DPRINTF(fmt, ...)                               \
38 e1c6bbab Blue Swirl
    do { printf("DEC: " fmt , ## __VA_ARGS__); } while (0)
39 e1c6bbab Blue Swirl
#else
40 e1c6bbab Blue Swirl
#define DEC_DPRINTF(fmt, ...)
41 e1c6bbab Blue Swirl
#endif
42 e1c6bbab Blue Swirl
43 e1c6bbab Blue Swirl
typedef struct DECState {
44 e1c6bbab Blue Swirl
    SysBusDevice busdev;
45 e1c6bbab Blue Swirl
    PCIHostState host_state;
46 e1c6bbab Blue Swirl
} DECState;
47 e1c6bbab Blue Swirl
48 d55380bb Blue Swirl
static int dec_map_irq(PCIDevice *pci_dev, int irq_num)
49 d55380bb Blue Swirl
{
50 d55380bb Blue Swirl
    return irq_num;
51 d55380bb Blue Swirl
}
52 d55380bb Blue Swirl
53 40021f08 Anthony Liguori
static void dec_21154_pci_bridge_class_init(ObjectClass *klass, void *data)
54 40021f08 Anthony Liguori
{
55 39bffca2 Anthony Liguori
    DeviceClass *dc = DEVICE_CLASS(klass);
56 40021f08 Anthony Liguori
    PCIDeviceClass *k = PCI_DEVICE_CLASS(klass);
57 40021f08 Anthony Liguori
58 40021f08 Anthony Liguori
    k->init = pci_bridge_initfn;
59 40021f08 Anthony Liguori
    k->exit = pci_bridge_exitfn;
60 40021f08 Anthony Liguori
    k->vendor_id = PCI_VENDOR_ID_DEC;
61 40021f08 Anthony Liguori
    k->device_id = PCI_DEVICE_ID_DEC_21154;
62 40021f08 Anthony Liguori
    k->config_write = pci_bridge_write_config;
63 40021f08 Anthony Liguori
    k->is_bridge = 1;
64 39bffca2 Anthony Liguori
    dc->desc = "DEC 21154 PCI-PCI bridge";
65 39bffca2 Anthony Liguori
    dc->reset = pci_bridge_reset;
66 39bffca2 Anthony Liguori
    dc->vmsd = &vmstate_pci_device;
67 40021f08 Anthony Liguori
}
68 40021f08 Anthony Liguori
69 39bffca2 Anthony Liguori
static TypeInfo dec_21154_pci_bridge_info = {
70 39bffca2 Anthony Liguori
    .name          = "dec-21154-p2p-bridge",
71 39bffca2 Anthony Liguori
    .parent        = TYPE_PCI_DEVICE,
72 39bffca2 Anthony Liguori
    .instance_size = sizeof(PCIBridge),
73 39bffca2 Anthony Liguori
    .class_init    = dec_21154_pci_bridge_class_init,
74 68f79994 Isaku Yamahata
};
75 68f79994 Isaku Yamahata
76 68f79994 Isaku Yamahata
PCIBus *pci_dec_21154_init(PCIBus *parent_bus, int devfn)
77 68f79994 Isaku Yamahata
{
78 68f79994 Isaku Yamahata
    PCIDevice *dev;
79 68f79994 Isaku Yamahata
    PCIBridge *br;
80 d55380bb Blue Swirl
81 68f79994 Isaku Yamahata
    dev = pci_create_multifunction(parent_bus, devfn, false,
82 68f79994 Isaku Yamahata
                                   "dec-21154-p2p-bridge");
83 68f79994 Isaku Yamahata
    br = DO_UPCAST(PCIBridge, dev, dev);
84 68f79994 Isaku Yamahata
    pci_bridge_map_irq(br, "DEC 21154 PCI-PCI bridge", dec_map_irq);
85 68f79994 Isaku Yamahata
    qdev_init_nofail(&dev->qdev);
86 68f79994 Isaku Yamahata
    return pci_bridge_get_sec_bus(br);
87 d55380bb Blue Swirl
}
88 d55380bb Blue Swirl
89 999e12bb Anthony Liguori
static int pci_dec_21154_device_init(SysBusDevice *dev)
90 e1c6bbab Blue Swirl
{
91 e1c6bbab Blue Swirl
    DECState *s;
92 e1c6bbab Blue Swirl
93 e1c6bbab Blue Swirl
    s = FROM_SYSBUS(DECState, dev);
94 e1c6bbab Blue Swirl
95 d0ed8076 Avi Kivity
    memory_region_init_io(&s->host_state.conf_mem, &pci_host_conf_le_ops,
96 d0ed8076 Avi Kivity
                          &s->host_state, "pci-conf-idx", 0x1000);
97 d0ed8076 Avi Kivity
    memory_region_init_io(&s->host_state.data_mem, &pci_host_data_le_ops,
98 d0ed8076 Avi Kivity
                          &s->host_state, "pci-data-idx", 0x1000);
99 750ecd44 Avi Kivity
    sysbus_init_mmio(dev, &s->host_state.conf_mem);
100 750ecd44 Avi Kivity
    sysbus_init_mmio(dev, &s->host_state.data_mem);
101 e1c6bbab Blue Swirl
    return 0;
102 e1c6bbab Blue Swirl
}
103 e1c6bbab Blue Swirl
104 e1c6bbab Blue Swirl
static int dec_21154_pci_host_init(PCIDevice *d)
105 e1c6bbab Blue Swirl
{
106 e1c6bbab Blue Swirl
    /* PCI2PCI bridge same values as PearPC - check this */
107 e1c6bbab Blue Swirl
    return 0;
108 e1c6bbab Blue Swirl
}
109 e1c6bbab Blue Swirl
110 40021f08 Anthony Liguori
static void dec_21154_pci_host_class_init(ObjectClass *klass, void *data)
111 40021f08 Anthony Liguori
{
112 40021f08 Anthony Liguori
    PCIDeviceClass *k = PCI_DEVICE_CLASS(klass);
113 40021f08 Anthony Liguori
114 40021f08 Anthony Liguori
    k->init = dec_21154_pci_host_init;
115 40021f08 Anthony Liguori
    k->vendor_id = PCI_VENDOR_ID_DEC;
116 40021f08 Anthony Liguori
    k->device_id = PCI_DEVICE_ID_DEC_21154;
117 40021f08 Anthony Liguori
    k->revision = 0x02;
118 40021f08 Anthony Liguori
    k->class_id = PCI_CLASS_BRIDGE_PCI;
119 40021f08 Anthony Liguori
    k->is_bridge = 1;
120 40021f08 Anthony Liguori
}
121 40021f08 Anthony Liguori
122 39bffca2 Anthony Liguori
static TypeInfo dec_21154_pci_host_info = {
123 39bffca2 Anthony Liguori
    .name          = "dec-21154",
124 39bffca2 Anthony Liguori
    .parent        = TYPE_PCI_DEVICE,
125 39bffca2 Anthony Liguori
    .instance_size = sizeof(PCIDevice),
126 39bffca2 Anthony Liguori
    .class_init    = dec_21154_pci_host_class_init,
127 e1c6bbab Blue Swirl
};
128 e1c6bbab Blue Swirl
129 999e12bb Anthony Liguori
static void pci_dec_21154_device_class_init(ObjectClass *klass, void *data)
130 e1c6bbab Blue Swirl
{
131 999e12bb Anthony Liguori
    SysBusDeviceClass *sdc = SYS_BUS_DEVICE_CLASS(klass);
132 999e12bb Anthony Liguori
133 999e12bb Anthony Liguori
    sdc->init = pci_dec_21154_device_init;
134 999e12bb Anthony Liguori
}
135 999e12bb Anthony Liguori
136 39bffca2 Anthony Liguori
static TypeInfo pci_dec_21154_device_info = {
137 39bffca2 Anthony Liguori
    .name          = "dec-21154-sysbus",
138 39bffca2 Anthony Liguori
    .parent        = TYPE_SYS_BUS_DEVICE,
139 39bffca2 Anthony Liguori
    .instance_size = sizeof(DECState),
140 39bffca2 Anthony Liguori
    .class_init    = pci_dec_21154_device_class_init,
141 999e12bb Anthony Liguori
};
142 40021f08 Anthony Liguori
143 83f7d43a Andreas Färber
static void dec_register_types(void)
144 999e12bb Anthony Liguori
{
145 39bffca2 Anthony Liguori
    type_register_static(&pci_dec_21154_device_info);
146 39bffca2 Anthony Liguori
    type_register_static(&dec_21154_pci_host_info);
147 39bffca2 Anthony Liguori
    type_register_static(&dec_21154_pci_bridge_info);
148 e1c6bbab Blue Swirl
}
149 e1c6bbab Blue Swirl
150 83f7d43a Andreas Färber
type_init(dec_register_types)