1386ce3c7SPavel Fedin /* 2386ce3c7SPavel Fedin * ITS support for ARM GICv3 3386ce3c7SPavel Fedin * 4386ce3c7SPavel Fedin * Copyright (c) 2015 Samsung Electronics Co., Ltd. 5386ce3c7SPavel Fedin * Written by Pavel Fedin 6386ce3c7SPavel Fedin * 7386ce3c7SPavel Fedin * This program is free software; you can redistribute it and/or modify 8386ce3c7SPavel Fedin * it under the terms of the GNU General Public License as published by 9386ce3c7SPavel Fedin * the Free Software Foundation, either version 2 of the License, or 10386ce3c7SPavel Fedin * (at your option) any later version. 11386ce3c7SPavel Fedin * 12386ce3c7SPavel Fedin * This program is distributed in the hope that it will be useful, 13386ce3c7SPavel Fedin * but WITHOUT ANY WARRANTY; without even the implied warranty of 14386ce3c7SPavel Fedin * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15386ce3c7SPavel Fedin * GNU General Public License for more details. 16386ce3c7SPavel Fedin * 17386ce3c7SPavel Fedin * You should have received a copy of the GNU General Public License along 18386ce3c7SPavel Fedin * with this program; if not, see <http://www.gnu.org/licenses/>. 19386ce3c7SPavel Fedin */ 20386ce3c7SPavel Fedin 21386ce3c7SPavel Fedin #ifndef QEMU_ARM_GICV3_ITS_COMMON_H 22386ce3c7SPavel Fedin #define QEMU_ARM_GICV3_ITS_COMMON_H 23386ce3c7SPavel Fedin 24386ce3c7SPavel Fedin #include "hw/sysbus.h" 25386ce3c7SPavel Fedin #include "hw/intc/arm_gicv3_common.h" 26386ce3c7SPavel Fedin 27386ce3c7SPavel Fedin #define ITS_CONTROL_SIZE 0x10000 28386ce3c7SPavel Fedin #define ITS_TRANS_SIZE 0x10000 29386ce3c7SPavel Fedin #define ITS_SIZE (ITS_CONTROL_SIZE + ITS_TRANS_SIZE) 30386ce3c7SPavel Fedin 31*cddafd8fSEric Auger #define GITS_CTLR 0x0 32*cddafd8fSEric Auger #define GITS_IIDR 0x4 33*cddafd8fSEric Auger #define GITS_CBASER 0x80 34*cddafd8fSEric Auger #define GITS_CWRITER 0x88 35*cddafd8fSEric Auger #define GITS_CREADR 0x90 36*cddafd8fSEric Auger #define GITS_BASER 0x100 37*cddafd8fSEric Auger 38386ce3c7SPavel Fedin struct GICv3ITSState { 39386ce3c7SPavel Fedin SysBusDevice parent_obj; 40386ce3c7SPavel Fedin 41386ce3c7SPavel Fedin MemoryRegion iomem_main; 42386ce3c7SPavel Fedin MemoryRegion iomem_its_cntrl; 43386ce3c7SPavel Fedin MemoryRegion iomem_its_translation; 44386ce3c7SPavel Fedin 45386ce3c7SPavel Fedin GICv3State *gicv3; 46386ce3c7SPavel Fedin 47386ce3c7SPavel Fedin int dev_fd; /* kvm device fd if backed by kvm vgic support */ 48386ce3c7SPavel Fedin uint64_t gits_translater_gpa; 49386ce3c7SPavel Fedin bool translater_gpa_known; 50386ce3c7SPavel Fedin 51386ce3c7SPavel Fedin /* Registers */ 52386ce3c7SPavel Fedin uint32_t ctlr; 53*cddafd8fSEric Auger uint32_t iidr; 54386ce3c7SPavel Fedin uint64_t cbaser; 55386ce3c7SPavel Fedin uint64_t cwriter; 56386ce3c7SPavel Fedin uint64_t creadr; 57386ce3c7SPavel Fedin uint64_t baser[8]; 58386ce3c7SPavel Fedin 59386ce3c7SPavel Fedin Error *migration_blocker; 60386ce3c7SPavel Fedin }; 61386ce3c7SPavel Fedin 62386ce3c7SPavel Fedin typedef struct GICv3ITSState GICv3ITSState; 63386ce3c7SPavel Fedin 64386ce3c7SPavel Fedin void gicv3_its_init_mmio(GICv3ITSState *s, const MemoryRegionOps *ops); 65386ce3c7SPavel Fedin 66386ce3c7SPavel Fedin #define TYPE_ARM_GICV3_ITS_COMMON "arm-gicv3-its-common" 67386ce3c7SPavel Fedin #define ARM_GICV3_ITS_COMMON(obj) \ 68386ce3c7SPavel Fedin OBJECT_CHECK(GICv3ITSState, (obj), TYPE_ARM_GICV3_ITS_COMMON) 69386ce3c7SPavel Fedin #define ARM_GICV3_ITS_COMMON_CLASS(klass) \ 70386ce3c7SPavel Fedin OBJECT_CLASS_CHECK(GICv3ITSCommonClass, (klass), TYPE_ARM_GICV3_ITS_COMMON) 71386ce3c7SPavel Fedin #define ARM_GICV3_ITS_COMMON_GET_CLASS(obj) \ 72386ce3c7SPavel Fedin OBJECT_GET_CLASS(GICv3ITSCommonClass, (obj), TYPE_ARM_GICV3_ITS_COMMON) 73386ce3c7SPavel Fedin 74386ce3c7SPavel Fedin struct GICv3ITSCommonClass { 75386ce3c7SPavel Fedin /*< private >*/ 76386ce3c7SPavel Fedin SysBusDeviceClass parent_class; 77386ce3c7SPavel Fedin /*< public >*/ 78386ce3c7SPavel Fedin 79386ce3c7SPavel Fedin int (*send_msi)(GICv3ITSState *s, uint32_t data, uint16_t devid); 80386ce3c7SPavel Fedin void (*pre_save)(GICv3ITSState *s); 81386ce3c7SPavel Fedin void (*post_load)(GICv3ITSState *s); 82386ce3c7SPavel Fedin }; 83386ce3c7SPavel Fedin 84386ce3c7SPavel Fedin typedef struct GICv3ITSCommonClass GICv3ITSCommonClass; 85386ce3c7SPavel Fedin 86386ce3c7SPavel Fedin #endif 87