mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-03 07:43:54 -06:00
Fifth RISC-V PR for QEMU 7.0
* Fixup checks for ext_zb[abcs] * Add AIA support for virt machine * Increase maximum number of CPUs in virt machine * Fixup OpenTitan SPI address * Add support for zfinx, zdinx and zhinx{min} extensions -----BEGIN PGP SIGNATURE----- iQEzBAABCAAdFiEE9sSsRtSTSGjTuM6PIeENKd+XcFQFAmIgUZ8ACgkQIeENKd+X cFTzegf8DbUYFLpyfURm6bJoJfLQHjtjB4Hs6PnszJZZAEtC6Ia+551TDjh93vTf GTbpWm0BlugQqEeyg+Mioe2mb2EhK2w208RGXRSDjT9QFVOaIp83NDAjaQTPqs22 XC35ygJYuo1Yf0WoJV77aB6IYPZB3ba5i+dkGb6lk60Ru5ULqoLvqp73tNe5KvNB uVAEy+ubzjmzWs5hGPw95HqTIbcMGnlHew4XU6xJaiJixSy71Z5nOCCn+2sxk+6A QW59Onglyfk01F9ac3GMLvi2e+FUdj0S0y07oVqchzxXWYpYwgTO4Xkt794c8mqU T02kuelfubr1qH1z/IolStju1JnaXw== =LzOY -----END PGP SIGNATURE----- Merge remote-tracking branch 'remotes/alistair/tags/pull-riscv-to-apply-20220303' into staging Fifth RISC-V PR for QEMU 7.0 * Fixup checks for ext_zb[abcs] * Add AIA support for virt machine * Increase maximum number of CPUs in virt machine * Fixup OpenTitan SPI address * Add support for zfinx, zdinx and zhinx{min} extensions # gpg: Signature made Thu 03 Mar 2022 05:26:55 GMT # gpg: using RSA key F6C4AC46D4934868D3B8CE8F21E10D29DF977054 # gpg: Good signature from "Alistair Francis <alistair@alistair23.me>" [full] # Primary key fingerprint: F6C4 AC46 D493 4868 D3B8 CE8F 21E1 0D29 DF97 7054 * remotes/alistair/tags/pull-riscv-to-apply-20220303: target/riscv: expose zfinx, zdinx, zhinx{min} properties target/riscv: add support for zhinx/zhinxmin target/riscv: add support for zdinx target/riscv: add support for zfinx target/riscv: hardwire mstatus.FS to zero when enable zfinx target/riscv: add cfg properties for zfinx, zdinx and zhinx{min} hw: riscv: opentitan: fixup SPI addresses hw/riscv: virt: Increase maximum number of allowed CPUs docs/system: riscv: Document AIA options for virt machine hw/riscv: virt: Add optional AIA IMSIC support to virt machine hw/intc: Add RISC-V AIA IMSIC device emulation hw/riscv: virt: Add optional AIA APLIC support to virt machine target/riscv: fix inverted checks for ext_zb[abcs] Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
commit
5959ef7d43
22 changed files with 2145 additions and 500 deletions
68
include/hw/intc/riscv_imsic.h
Normal file
68
include/hw/intc/riscv_imsic.h
Normal file
|
@ -0,0 +1,68 @@
|
|||
/*
|
||||
* RISC-V IMSIC (Incoming Message Signal Interrupt Controller) interface
|
||||
*
|
||||
* Copyright (c) 2021 Western Digital Corporation or its affiliates.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms and conditions of the GNU General Public License,
|
||||
* version 2 or later, as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef HW_RISCV_IMSIC_H
|
||||
#define HW_RISCV_IMSIC_H
|
||||
|
||||
#include "hw/sysbus.h"
|
||||
#include "qom/object.h"
|
||||
|
||||
#define TYPE_RISCV_IMSIC "riscv.imsic"
|
||||
|
||||
typedef struct RISCVIMSICState RISCVIMSICState;
|
||||
DECLARE_INSTANCE_CHECKER(RISCVIMSICState, RISCV_IMSIC, TYPE_RISCV_IMSIC)
|
||||
|
||||
#define IMSIC_MMIO_PAGE_SHIFT 12
|
||||
#define IMSIC_MMIO_PAGE_SZ (1UL << IMSIC_MMIO_PAGE_SHIFT)
|
||||
#define IMSIC_MMIO_SIZE(__num_pages) ((__num_pages) * IMSIC_MMIO_PAGE_SZ)
|
||||
|
||||
#define IMSIC_MMIO_HART_GUEST_MAX_BTIS 6
|
||||
#define IMSIC_MMIO_GROUP_MIN_SHIFT 24
|
||||
|
||||
#define IMSIC_HART_NUM_GUESTS(__guest_bits) \
|
||||
(1U << (__guest_bits))
|
||||
#define IMSIC_HART_SIZE(__guest_bits) \
|
||||
(IMSIC_HART_NUM_GUESTS(__guest_bits) * IMSIC_MMIO_PAGE_SZ)
|
||||
#define IMSIC_GROUP_NUM_HARTS(__hart_bits) \
|
||||
(1U << (__hart_bits))
|
||||
#define IMSIC_GROUP_SIZE(__hart_bits, __guest_bits) \
|
||||
(IMSIC_GROUP_NUM_HARTS(__hart_bits) * IMSIC_HART_SIZE(__guest_bits))
|
||||
|
||||
struct RISCVIMSICState {
|
||||
/*< private >*/
|
||||
SysBusDevice parent_obj;
|
||||
qemu_irq *external_irqs;
|
||||
|
||||
/*< public >*/
|
||||
MemoryRegion mmio;
|
||||
uint32_t num_eistate;
|
||||
uint32_t *eidelivery;
|
||||
uint32_t *eithreshold;
|
||||
uint32_t *eistate;
|
||||
|
||||
/* config */
|
||||
bool mmode;
|
||||
uint32_t hartid;
|
||||
uint32_t num_pages;
|
||||
uint32_t num_irqs;
|
||||
};
|
||||
|
||||
DeviceState *riscv_imsic_create(hwaddr addr, uint32_t hartid, bool mmode,
|
||||
uint32_t num_pages, uint32_t num_ids);
|
||||
|
||||
#endif
|
|
@ -57,8 +57,10 @@ enum {
|
|||
IBEX_DEV_FLASH,
|
||||
IBEX_DEV_FLASH_VIRTUAL,
|
||||
IBEX_DEV_UART,
|
||||
IBEX_DEV_SPI_DEVICE,
|
||||
IBEX_DEV_SPI_HOST0,
|
||||
IBEX_DEV_SPI_HOST1,
|
||||
IBEX_DEV_GPIO,
|
||||
IBEX_DEV_SPI,
|
||||
IBEX_DEV_I2C,
|
||||
IBEX_DEV_PATTGEN,
|
||||
IBEX_DEV_TIMER,
|
||||
|
|
|
@ -24,26 +24,36 @@
|
|||
#include "hw/block/flash.h"
|
||||
#include "qom/object.h"
|
||||
|
||||
#define VIRT_CPUS_MAX 32
|
||||
#define VIRT_SOCKETS_MAX 8
|
||||
#define VIRT_CPUS_MAX_BITS 9
|
||||
#define VIRT_CPUS_MAX (1 << VIRT_CPUS_MAX_BITS)
|
||||
#define VIRT_SOCKETS_MAX_BITS 2
|
||||
#define VIRT_SOCKETS_MAX (1 << VIRT_SOCKETS_MAX_BITS)
|
||||
|
||||
#define TYPE_RISCV_VIRT_MACHINE MACHINE_TYPE_NAME("virt")
|
||||
typedef struct RISCVVirtState RISCVVirtState;
|
||||
DECLARE_INSTANCE_CHECKER(RISCVVirtState, RISCV_VIRT_MACHINE,
|
||||
TYPE_RISCV_VIRT_MACHINE)
|
||||
|
||||
typedef enum RISCVVirtAIAType {
|
||||
VIRT_AIA_TYPE_NONE = 0,
|
||||
VIRT_AIA_TYPE_APLIC,
|
||||
VIRT_AIA_TYPE_APLIC_IMSIC,
|
||||
} RISCVVirtAIAType;
|
||||
|
||||
struct RISCVVirtState {
|
||||
/*< private >*/
|
||||
MachineState parent;
|
||||
|
||||
/*< public >*/
|
||||
RISCVHartArrayState soc[VIRT_SOCKETS_MAX];
|
||||
DeviceState *plic[VIRT_SOCKETS_MAX];
|
||||
DeviceState *irqchip[VIRT_SOCKETS_MAX];
|
||||
PFlashCFI01 *flash[2];
|
||||
FWCfgState *fw_cfg;
|
||||
|
||||
int fdt_size;
|
||||
bool have_aclint;
|
||||
RISCVVirtAIAType aia_type;
|
||||
int aia_guests;
|
||||
};
|
||||
|
||||
enum {
|
||||
|
@ -54,9 +64,13 @@ enum {
|
|||
VIRT_CLINT,
|
||||
VIRT_ACLINT_SSWI,
|
||||
VIRT_PLIC,
|
||||
VIRT_APLIC_M,
|
||||
VIRT_APLIC_S,
|
||||
VIRT_UART0,
|
||||
VIRT_VIRTIO,
|
||||
VIRT_FW_CFG,
|
||||
VIRT_IMSIC_M,
|
||||
VIRT_IMSIC_S,
|
||||
VIRT_FLASH,
|
||||
VIRT_DRAM,
|
||||
VIRT_PCIE_MMIO,
|
||||
|
@ -73,8 +87,13 @@ enum {
|
|||
VIRTIO_NDEV = 0x35 /* Arbitrary maximum number of interrupts */
|
||||
};
|
||||
|
||||
#define VIRT_PLIC_NUM_SOURCES 127
|
||||
#define VIRT_PLIC_NUM_PRIORITIES 7
|
||||
#define VIRT_IRQCHIP_IPI_MSI 1
|
||||
#define VIRT_IRQCHIP_NUM_MSIS 255
|
||||
#define VIRT_IRQCHIP_NUM_SOURCES VIRTIO_NDEV
|
||||
#define VIRT_IRQCHIP_NUM_PRIO_BITS 3
|
||||
#define VIRT_IRQCHIP_MAX_GUESTS_BITS 3
|
||||
#define VIRT_IRQCHIP_MAX_GUESTS ((1U << VIRT_IRQCHIP_MAX_GUESTS_BITS) - 1U)
|
||||
|
||||
#define VIRT_PLIC_PRIORITY_BASE 0x04
|
||||
#define VIRT_PLIC_PENDING_BASE 0x1000
|
||||
#define VIRT_PLIC_ENABLE_BASE 0x2000
|
||||
|
@ -86,9 +105,15 @@ enum {
|
|||
|
||||
#define FDT_PCI_ADDR_CELLS 3
|
||||
#define FDT_PCI_INT_CELLS 1
|
||||
#define FDT_PLIC_ADDR_CELLS 0
|
||||
#define FDT_PLIC_INT_CELLS 1
|
||||
#define FDT_INT_MAP_WIDTH (FDT_PCI_ADDR_CELLS + FDT_PCI_INT_CELLS + 1 + \
|
||||
FDT_PLIC_ADDR_CELLS + FDT_PLIC_INT_CELLS)
|
||||
#define FDT_APLIC_INT_CELLS 2
|
||||
#define FDT_IMSIC_INT_CELLS 0
|
||||
#define FDT_MAX_INT_CELLS 2
|
||||
#define FDT_MAX_INT_MAP_WIDTH (FDT_PCI_ADDR_CELLS + FDT_PCI_INT_CELLS + \
|
||||
1 + FDT_MAX_INT_CELLS)
|
||||
#define FDT_PLIC_INT_MAP_WIDTH (FDT_PCI_ADDR_CELLS + FDT_PCI_INT_CELLS + \
|
||||
1 + FDT_PLIC_INT_CELLS)
|
||||
#define FDT_APLIC_INT_MAP_WIDTH (FDT_PCI_ADDR_CELLS + FDT_PCI_INT_CELLS + \
|
||||
1 + FDT_APLIC_INT_CELLS)
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue