Revision f0513d2c

b/MAINTAINERS
644 644
F: include/qemu/cpu.h
645 645
F: target-i386/cpu.c
646 646

  
647
ICC Bus
648
M: Igor Mammedov <imammedo@redhat.com>
649
S: Supported
650
F: include/hw/cpu/icc_bus.h
651
F: hw/cpu/icc_bus.c
652

  
647 653
Device Tree
648 654
M: Peter Crosthwaite <peter.crosthwaite@petalogix.com>
649 655
M: Alexander Graf <agraf@suse.de>
b/default-configs/i386-softmmu.mak
44 44
CONFIG_PCI_Q35=y
45 45
CONFIG_APIC=y
46 46
CONFIG_IOAPIC=y
47
CONFIG_ICC_BUS=y
47 48
CONFIG_PVPANIC=y
b/default-configs/x86_64-softmmu.mak
44 44
CONFIG_PCI_Q35=y
45 45
CONFIG_APIC=y
46 46
CONFIG_IOAPIC=y
47
CONFIG_ICC_BUS=y
47 48
CONFIG_PVPANIC=y
b/hw/cpu/Makefile.objs
1 1
obj-$(CONFIG_ARM11MPCORE) += arm11mpcore.o
2 2
obj-$(CONFIG_ARM9MPCORE) += a9mpcore.o
3 3
obj-$(CONFIG_ARM15MPCORE) += a15mpcore.o
4
obj-$(CONFIG_ICC_BUS) += icc_bus.o
4 5

  
b/hw/cpu/icc_bus.c
1
/* icc_bus.c
2
 * emulate x86 ICC (Interrupt Controller Communications) bus
3
 *
4
 * Copyright (c) 2013 Red Hat, Inc
5
 *
6
 * Authors:
7
 *     Igor Mammedov <imammedo@redhat.com>
8
 *
9
 * This library is free software; you can redistribute it and/or
10
 * modify it under the terms of the GNU Lesser General Public
11
 * License as published by the Free Software Foundation; either
12
 * version 2 of the License, or (at your option) any later version.
13
 *
14
 * This library is distributed in the hope that it will be useful,
15
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17
 * Lesser General Public License for more details.
18
 *
19
 * You should have received a copy of the GNU Lesser General Public
20
 * License along with this library; if not, see <http://www.gnu.org/licenses/>
21
 */
22
#include "hw/cpu/icc_bus.h"
23
#include "hw/sysbus.h"
24

  
25
/* icc-bridge implementation */
26

  
27
static void icc_bus_init(Object *obj)
28
{
29
    BusState *b = BUS(obj);
30

  
31
    b->allow_hotplug = true;
32
}
33

  
34
static const TypeInfo icc_bus_info = {
35
    .name = TYPE_ICC_BUS,
36
    .parent = TYPE_BUS,
37
    .instance_size = sizeof(ICCBus),
38
    .instance_init = icc_bus_init,
39
};
40

  
41

  
42
/* icc-device implementation */
43

  
44
static void icc_device_realize(DeviceState *dev, Error **errp)
45
{
46
    ICCDevice *id = ICC_DEVICE(dev);
47
    ICCDeviceClass *idc = ICC_DEVICE_GET_CLASS(id);
48

  
49
    if (idc->init) {
50
        if (idc->init(id) < 0) {
51
            error_setg(errp, "%s initialization failed.",
52
                       object_get_typename(OBJECT(dev)));
53
        }
54
    }
55
}
56

  
57
static void icc_device_class_init(ObjectClass *oc, void *data)
58
{
59
    DeviceClass *dc = DEVICE_CLASS(oc);
60

  
61
    dc->realize = icc_device_realize;
62
    dc->bus_type = TYPE_ICC_BUS;
63
}
64

  
65
static const TypeInfo icc_device_info = {
66
    .name = TYPE_ICC_DEVICE,
67
    .parent = TYPE_DEVICE,
68
    .abstract = true,
69
    .instance_size = sizeof(ICCDevice),
70
    .class_size = sizeof(ICCDeviceClass),
71
    .class_init = icc_device_class_init,
72
};
73

  
74

  
75
/*  icc-bridge implementation */
76

  
77
typedef struct ICCBridgeState {
78
    /*< private >*/
79
    SysBusDevice parent_obj;
80
    /*< public >*/
81

  
82
    ICCBus icc_bus;
83
} ICCBridgeState;
84

  
85
#define ICC_BRIGDE(obj) OBJECT_CHECK(ICCBridgeState, (obj), TYPE_ICC_BRIDGE)
86

  
87
static void icc_bridge_init(Object *obj)
88
{
89
    ICCBridgeState *s = ICC_BRIGDE(obj);
90

  
91
    qbus_create_inplace(&s->icc_bus, TYPE_ICC_BUS, DEVICE(s), "icc");
92
}
93

  
94
static const TypeInfo icc_bridge_info = {
95
    .name  = TYPE_ICC_BRIDGE,
96
    .parent = TYPE_SYS_BUS_DEVICE,
97
    .instance_init  = icc_bridge_init,
98
    .instance_size  = sizeof(ICCBridgeState),
99
};
100

  
101

  
102
static void icc_bus_register_types(void)
103
{
104
    type_register_static(&icc_bus_info);
105
    type_register_static(&icc_device_info);
106
    type_register_static(&icc_bridge_info);
107
}
108

  
109
type_init(icc_bus_register_types)
b/hw/i386/pc_piix.c
37 37
#include "hw/kvm/clock.h"
38 38
#include "sysemu/sysemu.h"
39 39
#include "hw/sysbus.h"
40
#include "hw/cpu/icc_bus.h"
40 41
#include "sysemu/arch_init.h"
41 42
#include "sysemu/blockdev.h"
42 43
#include "hw/i2c/smbus.h"
......
87 88
    MemoryRegion *ram_memory;
88 89
    MemoryRegion *pci_memory;
89 90
    MemoryRegion *rom_memory;
91
    DeviceState *icc_bridge;
90 92
    void *fw_cfg = NULL;
91 93

  
94
    icc_bridge = qdev_create(NULL, TYPE_ICC_BRIDGE);
95
    object_property_add_child(qdev_get_machine(), "icc-bridge",
96
                              OBJECT(icc_bridge), NULL);
97

  
92 98
    pc_cpus_init(cpu_model);
93 99
    pc_acpi_init("acpi-dsdt.aml");
94 100

  
......
163 169
    if (pci_enabled) {
164 170
        ioapic_init_gsi(gsi_state, "i440fx");
165 171
    }
172
    qdev_init_nofail(icc_bridge);
166 173

  
167 174
    pc_register_ferr_irq(gsi[13]);
168 175

  
b/hw/i386/pc_q35.c
41 41
#include "hw/ide/pci.h"
42 42
#include "hw/ide/ahci.h"
43 43
#include "hw/usb.h"
44
#include "hw/cpu/icc_bus.h"
44 45

  
45 46
/* ICH9 AHCI has 6 ports */
46 47
#define MAX_SATA_PORTS     6
......
75 76
    int i;
76 77
    ICH9LPCState *ich9_lpc;
77 78
    PCIDevice *ahci;
79
    DeviceState *icc_bridge;
80

  
81
    icc_bridge = qdev_create(NULL, TYPE_ICC_BRIDGE);
82
    object_property_add_child(qdev_get_machine(), "icc-bridge",
83
                              OBJECT(icc_bridge), NULL);
78 84

  
79 85
    pc_cpus_init(cpu_model);
80 86
    pc_acpi_init("q35-acpi-dsdt.aml");
......
158 164
    if (pci_enabled) {
159 165
        ioapic_init_gsi(gsi_state, NULL);
160 166
    }
167
    qdev_init_nofail(icc_bridge);
161 168

  
162 169
    pc_register_ferr_irq(gsi[13]);
163 170

  
b/include/hw/cpu/icc_bus.h
1
/* icc_bus.h
2
 * emulate x86 ICC (Interrupt Controller Communications) bus
3
 *
4
 * Copyright (c) 2013 Red Hat, Inc
5
 *
6
 * Authors:
7
 *     Igor Mammedov <imammedo@redhat.com>
8
 *
9
 * This library is free software; you can redistribute it and/or
10
 * modify it under the terms of the GNU Lesser General Public
11
 * License as published by the Free Software Foundation; either
12
 * version 2 of the License, or (at your option) any later version.
13
 *
14
 * This library is distributed in the hope that it will be useful,
15
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17
 * Lesser General Public License for more details.
18
 *
19
 * You should have received a copy of the GNU Lesser General Public
20
 * License along with this library; if not, see <http://www.gnu.org/licenses/>
21
 */
22
#ifndef ICC_BUS_H
23
#define ICC_BUS_H
24

  
25
#include "hw/qdev-core.h"
26

  
27
#define TYPE_ICC_BUS "icc-bus"
28

  
29
#ifndef CONFIG_USER_ONLY
30

  
31
/**
32
 * ICCBus:
33
 *
34
 * ICC bus
35
 */
36
typedef struct ICCBus {
37
    /*< private >*/
38
    BusState parent_obj;
39
    /*< public >*/
40
} ICCBus;
41

  
42
#define ICC_BUS(obj) OBJECT_CHECK(ICCBus, (obj), TYPE_ICC_BUS)
43

  
44
/**
45
 * ICCDevice:
46
 *
47
 * ICC device
48
 */
49
typedef struct ICCDevice {
50
    /*< private >*/
51
    DeviceState qdev;
52
    /*< public >*/
53
} ICCDevice;
54

  
55
/**
56
 * ICCDeviceClass:
57
 * @init: Initialization callback for derived classes.
58
 *
59
 * ICC device class
60
 */
61
typedef struct ICCDeviceClass {
62
    /*< private >*/
63
    DeviceClass parent_class;
64
    /*< public >*/
65

  
66
    int (*init)(ICCDevice *dev); /* TODO replace with QOM realize */
67
} ICCDeviceClass;
68

  
69
#define TYPE_ICC_DEVICE "icc-device"
70
#define ICC_DEVICE(obj) OBJECT_CHECK(ICCDevice, (obj), TYPE_ICC_DEVICE)
71
#define ICC_DEVICE_CLASS(klass) \
72
     OBJECT_CLASS_CHECK(ICCDeviceClass, (klass), TYPE_ICC_DEVICE)
73
#define ICC_DEVICE_GET_CLASS(obj) \
74
     OBJECT_GET_CLASS(ICCDeviceClass, (obj), TYPE_ICC_DEVICE)
75

  
76
#define TYPE_ICC_BRIDGE "icc-bridge"
77

  
78
#endif /* CONFIG_USER_ONLY */
79
#endif

Also available in: Unified diff