2016-10-04 15:28:08 +03:00
|
|
|
/*
|
|
|
|
* ITS support for ARM GICv3
|
|
|
|
*
|
|
|
|
* Copyright (c) 2015 Samsung Electronics Co., Ltd.
|
|
|
|
* Written by Pavel Fedin
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that 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 QEMU_ARM_GICV3_ITS_COMMON_H
|
|
|
|
#define QEMU_ARM_GICV3_ITS_COMMON_H
|
|
|
|
|
|
|
|
#include "hw/sysbus.h"
|
|
|
|
#include "hw/intc/arm_gicv3_common.h"
|
2020-09-03 23:43:22 +03:00
|
|
|
#include "qom/object.h"
|
2016-10-04 15:28:08 +03:00
|
|
|
|
2021-09-13 18:07:23 +03:00
|
|
|
#define TYPE_ARM_GICV3_ITS "arm-gicv3-its"
|
|
|
|
|
2016-10-04 15:28:08 +03:00
|
|
|
#define ITS_CONTROL_SIZE 0x10000
|
|
|
|
#define ITS_TRANS_SIZE 0x10000
|
|
|
|
#define ITS_SIZE (ITS_CONTROL_SIZE + ITS_TRANS_SIZE)
|
|
|
|
|
2017-06-13 16:57:00 +03:00
|
|
|
#define GITS_CTLR 0x0
|
|
|
|
#define GITS_IIDR 0x4
|
2021-09-13 18:07:23 +03:00
|
|
|
#define GITS_TYPER 0x8
|
2017-06-13 16:57:00 +03:00
|
|
|
#define GITS_CBASER 0x80
|
|
|
|
#define GITS_CWRITER 0x88
|
|
|
|
#define GITS_CREADR 0x90
|
|
|
|
#define GITS_BASER 0x100
|
|
|
|
|
2021-09-13 18:07:23 +03:00
|
|
|
#define GITS_TRANSLATER 0x0040
|
|
|
|
|
2021-09-13 18:07:23 +03:00
|
|
|
typedef struct {
|
|
|
|
bool valid;
|
|
|
|
bool indirect;
|
|
|
|
uint16_t entry_sz;
|
|
|
|
uint32_t page_sz;
|
2022-01-07 20:08:00 +03:00
|
|
|
uint32_t num_entries;
|
|
|
|
uint32_t num_ids;
|
2021-09-13 18:07:23 +03:00
|
|
|
uint64_t base_addr;
|
|
|
|
} TableDesc;
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
bool valid;
|
2022-01-07 20:08:00 +03:00
|
|
|
uint32_t num_entries;
|
2021-09-13 18:07:23 +03:00
|
|
|
uint64_t base_addr;
|
|
|
|
} CmdQDesc;
|
|
|
|
|
2016-10-04 15:28:08 +03:00
|
|
|
struct GICv3ITSState {
|
|
|
|
SysBusDevice parent_obj;
|
|
|
|
|
|
|
|
MemoryRegion iomem_main;
|
|
|
|
MemoryRegion iomem_its_cntrl;
|
|
|
|
MemoryRegion iomem_its_translation;
|
|
|
|
|
|
|
|
GICv3State *gicv3;
|
|
|
|
|
|
|
|
int dev_fd; /* kvm device fd if backed by kvm vgic support */
|
|
|
|
uint64_t gits_translater_gpa;
|
|
|
|
bool translater_gpa_known;
|
|
|
|
|
|
|
|
/* Registers */
|
|
|
|
uint32_t ctlr;
|
2017-06-13 16:57:00 +03:00
|
|
|
uint32_t iidr;
|
2021-09-13 18:07:23 +03:00
|
|
|
uint64_t typer;
|
2016-10-04 15:28:08 +03:00
|
|
|
uint64_t cbaser;
|
|
|
|
uint64_t cwriter;
|
|
|
|
uint64_t creadr;
|
|
|
|
uint64_t baser[8];
|
|
|
|
|
2021-09-13 18:07:23 +03:00
|
|
|
TableDesc dt;
|
|
|
|
TableDesc ct;
|
|
|
|
CmdQDesc cq;
|
|
|
|
|
2016-10-04 15:28:08 +03:00
|
|
|
Error *migration_blocker;
|
|
|
|
};
|
|
|
|
|
|
|
|
typedef struct GICv3ITSState GICv3ITSState;
|
|
|
|
|
2021-09-13 18:07:23 +03:00
|
|
|
void gicv3_its_init_mmio(GICv3ITSState *s, const MemoryRegionOps *ops,
|
|
|
|
const MemoryRegionOps *tops);
|
2016-10-04 15:28:08 +03:00
|
|
|
|
|
|
|
#define TYPE_ARM_GICV3_ITS_COMMON "arm-gicv3-its-common"
|
2020-09-03 23:43:22 +03:00
|
|
|
typedef struct GICv3ITSCommonClass GICv3ITSCommonClass;
|
2020-09-01 00:07:33 +03:00
|
|
|
DECLARE_OBJ_CHECKERS(GICv3ITSState, GICv3ITSCommonClass,
|
|
|
|
ARM_GICV3_ITS_COMMON, TYPE_ARM_GICV3_ITS_COMMON)
|
2016-10-04 15:28:08 +03:00
|
|
|
|
|
|
|
struct GICv3ITSCommonClass {
|
|
|
|
/*< private >*/
|
|
|
|
SysBusDeviceClass parent_class;
|
|
|
|
/*< public >*/
|
|
|
|
|
|
|
|
int (*send_msi)(GICv3ITSState *s, uint32_t data, uint16_t devid);
|
|
|
|
void (*pre_save)(GICv3ITSState *s);
|
|
|
|
void (*post_load)(GICv3ITSState *s);
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
#endif
|