2010-06-29 04:48:55 +02:00
|
|
|
/*
|
|
|
|
* bonito north bridge support
|
|
|
|
*
|
|
|
|
* Copyright (c) 2008 yajin (yajin@vm-kernel.org)
|
|
|
|
* Copyright (c) 2010 Huacai Chen (zltjiangshi@gmail.com)
|
|
|
|
*
|
|
|
|
* This code is licensed under the GNU GPL v2.
|
2012-01-13 17:44:23 +01:00
|
|
|
*
|
|
|
|
* Contributions after 2012-01-13 are licensed under the terms of the
|
|
|
|
* GNU GPL, version 2 or (at your option) any later version.
|
2010-06-29 04:48:55 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
2020-04-26 12:16:37 +02:00
|
|
|
* fuloong 2e mini pc has a bonito north bridge.
|
2010-06-29 04:48:55 +02:00
|
|
|
*/
|
|
|
|
|
2019-12-06 14:58:07 +01:00
|
|
|
/*
|
|
|
|
* what is the meaning of devfn in qemu and IDSEL in bonito northbridge?
|
2010-06-29 04:48:55 +02:00
|
|
|
*
|
|
|
|
* devfn pci_slot<<3 + funno
|
|
|
|
* one pci bus can have 32 devices and each device can have 8 functions.
|
|
|
|
*
|
|
|
|
* In bonito north bridge, pci slot = IDSEL bit - 12.
|
|
|
|
* For example, PCI_IDSEL_VIA686B = 17,
|
|
|
|
* pci slot = 17-12=5
|
|
|
|
*
|
|
|
|
* so
|
|
|
|
* VT686B_FUN0's devfn = (5<<3)+0
|
|
|
|
* VT686B_FUN1's devfn = (5<<3)+1
|
|
|
|
*
|
|
|
|
* qemu also uses pci address for north bridge to access pci config register.
|
|
|
|
* bus_no [23:16]
|
|
|
|
* dev_no [15:11]
|
|
|
|
* fun_no [10:8]
|
|
|
|
* reg_no [7:2]
|
|
|
|
*
|
|
|
|
* so function bonito_sbridge_pciaddr for the translation from
|
|
|
|
* north bridge address to pci address.
|
|
|
|
*/
|
|
|
|
|
2016-01-26 19:17:15 +01:00
|
|
|
#include "qemu/osdep.h"
|
2020-05-10 21:42:11 +02:00
|
|
|
#include "qemu/units.h"
|
qdev: Convert uses of qdev_create() with Coccinelle
This is the transformation explained in the commit before previous.
Takes care of just one pattern that needs conversion. More to come in
this series.
Coccinelle script:
@ depends on !(file in "hw/arm/highbank.c")@
expression bus, type_name, dev, expr;
@@
- dev = qdev_create(bus, type_name);
+ dev = qdev_new(type_name);
... when != dev = expr
- qdev_init_nofail(dev);
+ qdev_realize_and_unref(dev, bus, &error_fatal);
@@
expression bus, type_name, dev, expr;
identifier DOWN;
@@
- dev = DOWN(qdev_create(bus, type_name));
+ dev = DOWN(qdev_new(type_name));
... when != dev = expr
- qdev_init_nofail(DEVICE(dev));
+ qdev_realize_and_unref(DEVICE(dev), bus, &error_fatal);
@@
expression bus, type_name, expr;
identifier dev;
@@
- DeviceState *dev = qdev_create(bus, type_name);
+ DeviceState *dev = qdev_new(type_name);
... when != dev = expr
- qdev_init_nofail(dev);
+ qdev_realize_and_unref(dev, bus, &error_fatal);
@@
expression bus, type_name, dev, expr, errp;
symbol true;
@@
- dev = qdev_create(bus, type_name);
+ dev = qdev_new(type_name);
... when != dev = expr
- object_property_set_bool(OBJECT(dev), true, "realized", errp);
+ qdev_realize_and_unref(dev, bus, errp);
@@
expression bus, type_name, expr, errp;
identifier dev;
symbol true;
@@
- DeviceState *dev = qdev_create(bus, type_name);
+ DeviceState *dev = qdev_new(type_name);
... when != dev = expr
- object_property_set_bool(OBJECT(dev), true, "realized", errp);
+ qdev_realize_and_unref(dev, bus, errp);
The first rule exempts hw/arm/highbank.c, because it matches along two
control flow paths there, with different @type_name. Covered by the
next commit's manual conversions.
Missing #include "qapi/error.h" added manually.
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Message-Id: <20200610053247.1583243-10-armbru@redhat.com>
[Conflicts in hw/misc/empty_slot.c and hw/sparc/leon3.c resolved]
2020-06-10 07:31:58 +02:00
|
|
|
#include "qapi/error.h"
|
hw/pci*: Replace fprintf(stderr, "*\n" with error_report()
Replace a large number of the fprintf(stderr, "*\n" calls with
error_report(). The functions were renamed with these commands and then
compiler issues where manually fixed.
find ./* -type f -exec sed -i \
'N;N;N;N;N;N;N;N;N;N;N;N; {s|fprintf(stderr, "\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
{} +
find ./* -type f -exec sed -i \
'N;N;N;N;N;N;N;N;N;N;N; {s|fprintf(stderr, "\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
{} +
find ./* -type f -exec sed -i \
'N;N;N;N;N;N;N;N;N; {s|fprintf(stderr, "\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
{} +
find ./* -type f -exec sed -i \
'N;N;N;N;N;N;N;N; {s|fprintf(stderr, "\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
{} +
find ./* -type f -exec sed -i \
'N;N;N;N;N;N;N; {s|fprintf(stderr, "\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
{} +
find ./* -type f -exec sed -i \
'N;N;N;N;N;N; {s|fprintf(stderr, "\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
{} +
find ./* -type f -exec sed -i \
'N;N;N;N;N; {s|fprintf(stderr, "\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
{} +
find ./* -type f -exec sed -i \
'N;N;N;N; {s|fprintf(stderr, "\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
{} +
find ./* -type f -exec sed -i \
'N;N;N; {s|fprintf(stderr, "\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
{} +
find ./* -type f -exec sed -i \
'N;N; {s|fprintf(stderr, "\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
{} +
find ./* -type f -exec sed -i \
'N; {s|fprintf(stderr, "\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
{} +
Some lines where then manually tweaked to pass checkpatch.
A trailing '.' was removed in hw/pci/pci.c
Signed-off-by: Alistair Francis <alistair.francis@xilinx.com>
Cc: "Michael S. Tsirkin" <mst@redhat.com>
Cc: Marcel Apfelbaum <marcel@redhat.com>
Conversions that aren't followed by exit() dropped, because they might
be inappropriate.
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Message-Id: <20180203084315.20497-9-armbru@redhat.com>
2018-02-03 09:43:09 +01:00
|
|
|
#include "qemu/error-report.h"
|
2013-02-04 15:40:22 +01:00
|
|
|
#include "hw/pci/pci.h"
|
2019-08-12 07:23:42 +02:00
|
|
|
#include "hw/irq.h"
|
2013-02-05 17:06:20 +01:00
|
|
|
#include "hw/mips/mips.h"
|
2013-02-04 15:40:22 +01:00
|
|
|
#include "hw/pci/pci_host.h"
|
2019-08-12 07:23:45 +02:00
|
|
|
#include "migration/vmstate.h"
|
2019-08-12 07:23:38 +02:00
|
|
|
#include "sysemu/reset.h"
|
2019-08-12 07:23:59 +02:00
|
|
|
#include "sysemu/runstate.h"
|
2012-12-17 18:19:49 +01:00
|
|
|
#include "exec/address-spaces.h"
|
2020-05-10 19:26:36 +02:00
|
|
|
#include "hw/misc/unimp.h"
|
2020-05-10 21:36:37 +02:00
|
|
|
#include "hw/registerfields.h"
|
2020-09-03 22:43:22 +02:00
|
|
|
#include "qom/object.h"
|
2010-06-29 04:48:55 +02:00
|
|
|
|
2019-12-06 14:58:07 +01:00
|
|
|
/* #define DEBUG_BONITO */
|
2010-06-29 04:48:55 +02:00
|
|
|
|
|
|
|
#ifdef DEBUG_BONITO
|
2017-11-08 23:56:31 +01:00
|
|
|
#define DPRINTF(fmt, ...) fprintf(stderr, "%s: " fmt, __func__, ##__VA_ARGS__)
|
2010-06-29 04:48:55 +02:00
|
|
|
#else
|
|
|
|
#define DPRINTF(fmt, ...)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* from linux soure code. include/asm-mips/mips-boards/bonito64.h*/
|
|
|
|
#define BONITO_BOOT_BASE 0x1fc00000
|
|
|
|
#define BONITO_BOOT_SIZE 0x00100000
|
2019-12-06 14:58:07 +01:00
|
|
|
#define BONITO_BOOT_TOP (BONITO_BOOT_BASE + BONITO_BOOT_SIZE - 1)
|
2010-06-29 04:48:55 +02:00
|
|
|
#define BONITO_FLASH_BASE 0x1c000000
|
|
|
|
#define BONITO_FLASH_SIZE 0x03000000
|
2019-12-06 14:58:07 +01:00
|
|
|
#define BONITO_FLASH_TOP (BONITO_FLASH_BASE + BONITO_FLASH_SIZE - 1)
|
2010-06-29 04:48:55 +02:00
|
|
|
#define BONITO_SOCKET_BASE 0x1f800000
|
|
|
|
#define BONITO_SOCKET_SIZE 0x00400000
|
2019-12-06 14:58:07 +01:00
|
|
|
#define BONITO_SOCKET_TOP (BONITO_SOCKET_BASE + BONITO_SOCKET_SIZE - 1)
|
2010-06-29 04:48:55 +02:00
|
|
|
#define BONITO_REG_BASE 0x1fe00000
|
|
|
|
#define BONITO_REG_SIZE 0x00040000
|
2019-12-06 14:58:07 +01:00
|
|
|
#define BONITO_REG_TOP (BONITO_REG_BASE + BONITO_REG_SIZE - 1)
|
2010-06-29 04:48:55 +02:00
|
|
|
#define BONITO_DEV_BASE 0x1ff00000
|
|
|
|
#define BONITO_DEV_SIZE 0x00100000
|
2019-12-06 14:58:07 +01:00
|
|
|
#define BONITO_DEV_TOP (BONITO_DEV_BASE + BONITO_DEV_SIZE - 1)
|
2010-06-29 04:48:55 +02:00
|
|
|
#define BONITO_PCILO_BASE 0x10000000
|
|
|
|
#define BONITO_PCILO_BASE_VA 0xb0000000
|
|
|
|
#define BONITO_PCILO_SIZE 0x0c000000
|
2019-12-06 14:58:07 +01:00
|
|
|
#define BONITO_PCILO_TOP (BONITO_PCILO_BASE + BONITO_PCILO_SIZE - 1)
|
2010-06-29 04:48:55 +02:00
|
|
|
#define BONITO_PCILO0_BASE 0x10000000
|
|
|
|
#define BONITO_PCILO1_BASE 0x14000000
|
|
|
|
#define BONITO_PCILO2_BASE 0x18000000
|
|
|
|
#define BONITO_PCIHI_BASE 0x20000000
|
2020-05-10 21:42:11 +02:00
|
|
|
#define BONITO_PCIHI_SIZE 0x60000000
|
2019-12-06 14:58:07 +01:00
|
|
|
#define BONITO_PCIHI_TOP (BONITO_PCIHI_BASE + BONITO_PCIHI_SIZE - 1)
|
2010-06-29 04:48:55 +02:00
|
|
|
#define BONITO_PCIIO_BASE 0x1fd00000
|
|
|
|
#define BONITO_PCIIO_BASE_VA 0xbfd00000
|
|
|
|
#define BONITO_PCIIO_SIZE 0x00010000
|
2019-12-06 14:58:07 +01:00
|
|
|
#define BONITO_PCIIO_TOP (BONITO_PCIIO_BASE + BONITO_PCIIO_SIZE - 1)
|
2010-06-29 04:48:55 +02:00
|
|
|
#define BONITO_PCICFG_BASE 0x1fe80000
|
|
|
|
#define BONITO_PCICFG_SIZE 0x00080000
|
2019-12-06 14:58:07 +01:00
|
|
|
#define BONITO_PCICFG_TOP (BONITO_PCICFG_BASE + BONITO_PCICFG_SIZE - 1)
|
2010-06-29 04:48:55 +02:00
|
|
|
|
|
|
|
|
|
|
|
#define BONITO_PCICONFIGBASE 0x00
|
|
|
|
#define BONITO_REGBASE 0x100
|
|
|
|
|
2019-12-06 14:58:07 +01:00
|
|
|
#define BONITO_PCICONFIG_BASE (BONITO_PCICONFIGBASE + BONITO_REG_BASE)
|
2010-06-29 04:48:55 +02:00
|
|
|
#define BONITO_PCICONFIG_SIZE (0x100)
|
|
|
|
|
2019-12-06 14:58:07 +01:00
|
|
|
#define BONITO_INTERNAL_REG_BASE (BONITO_REGBASE + BONITO_REG_BASE)
|
2010-06-29 04:48:55 +02:00
|
|
|
#define BONITO_INTERNAL_REG_SIZE (0x70)
|
|
|
|
|
|
|
|
#define BONITO_SPCICONFIG_BASE (BONITO_PCICFG_BASE)
|
|
|
|
#define BONITO_SPCICONFIG_SIZE (BONITO_PCICFG_SIZE)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* 1. Bonito h/w Configuration */
|
|
|
|
/* Power on register */
|
|
|
|
|
|
|
|
#define BONITO_BONPONCFG (0x00 >> 2) /* 0x100 */
|
2020-05-10 21:36:37 +02:00
|
|
|
|
|
|
|
/* PCI configuration register */
|
2010-06-29 04:48:55 +02:00
|
|
|
#define BONITO_BONGENCFG_OFFSET 0x4
|
2019-12-06 14:58:07 +01:00
|
|
|
#define BONITO_BONGENCFG (BONITO_BONGENCFG_OFFSET >> 2) /*0x104 */
|
2020-05-10 21:36:37 +02:00
|
|
|
REG32(BONGENCFG, 0x104)
|
|
|
|
FIELD(BONGENCFG, DEBUGMODE, 0, 1)
|
|
|
|
FIELD(BONGENCFG, SNOOP, 1, 1)
|
|
|
|
FIELD(BONGENCFG, CPUSELFRESET, 2, 1)
|
|
|
|
FIELD(BONGENCFG, BYTESWAP, 6, 1)
|
|
|
|
FIELD(BONGENCFG, UNCACHED, 7, 1)
|
|
|
|
FIELD(BONGENCFG, PREFETCH, 8, 1)
|
|
|
|
FIELD(BONGENCFG, WRITEBEHIND, 9, 1)
|
|
|
|
FIELD(BONGENCFG, PCIQUEUE, 12, 1)
|
2010-06-29 04:48:55 +02:00
|
|
|
|
|
|
|
/* 2. IO & IDE configuration */
|
|
|
|
#define BONITO_IODEVCFG (0x08 >> 2) /* 0x108 */
|
|
|
|
|
|
|
|
/* 3. IO & IDE configuration */
|
|
|
|
#define BONITO_SDCFG (0x0c >> 2) /* 0x10c */
|
|
|
|
|
|
|
|
/* 4. PCI address map control */
|
|
|
|
#define BONITO_PCIMAP (0x10 >> 2) /* 0x110 */
|
|
|
|
#define BONITO_PCIMEMBASECFG (0x14 >> 2) /* 0x114 */
|
|
|
|
#define BONITO_PCIMAP_CFG (0x18 >> 2) /* 0x118 */
|
|
|
|
|
|
|
|
/* 5. ICU & GPIO regs */
|
|
|
|
/* GPIO Regs - r/w */
|
|
|
|
#define BONITO_GPIODATA_OFFSET 0x1c
|
|
|
|
#define BONITO_GPIODATA (BONITO_GPIODATA_OFFSET >> 2) /* 0x11c */
|
|
|
|
#define BONITO_GPIOIE (0x20 >> 2) /* 0x120 */
|
|
|
|
|
|
|
|
/* ICU Configuration Regs - r/w */
|
|
|
|
#define BONITO_INTEDGE (0x24 >> 2) /* 0x124 */
|
|
|
|
#define BONITO_INTSTEER (0x28 >> 2) /* 0x128 */
|
|
|
|
#define BONITO_INTPOL (0x2c >> 2) /* 0x12c */
|
|
|
|
|
|
|
|
/* ICU Enable Regs - IntEn & IntISR are r/o. */
|
|
|
|
#define BONITO_INTENSET (0x30 >> 2) /* 0x130 */
|
|
|
|
#define BONITO_INTENCLR (0x34 >> 2) /* 0x134 */
|
|
|
|
#define BONITO_INTEN (0x38 >> 2) /* 0x138 */
|
|
|
|
#define BONITO_INTISR (0x3c >> 2) /* 0x13c */
|
|
|
|
|
|
|
|
/* PCI mail boxes */
|
|
|
|
#define BONITO_PCIMAIL0_OFFSET 0x40
|
|
|
|
#define BONITO_PCIMAIL1_OFFSET 0x44
|
|
|
|
#define BONITO_PCIMAIL2_OFFSET 0x48
|
|
|
|
#define BONITO_PCIMAIL3_OFFSET 0x4c
|
|
|
|
#define BONITO_PCIMAIL0 (0x40 >> 2) /* 0x140 */
|
|
|
|
#define BONITO_PCIMAIL1 (0x44 >> 2) /* 0x144 */
|
|
|
|
#define BONITO_PCIMAIL2 (0x48 >> 2) /* 0x148 */
|
|
|
|
#define BONITO_PCIMAIL3 (0x4c >> 2) /* 0x14c */
|
|
|
|
|
|
|
|
/* 6. PCI cache */
|
|
|
|
#define BONITO_PCICACHECTRL (0x50 >> 2) /* 0x150 */
|
|
|
|
#define BONITO_PCICACHETAG (0x54 >> 2) /* 0x154 */
|
|
|
|
#define BONITO_PCIBADADDR (0x58 >> 2) /* 0x158 */
|
|
|
|
#define BONITO_PCIMSTAT (0x5c >> 2) /* 0x15c */
|
|
|
|
|
|
|
|
/* 7. other*/
|
|
|
|
#define BONITO_TIMECFG (0x60 >> 2) /* 0x160 */
|
|
|
|
#define BONITO_CPUCFG (0x64 >> 2) /* 0x164 */
|
|
|
|
#define BONITO_DQCFG (0x68 >> 2) /* 0x168 */
|
|
|
|
#define BONITO_MEMSIZE (0x6C >> 2) /* 0x16c */
|
|
|
|
|
|
|
|
#define BONITO_REGS (0x70 >> 2)
|
|
|
|
|
|
|
|
/* PCI config for south bridge. type 0 */
|
|
|
|
#define BONITO_PCICONF_IDSEL_MASK 0xfffff800 /* [31:11] */
|
|
|
|
#define BONITO_PCICONF_IDSEL_OFFSET 11
|
|
|
|
#define BONITO_PCICONF_FUN_MASK 0x700 /* [10:8] */
|
|
|
|
#define BONITO_PCICONF_FUN_OFFSET 8
|
|
|
|
#define BONITO_PCICONF_REG_MASK 0xFC
|
|
|
|
#define BONITO_PCICONF_REG_OFFSET 0
|
|
|
|
|
|
|
|
|
|
|
|
/* idsel BIT = pci slot number +12 */
|
|
|
|
#define PCI_SLOT_BASE 12
|
|
|
|
#define PCI_IDSEL_VIA686B_BIT (17)
|
2019-12-06 14:58:07 +01:00
|
|
|
#define PCI_IDSEL_VIA686B (1 << PCI_IDSEL_VIA686B_BIT)
|
2010-06-29 04:48:55 +02:00
|
|
|
|
2019-12-06 14:58:07 +01:00
|
|
|
#define PCI_ADDR(busno , devno , funno , regno) \
|
2020-10-11 17:18:59 +02:00
|
|
|
((PCI_BUILD_BDF(busno, PCI_DEVFN(devno , funno)) << 8) + (regno))
|
2010-06-29 04:48:55 +02:00
|
|
|
|
2012-08-20 19:07:58 +02:00
|
|
|
typedef struct BonitoState BonitoState;
|
2010-06-29 04:48:55 +02:00
|
|
|
|
2020-09-03 22:43:22 +02:00
|
|
|
struct PCIBonitoState {
|
2010-06-29 04:48:55 +02:00
|
|
|
PCIDevice dev;
|
2012-08-20 19:07:58 +02:00
|
|
|
|
2010-06-29 04:48:55 +02:00
|
|
|
BonitoState *pcihost;
|
|
|
|
uint32_t regs[BONITO_REGS];
|
|
|
|
|
|
|
|
struct bonldma {
|
|
|
|
uint32_t ldmactrl;
|
|
|
|
uint32_t ldmastat;
|
|
|
|
uint32_t ldmaaddr;
|
|
|
|
uint32_t ldmago;
|
|
|
|
} bonldma;
|
|
|
|
|
|
|
|
/* Based at 1fe00300, bonito Copier */
|
|
|
|
struct boncop {
|
|
|
|
uint32_t copctrl;
|
|
|
|
uint32_t copstat;
|
|
|
|
uint32_t coppaddr;
|
|
|
|
uint32_t copgo;
|
|
|
|
} boncop;
|
|
|
|
|
|
|
|
/* Bonito registers */
|
2011-11-24 14:31:18 +01:00
|
|
|
MemoryRegion iomem;
|
2011-11-24 14:31:21 +01:00
|
|
|
MemoryRegion iomem_ldma;
|
2011-11-24 14:31:22 +01:00
|
|
|
MemoryRegion iomem_cop;
|
2013-07-22 15:54:21 +02:00
|
|
|
MemoryRegion bonito_pciio;
|
|
|
|
MemoryRegion bonito_localio;
|
2010-06-29 04:48:55 +02:00
|
|
|
|
2020-09-03 22:43:22 +02:00
|
|
|
};
|
|
|
|
typedef struct PCIBonitoState PCIBonitoState;
|
2010-06-29 04:48:55 +02:00
|
|
|
|
2012-08-20 19:07:58 +02:00
|
|
|
struct BonitoState {
|
|
|
|
PCIHostState parent_obj;
|
|
|
|
qemu_irq *pic;
|
|
|
|
PCIBonitoState *pci_dev;
|
2019-02-21 13:25:00 +01:00
|
|
|
MemoryRegion pci_mem;
|
2012-08-20 19:07:58 +02:00
|
|
|
};
|
2010-06-29 04:48:55 +02:00
|
|
|
|
2016-01-05 11:57:49 +01:00
|
|
|
#define TYPE_BONITO_PCI_HOST_BRIDGE "Bonito-pcihost"
|
2020-09-16 20:25:19 +02:00
|
|
|
OBJECT_DECLARE_SIMPLE_TYPE(BonitoState, BONITO_PCI_HOST_BRIDGE)
|
2016-01-05 11:57:49 +01:00
|
|
|
|
|
|
|
#define TYPE_PCI_BONITO "Bonito"
|
2020-09-16 20:25:19 +02:00
|
|
|
OBJECT_DECLARE_SIMPLE_TYPE(PCIBonitoState, PCI_BONITO)
|
2016-01-05 11:57:49 +01:00
|
|
|
|
2012-10-23 12:30:10 +02:00
|
|
|
static void bonito_writel(void *opaque, hwaddr addr,
|
2011-11-24 14:31:18 +01:00
|
|
|
uint64_t val, unsigned size)
|
2010-06-29 04:48:55 +02:00
|
|
|
{
|
|
|
|
PCIBonitoState *s = opaque;
|
|
|
|
uint32_t saddr;
|
|
|
|
int reset = 0;
|
|
|
|
|
2015-04-16 22:11:23 +02:00
|
|
|
saddr = addr >> 2;
|
2010-06-29 04:48:55 +02:00
|
|
|
|
2020-05-10 21:34:11 +02:00
|
|
|
DPRINTF("bonito_writel "TARGET_FMT_plx" val %lx saddr %x\n",
|
2019-12-06 14:58:07 +01:00
|
|
|
addr, val, saddr);
|
2010-06-29 04:48:55 +02:00
|
|
|
switch (saddr) {
|
|
|
|
case BONITO_BONPONCFG:
|
|
|
|
case BONITO_IODEVCFG:
|
|
|
|
case BONITO_SDCFG:
|
|
|
|
case BONITO_PCIMAP:
|
|
|
|
case BONITO_PCIMEMBASECFG:
|
|
|
|
case BONITO_PCIMAP_CFG:
|
|
|
|
case BONITO_GPIODATA:
|
|
|
|
case BONITO_GPIOIE:
|
|
|
|
case BONITO_INTEDGE:
|
|
|
|
case BONITO_INTSTEER:
|
|
|
|
case BONITO_INTPOL:
|
|
|
|
case BONITO_PCIMAIL0:
|
|
|
|
case BONITO_PCIMAIL1:
|
|
|
|
case BONITO_PCIMAIL2:
|
|
|
|
case BONITO_PCIMAIL3:
|
|
|
|
case BONITO_PCICACHECTRL:
|
|
|
|
case BONITO_PCICACHETAG:
|
|
|
|
case BONITO_PCIBADADDR:
|
|
|
|
case BONITO_PCIMSTAT:
|
|
|
|
case BONITO_TIMECFG:
|
|
|
|
case BONITO_CPUCFG:
|
|
|
|
case BONITO_DQCFG:
|
|
|
|
case BONITO_MEMSIZE:
|
|
|
|
s->regs[saddr] = val;
|
|
|
|
break;
|
|
|
|
case BONITO_BONGENCFG:
|
|
|
|
if (!(s->regs[saddr] & 0x04) && (val & 0x04)) {
|
|
|
|
reset = 1; /* bit 2 jump from 0 to 1 cause reset */
|
|
|
|
}
|
|
|
|
s->regs[saddr] = val;
|
|
|
|
if (reset) {
|
2017-05-15 23:41:13 +02:00
|
|
|
qemu_system_reset_request(SHUTDOWN_CAUSE_GUEST_RESET);
|
2010-06-29 04:48:55 +02:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case BONITO_INTENSET:
|
|
|
|
s->regs[BONITO_INTENSET] = val;
|
|
|
|
s->regs[BONITO_INTEN] |= val;
|
|
|
|
break;
|
|
|
|
case BONITO_INTENCLR:
|
|
|
|
s->regs[BONITO_INTENCLR] = val;
|
|
|
|
s->regs[BONITO_INTEN] &= ~val;
|
|
|
|
break;
|
|
|
|
case BONITO_INTEN:
|
|
|
|
case BONITO_INTISR:
|
2011-09-12 22:33:01 +02:00
|
|
|
DPRINTF("write to readonly bonito register %x\n", saddr);
|
2010-06-29 04:48:55 +02:00
|
|
|
break;
|
|
|
|
default:
|
2011-09-12 22:33:01 +02:00
|
|
|
DPRINTF("write to unknown bonito register %x\n", saddr);
|
2010-06-29 04:48:55 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-10-23 12:30:10 +02:00
|
|
|
static uint64_t bonito_readl(void *opaque, hwaddr addr,
|
2011-11-24 14:31:18 +01:00
|
|
|
unsigned size)
|
2010-06-29 04:48:55 +02:00
|
|
|
{
|
|
|
|
PCIBonitoState *s = opaque;
|
|
|
|
uint32_t saddr;
|
|
|
|
|
2015-04-16 22:11:23 +02:00
|
|
|
saddr = addr >> 2;
|
2010-06-29 04:48:55 +02:00
|
|
|
|
2011-09-12 22:33:01 +02:00
|
|
|
DPRINTF("bonito_readl "TARGET_FMT_plx"\n", addr);
|
2010-06-29 04:48:55 +02:00
|
|
|
switch (saddr) {
|
|
|
|
case BONITO_INTISR:
|
|
|
|
return s->regs[saddr];
|
|
|
|
default:
|
|
|
|
return s->regs[saddr];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-11-24 14:31:18 +01:00
|
|
|
static const MemoryRegionOps bonito_ops = {
|
|
|
|
.read = bonito_readl,
|
|
|
|
.write = bonito_writel,
|
|
|
|
.endianness = DEVICE_NATIVE_ENDIAN,
|
|
|
|
.valid = {
|
|
|
|
.min_access_size = 4,
|
|
|
|
.max_access_size = 4,
|
|
|
|
},
|
2010-06-29 04:48:55 +02:00
|
|
|
};
|
|
|
|
|
2012-10-23 12:30:10 +02:00
|
|
|
static void bonito_pciconf_writel(void *opaque, hwaddr addr,
|
2011-11-24 14:31:19 +01:00
|
|
|
uint64_t val, unsigned size)
|
2010-06-29 04:48:55 +02:00
|
|
|
{
|
|
|
|
PCIBonitoState *s = opaque;
|
2012-08-20 19:07:58 +02:00
|
|
|
PCIDevice *d = PCI_DEVICE(s);
|
2010-06-29 04:48:55 +02:00
|
|
|
|
2020-05-10 21:34:11 +02:00
|
|
|
DPRINTF("bonito_pciconf_writel "TARGET_FMT_plx" val %lx\n", addr, val);
|
2012-08-20 19:07:58 +02:00
|
|
|
d->config_write(d, addr, val, 4);
|
2010-06-29 04:48:55 +02:00
|
|
|
}
|
|
|
|
|
2012-10-23 12:30:10 +02:00
|
|
|
static uint64_t bonito_pciconf_readl(void *opaque, hwaddr addr,
|
2011-11-24 14:31:19 +01:00
|
|
|
unsigned size)
|
2010-06-29 04:48:55 +02:00
|
|
|
{
|
|
|
|
|
|
|
|
PCIBonitoState *s = opaque;
|
2012-08-20 19:07:58 +02:00
|
|
|
PCIDevice *d = PCI_DEVICE(s);
|
2010-06-29 04:48:55 +02:00
|
|
|
|
|
|
|
DPRINTF("bonito_pciconf_readl "TARGET_FMT_plx"\n", addr);
|
2012-08-20 19:07:58 +02:00
|
|
|
return d->config_read(d, addr, 4);
|
2010-06-29 04:48:55 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* north bridge PCI configure space. 0x1fe0 0000 - 0x1fe0 00ff */
|
|
|
|
|
2011-11-24 14:31:19 +01:00
|
|
|
static const MemoryRegionOps bonito_pciconf_ops = {
|
|
|
|
.read = bonito_pciconf_readl,
|
|
|
|
.write = bonito_pciconf_writel,
|
|
|
|
.endianness = DEVICE_NATIVE_ENDIAN,
|
|
|
|
.valid = {
|
|
|
|
.min_access_size = 4,
|
|
|
|
.max_access_size = 4,
|
|
|
|
},
|
2010-06-29 04:48:55 +02:00
|
|
|
};
|
|
|
|
|
2012-10-23 12:30:10 +02:00
|
|
|
static uint64_t bonito_ldma_readl(void *opaque, hwaddr addr,
|
2011-11-24 14:31:21 +01:00
|
|
|
unsigned size)
|
2010-06-29 04:48:55 +02:00
|
|
|
{
|
|
|
|
uint32_t val;
|
|
|
|
PCIBonitoState *s = opaque;
|
|
|
|
|
2015-07-30 17:33:42 +02:00
|
|
|
if (addr >= sizeof(s->bonldma)) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2019-12-06 14:58:07 +01:00
|
|
|
val = ((uint32_t *)(&s->bonldma))[addr / sizeof(uint32_t)];
|
2010-06-29 04:48:55 +02:00
|
|
|
|
|
|
|
return val;
|
|
|
|
}
|
|
|
|
|
2012-10-23 12:30:10 +02:00
|
|
|
static void bonito_ldma_writel(void *opaque, hwaddr addr,
|
2011-11-24 14:31:21 +01:00
|
|
|
uint64_t val, unsigned size)
|
2010-06-29 04:48:55 +02:00
|
|
|
{
|
|
|
|
PCIBonitoState *s = opaque;
|
|
|
|
|
2015-07-30 17:33:42 +02:00
|
|
|
if (addr >= sizeof(s->bonldma)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2019-12-06 14:58:07 +01:00
|
|
|
((uint32_t *)(&s->bonldma))[addr / sizeof(uint32_t)] = val & 0xffffffff;
|
2010-06-29 04:48:55 +02:00
|
|
|
}
|
|
|
|
|
2011-11-24 14:31:21 +01:00
|
|
|
static const MemoryRegionOps bonito_ldma_ops = {
|
|
|
|
.read = bonito_ldma_readl,
|
|
|
|
.write = bonito_ldma_writel,
|
|
|
|
.endianness = DEVICE_NATIVE_ENDIAN,
|
|
|
|
.valid = {
|
|
|
|
.min_access_size = 4,
|
|
|
|
.max_access_size = 4,
|
|
|
|
},
|
2010-06-29 04:48:55 +02:00
|
|
|
};
|
|
|
|
|
2012-10-23 12:30:10 +02:00
|
|
|
static uint64_t bonito_cop_readl(void *opaque, hwaddr addr,
|
2011-11-24 14:31:22 +01:00
|
|
|
unsigned size)
|
2010-06-29 04:48:55 +02:00
|
|
|
{
|
|
|
|
uint32_t val;
|
|
|
|
PCIBonitoState *s = opaque;
|
|
|
|
|
2015-07-30 17:33:42 +02:00
|
|
|
if (addr >= sizeof(s->boncop)) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2019-12-06 14:58:07 +01:00
|
|
|
val = ((uint32_t *)(&s->boncop))[addr / sizeof(uint32_t)];
|
2010-06-29 04:48:55 +02:00
|
|
|
|
|
|
|
return val;
|
|
|
|
}
|
|
|
|
|
2012-10-23 12:30:10 +02:00
|
|
|
static void bonito_cop_writel(void *opaque, hwaddr addr,
|
2011-11-24 14:31:22 +01:00
|
|
|
uint64_t val, unsigned size)
|
2010-06-29 04:48:55 +02:00
|
|
|
{
|
|
|
|
PCIBonitoState *s = opaque;
|
|
|
|
|
2015-07-30 17:33:42 +02:00
|
|
|
if (addr >= sizeof(s->boncop)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2019-12-06 14:58:07 +01:00
|
|
|
((uint32_t *)(&s->boncop))[addr / sizeof(uint32_t)] = val & 0xffffffff;
|
2010-06-29 04:48:55 +02:00
|
|
|
}
|
|
|
|
|
2011-11-24 14:31:22 +01:00
|
|
|
static const MemoryRegionOps bonito_cop_ops = {
|
|
|
|
.read = bonito_cop_readl,
|
|
|
|
.write = bonito_cop_writel,
|
|
|
|
.endianness = DEVICE_NATIVE_ENDIAN,
|
|
|
|
.valid = {
|
|
|
|
.min_access_size = 4,
|
|
|
|
.max_access_size = 4,
|
|
|
|
},
|
2010-06-29 04:48:55 +02:00
|
|
|
};
|
|
|
|
|
2012-10-23 12:30:10 +02:00
|
|
|
static uint32_t bonito_sbridge_pciaddr(void *opaque, hwaddr addr)
|
2010-06-29 04:48:55 +02:00
|
|
|
{
|
|
|
|
PCIBonitoState *s = opaque;
|
2012-08-20 19:08:08 +02:00
|
|
|
PCIHostState *phb = PCI_HOST_BRIDGE(s->pcihost);
|
2010-06-29 04:48:55 +02:00
|
|
|
uint32_t cfgaddr;
|
|
|
|
uint32_t idsel;
|
|
|
|
uint32_t devno;
|
|
|
|
uint32_t funno;
|
|
|
|
uint32_t regno;
|
|
|
|
uint32_t pciaddr;
|
|
|
|
|
|
|
|
/* support type0 pci config */
|
|
|
|
if ((s->regs[BONITO_PCIMAP_CFG] & 0x10000) != 0x0) {
|
|
|
|
return 0xffffffff;
|
|
|
|
}
|
|
|
|
|
|
|
|
cfgaddr = addr & 0xffff;
|
|
|
|
cfgaddr |= (s->regs[BONITO_PCIMAP_CFG] & 0xffff) << 16;
|
|
|
|
|
2019-12-06 14:58:07 +01:00
|
|
|
idsel = (cfgaddr & BONITO_PCICONF_IDSEL_MASK) >>
|
|
|
|
BONITO_PCICONF_IDSEL_OFFSET;
|
2015-03-23 16:29:26 +01:00
|
|
|
devno = ctz32(idsel);
|
2010-06-29 04:48:55 +02:00
|
|
|
funno = (cfgaddr & BONITO_PCICONF_FUN_MASK) >> BONITO_PCICONF_FUN_OFFSET;
|
|
|
|
regno = (cfgaddr & BONITO_PCICONF_REG_MASK) >> BONITO_PCICONF_REG_OFFSET;
|
|
|
|
|
|
|
|
if (idsel == 0) {
|
2020-12-31 21:33:55 +01:00
|
|
|
error_report("error in bonito pci config address 0x" TARGET_FMT_plx
|
|
|
|
",pcimap_cfg=0x%x", addr, s->regs[BONITO_PCIMAP_CFG]);
|
2010-06-29 04:48:55 +02:00
|
|
|
exit(1);
|
|
|
|
}
|
2012-08-20 19:07:58 +02:00
|
|
|
pciaddr = PCI_ADDR(pci_bus_num(phb->bus), devno, funno, regno);
|
2011-09-12 22:33:01 +02:00
|
|
|
DPRINTF("cfgaddr %x pciaddr %x busno %x devno %d funno %d regno %d\n",
|
2012-08-20 19:07:58 +02:00
|
|
|
cfgaddr, pciaddr, pci_bus_num(phb->bus), devno, funno, regno);
|
2010-06-29 04:48:55 +02:00
|
|
|
|
|
|
|
return pciaddr;
|
|
|
|
}
|
|
|
|
|
2018-08-02 17:51:47 +02:00
|
|
|
static void bonito_spciconf_write(void *opaque, hwaddr addr, uint64_t val,
|
|
|
|
unsigned size)
|
2010-06-29 04:48:55 +02:00
|
|
|
{
|
|
|
|
PCIBonitoState *s = opaque;
|
2012-08-20 19:07:58 +02:00
|
|
|
PCIDevice *d = PCI_DEVICE(s);
|
2012-08-20 19:08:08 +02:00
|
|
|
PCIHostState *phb = PCI_HOST_BRIDGE(s->pcihost);
|
2010-06-29 04:48:55 +02:00
|
|
|
uint32_t pciaddr;
|
|
|
|
uint16_t status;
|
|
|
|
|
2020-05-10 21:34:11 +02:00
|
|
|
DPRINTF("bonito_spciconf_write "TARGET_FMT_plx" size %d val %lx\n",
|
2018-08-02 17:51:47 +02:00
|
|
|
addr, size, val);
|
2010-06-29 04:48:55 +02:00
|
|
|
|
|
|
|
pciaddr = bonito_sbridge_pciaddr(s, addr);
|
|
|
|
|
|
|
|
if (pciaddr == 0xffffffff) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* set the pci address in s->config_reg */
|
2012-08-20 19:07:58 +02:00
|
|
|
phb->config_reg = (pciaddr) | (1u << 31);
|
2018-08-02 17:51:47 +02:00
|
|
|
pci_data_write(phb->bus, phb->config_reg, val, size);
|
2010-06-29 04:48:55 +02:00
|
|
|
|
|
|
|
/* clear PCI_STATUS_REC_MASTER_ABORT and PCI_STATUS_REC_TARGET_ABORT */
|
2012-08-20 19:07:58 +02:00
|
|
|
status = pci_get_word(d->config + PCI_STATUS);
|
2010-06-29 04:48:55 +02:00
|
|
|
status &= ~(PCI_STATUS_REC_MASTER_ABORT | PCI_STATUS_REC_TARGET_ABORT);
|
2012-08-20 19:07:58 +02:00
|
|
|
pci_set_word(d->config + PCI_STATUS, status);
|
2010-06-29 04:48:55 +02:00
|
|
|
}
|
|
|
|
|
2018-08-02 17:51:47 +02:00
|
|
|
static uint64_t bonito_spciconf_read(void *opaque, hwaddr addr, unsigned size)
|
2010-06-29 04:48:55 +02:00
|
|
|
{
|
|
|
|
PCIBonitoState *s = opaque;
|
2012-08-20 19:07:58 +02:00
|
|
|
PCIDevice *d = PCI_DEVICE(s);
|
2012-08-20 19:08:08 +02:00
|
|
|
PCIHostState *phb = PCI_HOST_BRIDGE(s->pcihost);
|
2010-06-29 04:48:55 +02:00
|
|
|
uint32_t pciaddr;
|
|
|
|
uint16_t status;
|
|
|
|
|
2018-08-02 17:51:47 +02:00
|
|
|
DPRINTF("bonito_spciconf_read "TARGET_FMT_plx" size %d\n", addr, size);
|
2010-06-29 04:48:55 +02:00
|
|
|
|
|
|
|
pciaddr = bonito_sbridge_pciaddr(s, addr);
|
|
|
|
|
|
|
|
if (pciaddr == 0xffffffff) {
|
2018-08-02 17:51:47 +02:00
|
|
|
return MAKE_64BIT_MASK(0, size * 8);
|
2010-06-29 04:48:55 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* set the pci address in s->config_reg */
|
2012-08-20 19:07:58 +02:00
|
|
|
phb->config_reg = (pciaddr) | (1u << 31);
|
2010-06-29 04:48:55 +02:00
|
|
|
|
|
|
|
/* clear PCI_STATUS_REC_MASTER_ABORT and PCI_STATUS_REC_TARGET_ABORT */
|
2012-08-20 19:07:58 +02:00
|
|
|
status = pci_get_word(d->config + PCI_STATUS);
|
2010-06-29 04:48:55 +02:00
|
|
|
status &= ~(PCI_STATUS_REC_MASTER_ABORT | PCI_STATUS_REC_TARGET_ABORT);
|
2012-08-20 19:07:58 +02:00
|
|
|
pci_set_word(d->config + PCI_STATUS, status);
|
2010-06-29 04:48:55 +02:00
|
|
|
|
2018-08-02 17:51:47 +02:00
|
|
|
return pci_data_read(phb->bus, phb->config_reg, size);
|
2010-06-29 04:48:55 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* south bridge PCI configure space. 0x1fe8 0000 - 0x1fef ffff */
|
2011-11-24 14:31:20 +01:00
|
|
|
static const MemoryRegionOps bonito_spciconf_ops = {
|
2018-08-02 17:51:47 +02:00
|
|
|
.read = bonito_spciconf_read,
|
|
|
|
.write = bonito_spciconf_write,
|
|
|
|
.valid.min_access_size = 1,
|
|
|
|
.valid.max_access_size = 4,
|
|
|
|
.impl.min_access_size = 1,
|
|
|
|
.impl.max_access_size = 4,
|
2011-11-24 14:31:20 +01:00
|
|
|
.endianness = DEVICE_NATIVE_ENDIAN,
|
2010-06-29 04:48:55 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
#define BONITO_IRQ_BASE 32
|
|
|
|
|
|
|
|
static void pci_bonito_set_irq(void *opaque, int irq_num, int level)
|
|
|
|
{
|
2012-08-20 19:07:58 +02:00
|
|
|
BonitoState *s = opaque;
|
|
|
|
qemu_irq *pic = s->pic;
|
|
|
|
PCIBonitoState *bonito_state = s->pci_dev;
|
2010-06-29 04:48:55 +02:00
|
|
|
int internal_irq = irq_num - BONITO_IRQ_BASE;
|
|
|
|
|
2012-08-20 19:07:58 +02:00
|
|
|
if (bonito_state->regs[BONITO_INTEDGE] & (1 << internal_irq)) {
|
2010-06-29 04:48:55 +02:00
|
|
|
qemu_irq_pulse(*pic);
|
|
|
|
} else { /* level triggered */
|
2012-08-20 19:07:58 +02:00
|
|
|
if (bonito_state->regs[BONITO_INTPOL] & (1 << internal_irq)) {
|
2010-06-29 04:48:55 +02:00
|
|
|
qemu_irq_raise(*pic);
|
|
|
|
} else {
|
|
|
|
qemu_irq_lower(*pic);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* map the original irq (0~3) to bonito irq (16~47, but 16~31 are unused) */
|
2019-12-06 14:58:07 +01:00
|
|
|
static int pci_bonito_map_irq(PCIDevice *pci_dev, int irq_num)
|
2010-06-29 04:48:55 +02:00
|
|
|
{
|
|
|
|
int slot;
|
|
|
|
|
2020-10-11 17:04:23 +02:00
|
|
|
slot = PCI_SLOT(pci_dev->devfn);
|
2010-06-29 04:48:55 +02:00
|
|
|
|
|
|
|
switch (slot) {
|
2020-04-26 12:16:37 +02:00
|
|
|
case 5: /* FULOONG2E_VIA_SLOT, SouthBridge, IDE, USB, ACPI, AC97, MC97 */
|
2010-06-29 04:48:55 +02:00
|
|
|
return irq_num % 4 + BONITO_IRQ_BASE;
|
2020-04-26 12:16:37 +02:00
|
|
|
case 6: /* FULOONG2E_ATI_SLOT, VGA */
|
2010-06-29 04:48:55 +02:00
|
|
|
return 4 + BONITO_IRQ_BASE;
|
2020-04-26 12:16:37 +02:00
|
|
|
case 7: /* FULOONG2E_RTL_SLOT, RTL8139 */
|
2010-06-29 04:48:55 +02:00
|
|
|
return 5 + BONITO_IRQ_BASE;
|
|
|
|
case 8 ... 12: /* PCI slot 1 to 4 */
|
|
|
|
return (slot - 8 + irq_num) + 6 + BONITO_IRQ_BASE;
|
|
|
|
default: /* Unknown device, don't do any translation */
|
|
|
|
return irq_num;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void bonito_reset(void *opaque)
|
|
|
|
{
|
|
|
|
PCIBonitoState *s = opaque;
|
2020-05-10 21:36:37 +02:00
|
|
|
uint32_t val = 0;
|
2010-06-29 04:48:55 +02:00
|
|
|
|
|
|
|
/* set the default value of north bridge registers */
|
|
|
|
|
|
|
|
s->regs[BONITO_BONPONCFG] = 0xc40;
|
2020-05-10 21:36:37 +02:00
|
|
|
val = FIELD_DP32(val, BONGENCFG, PCIQUEUE, 1);
|
|
|
|
val = FIELD_DP32(val, BONGENCFG, WRITEBEHIND, 1);
|
|
|
|
val = FIELD_DP32(val, BONGENCFG, PREFETCH, 1);
|
|
|
|
val = FIELD_DP32(val, BONGENCFG, UNCACHED, 1);
|
|
|
|
val = FIELD_DP32(val, BONGENCFG, CPUSELFRESET, 1);
|
|
|
|
s->regs[BONITO_BONGENCFG] = val;
|
|
|
|
|
2010-06-29 04:48:55 +02:00
|
|
|
s->regs[BONITO_IODEVCFG] = 0x2bff8010;
|
|
|
|
s->regs[BONITO_SDCFG] = 0x255e0091;
|
|
|
|
|
|
|
|
s->regs[BONITO_GPIODATA] = 0x1ff;
|
|
|
|
s->regs[BONITO_GPIOIE] = 0x1ff;
|
|
|
|
s->regs[BONITO_DQCFG] = 0x8;
|
|
|
|
s->regs[BONITO_MEMSIZE] = 0x10000000;
|
|
|
|
s->regs[BONITO_PCIMAP] = 0x6140;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const VMStateDescription vmstate_bonito = {
|
|
|
|
.name = "Bonito",
|
|
|
|
.version_id = 1,
|
|
|
|
.minimum_version_id = 1,
|
2014-04-16 16:01:33 +02:00
|
|
|
.fields = (VMStateField[]) {
|
2010-06-29 04:48:55 +02:00
|
|
|
VMSTATE_PCI_DEVICE(dev, PCIBonitoState),
|
|
|
|
VMSTATE_END_OF_LIST()
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2018-10-02 23:25:15 +02:00
|
|
|
static void bonito_pcihost_realize(DeviceState *dev, Error **errp)
|
2010-06-29 04:48:55 +02:00
|
|
|
{
|
2012-08-20 19:08:08 +02:00
|
|
|
PCIHostState *phb = PCI_HOST_BRIDGE(dev);
|
2019-02-21 13:25:00 +01:00
|
|
|
BonitoState *bs = BONITO_PCI_HOST_BRIDGE(dev);
|
2020-05-10 21:42:11 +02:00
|
|
|
MemoryRegion *pcimem_lo_alias = g_new(MemoryRegion, 3);
|
2012-08-20 19:07:58 +02:00
|
|
|
|
2020-05-10 21:42:11 +02:00
|
|
|
memory_region_init(&bs->pci_mem, OBJECT(dev), "pci.mem", BONITO_PCIHI_SIZE);
|
2020-05-12 09:00:20 +02:00
|
|
|
phb->bus = pci_register_root_bus(dev, "pci",
|
2017-11-29 09:46:22 +01:00
|
|
|
pci_bonito_set_irq, pci_bonito_map_irq,
|
2019-02-21 13:25:00 +01:00
|
|
|
dev, &bs->pci_mem, get_system_io(),
|
2020-10-12 08:36:41 +02:00
|
|
|
PCI_DEVFN(5, 0), 32, TYPE_PCI_BUS);
|
2020-05-10 21:42:11 +02:00
|
|
|
|
|
|
|
for (size_t i = 0; i < 3; i++) {
|
|
|
|
char *name = g_strdup_printf("pci.lomem%zu", i);
|
|
|
|
|
|
|
|
memory_region_init_alias(&pcimem_lo_alias[i], NULL, name,
|
|
|
|
&bs->pci_mem, i * 64 * MiB, 64 * MiB);
|
|
|
|
memory_region_add_subregion(get_system_memory(),
|
|
|
|
BONITO_PCILO_BASE + i * 64 * MiB,
|
|
|
|
&pcimem_lo_alias[i]);
|
|
|
|
g_free(name);
|
|
|
|
}
|
|
|
|
|
|
|
|
create_unimplemented_device("pci.io", BONITO_PCIIO_BASE, 1 * MiB);
|
2010-06-29 04:48:55 +02:00
|
|
|
}
|
|
|
|
|
2015-01-19 15:52:30 +01:00
|
|
|
static void bonito_realize(PCIDevice *dev, Error **errp)
|
2010-06-29 04:48:55 +02:00
|
|
|
{
|
2016-01-05 11:57:49 +01:00
|
|
|
PCIBonitoState *s = PCI_BONITO(dev);
|
2012-08-20 19:07:58 +02:00
|
|
|
SysBusDevice *sysbus = SYS_BUS_DEVICE(s->pcihost);
|
2012-08-20 19:08:08 +02:00
|
|
|
PCIHostState *phb = PCI_HOST_BRIDGE(s->pcihost);
|
2020-05-10 21:42:11 +02:00
|
|
|
BonitoState *bs = BONITO_PCI_HOST_BRIDGE(s->pcihost);
|
|
|
|
MemoryRegion *pcimem_alias = g_new(MemoryRegion, 1);
|
2010-06-29 04:48:55 +02:00
|
|
|
|
2019-12-06 14:58:07 +01:00
|
|
|
/*
|
|
|
|
* Bonito North Bridge, built on FPGA,
|
|
|
|
* VENDOR_ID/DEVICE_ID are "undefined"
|
|
|
|
*/
|
2010-06-29 04:48:55 +02:00
|
|
|
pci_config_set_prog_interface(dev->config, 0x00);
|
|
|
|
|
|
|
|
/* set the north bridge register mapping */
|
2013-06-07 03:25:08 +02:00
|
|
|
memory_region_init_io(&s->iomem, OBJECT(s), &bonito_ops, s,
|
2011-11-24 14:31:18 +01:00
|
|
|
"north-bridge-register", BONITO_INTERNAL_REG_SIZE);
|
2011-11-27 10:38:10 +01:00
|
|
|
sysbus_init_mmio(sysbus, &s->iomem);
|
2011-11-24 14:31:18 +01:00
|
|
|
sysbus_mmio_map(sysbus, 0, BONITO_INTERNAL_REG_BASE);
|
2010-06-29 04:48:55 +02:00
|
|
|
|
|
|
|
/* set the north bridge pci configure mapping */
|
2013-06-07 03:25:08 +02:00
|
|
|
memory_region_init_io(&phb->conf_mem, OBJECT(s), &bonito_pciconf_ops, s,
|
2011-11-24 14:31:19 +01:00
|
|
|
"north-bridge-pci-config", BONITO_PCICONFIG_SIZE);
|
2012-08-20 19:07:58 +02:00
|
|
|
sysbus_init_mmio(sysbus, &phb->conf_mem);
|
2011-11-24 14:31:19 +01:00
|
|
|
sysbus_mmio_map(sysbus, 1, BONITO_PCICONFIG_BASE);
|
2010-06-29 04:48:55 +02:00
|
|
|
|
|
|
|
/* set the south bridge pci configure mapping */
|
2013-06-07 03:25:08 +02:00
|
|
|
memory_region_init_io(&phb->data_mem, OBJECT(s), &bonito_spciconf_ops, s,
|
2011-11-24 14:31:20 +01:00
|
|
|
"south-bridge-pci-config", BONITO_SPCICONFIG_SIZE);
|
2012-08-20 19:07:58 +02:00
|
|
|
sysbus_init_mmio(sysbus, &phb->data_mem);
|
2011-11-24 14:31:20 +01:00
|
|
|
sysbus_mmio_map(sysbus, 2, BONITO_SPCICONFIG_BASE);
|
2010-06-29 04:48:55 +02:00
|
|
|
|
2020-05-10 19:26:36 +02:00
|
|
|
create_unimplemented_device("bonito", BONITO_REG_BASE, BONITO_REG_SIZE);
|
|
|
|
|
2013-06-07 03:25:08 +02:00
|
|
|
memory_region_init_io(&s->iomem_ldma, OBJECT(s), &bonito_ldma_ops, s,
|
2011-11-24 14:31:21 +01:00
|
|
|
"ldma", 0x100);
|
2011-11-27 10:38:10 +01:00
|
|
|
sysbus_init_mmio(sysbus, &s->iomem_ldma);
|
2020-05-10 19:25:18 +02:00
|
|
|
sysbus_mmio_map(sysbus, 3, 0x1fe00200);
|
2010-06-29 04:48:55 +02:00
|
|
|
|
2020-05-10 21:42:11 +02:00
|
|
|
/* PCI copier */
|
2013-06-07 03:25:08 +02:00
|
|
|
memory_region_init_io(&s->iomem_cop, OBJECT(s), &bonito_cop_ops, s,
|
2011-11-24 14:31:22 +01:00
|
|
|
"cop", 0x100);
|
2011-11-27 10:38:10 +01:00
|
|
|
sysbus_init_mmio(sysbus, &s->iomem_cop);
|
2020-05-10 19:25:18 +02:00
|
|
|
sysbus_mmio_map(sysbus, 4, 0x1fe00300);
|
2010-06-29 04:48:55 +02:00
|
|
|
|
2020-05-10 21:46:43 +02:00
|
|
|
create_unimplemented_device("ROMCS", BONITO_FLASH_BASE, 60 * MiB);
|
|
|
|
|
2010-06-29 04:48:55 +02:00
|
|
|
/* Map PCI IO Space 0x1fd0 0000 - 0x1fd1 0000 */
|
2013-07-22 15:54:21 +02:00
|
|
|
memory_region_init_alias(&s->bonito_pciio, OBJECT(s), "isa_mmio",
|
|
|
|
get_system_io(), 0, BONITO_PCIIO_SIZE);
|
|
|
|
sysbus_init_mmio(sysbus, &s->bonito_pciio);
|
|
|
|
sysbus_mmio_map(sysbus, 5, BONITO_PCIIO_BASE);
|
2010-06-29 04:48:55 +02:00
|
|
|
|
|
|
|
/* add pci local io mapping */
|
2020-05-10 21:46:43 +02:00
|
|
|
|
|
|
|
memory_region_init_alias(&s->bonito_localio, OBJECT(s), "IOCS[0]",
|
|
|
|
get_system_io(), 0, 256 * KiB);
|
2013-07-22 15:54:21 +02:00
|
|
|
sysbus_init_mmio(sysbus, &s->bonito_localio);
|
|
|
|
sysbus_mmio_map(sysbus, 6, BONITO_DEV_BASE);
|
2020-05-10 21:46:43 +02:00
|
|
|
create_unimplemented_device("IOCS[1]", BONITO_DEV_BASE + 1 * 256 * KiB,
|
|
|
|
256 * KiB);
|
|
|
|
create_unimplemented_device("IOCS[2]", BONITO_DEV_BASE + 2 * 256 * KiB,
|
|
|
|
256 * KiB);
|
|
|
|
create_unimplemented_device("IOCS[3]", BONITO_DEV_BASE + 3 * 256 * KiB,
|
|
|
|
256 * KiB);
|
2010-06-29 04:48:55 +02:00
|
|
|
|
2020-05-10 21:42:11 +02:00
|
|
|
memory_region_init_alias(pcimem_alias, NULL, "pci.mem.alias",
|
|
|
|
&bs->pci_mem, 0, BONITO_PCIHI_SIZE);
|
|
|
|
memory_region_add_subregion(get_system_memory(),
|
|
|
|
BONITO_PCIHI_BASE, pcimem_alias);
|
|
|
|
create_unimplemented_device("PCI_2",
|
|
|
|
(hwaddr)BONITO_PCIHI_BASE + BONITO_PCIHI_SIZE,
|
|
|
|
2 * GiB);
|
|
|
|
|
2010-06-29 04:48:55 +02:00
|
|
|
/* set the default value of north bridge pci config */
|
|
|
|
pci_set_word(dev->config + PCI_COMMAND, 0x0000);
|
|
|
|
pci_set_word(dev->config + PCI_STATUS, 0x0000);
|
|
|
|
pci_set_word(dev->config + PCI_SUBSYSTEM_VENDOR_ID, 0x0000);
|
|
|
|
pci_set_word(dev->config + PCI_SUBSYSTEM_ID, 0x0000);
|
|
|
|
|
|
|
|
pci_set_byte(dev->config + PCI_INTERRUPT_LINE, 0x00);
|
2020-12-31 22:04:13 +01:00
|
|
|
pci_config_set_interrupt_pin(dev->config, 0x01); /* interrupt pin A */
|
|
|
|
|
2010-06-29 04:48:55 +02:00
|
|
|
pci_set_byte(dev->config + PCI_MIN_GNT, 0x3c);
|
|
|
|
pci_set_byte(dev->config + PCI_MAX_LAT, 0x00);
|
|
|
|
|
|
|
|
qemu_register_reset(bonito_reset, s);
|
|
|
|
}
|
|
|
|
|
|
|
|
PCIBus *bonito_init(qemu_irq *pic)
|
|
|
|
{
|
|
|
|
DeviceState *dev;
|
|
|
|
BonitoState *pcihost;
|
2012-08-20 19:07:58 +02:00
|
|
|
PCIHostState *phb;
|
2010-06-29 04:48:55 +02:00
|
|
|
PCIBonitoState *s;
|
|
|
|
PCIDevice *d;
|
|
|
|
|
qdev: Convert uses of qdev_create() with Coccinelle
This is the transformation explained in the commit before previous.
Takes care of just one pattern that needs conversion. More to come in
this series.
Coccinelle script:
@ depends on !(file in "hw/arm/highbank.c")@
expression bus, type_name, dev, expr;
@@
- dev = qdev_create(bus, type_name);
+ dev = qdev_new(type_name);
... when != dev = expr
- qdev_init_nofail(dev);
+ qdev_realize_and_unref(dev, bus, &error_fatal);
@@
expression bus, type_name, dev, expr;
identifier DOWN;
@@
- dev = DOWN(qdev_create(bus, type_name));
+ dev = DOWN(qdev_new(type_name));
... when != dev = expr
- qdev_init_nofail(DEVICE(dev));
+ qdev_realize_and_unref(DEVICE(dev), bus, &error_fatal);
@@
expression bus, type_name, expr;
identifier dev;
@@
- DeviceState *dev = qdev_create(bus, type_name);
+ DeviceState *dev = qdev_new(type_name);
... when != dev = expr
- qdev_init_nofail(dev);
+ qdev_realize_and_unref(dev, bus, &error_fatal);
@@
expression bus, type_name, dev, expr, errp;
symbol true;
@@
- dev = qdev_create(bus, type_name);
+ dev = qdev_new(type_name);
... when != dev = expr
- object_property_set_bool(OBJECT(dev), true, "realized", errp);
+ qdev_realize_and_unref(dev, bus, errp);
@@
expression bus, type_name, expr, errp;
identifier dev;
symbol true;
@@
- DeviceState *dev = qdev_create(bus, type_name);
+ DeviceState *dev = qdev_new(type_name);
... when != dev = expr
- object_property_set_bool(OBJECT(dev), true, "realized", errp);
+ qdev_realize_and_unref(dev, bus, errp);
The first rule exempts hw/arm/highbank.c, because it matches along two
control flow paths there, with different @type_name. Covered by the
next commit's manual conversions.
Missing #include "qapi/error.h" added manually.
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Message-Id: <20200610053247.1583243-10-armbru@redhat.com>
[Conflicts in hw/misc/empty_slot.c and hw/sparc/leon3.c resolved]
2020-06-10 07:31:58 +02:00
|
|
|
dev = qdev_new(TYPE_BONITO_PCI_HOST_BRIDGE);
|
2012-08-20 19:08:08 +02:00
|
|
|
phb = PCI_HOST_BRIDGE(dev);
|
2012-08-20 19:07:58 +02:00
|
|
|
pcihost = BONITO_PCI_HOST_BRIDGE(dev);
|
|
|
|
pcihost->pic = pic;
|
sysbus: Convert to sysbus_realize() etc. with Coccinelle
Convert from qdev_realize(), qdev_realize_and_unref() with null @bus
argument to sysbus_realize(), sysbus_realize_and_unref().
Coccinelle script:
@@
expression dev, errp;
@@
- qdev_realize(DEVICE(dev), NULL, errp);
+ sysbus_realize(SYS_BUS_DEVICE(dev), errp);
@@
expression sysbus_dev, dev, errp;
@@
+ sysbus_dev = SYS_BUS_DEVICE(dev);
- qdev_realize_and_unref(dev, NULL, errp);
+ sysbus_realize_and_unref(sysbus_dev, errp);
- sysbus_dev = SYS_BUS_DEVICE(dev);
@@
expression sysbus_dev, dev, errp;
expression expr;
@@
sysbus_dev = SYS_BUS_DEVICE(dev);
... when != dev = expr;
- qdev_realize_and_unref(dev, NULL, errp);
+ sysbus_realize_and_unref(sysbus_dev, errp);
@@
expression dev, errp;
@@
- qdev_realize_and_unref(DEVICE(dev), NULL, errp);
+ sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), errp);
@@
expression dev, errp;
@@
- qdev_realize_and_unref(dev, NULL, errp);
+ sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), errp);
Whitespace changes minimized manually.
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Acked-by: Alistair Francis <alistair.francis@wdc.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Message-Id: <20200610053247.1583243-46-armbru@redhat.com>
[Conflicts in hw/misc/empty_slot.c and hw/sparc/leon3.c resolved]
2020-06-10 07:32:34 +02:00
|
|
|
sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal);
|
2010-06-29 04:48:55 +02:00
|
|
|
|
pci: Convert uses of pci_create() etc. with Coccinelle
Replace
dev = pci_create(bus, type_name);
...
qdev_init_nofail(dev);
by
dev = pci_new(type_name);
...
pci_realize_and_unref(dev, bus, &error_fatal);
and similarly for pci_create_multifunction().
Recent commit "qdev: New qdev_new(), qdev_realize(), etc." explains
why.
Coccinelle script:
@@
expression dev, bus, expr;
expression list args;
@@
- dev = pci_create(bus, args);
+ dev = pci_new(args);
... when != dev = expr
- qdev_init_nofail(&dev->qdev);
+ pci_realize_and_unref(dev, bus, &error_fatal);
@@
expression dev, bus, expr;
expression list args;
expression d;
@@
- dev = pci_create(bus, args);
+ dev = pci_new(args);
(
d = &dev->qdev;
|
d = DEVICE(dev);
)
... when != dev = expr
- qdev_init_nofail(d);
+ pci_realize_and_unref(dev, bus, &error_fatal);
@@
expression dev, bus, expr;
expression list args;
@@
- dev = pci_create(bus, args);
+ dev = pci_new(args);
... when != dev = expr
- qdev_init_nofail(DEVICE(dev));
+ pci_realize_and_unref(dev, bus, &error_fatal);
@@
expression dev, bus, expr;
expression list args;
@@
- dev = DEVICE(pci_create(bus, args));
+ PCIDevice *pci_dev; // TODO move
+ pci_dev = pci_new(args);
+ dev = DEVICE(pci_dev);
... when != dev = expr
- qdev_init_nofail(dev);
+ pci_realize_and_unref(pci_dev, bus, &error_fatal);
@@
expression dev, bus, expr;
expression list args;
@@
- dev = pci_create_multifunction(bus, args);
+ dev = pci_new_multifunction(args);
... when != dev = expr
- qdev_init_nofail(&dev->qdev);
+ pci_realize_and_unref(dev, bus, &error_fatal);
@@
expression bus, expr;
expression list args;
identifier dev;
@@
- PCIDevice *dev = pci_create_multifunction(bus, args);
+ PCIDevice *dev = pci_new_multifunction(args);
... when != dev = expr
- qdev_init_nofail(&dev->qdev);
+ pci_realize_and_unref(dev, bus, &error_fatal);
@@
expression dev, bus, expr;
expression list args;
@@
- dev = pci_create_multifunction(bus, args);
+ dev = pci_new_multifunction(args);
... when != dev = expr
- qdev_init_nofail(DEVICE(dev));
+ pci_realize_and_unref(dev, bus, &error_fatal);
Missing #include "qapi/error.h" added manually, whitespace changes
minimized manually, @pci_dev declarations moved manually.
Cc: Michael S. Tsirkin <mst@redhat.com>
Cc: Marcel Apfelbaum <marcel.apfelbaum@gmail.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Message-Id: <20200610053247.1583243-16-armbru@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
2020-06-10 07:32:04 +02:00
|
|
|
d = pci_new(PCI_DEVFN(0, 0), TYPE_PCI_BONITO);
|
2016-01-05 11:57:49 +01:00
|
|
|
s = PCI_BONITO(d);
|
2010-06-29 04:48:55 +02:00
|
|
|
s->pcihost = pcihost;
|
2012-08-20 19:07:58 +02:00
|
|
|
pcihost->pci_dev = s;
|
pci: Convert uses of pci_create() etc. with Coccinelle
Replace
dev = pci_create(bus, type_name);
...
qdev_init_nofail(dev);
by
dev = pci_new(type_name);
...
pci_realize_and_unref(dev, bus, &error_fatal);
and similarly for pci_create_multifunction().
Recent commit "qdev: New qdev_new(), qdev_realize(), etc." explains
why.
Coccinelle script:
@@
expression dev, bus, expr;
expression list args;
@@
- dev = pci_create(bus, args);
+ dev = pci_new(args);
... when != dev = expr
- qdev_init_nofail(&dev->qdev);
+ pci_realize_and_unref(dev, bus, &error_fatal);
@@
expression dev, bus, expr;
expression list args;
expression d;
@@
- dev = pci_create(bus, args);
+ dev = pci_new(args);
(
d = &dev->qdev;
|
d = DEVICE(dev);
)
... when != dev = expr
- qdev_init_nofail(d);
+ pci_realize_and_unref(dev, bus, &error_fatal);
@@
expression dev, bus, expr;
expression list args;
@@
- dev = pci_create(bus, args);
+ dev = pci_new(args);
... when != dev = expr
- qdev_init_nofail(DEVICE(dev));
+ pci_realize_and_unref(dev, bus, &error_fatal);
@@
expression dev, bus, expr;
expression list args;
@@
- dev = DEVICE(pci_create(bus, args));
+ PCIDevice *pci_dev; // TODO move
+ pci_dev = pci_new(args);
+ dev = DEVICE(pci_dev);
... when != dev = expr
- qdev_init_nofail(dev);
+ pci_realize_and_unref(pci_dev, bus, &error_fatal);
@@
expression dev, bus, expr;
expression list args;
@@
- dev = pci_create_multifunction(bus, args);
+ dev = pci_new_multifunction(args);
... when != dev = expr
- qdev_init_nofail(&dev->qdev);
+ pci_realize_and_unref(dev, bus, &error_fatal);
@@
expression bus, expr;
expression list args;
identifier dev;
@@
- PCIDevice *dev = pci_create_multifunction(bus, args);
+ PCIDevice *dev = pci_new_multifunction(args);
... when != dev = expr
- qdev_init_nofail(&dev->qdev);
+ pci_realize_and_unref(dev, bus, &error_fatal);
@@
expression dev, bus, expr;
expression list args;
@@
- dev = pci_create_multifunction(bus, args);
+ dev = pci_new_multifunction(args);
... when != dev = expr
- qdev_init_nofail(DEVICE(dev));
+ pci_realize_and_unref(dev, bus, &error_fatal);
Missing #include "qapi/error.h" added manually, whitespace changes
minimized manually, @pci_dev declarations moved manually.
Cc: Michael S. Tsirkin <mst@redhat.com>
Cc: Marcel Apfelbaum <marcel.apfelbaum@gmail.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Message-Id: <20200610053247.1583243-16-armbru@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
2020-06-10 07:32:04 +02:00
|
|
|
pci_realize_and_unref(d, phb->bus, &error_fatal);
|
2010-06-29 04:48:55 +02:00
|
|
|
|
2012-08-20 19:07:58 +02:00
|
|
|
return phb->bus;
|
2010-06-29 04:48:55 +02:00
|
|
|
}
|
|
|
|
|
2011-12-04 19:22:06 +01:00
|
|
|
static void bonito_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 = bonito_realize;
|
2011-12-04 19:22:06 +01:00
|
|
|
k->vendor_id = 0xdf53;
|
|
|
|
k->device_id = 0x00d5;
|
|
|
|
k->revision = 0x01;
|
|
|
|
k->class_id = PCI_CLASS_BRIDGE_HOST;
|
2011-12-08 04:34:16 +01:00
|
|
|
dc->desc = "Host bridge";
|
|
|
|
dc->vmsd = &vmstate_bonito;
|
pci-host: Consistently set cannot_instantiate_with_device_add_yet
Many PCI host bridges consist of a sysbus device and a PCI device.
You need both for the thing to work. Arguably, these bridges should
be modelled as a single, composite devices instead of pairs of
seemingly independent devices you can only use together, but we're not
there, yet.
Since the sysbus part can't be instantiated with device_add, yet,
permitting it with the PCI part is useless. We shouldn't offer
useless options to the user, so let's set
cannot_instantiate_with_device_add_yet for them.
It's already set for Bonito, Grackle, i440FX and Raven. Document why.
Set it for the others: dec-21154, e500-host-bridge, gt64120_pci, mch,
pbm-pci, ppc4xx-host-bridge, sh_pci_host, u3-agp, uni-north-agp,
uni-north-internal-pci, uni-north-pci, and versatile_pci_host.
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Marcel Apfelbaum <marcel.a@redhat.com>
Signed-off-by: Andreas Färber <afaerber@suse.de>
2013-11-28 17:26:58 +01:00
|
|
|
/*
|
|
|
|
* PCI-facing part of the host bridge, not usable without the
|
|
|
|
* host-facing part, which can't be device_add'ed, yet.
|
|
|
|
*/
|
2017-05-03 22:35:44 +02:00
|
|
|
dc->user_creatable = false;
|
2011-12-04 19:22:06 +01:00
|
|
|
}
|
|
|
|
|
2012-08-20 19:07:56 +02:00
|
|
|
static const TypeInfo bonito_info = {
|
2016-01-05 11:57:49 +01:00
|
|
|
.name = TYPE_PCI_BONITO,
|
2011-12-08 04:34:16 +01:00
|
|
|
.parent = TYPE_PCI_DEVICE,
|
|
|
|
.instance_size = sizeof(PCIBonitoState),
|
|
|
|
.class_init = bonito_class_init,
|
2017-09-27 21:56:34 +02:00
|
|
|
.interfaces = (InterfaceInfo[]) {
|
|
|
|
{ INTERFACE_CONVENTIONAL_PCI_DEVICE },
|
|
|
|
{ },
|
|
|
|
},
|
2010-06-29 04:48:55 +02:00
|
|
|
};
|
|
|
|
|
2012-01-24 20:12:29 +01:00
|
|
|
static void bonito_pcihost_class_init(ObjectClass *klass, void *data)
|
|
|
|
{
|
2018-10-02 23:25:15 +02:00
|
|
|
DeviceClass *dc = DEVICE_CLASS(klass);
|
2012-01-24 20:12:29 +01:00
|
|
|
|
2018-10-02 23:25:15 +02:00
|
|
|
dc->realize = bonito_pcihost_realize;
|
2012-01-24 20:12:29 +01:00
|
|
|
}
|
|
|
|
|
2012-08-20 19:07:56 +02:00
|
|
|
static const TypeInfo bonito_pcihost_info = {
|
2012-08-20 19:07:58 +02:00
|
|
|
.name = TYPE_BONITO_PCI_HOST_BRIDGE,
|
2012-08-20 19:08:08 +02:00
|
|
|
.parent = TYPE_PCI_HOST_BRIDGE,
|
2011-12-08 04:34:16 +01:00
|
|
|
.instance_size = sizeof(BonitoState),
|
|
|
|
.class_init = bonito_pcihost_class_init,
|
2010-06-29 04:48:55 +02:00
|
|
|
};
|
|
|
|
|
2012-02-09 15:20:55 +01:00
|
|
|
static void bonito_register_types(void)
|
2010-06-29 04:48:55 +02:00
|
|
|
{
|
2011-12-08 04:34:16 +01:00
|
|
|
type_register_static(&bonito_pcihost_info);
|
|
|
|
type_register_static(&bonito_info);
|
2010-06-29 04:48:55 +02:00
|
|
|
}
|
2012-02-09 15:20:55 +01:00
|
|
|
|
|
|
|
type_init(bonito_register_types)
|