2007-10-29 00:42:18 +01:00
|
|
|
/*
|
|
|
|
* PowerMac MacIO device emulation
|
|
|
|
*
|
|
|
|
* Copyright (c) 2005-2007 Fabrice Bellard
|
|
|
|
* Copyright (c) 2007 Jocelyn Mayer
|
|
|
|
*
|
|
|
|
* 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:16:58 +01:00
|
|
|
#include "qemu/osdep.h"
|
include/qemu/osdep.h: Don't include qapi/error.h
Commit 57cb38b included qapi/error.h into qemu/osdep.h to get the
Error typedef. Since then, we've moved to include qemu/osdep.h
everywhere. Its file comment explains: "To avoid getting into
possible circular include dependencies, this file should not include
any other QEMU headers, with the exceptions of config-host.h,
compiler.h, os-posix.h and os-win32.h, all of which are doing a
similar job to this file and are under similar constraints."
qapi/error.h doesn't do a similar job, and it doesn't adhere to
similar constraints: it includes qapi-types.h. That's in excess of
100KiB of crap most .c files don't actually need.
Add the typedef to qemu/typedefs.h, and include that instead of
qapi/error.h. Include qapi/error.h in .c files that need it and don't
get it now. Include qapi-types.h in qom/object.h for uint16List.
Update scripts/clean-includes accordingly. Update it further to match
reality: replace config.h by config-target.h, add sysemu/os-posix.h,
sysemu/os-win32.h. Update the list of includes in the qemu/osdep.h
comment quoted above similarly.
This reduces the number of objects depending on qapi/error.h from "all
of them" to less than a third. Unfortunately, the number depending on
qapi-types.h shrinks only a little. More work is needed for that one.
Signed-off-by: Markus Armbruster <armbru@redhat.com>
[Fix compilation without the spice devel packages. - Paolo]
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2016-03-14 09:01:28 +01:00
|
|
|
#include "qapi/error.h"
|
2013-02-04 15:40:22 +01:00
|
|
|
#include "hw/hw.h"
|
|
|
|
#include "hw/ppc/mac.h"
|
|
|
|
#include "hw/pci/pci.h"
|
2013-02-05 17:06:20 +01:00
|
|
|
#include "hw/ppc/mac_dbdma.h"
|
|
|
|
#include "hw/char/escc.h"
|
2007-10-29 00:42:18 +01:00
|
|
|
|
2013-01-24 00:03:55 +01:00
|
|
|
#define TYPE_MACIO "macio"
|
|
|
|
#define MACIO(obj) OBJECT_CHECK(MacIOState, (obj), TYPE_MACIO)
|
|
|
|
|
2011-12-21 23:14:09 +01:00
|
|
|
typedef struct MacIOState
|
|
|
|
{
|
2013-01-24 00:03:55 +01:00
|
|
|
/*< private >*/
|
2011-12-21 23:14:09 +01:00
|
|
|
PCIDevice parent;
|
2013-01-24 00:03:55 +01:00
|
|
|
/*< public >*/
|
|
|
|
|
2011-08-08 15:09:17 +02:00
|
|
|
MemoryRegion bar;
|
2013-01-24 00:04:02 +01:00
|
|
|
CUDAState cuda;
|
2017-09-24 16:47:42 +02:00
|
|
|
DBDMAState *dbdma;
|
2011-08-08 15:09:17 +02:00
|
|
|
MemoryRegion *pic_mem;
|
|
|
|
MemoryRegion *escc_mem;
|
2014-07-13 22:31:53 +02:00
|
|
|
uint64_t frequency;
|
2011-12-21 23:14:09 +01:00
|
|
|
} MacIOState;
|
2007-10-29 00:42:18 +01:00
|
|
|
|
2013-01-24 00:04:00 +01:00
|
|
|
#define OLDWORLD_MACIO(obj) \
|
|
|
|
OBJECT_CHECK(OldWorldMacIOState, (obj), TYPE_OLDWORLD_MACIO)
|
|
|
|
|
|
|
|
typedef struct OldWorldMacIOState {
|
|
|
|
/*< private >*/
|
|
|
|
MacIOState parent_obj;
|
|
|
|
/*< public >*/
|
|
|
|
|
2013-06-24 21:40:50 +02:00
|
|
|
qemu_irq irqs[5];
|
2013-01-24 00:04:01 +01:00
|
|
|
|
2013-01-24 00:04:00 +01:00
|
|
|
MacIONVRAMState nvram;
|
2013-06-24 21:40:50 +02:00
|
|
|
MACIOIDEState ide[2];
|
2013-01-24 00:04:00 +01:00
|
|
|
} OldWorldMacIOState;
|
|
|
|
|
2013-01-24 00:04:01 +01:00
|
|
|
#define NEWWORLD_MACIO(obj) \
|
|
|
|
OBJECT_CHECK(NewWorldMacIOState, (obj), TYPE_NEWWORLD_MACIO)
|
|
|
|
|
|
|
|
typedef struct NewWorldMacIOState {
|
|
|
|
/*< private >*/
|
|
|
|
MacIOState parent_obj;
|
|
|
|
/*< public >*/
|
2013-01-24 00:04:02 +01:00
|
|
|
qemu_irq irqs[5];
|
2013-01-24 00:04:01 +01:00
|
|
|
MACIOIDEState ide[2];
|
|
|
|
} NewWorldMacIOState;
|
|
|
|
|
2013-06-26 13:58:31 +02:00
|
|
|
/*
|
|
|
|
* The mac-io has two interfaces to the ESCC. One is called "escc-legacy",
|
|
|
|
* while the other one is the normal, current ESCC interface.
|
|
|
|
*
|
|
|
|
* The magic below creates memory aliases to spawn the escc-legacy device
|
|
|
|
* purely by rerouting the respective registers to our escc region. This
|
|
|
|
* works because the only difference between the two memory regions is the
|
|
|
|
* register layout, not their semantics.
|
|
|
|
*
|
|
|
|
* Reference: ftp://ftp.software.ibm.com/rs6000/technology/spec/chrp/inwork/CHRP_IORef_1.0.pdf
|
|
|
|
*/
|
|
|
|
static void macio_escc_legacy_setup(MacIOState *macio_state)
|
|
|
|
{
|
|
|
|
MemoryRegion *escc_legacy = g_new(MemoryRegion, 1);
|
|
|
|
MemoryRegion *bar = &macio_state->bar;
|
|
|
|
int i;
|
|
|
|
static const int maps[] = {
|
2016-08-02 11:22:43 +02:00
|
|
|
0x00, 0x00, /* Command B */
|
|
|
|
0x02, 0x20, /* Command A */
|
|
|
|
0x04, 0x10, /* Data B */
|
|
|
|
0x06, 0x30, /* Data A */
|
|
|
|
0x08, 0x40, /* Enhancement B */
|
|
|
|
0x0A, 0x50, /* Enhancement A */
|
|
|
|
0x80, 0x80, /* Recovery count */
|
|
|
|
0x90, 0x90, /* Start A */
|
|
|
|
0xa0, 0xa0, /* Start B */
|
|
|
|
0xb0, 0xb0, /* Detect AB */
|
2013-06-26 13:58:31 +02:00
|
|
|
};
|
|
|
|
|
2015-10-01 10:59:51 +02:00
|
|
|
memory_region_init(escc_legacy, OBJECT(macio_state), "escc-legacy", 256);
|
2013-06-26 13:58:31 +02:00
|
|
|
for (i = 0; i < ARRAY_SIZE(maps); i += 2) {
|
|
|
|
MemoryRegion *port = g_new(MemoryRegion, 1);
|
2015-10-01 10:59:51 +02:00
|
|
|
memory_region_init_alias(port, OBJECT(macio_state), "escc-legacy-port",
|
2013-06-06 11:41:28 +02:00
|
|
|
macio_state->escc_mem, maps[i+1], 0x2);
|
2013-06-26 13:58:31 +02:00
|
|
|
memory_region_add_subregion(escc_legacy, maps[i], port);
|
|
|
|
}
|
|
|
|
|
|
|
|
memory_region_add_subregion(bar, 0x12000, escc_legacy);
|
|
|
|
}
|
|
|
|
|
2011-12-21 23:14:09 +01:00
|
|
|
static void macio_bar_setup(MacIOState *macio_state)
|
2007-10-29 00:42:18 +01:00
|
|
|
{
|
2011-08-08 15:09:17 +02:00
|
|
|
MemoryRegion *bar = &macio_state->bar;
|
2007-10-29 00:42:18 +01:00
|
|
|
|
2011-08-08 15:09:17 +02:00
|
|
|
if (macio_state->escc_mem) {
|
|
|
|
memory_region_add_subregion(bar, 0x13000, macio_state->escc_mem);
|
2013-06-26 13:58:31 +02:00
|
|
|
macio_escc_legacy_setup(macio_state);
|
2009-01-12 18:40:23 +01:00
|
|
|
}
|
2007-10-29 00:42:18 +01:00
|
|
|
}
|
|
|
|
|
2015-03-17 08:46:15 +01:00
|
|
|
static void macio_common_realize(PCIDevice *d, Error **errp)
|
2011-12-21 23:14:09 +01:00
|
|
|
{
|
2013-01-24 00:03:56 +01:00
|
|
|
MacIOState *s = MACIO(d);
|
2013-01-24 00:04:02 +01:00
|
|
|
SysBusDevice *sysbus_dev;
|
2015-03-17 08:46:15 +01:00
|
|
|
Error *err = NULL;
|
2015-10-01 10:59:52 +02:00
|
|
|
|
2017-09-24 16:47:42 +02:00
|
|
|
object_property_set_bool(OBJECT(s->dbdma), true, "realized", &err);
|
|
|
|
if (err) {
|
|
|
|
error_propagate(errp, err);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
sysbus_dev = SYS_BUS_DEVICE(s->dbdma);
|
|
|
|
memory_region_add_subregion(&s->bar, 0x08000,
|
|
|
|
sysbus_mmio_get_region(sysbus_dev, 0));
|
2013-01-24 00:03:56 +01:00
|
|
|
|
2015-03-17 08:46:15 +01:00
|
|
|
object_property_set_bool(OBJECT(&s->cuda), true, "realized", &err);
|
|
|
|
if (err) {
|
|
|
|
error_propagate(errp, err);
|
|
|
|
return;
|
2013-01-24 00:04:02 +01:00
|
|
|
}
|
|
|
|
sysbus_dev = SYS_BUS_DEVICE(&s->cuda);
|
|
|
|
memory_region_add_subregion(&s->bar, 0x16000,
|
|
|
|
sysbus_mmio_get_region(sysbus_dev, 0));
|
|
|
|
|
2013-01-24 00:03:56 +01:00
|
|
|
macio_bar_setup(s);
|
|
|
|
pci_register_bar(d, 0, PCI_BASE_ADDRESS_SPACE_MEMORY, &s->bar);
|
2011-12-21 23:14:09 +01:00
|
|
|
}
|
|
|
|
|
2015-03-17 08:46:15 +01:00
|
|
|
static void macio_realize_ide(MacIOState *s, MACIOIDEState *ide,
|
|
|
|
qemu_irq irq0, qemu_irq irq1, int dmaid,
|
|
|
|
Error **errp)
|
2013-06-24 21:40:50 +02:00
|
|
|
{
|
|
|
|
SysBusDevice *sysbus_dev;
|
|
|
|
|
|
|
|
sysbus_dev = SYS_BUS_DEVICE(ide);
|
|
|
|
sysbus_connect_irq(sysbus_dev, 0, irq0);
|
|
|
|
sysbus_connect_irq(sysbus_dev, 1, irq1);
|
2017-09-24 16:47:43 +02:00
|
|
|
qdev_prop_set_uint32(DEVICE(ide), "channel", dmaid);
|
|
|
|
macio_ide_register_dma(ide, s->dbdma);
|
|
|
|
|
2015-03-17 08:46:15 +01:00
|
|
|
object_property_set_bool(OBJECT(ide), true, "realized", errp);
|
2013-06-24 21:40:50 +02:00
|
|
|
}
|
|
|
|
|
2015-03-17 08:46:15 +01:00
|
|
|
static void macio_oldworld_realize(PCIDevice *d, Error **errp)
|
2013-01-24 00:03:57 +01:00
|
|
|
{
|
|
|
|
MacIOState *s = MACIO(d);
|
2013-01-24 00:04:00 +01:00
|
|
|
OldWorldMacIOState *os = OLDWORLD_MACIO(d);
|
2015-03-17 08:46:15 +01:00
|
|
|
Error *err = NULL;
|
2013-01-24 00:04:00 +01:00
|
|
|
SysBusDevice *sysbus_dev;
|
2013-06-24 21:40:50 +02:00
|
|
|
int i;
|
|
|
|
int cur_irq = 0;
|
2015-03-17 08:46:15 +01:00
|
|
|
|
|
|
|
macio_common_realize(d, &err);
|
|
|
|
if (err) {
|
|
|
|
error_propagate(errp, err);
|
|
|
|
return;
|
2013-01-24 00:03:57 +01:00
|
|
|
}
|
|
|
|
|
2013-01-24 00:04:02 +01:00
|
|
|
sysbus_dev = SYS_BUS_DEVICE(&s->cuda);
|
2013-06-24 21:40:50 +02:00
|
|
|
sysbus_connect_irq(sysbus_dev, 0, os->irqs[cur_irq++]);
|
2013-01-24 00:04:02 +01:00
|
|
|
|
2015-03-17 08:46:15 +01:00
|
|
|
object_property_set_bool(OBJECT(&os->nvram), true, "realized", &err);
|
|
|
|
if (err) {
|
|
|
|
error_propagate(errp, err);
|
|
|
|
return;
|
2013-01-24 00:04:00 +01:00
|
|
|
}
|
|
|
|
sysbus_dev = SYS_BUS_DEVICE(&os->nvram);
|
|
|
|
memory_region_add_subregion(&s->bar, 0x60000,
|
|
|
|
sysbus_mmio_get_region(sysbus_dev, 0));
|
|
|
|
pmac_format_nvram_partition(&os->nvram, os->nvram.size);
|
|
|
|
|
2013-01-24 00:03:57 +01:00
|
|
|
if (s->pic_mem) {
|
|
|
|
/* Heathrow PIC */
|
|
|
|
memory_region_add_subregion(&s->bar, 0x00000, s->pic_mem);
|
|
|
|
}
|
|
|
|
|
2013-06-24 21:40:50 +02:00
|
|
|
/* IDE buses */
|
|
|
|
for (i = 0; i < ARRAY_SIZE(os->ide); i++) {
|
|
|
|
qemu_irq irq0 = os->irqs[cur_irq++];
|
|
|
|
qemu_irq irq1 = os->irqs[cur_irq++];
|
|
|
|
|
2015-03-17 08:46:15 +01:00
|
|
|
macio_realize_ide(s, &os->ide[i], irq0, irq1, 0x16 + (i * 4), &err);
|
|
|
|
if (err) {
|
|
|
|
error_propagate(errp, err);
|
|
|
|
return;
|
2013-06-24 21:40:50 +02:00
|
|
|
}
|
2013-01-24 00:04:01 +01:00
|
|
|
}
|
2013-01-24 00:03:57 +01:00
|
|
|
}
|
|
|
|
|
2013-08-23 19:37:12 +02:00
|
|
|
static void macio_init_ide(MacIOState *s, MACIOIDEState *ide, size_t ide_size,
|
|
|
|
int index)
|
2013-06-24 21:40:50 +02:00
|
|
|
{
|
|
|
|
gchar *name;
|
|
|
|
|
2013-08-23 19:37:12 +02:00
|
|
|
object_initialize(ide, ide_size, TYPE_MACIO_IDE);
|
2013-06-24 21:40:50 +02:00
|
|
|
qdev_set_parent_bus(DEVICE(ide), sysbus_get_default());
|
|
|
|
memory_region_add_subregion(&s->bar, 0x1f000 + ((index + 1) * 0x1000),
|
|
|
|
&ide->mem);
|
|
|
|
name = g_strdup_printf("ide[%i]", index);
|
|
|
|
object_property_add_child(OBJECT(s), name, OBJECT(ide), NULL);
|
|
|
|
g_free(name);
|
|
|
|
}
|
|
|
|
|
2013-01-24 00:04:00 +01:00
|
|
|
static void macio_oldworld_init(Object *obj)
|
|
|
|
{
|
2013-01-24 00:04:01 +01:00
|
|
|
MacIOState *s = MACIO(obj);
|
2013-01-24 00:04:00 +01:00
|
|
|
OldWorldMacIOState *os = OLDWORLD_MACIO(obj);
|
|
|
|
DeviceState *dev;
|
2013-06-24 21:40:50 +02:00
|
|
|
int i;
|
2013-01-24 00:04:00 +01:00
|
|
|
|
2013-01-24 00:04:01 +01:00
|
|
|
qdev_init_gpio_out(DEVICE(obj), os->irqs, ARRAY_SIZE(os->irqs));
|
|
|
|
|
2013-08-23 19:37:12 +02:00
|
|
|
object_initialize(&os->nvram, sizeof(os->nvram), TYPE_MACIO_NVRAM);
|
2013-01-24 00:04:00 +01:00
|
|
|
dev = DEVICE(&os->nvram);
|
|
|
|
qdev_prop_set_uint32(dev, "size", 0x2000);
|
|
|
|
qdev_prop_set_uint32(dev, "it_shift", 4);
|
2013-01-24 00:04:01 +01:00
|
|
|
|
2013-06-24 21:40:50 +02:00
|
|
|
for (i = 0; i < 2; i++) {
|
2013-08-23 19:37:12 +02:00
|
|
|
macio_init_ide(s, &os->ide[i], sizeof(os->ide[i]), i);
|
2013-06-24 21:40:50 +02:00
|
|
|
}
|
2013-01-24 00:04:00 +01:00
|
|
|
}
|
|
|
|
|
2013-06-30 05:15:14 +02:00
|
|
|
static void timer_write(void *opaque, hwaddr addr, uint64_t value,
|
|
|
|
unsigned size)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
static uint64_t timer_read(void *opaque, hwaddr addr, unsigned size)
|
|
|
|
{
|
|
|
|
uint32_t value = 0;
|
2014-07-13 16:45:46 +02:00
|
|
|
uint64_t systime = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL);
|
|
|
|
uint64_t kltime;
|
|
|
|
|
2016-03-21 17:02:30 +01:00
|
|
|
kltime = muldiv64(systime, 4194300, NANOSECONDS_PER_SECOND * 4);
|
2014-07-13 16:45:46 +02:00
|
|
|
kltime = muldiv64(kltime, 18432000, 1048575);
|
2013-06-30 05:15:14 +02:00
|
|
|
|
|
|
|
switch (addr) {
|
|
|
|
case 0x38:
|
2014-07-13 16:45:46 +02:00
|
|
|
value = kltime;
|
2013-06-30 05:15:14 +02:00
|
|
|
break;
|
|
|
|
case 0x3c:
|
2014-07-13 16:45:46 +02:00
|
|
|
value = kltime >> 32;
|
2013-06-30 05:15:14 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return value;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const MemoryRegionOps timer_ops = {
|
|
|
|
.read = timer_read,
|
|
|
|
.write = timer_write,
|
2014-05-27 01:59:06 +02:00
|
|
|
.endianness = DEVICE_LITTLE_ENDIAN,
|
2013-06-30 05:15:14 +02:00
|
|
|
};
|
|
|
|
|
2015-03-17 08:46:15 +01:00
|
|
|
static void macio_newworld_realize(PCIDevice *d, Error **errp)
|
2013-01-24 00:03:57 +01:00
|
|
|
{
|
|
|
|
MacIOState *s = MACIO(d);
|
2013-01-24 00:04:01 +01:00
|
|
|
NewWorldMacIOState *ns = NEWWORLD_MACIO(d);
|
2015-03-17 08:46:15 +01:00
|
|
|
Error *err = NULL;
|
2013-01-24 00:04:01 +01:00
|
|
|
SysBusDevice *sysbus_dev;
|
2015-02-27 08:50:14 +01:00
|
|
|
MemoryRegion *timer_memory = NULL;
|
2013-06-24 21:40:50 +02:00
|
|
|
int i;
|
|
|
|
int cur_irq = 0;
|
2015-03-17 08:46:15 +01:00
|
|
|
|
|
|
|
macio_common_realize(d, &err);
|
|
|
|
if (err) {
|
|
|
|
error_propagate(errp, err);
|
|
|
|
return;
|
2013-01-24 00:03:57 +01:00
|
|
|
}
|
|
|
|
|
2013-01-24 00:04:02 +01:00
|
|
|
sysbus_dev = SYS_BUS_DEVICE(&s->cuda);
|
2013-06-24 21:40:50 +02:00
|
|
|
sysbus_connect_irq(sysbus_dev, 0, ns->irqs[cur_irq++]);
|
2013-01-24 00:04:02 +01:00
|
|
|
|
2013-01-24 00:03:57 +01:00
|
|
|
if (s->pic_mem) {
|
|
|
|
/* OpenPIC */
|
|
|
|
memory_region_add_subregion(&s->bar, 0x40000, s->pic_mem);
|
|
|
|
}
|
|
|
|
|
2013-06-24 21:40:50 +02:00
|
|
|
/* IDE buses */
|
|
|
|
for (i = 0; i < ARRAY_SIZE(ns->ide); i++) {
|
|
|
|
qemu_irq irq0 = ns->irqs[cur_irq++];
|
|
|
|
qemu_irq irq1 = ns->irqs[cur_irq++];
|
2013-01-24 00:04:01 +01:00
|
|
|
|
2015-03-17 08:46:15 +01:00
|
|
|
macio_realize_ide(s, &ns->ide[i], irq0, irq1, 0x16 + (i * 4), &err);
|
|
|
|
if (err) {
|
|
|
|
error_propagate(errp, err);
|
|
|
|
return;
|
2013-06-24 21:40:50 +02:00
|
|
|
}
|
2013-01-24 00:04:01 +01:00
|
|
|
}
|
|
|
|
|
2013-06-30 05:15:14 +02:00
|
|
|
/* Timer */
|
2015-02-27 08:50:14 +01:00
|
|
|
timer_memory = g_new(MemoryRegion, 1);
|
2013-06-30 05:15:14 +02:00
|
|
|
memory_region_init_io(timer_memory, OBJECT(s), &timer_ops, NULL, "timer",
|
|
|
|
0x1000);
|
|
|
|
memory_region_add_subregion(&s->bar, 0x15000, timer_memory);
|
2013-01-24 00:03:57 +01:00
|
|
|
}
|
|
|
|
|
2013-01-24 00:04:01 +01:00
|
|
|
static void macio_newworld_init(Object *obj)
|
|
|
|
{
|
|
|
|
MacIOState *s = MACIO(obj);
|
|
|
|
NewWorldMacIOState *ns = NEWWORLD_MACIO(obj);
|
|
|
|
int i;
|
|
|
|
|
|
|
|
qdev_init_gpio_out(DEVICE(obj), ns->irqs, ARRAY_SIZE(ns->irqs));
|
|
|
|
|
|
|
|
for (i = 0; i < 2; i++) {
|
2013-08-23 19:37:12 +02:00
|
|
|
macio_init_ide(s, &ns->ide[i], sizeof(ns->ide[i]), i);
|
2013-01-24 00:04:01 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-01-24 00:03:55 +01:00
|
|
|
static void macio_instance_init(Object *obj)
|
|
|
|
{
|
|
|
|
MacIOState *s = MACIO(obj);
|
|
|
|
|
2015-10-01 10:59:51 +02:00
|
|
|
memory_region_init(&s->bar, obj, "macio", 0x80000);
|
2013-01-24 00:04:01 +01:00
|
|
|
|
2013-08-23 19:37:12 +02:00
|
|
|
object_initialize(&s->cuda, sizeof(s->cuda), TYPE_CUDA);
|
2013-01-24 00:04:02 +01:00
|
|
|
qdev_set_parent_bus(DEVICE(&s->cuda), sysbus_get_default());
|
|
|
|
object_property_add_child(obj, "cuda", OBJECT(&s->cuda), NULL);
|
2017-09-24 16:47:42 +02:00
|
|
|
|
|
|
|
s->dbdma = MAC_DBDMA(object_new(TYPE_MAC_DBDMA));
|
|
|
|
object_property_add_child(obj, "dbdma", OBJECT(s->dbdma), NULL);
|
2013-01-24 00:03:55 +01:00
|
|
|
}
|
|
|
|
|
2015-02-09 23:40:44 +01:00
|
|
|
static const VMStateDescription vmstate_macio_oldworld = {
|
|
|
|
.name = "macio-oldworld",
|
|
|
|
.version_id = 0,
|
|
|
|
.minimum_version_id = 0,
|
|
|
|
.fields = (VMStateField[]) {
|
|
|
|
VMSTATE_PCI_DEVICE(parent_obj.parent, OldWorldMacIOState),
|
|
|
|
VMSTATE_END_OF_LIST()
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2013-01-24 00:03:57 +01:00
|
|
|
static void macio_oldworld_class_init(ObjectClass *oc, void *data)
|
|
|
|
{
|
|
|
|
PCIDeviceClass *pdc = PCI_DEVICE_CLASS(oc);
|
2015-02-09 23:40:44 +01:00
|
|
|
DeviceClass *dc = DEVICE_CLASS(oc);
|
2013-01-24 00:03:57 +01:00
|
|
|
|
2015-03-17 08:46:15 +01:00
|
|
|
pdc->realize = macio_oldworld_realize;
|
2013-01-24 00:03:57 +01:00
|
|
|
pdc->device_id = PCI_DEVICE_ID_APPLE_343S1201;
|
2015-02-09 23:40:44 +01:00
|
|
|
dc->vmsd = &vmstate_macio_oldworld;
|
2013-01-24 00:03:57 +01:00
|
|
|
}
|
|
|
|
|
2015-02-09 23:40:44 +01:00
|
|
|
static const VMStateDescription vmstate_macio_newworld = {
|
|
|
|
.name = "macio-newworld",
|
|
|
|
.version_id = 0,
|
|
|
|
.minimum_version_id = 0,
|
|
|
|
.fields = (VMStateField[]) {
|
|
|
|
VMSTATE_PCI_DEVICE(parent_obj.parent, NewWorldMacIOState),
|
|
|
|
VMSTATE_END_OF_LIST()
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2013-01-24 00:03:57 +01:00
|
|
|
static void macio_newworld_class_init(ObjectClass *oc, void *data)
|
|
|
|
{
|
|
|
|
PCIDeviceClass *pdc = PCI_DEVICE_CLASS(oc);
|
2015-02-09 23:40:44 +01:00
|
|
|
DeviceClass *dc = DEVICE_CLASS(oc);
|
2013-01-24 00:03:57 +01:00
|
|
|
|
2015-03-17 08:46:15 +01:00
|
|
|
pdc->realize = macio_newworld_realize;
|
2013-01-24 00:03:57 +01:00
|
|
|
pdc->device_id = PCI_DEVICE_ID_APPLE_UNI_N_KEYL;
|
2015-02-09 23:40:44 +01:00
|
|
|
dc->vmsd = &vmstate_macio_newworld;
|
2013-01-24 00:03:57 +01:00
|
|
|
}
|
|
|
|
|
2014-07-13 22:31:53 +02:00
|
|
|
static Property macio_properties[] = {
|
|
|
|
DEFINE_PROP_UINT64("frequency", MacIOState, frequency, 0),
|
|
|
|
DEFINE_PROP_END_OF_LIST()
|
|
|
|
};
|
|
|
|
|
2011-12-04 19:22:06 +01:00
|
|
|
static void macio_class_init(ObjectClass *klass, void *data)
|
|
|
|
{
|
|
|
|
PCIDeviceClass *k = PCI_DEVICE_CLASS(klass);
|
2014-07-13 22:31:53 +02:00
|
|
|
DeviceClass *dc = DEVICE_CLASS(klass);
|
2011-12-04 19:22:06 +01:00
|
|
|
|
|
|
|
k->vendor_id = PCI_VENDOR_ID_APPLE;
|
|
|
|
k->class_id = PCI_CLASS_OTHERS << 8;
|
2014-07-13 22:31:53 +02:00
|
|
|
dc->props = macio_properties;
|
2015-09-26 18:22:10 +02:00
|
|
|
set_bit(DEVICE_CATEGORY_BRIDGE, dc->categories);
|
2011-12-04 19:22:06 +01:00
|
|
|
}
|
|
|
|
|
2013-01-24 00:03:57 +01:00
|
|
|
static const TypeInfo macio_oldworld_type_info = {
|
|
|
|
.name = TYPE_OLDWORLD_MACIO,
|
|
|
|
.parent = TYPE_MACIO,
|
2013-01-24 00:04:00 +01:00
|
|
|
.instance_size = sizeof(OldWorldMacIOState),
|
|
|
|
.instance_init = macio_oldworld_init,
|
2013-01-24 00:03:57 +01:00
|
|
|
.class_init = macio_oldworld_class_init,
|
|
|
|
};
|
|
|
|
|
|
|
|
static const TypeInfo macio_newworld_type_info = {
|
|
|
|
.name = TYPE_NEWWORLD_MACIO,
|
|
|
|
.parent = TYPE_MACIO,
|
2013-01-24 00:04:01 +01:00
|
|
|
.instance_size = sizeof(NewWorldMacIOState),
|
|
|
|
.instance_init = macio_newworld_init,
|
2013-01-24 00:03:57 +01:00
|
|
|
.class_init = macio_newworld_class_init,
|
|
|
|
};
|
|
|
|
|
2013-01-24 00:03:55 +01:00
|
|
|
static const TypeInfo macio_type_info = {
|
|
|
|
.name = TYPE_MACIO,
|
2011-12-08 04:34:16 +01:00
|
|
|
.parent = TYPE_PCI_DEVICE,
|
|
|
|
.instance_size = sizeof(MacIOState),
|
2013-01-24 00:03:55 +01:00
|
|
|
.instance_init = macio_instance_init,
|
2013-01-24 00:03:57 +01:00
|
|
|
.abstract = true,
|
2011-12-08 04:34:16 +01:00
|
|
|
.class_init = macio_class_init,
|
2011-12-21 23:14:09 +01:00
|
|
|
};
|
|
|
|
|
2012-02-09 15:20:55 +01:00
|
|
|
static void macio_register_types(void)
|
2011-12-21 23:14:09 +01:00
|
|
|
{
|
2013-01-24 00:03:55 +01:00
|
|
|
type_register_static(&macio_type_info);
|
2013-01-24 00:03:57 +01:00
|
|
|
type_register_static(&macio_oldworld_type_info);
|
|
|
|
type_register_static(&macio_newworld_type_info);
|
2011-12-21 23:14:09 +01:00
|
|
|
}
|
|
|
|
|
2012-02-09 15:20:55 +01:00
|
|
|
type_init(macio_register_types)
|
2011-12-21 23:14:09 +01:00
|
|
|
|
2013-01-24 00:03:57 +01:00
|
|
|
void macio_init(PCIDevice *d,
|
2013-01-24 00:04:01 +01:00
|
|
|
MemoryRegion *pic_mem,
|
2013-01-24 00:03:57 +01:00
|
|
|
MemoryRegion *escc_mem)
|
2007-10-29 00:42:18 +01:00
|
|
|
{
|
2013-01-24 00:03:57 +01:00
|
|
|
MacIOState *macio_state = MACIO(d);
|
2007-10-29 00:42:18 +01:00
|
|
|
|
2011-08-08 15:09:17 +02:00
|
|
|
macio_state->pic_mem = pic_mem;
|
|
|
|
macio_state->escc_mem = escc_mem;
|
2007-10-29 00:42:18 +01:00
|
|
|
/* Note: this code is strongly inspirated from the corresponding code
|
|
|
|
in PearPC */
|
2014-07-13 22:31:53 +02:00
|
|
|
qdev_prop_set_uint64(DEVICE(&macio_state->cuda), "frequency",
|
|
|
|
macio_state->frequency);
|
2009-01-26 16:37:35 +01:00
|
|
|
|
2013-01-24 00:03:56 +01:00
|
|
|
qdev_init_nofail(DEVICE(d));
|
2007-10-29 00:42:18 +01:00
|
|
|
}
|