2009-08-28 15:28:13 +02:00
|
|
|
/*
|
|
|
|
* QEMU PIIX4 PCI Bridge Emulation
|
|
|
|
*
|
|
|
|
* Copyright (c) 2006 Fabrice Bellard
|
2018-01-06 16:37:20 +01:00
|
|
|
* Copyright (c) 2018 Hervé Poussineau
|
2009-08-28 15:28:13 +02:00
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
2016-01-26 19:17:03 +01:00
|
|
|
#include "qemu/osdep.h"
|
2018-01-06 16:37:26 +01:00
|
|
|
#include "qapi/error.h"
|
2018-01-06 16:37:21 +01:00
|
|
|
#include "hw/irq.h"
|
2019-02-02 01:13:12 +01:00
|
|
|
#include "hw/southbridge/piix.h"
|
2013-02-04 15:40:22 +01:00
|
|
|
#include "hw/pci/pci.h"
|
2013-02-05 17:06:20 +01:00
|
|
|
#include "hw/isa/isa.h"
|
2019-12-12 17:15:43 +01:00
|
|
|
#include "hw/intc/i8259.h"
|
2018-01-06 16:37:22 +01:00
|
|
|
#include "hw/dma/i8257.h"
|
2018-01-06 16:37:23 +01:00
|
|
|
#include "hw/timer/i8254.h"
|
2018-01-06 16:37:26 +01:00
|
|
|
#include "hw/rtc/mc146818rtc.h"
|
2020-03-17 16:05:37 +01:00
|
|
|
#include "hw/ide/pci.h"
|
2022-05-28 11:02:11 +02:00
|
|
|
#include "hw/acpi/piix4.h"
|
2022-06-03 20:50:38 +02:00
|
|
|
#include "hw/usb/hcd-uhci.h"
|
2019-08-12 07:23:45 +02:00
|
|
|
#include "migration/vmstate.h"
|
2018-01-06 16:37:20 +01:00
|
|
|
#include "sysemu/reset.h"
|
|
|
|
#include "sysemu/runstate.h"
|
2020-09-03 22:43:22 +02:00
|
|
|
#include "qom/object.h"
|
2009-08-28 15:28:13 +02:00
|
|
|
|
2020-09-03 22:43:22 +02:00
|
|
|
struct PIIX4State {
|
2010-12-02 16:26:56 +01:00
|
|
|
PCIDevice dev;
|
2018-01-06 16:37:21 +01:00
|
|
|
qemu_irq cpu_intr;
|
|
|
|
qemu_irq *isa;
|
2018-01-06 16:37:20 +01:00
|
|
|
|
2018-01-06 16:37:26 +01:00
|
|
|
RTCState rtc;
|
2022-06-03 20:50:38 +02:00
|
|
|
PCIIDEState ide;
|
|
|
|
UHCIState uhci;
|
2018-01-06 16:37:20 +01:00
|
|
|
/* Reset Control Register */
|
|
|
|
MemoryRegion rcr_mem;
|
|
|
|
uint8_t rcr;
|
2020-09-03 22:43:22 +02:00
|
|
|
};
|
2010-12-02 16:26:56 +01:00
|
|
|
|
2020-09-16 20:25:19 +02:00
|
|
|
OBJECT_DECLARE_SIMPLE_TYPE(PIIX4State, PIIX4_PCI_DEVICE)
|
2015-05-13 02:43:24 +02:00
|
|
|
|
2022-02-17 11:19:19 +01:00
|
|
|
static void piix4_set_irq(void *opaque, int irq_num, int level)
|
|
|
|
{
|
|
|
|
int i, pic_irq, pic_level;
|
2022-02-17 11:19:21 +01:00
|
|
|
PIIX4State *s = opaque;
|
2022-02-17 11:19:22 +01:00
|
|
|
PCIBus *bus = pci_get_bus(&s->dev);
|
2022-02-17 11:19:19 +01:00
|
|
|
|
|
|
|
/* now we change the pic irq level according to the piix irq mappings */
|
|
|
|
/* XXX: optimize */
|
2022-02-17 11:19:22 +01:00
|
|
|
pic_irq = s->dev.config[PIIX_PIRQCA + irq_num];
|
2022-02-17 11:19:23 +01:00
|
|
|
if (pic_irq < ISA_NUM_IRQS) {
|
2022-02-17 11:19:19 +01:00
|
|
|
/* The pic level is the logical OR of all the PCI irqs mapped to it. */
|
|
|
|
pic_level = 0;
|
2022-02-17 11:19:23 +01:00
|
|
|
for (i = 0; i < PIIX_NUM_PIRQS; i++) {
|
2022-02-17 11:19:22 +01:00
|
|
|
if (pic_irq == s->dev.config[PIIX_PIRQCA + i]) {
|
2022-02-17 11:19:19 +01:00
|
|
|
pic_level |= pci_bus_get_irq_level(bus, i);
|
|
|
|
}
|
|
|
|
}
|
2022-02-17 11:19:21 +01:00
|
|
|
qemu_set_irq(s->isa[pic_irq], pic_level);
|
2022-02-17 11:19:19 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-06-03 20:50:37 +02:00
|
|
|
static int pci_slot_get_pirq(PCIDevice *pci_dev, int irq_num)
|
|
|
|
{
|
|
|
|
int slot;
|
|
|
|
|
|
|
|
slot = PCI_SLOT(pci_dev->devfn);
|
|
|
|
|
|
|
|
switch (slot) {
|
|
|
|
/* PIIX4 USB */
|
|
|
|
case 10:
|
|
|
|
return 3;
|
|
|
|
/* AMD 79C973 Ethernet */
|
|
|
|
case 11:
|
|
|
|
return 1;
|
|
|
|
/* Crystal 4281 Sound */
|
|
|
|
case 12:
|
|
|
|
return 2;
|
|
|
|
/* PCI slot 1 to 4 */
|
|
|
|
case 18 ... 21:
|
|
|
|
return ((slot - 18) + irq_num) & 0x03;
|
|
|
|
/* Unknown device, don't do any translation */
|
|
|
|
default:
|
|
|
|
return irq_num;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-10-10 15:15:21 +02:00
|
|
|
static void piix4_isa_reset(DeviceState *dev)
|
2009-08-28 15:28:13 +02:00
|
|
|
{
|
2019-10-10 15:15:21 +02:00
|
|
|
PIIX4State *d = PIIX4_PCI_DEVICE(dev);
|
2010-12-02 16:26:56 +01:00
|
|
|
uint8_t *pci_conf = d->dev.config;
|
2009-08-28 15:28:13 +02:00
|
|
|
|
|
|
|
pci_conf[0x04] = 0x07; // master, memory and I/O
|
|
|
|
pci_conf[0x05] = 0x00;
|
|
|
|
pci_conf[0x06] = 0x00;
|
|
|
|
pci_conf[0x07] = 0x02; // PCI_status_devsel_medium
|
|
|
|
pci_conf[0x4c] = 0x4d;
|
|
|
|
pci_conf[0x4e] = 0x03;
|
|
|
|
pci_conf[0x4f] = 0x00;
|
|
|
|
pci_conf[0x60] = 0x0a; // PCI A -> IRQ 10
|
|
|
|
pci_conf[0x61] = 0x0a; // PCI B -> IRQ 10
|
|
|
|
pci_conf[0x62] = 0x0b; // PCI C -> IRQ 11
|
|
|
|
pci_conf[0x63] = 0x0b; // PCI D -> IRQ 11
|
|
|
|
pci_conf[0x69] = 0x02;
|
|
|
|
pci_conf[0x70] = 0x80;
|
|
|
|
pci_conf[0x76] = 0x0c;
|
|
|
|
pci_conf[0x77] = 0x0c;
|
|
|
|
pci_conf[0x78] = 0x02;
|
|
|
|
pci_conf[0x79] = 0x00;
|
|
|
|
pci_conf[0x80] = 0x00;
|
|
|
|
pci_conf[0x82] = 0x00;
|
|
|
|
pci_conf[0xa0] = 0x08;
|
|
|
|
pci_conf[0xa2] = 0x00;
|
|
|
|
pci_conf[0xa3] = 0x00;
|
|
|
|
pci_conf[0xa4] = 0x00;
|
|
|
|
pci_conf[0xa5] = 0x00;
|
|
|
|
pci_conf[0xa6] = 0x00;
|
|
|
|
pci_conf[0xa7] = 0x00;
|
|
|
|
pci_conf[0xa8] = 0x0f;
|
|
|
|
pci_conf[0xaa] = 0x00;
|
|
|
|
pci_conf[0xab] = 0x00;
|
|
|
|
pci_conf[0xac] = 0x00;
|
|
|
|
pci_conf[0xae] = 0x00;
|
|
|
|
}
|
|
|
|
|
2021-03-24 14:54:43 +01:00
|
|
|
static int piix4_ide_post_load(void *opaque, int version_id)
|
|
|
|
{
|
|
|
|
PIIX4State *s = opaque;
|
|
|
|
|
|
|
|
if (version_id == 2) {
|
|
|
|
s->rcr = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2010-12-02 16:59:33 +01:00
|
|
|
static const VMStateDescription vmstate_piix4 = {
|
|
|
|
.name = "PIIX4",
|
2021-03-24 14:54:43 +01:00
|
|
|
.version_id = 3,
|
2010-12-02 16:59:33 +01:00
|
|
|
.minimum_version_id = 2,
|
2021-03-24 14:54:43 +01:00
|
|
|
.post_load = piix4_ide_post_load,
|
2014-04-16 15:32:32 +02:00
|
|
|
.fields = (VMStateField[]) {
|
2010-12-02 16:59:33 +01:00
|
|
|
VMSTATE_PCI_DEVICE(dev, PIIX4State),
|
2021-03-24 14:54:43 +01:00
|
|
|
VMSTATE_UINT8_V(rcr, PIIX4State, 3),
|
2010-12-02 16:59:33 +01:00
|
|
|
VMSTATE_END_OF_LIST()
|
|
|
|
}
|
|
|
|
};
|
2009-08-28 15:28:13 +02:00
|
|
|
|
2018-01-06 16:37:21 +01:00
|
|
|
static void piix4_request_i8259_irq(void *opaque, int irq, int level)
|
|
|
|
{
|
|
|
|
PIIX4State *s = opaque;
|
|
|
|
qemu_set_irq(s->cpu_intr, level);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void piix4_set_i8259_irq(void *opaque, int irq, int level)
|
|
|
|
{
|
|
|
|
PIIX4State *s = opaque;
|
|
|
|
qemu_set_irq(s->isa[irq], level);
|
|
|
|
}
|
|
|
|
|
2018-01-06 16:37:20 +01:00
|
|
|
static void piix4_rcr_write(void *opaque, hwaddr addr, uint64_t val,
|
|
|
|
unsigned int len)
|
|
|
|
{
|
|
|
|
PIIX4State *s = opaque;
|
|
|
|
|
|
|
|
if (val & 4) {
|
|
|
|
qemu_system_reset_request(SHUTDOWN_CAUSE_GUEST_RESET);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
s->rcr = val & 2; /* keep System Reset type only */
|
|
|
|
}
|
|
|
|
|
|
|
|
static uint64_t piix4_rcr_read(void *opaque, hwaddr addr, unsigned int len)
|
|
|
|
{
|
|
|
|
PIIX4State *s = opaque;
|
|
|
|
|
|
|
|
return s->rcr;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const MemoryRegionOps piix4_rcr_ops = {
|
|
|
|
.read = piix4_rcr_read,
|
|
|
|
.write = piix4_rcr_write,
|
|
|
|
.endianness = DEVICE_LITTLE_ENDIAN,
|
|
|
|
.impl = {
|
|
|
|
.min_access_size = 1,
|
|
|
|
.max_access_size = 1,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2015-01-19 15:52:30 +01:00
|
|
|
static void piix4_realize(PCIDevice *dev, Error **errp)
|
2009-08-28 15:28:13 +02:00
|
|
|
{
|
2018-01-06 16:37:20 +01:00
|
|
|
PIIX4State *s = PIIX4_PCI_DEVICE(dev);
|
2022-06-03 20:50:38 +02:00
|
|
|
PCIBus *pci_bus = pci_get_bus(dev);
|
2018-01-06 16:37:21 +01:00
|
|
|
ISABus *isa_bus;
|
|
|
|
qemu_irq *i8259_out_irq;
|
2009-08-28 15:28:13 +02:00
|
|
|
|
2018-01-06 16:37:21 +01:00
|
|
|
isa_bus = isa_bus_new(DEVICE(dev), pci_address_space(dev),
|
|
|
|
pci_address_space_io(dev), errp);
|
|
|
|
if (!isa_bus) {
|
isa: Clean up error handling around isa_bus_new()
We can have at most one ISA bus. If you try to create another one,
isa_bus_new() complains to stderr and returns null.
isa_bus_new() is called in two contexts, machine's init() and device's
realize() methods. Since complaining to stderr is not proper in the
latter context, convert isa_bus_new() to Error.
Machine's init():
* mips_jazz_init(), called from the init() methods of machines
"magnum" and "pica"
* mips_r4k_init(), the init() method of machine "mips"
* pc_init1() called from the init() methods of non-q35 PC machines
* typhoon_init(), called from clipper_init(), the init() method of
machine "clipper"
These callers always create the first ISA bus, hence isa_bus_new()
can't fail. Simply pass &error_abort.
Device's realize():
* i82378_realize(), of PCI device "i82378"
* ich9_lpc_realize(), of PCI device "ICH9-LPC"
* pci_ebus_realize(), of PCI device "ebus"
* piix3_realize(), of PCI device "pci-piix3", abstract parent of
"PIIX3" and "PIIX3-xen"
* piix4_realize(), of PCI device "PIIX4"
* vt82c686b_realize(), of PCI device "VT82C686B"
Propagate the error. Note that these devices are typically created
only by machine init() methods with qdev_init_nofail() or similar. If
we screwed up and created an ISA bus before that call, we now give up
right away. Before, we'd hobble on, and typically die in
isa_bus_irqs(). Similar if someone finds a way to hot-plug one of
these critters.
Cc: Richard Henderson <rth@twiddle.net>
Cc: "Michael S. Tsirkin" <mst@redhat.com>
Cc: "Hervé Poussineau" <hpoussin@reactos.org>
Cc: Aurelien Jarno <aurelien@aurel32.net>
Cc: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
Reviewed-by: Marcel Apfelbaum <marcel@redhat.com>
Reviewed-by: Hervé Poussineau <hpoussin@reactos.org>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Message-Id: <1450370121-5768-11-git-send-email-armbru@redhat.com>
2015-12-17 17:35:18 +01:00
|
|
|
return;
|
|
|
|
}
|
2018-01-06 16:37:20 +01:00
|
|
|
|
2018-01-06 16:37:21 +01:00
|
|
|
qdev_init_gpio_in_named(DEVICE(dev), piix4_set_i8259_irq,
|
|
|
|
"isa", ISA_NUM_IRQS);
|
|
|
|
qdev_init_gpio_out_named(DEVICE(dev), &s->cpu_intr,
|
|
|
|
"intr", 1);
|
|
|
|
|
2018-01-06 16:37:20 +01:00
|
|
|
memory_region_init_io(&s->rcr_mem, OBJECT(dev), &piix4_rcr_ops, s,
|
|
|
|
"reset-control", 1);
|
|
|
|
memory_region_add_subregion_overlap(pci_address_space_io(dev),
|
2019-02-02 20:48:46 +01:00
|
|
|
PIIX_RCR_IOPORT, &s->rcr_mem, 1);
|
2018-01-06 16:37:20 +01:00
|
|
|
|
2018-01-06 16:37:21 +01:00
|
|
|
/* initialize i8259 pic */
|
|
|
|
i8259_out_irq = qemu_allocate_irqs(piix4_request_i8259_irq, s, 1);
|
|
|
|
s->isa = i8259_init(isa_bus, *i8259_out_irq);
|
2009-08-28 15:28:13 +02:00
|
|
|
|
2018-01-06 16:37:21 +01:00
|
|
|
/* initialize ISA irqs */
|
|
|
|
isa_bus_irqs(isa_bus, s->isa);
|
2009-08-28 15:28:13 +02:00
|
|
|
|
2018-01-06 16:37:23 +01:00
|
|
|
/* initialize pit */
|
|
|
|
i8254_pit_init(isa_bus, 0x40, 0, NULL);
|
|
|
|
|
2018-01-06 16:37:22 +01:00
|
|
|
/* DMA */
|
|
|
|
i8257_dma_init(isa_bus, 0);
|
|
|
|
|
2018-01-06 16:37:26 +01:00
|
|
|
/* RTC */
|
|
|
|
qdev_prop_set_int32(DEVICE(&s->rtc), "base_year", 2000);
|
error: Eliminate error_propagate() with Coccinelle, part 1
When all we do with an Error we receive into a local variable is
propagating to somewhere else, we can just as well receive it there
right away. Convert
if (!foo(..., &err)) {
...
error_propagate(errp, err);
...
return ...
}
to
if (!foo(..., errp)) {
...
...
return ...
}
where nothing else needs @err. Coccinelle script:
@rule1 forall@
identifier fun, err, errp, lbl;
expression list args, args2;
binary operator op;
constant c1, c2;
symbol false;
@@
if (
(
- fun(args, &err, args2)
+ fun(args, errp, args2)
|
- !fun(args, &err, args2)
+ !fun(args, errp, args2)
|
- fun(args, &err, args2) op c1
+ fun(args, errp, args2) op c1
)
)
{
... when != err
when != lbl:
when strict
- error_propagate(errp, err);
... when != err
(
return;
|
return c2;
|
return false;
)
}
@rule2 forall@
identifier fun, err, errp, lbl;
expression list args, args2;
expression var;
binary operator op;
constant c1, c2;
symbol false;
@@
- var = fun(args, &err, args2);
+ var = fun(args, errp, args2);
... when != err
if (
(
var
|
!var
|
var op c1
)
)
{
... when != err
when != lbl:
when strict
- error_propagate(errp, err);
... when != err
(
return;
|
return c2;
|
return false;
|
return var;
)
}
@depends on rule1 || rule2@
identifier err;
@@
- Error *err = NULL;
... when != err
Not exactly elegant, I'm afraid.
The "when != lbl:" is necessary to avoid transforming
if (fun(args, &err)) {
goto out
}
...
out:
error_propagate(errp, err);
even though other paths to label out still need the error_propagate().
For an actual example, see sclp_realize().
Without the "when strict", Coccinelle transforms vfio_msix_setup(),
incorrectly. I don't know what exactly "when strict" does, only that
it helps here.
The match of return is narrower than what I want, but I can't figure
out how to express "return where the operand doesn't use @err". For
an example where it's too narrow, see vfio_intx_enable().
Silently fails to convert hw/arm/armsse.c, because Coccinelle gets
confused by ARMSSE being used both as typedef and function-like macro
there. Converted manually.
Line breaks tidied up manually. One nested declaration of @local_err
deleted manually. Preexisting unwanted blank line dropped in
hw/riscv/sifive_e.c.
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Message-Id: <20200707160613.848843-35-armbru@redhat.com>
2020-07-07 18:06:02 +02:00
|
|
|
if (!qdev_realize(DEVICE(&s->rtc), BUS(isa_bus), errp)) {
|
2018-01-06 16:37:26 +01:00
|
|
|
return;
|
|
|
|
}
|
2022-03-01 23:00:37 +01:00
|
|
|
s->rtc.irq = isa_get_irq(ISA_DEVICE(&s->rtc), s->rtc.isairq);
|
2022-06-03 20:50:38 +02:00
|
|
|
|
|
|
|
/* IDE */
|
|
|
|
qdev_prop_set_int32(DEVICE(&s->ide), "addr", dev->devfn + 1);
|
|
|
|
if (!qdev_realize(DEVICE(&s->ide), BUS(pci_bus), errp)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
pci_ide_create_devs(PCI_DEVICE(&s->ide));
|
|
|
|
|
|
|
|
/* USB */
|
|
|
|
qdev_prop_set_int32(DEVICE(&s->uhci), "addr", dev->devfn + 2);
|
|
|
|
if (!qdev_realize(DEVICE(&s->uhci), BUS(pci_bus), errp)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
pci_bus_irqs(pci_bus, piix4_set_irq, pci_slot_get_pirq, s, PIIX_NUM_PIRQS);
|
2009-08-28 15:28:13 +02:00
|
|
|
}
|
|
|
|
|
2018-01-06 16:37:26 +01:00
|
|
|
static void piix4_init(Object *obj)
|
|
|
|
{
|
|
|
|
PIIX4State *s = PIIX4_PCI_DEVICE(obj);
|
|
|
|
|
2022-06-03 20:50:36 +02:00
|
|
|
object_initialize_child(obj, "rtc", &s->rtc, TYPE_MC146818_RTC);
|
2022-06-03 20:50:38 +02:00
|
|
|
object_initialize_child(obj, "ide", &s->ide, "piix4-ide");
|
|
|
|
object_initialize_child(obj, "uhci", &s->uhci, "piix4-usb-uhci");
|
2018-01-06 16:37:26 +01:00
|
|
|
}
|
|
|
|
|
2011-12-04 19:22:06 +01:00
|
|
|
static void piix4_class_init(ObjectClass *klass, void *data)
|
|
|
|
{
|
2011-12-08 04:34:16 +01:00
|
|
|
DeviceClass *dc = DEVICE_CLASS(klass);
|
2011-12-04 19:22:06 +01:00
|
|
|
PCIDeviceClass *k = PCI_DEVICE_CLASS(klass);
|
|
|
|
|
2015-01-19 15:52:30 +01:00
|
|
|
k->realize = piix4_realize;
|
2011-12-04 19:22:06 +01:00
|
|
|
k->vendor_id = PCI_VENDOR_ID_INTEL;
|
|
|
|
k->device_id = PCI_DEVICE_ID_INTEL_82371AB_0;
|
|
|
|
k->class_id = PCI_CLASS_BRIDGE_ISA;
|
2019-10-10 15:15:21 +02:00
|
|
|
dc->reset = piix4_isa_reset;
|
2011-12-08 04:34:16 +01:00
|
|
|
dc->desc = "ISA bridge";
|
|
|
|
dc->vmsd = &vmstate_piix4;
|
2013-11-28 17:27:00 +01:00
|
|
|
/*
|
|
|
|
* Reason: part of PIIX4 southbridge, needs to be wired up,
|
|
|
|
* e.g. by mips_malta_init()
|
|
|
|
*/
|
2017-05-03 22:35:44 +02:00
|
|
|
dc->user_creatable = false;
|
2014-02-05 16:36:48 +01:00
|
|
|
dc->hotpluggable = false;
|
2011-12-04 19:22:06 +01:00
|
|
|
}
|
|
|
|
|
2013-01-10 16:19:07 +01:00
|
|
|
static const TypeInfo piix4_info = {
|
2015-05-13 02:43:24 +02:00
|
|
|
.name = TYPE_PIIX4_PCI_DEVICE,
|
2011-12-08 04:34:16 +01:00
|
|
|
.parent = TYPE_PCI_DEVICE,
|
|
|
|
.instance_size = sizeof(PIIX4State),
|
2018-01-06 16:37:26 +01:00
|
|
|
.instance_init = piix4_init,
|
2011-12-08 04:34:16 +01:00
|
|
|
.class_init = piix4_class_init,
|
2017-09-27 21:56:34 +02:00
|
|
|
.interfaces = (InterfaceInfo[]) {
|
|
|
|
{ INTERFACE_CONVENTIONAL_PCI_DEVICE },
|
|
|
|
{ },
|
|
|
|
},
|
2009-08-28 15:28:13 +02:00
|
|
|
};
|
|
|
|
|
2012-02-09 15:20:55 +01:00
|
|
|
static void piix4_register_types(void)
|
2009-08-28 15:28:13 +02:00
|
|
|
{
|
2011-12-08 04:34:16 +01:00
|
|
|
type_register_static(&piix4_info);
|
2009-08-28 15:28:13 +02:00
|
|
|
}
|
2012-02-09 15:20:55 +01:00
|
|
|
|
|
|
|
type_init(piix4_register_types)
|
2019-02-02 01:13:12 +01:00
|
|
|
|
2022-06-03 20:50:39 +02:00
|
|
|
DeviceState *piix4_create(PCIBus *pci_bus, I2CBus **smbus)
|
2019-02-02 01:13:12 +01:00
|
|
|
{
|
|
|
|
PCIDevice *pci;
|
|
|
|
DeviceState *dev;
|
2020-03-17 16:05:37 +01:00
|
|
|
int devfn = PCI_DEVFN(10, 0);
|
2019-02-02 01:13:12 +01:00
|
|
|
|
2020-03-17 16:05:37 +01:00
|
|
|
pci = pci_create_simple_multifunction(pci_bus, devfn, true,
|
|
|
|
TYPE_PIIX4_PCI_DEVICE);
|
2019-02-02 01:13:12 +01:00
|
|
|
dev = DEVICE(pci);
|
2022-06-03 20:50:38 +02:00
|
|
|
|
2019-02-02 01:13:12 +01:00
|
|
|
if (smbus) {
|
2022-05-28 11:02:11 +02:00
|
|
|
pci = pci_new(devfn + 3, TYPE_PIIX4_PM);
|
|
|
|
qdev_prop_set_uint32(DEVICE(pci), "smb_io_base", 0x1100);
|
|
|
|
qdev_prop_set_bit(DEVICE(pci), "smm-enabled", 0);
|
|
|
|
pci_realize_and_unref(pci, pci_bus, &error_fatal);
|
|
|
|
qdev_connect_gpio_out(DEVICE(pci), 0,
|
2022-05-28 11:02:11 +02:00
|
|
|
qdev_get_gpio_in_named(dev, "isa", 9));
|
2022-05-28 11:02:11 +02:00
|
|
|
*smbus = I2C_BUS(qdev_get_child_bus(DEVICE(pci), "i2c"));
|
2021-03-24 15:24:41 +01:00
|
|
|
}
|
2019-02-02 01:13:12 +01:00
|
|
|
|
|
|
|
return dev;
|
|
|
|
}
|