Statistics
| Branch: | Revision:

root / hw / dec_pci.c @ 6bcb1a79

History | View | Annotate | Download (3.2 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 e1c6bbab Blue Swirl
31 e1c6bbab Blue Swirl
/* debug DEC */
32 e1c6bbab Blue Swirl
//#define DEBUG_DEC
33 e1c6bbab Blue Swirl
34 e1c6bbab Blue Swirl
#ifdef DEBUG_DEC
35 e1c6bbab Blue Swirl
#define DEC_DPRINTF(fmt, ...)                               \
36 e1c6bbab Blue Swirl
    do { printf("DEC: " fmt , ## __VA_ARGS__); } while (0)
37 e1c6bbab Blue Swirl
#else
38 e1c6bbab Blue Swirl
#define DEC_DPRINTF(fmt, ...)
39 e1c6bbab Blue Swirl
#endif
40 e1c6bbab Blue Swirl
41 e1c6bbab Blue Swirl
typedef struct DECState {
42 e1c6bbab Blue Swirl
    SysBusDevice busdev;
43 e1c6bbab Blue Swirl
    PCIHostState host_state;
44 e1c6bbab Blue Swirl
} DECState;
45 e1c6bbab Blue Swirl
46 d55380bb Blue Swirl
static int dec_map_irq(PCIDevice *pci_dev, int irq_num)
47 d55380bb Blue Swirl
{
48 d55380bb Blue Swirl
    return irq_num;
49 d55380bb Blue Swirl
}
50 d55380bb Blue Swirl
51 d55380bb Blue Swirl
PCIBus *pci_dec_21154_init(PCIBus *parent_bus, int devfn)
52 d55380bb Blue Swirl
{
53 d55380bb Blue Swirl
    DeviceState *dev;
54 d55380bb Blue Swirl
    PCIBus *ret;
55 d55380bb Blue Swirl
56 d55380bb Blue Swirl
    dev = qdev_create(NULL, "dec-21154");
57 d55380bb Blue Swirl
    qdev_init_nofail(dev);
58 7c7b829e Isaku Yamahata
    ret = pci_bridge_init(parent_bus, devfn, false,
59 d55380bb Blue Swirl
                          PCI_VENDOR_ID_DEC, PCI_DEVICE_ID_DEC_21154,
60 d55380bb Blue Swirl
                          dec_map_irq, "DEC 21154 PCI-PCI bridge");
61 d55380bb Blue Swirl
62 d55380bb Blue Swirl
    return ret;
63 d55380bb Blue Swirl
}
64 d55380bb Blue Swirl
65 e1c6bbab Blue Swirl
static int pci_dec_21154_init_device(SysBusDevice *dev)
66 e1c6bbab Blue Swirl
{
67 e1c6bbab Blue Swirl
    DECState *s;
68 e1c6bbab Blue Swirl
    int pci_mem_config, pci_mem_data;
69 e1c6bbab Blue Swirl
70 e1c6bbab Blue Swirl
    s = FROM_SYSBUS(DECState, dev);
71 e1c6bbab Blue Swirl
72 952760bb Blue Swirl
    pci_mem_config = pci_host_conf_register_mmio(&s->host_state, 1);
73 952760bb Blue Swirl
    pci_mem_data = pci_host_data_register_mmio(&s->host_state, 1);
74 e1c6bbab Blue Swirl
    sysbus_init_mmio(dev, 0x1000, pci_mem_config);
75 e1c6bbab Blue Swirl
    sysbus_init_mmio(dev, 0x1000, pci_mem_data);
76 e1c6bbab Blue Swirl
    return 0;
77 e1c6bbab Blue Swirl
}
78 e1c6bbab Blue Swirl
79 e1c6bbab Blue Swirl
static int dec_21154_pci_host_init(PCIDevice *d)
80 e1c6bbab Blue Swirl
{
81 e1c6bbab Blue Swirl
    /* PCI2PCI bridge same values as PearPC - check this */
82 e1c6bbab Blue Swirl
    pci_config_set_vendor_id(d->config, PCI_VENDOR_ID_DEC);
83 e1c6bbab Blue Swirl
    pci_config_set_device_id(d->config, PCI_DEVICE_ID_DEC_21154);
84 204ff571 Blue Swirl
    pci_set_byte(d->config + PCI_REVISION_ID, 0x02);
85 e1c6bbab Blue Swirl
    pci_config_set_class(d->config, PCI_CLASS_BRIDGE_PCI);
86 e1c6bbab Blue Swirl
    return 0;
87 e1c6bbab Blue Swirl
}
88 e1c6bbab Blue Swirl
89 e1c6bbab Blue Swirl
static PCIDeviceInfo dec_21154_pci_host_info = {
90 e1c6bbab Blue Swirl
    .qdev.name = "dec-21154",
91 e1c6bbab Blue Swirl
    .qdev.size = sizeof(PCIDevice),
92 e1c6bbab Blue Swirl
    .init      = dec_21154_pci_host_init,
93 e327e323 Isaku Yamahata
    .is_bridge  = 1,
94 e1c6bbab Blue Swirl
};
95 e1c6bbab Blue Swirl
96 e1c6bbab Blue Swirl
static void dec_register_devices(void)
97 e1c6bbab Blue Swirl
{
98 e1c6bbab Blue Swirl
    sysbus_register_dev("dec-21154", sizeof(DECState),
99 e1c6bbab Blue Swirl
                        pci_dec_21154_init_device);
100 e1c6bbab Blue Swirl
    pci_qdev_register(&dec_21154_pci_host_info);
101 e1c6bbab Blue Swirl
}
102 e1c6bbab Blue Swirl
103 e1c6bbab Blue Swirl
device_init(dec_register_devices)