1*31bfbc00SFrederic Barrat /* 2*31bfbc00SFrederic Barrat * QTest testcase for PowerNV 10 interrupt controller (xive2) 3*31bfbc00SFrederic Barrat * 4*31bfbc00SFrederic Barrat * Copyright (c) 2024, IBM Corporation. 5*31bfbc00SFrederic Barrat * 6*31bfbc00SFrederic Barrat * SPDX-License-Identifier: GPL-2.0-or-later 7*31bfbc00SFrederic Barrat */ 8*31bfbc00SFrederic Barrat 9*31bfbc00SFrederic Barrat #ifndef TEST_PNV_XIVE2_COMMON_H 10*31bfbc00SFrederic Barrat #define TEST_PNV_XIVE2_COMMON_H 11*31bfbc00SFrederic Barrat 12*31bfbc00SFrederic Barrat #define PPC_BIT(bit) (0x8000000000000000ULL >> (bit)) 13*31bfbc00SFrederic Barrat #define PPC_BIT32(bit) (0x80000000 >> (bit)) 14*31bfbc00SFrederic Barrat #define PPC_BIT8(bit) (0x80 >> (bit)) 15*31bfbc00SFrederic Barrat #define PPC_BITMASK(bs, be) ((PPC_BIT(bs) - PPC_BIT(be)) | PPC_BIT(bs)) 16*31bfbc00SFrederic Barrat #define PPC_BITMASK32(bs, be) ((PPC_BIT32(bs) - PPC_BIT32(be)) | \ 17*31bfbc00SFrederic Barrat PPC_BIT32(bs)) 18*31bfbc00SFrederic Barrat #include "qemu/bswap.h" 19*31bfbc00SFrederic Barrat #include "hw/intc/pnv_xive2_regs.h" 20*31bfbc00SFrederic Barrat #include "hw/ppc/xive_regs.h" 21*31bfbc00SFrederic Barrat #include "hw/ppc/xive2_regs.h" 22*31bfbc00SFrederic Barrat 23*31bfbc00SFrederic Barrat /* 24*31bfbc00SFrederic Barrat * sizing: 25*31bfbc00SFrederic Barrat * 128 interrupts 26*31bfbc00SFrederic Barrat * => ESB BAR range: 16M 27*31bfbc00SFrederic Barrat * 256 ENDs 28*31bfbc00SFrederic Barrat * => END BAR range: 16M 29*31bfbc00SFrederic Barrat * 256 VPs 30*31bfbc00SFrederic Barrat * => NVPG,NVC BAR range: 32M 31*31bfbc00SFrederic Barrat */ 32*31bfbc00SFrederic Barrat #define MAX_IRQS 128 33*31bfbc00SFrederic Barrat #define MAX_ENDS 256 34*31bfbc00SFrederic Barrat #define MAX_VPS 256 35*31bfbc00SFrederic Barrat 36*31bfbc00SFrederic Barrat #define XIVE_PAGE_SHIFT 16 37*31bfbc00SFrederic Barrat 38*31bfbc00SFrederic Barrat #define XIVE_TRIGGER_PAGE 0 39*31bfbc00SFrederic Barrat #define XIVE_EOI_PAGE 1 40*31bfbc00SFrederic Barrat 41*31bfbc00SFrederic Barrat #define XIVE_IC_ADDR 0x0006030200000000ull 42*31bfbc00SFrederic Barrat #define XIVE_IC_TM_INDIRECT (XIVE_IC_ADDR + (256 << XIVE_PAGE_SHIFT)) 43*31bfbc00SFrederic Barrat #define XIVE_IC_BAR ((0x3ull << 62) | XIVE_IC_ADDR) 44*31bfbc00SFrederic Barrat #define XIVE_TM_BAR 0xc006030203180000ull 45*31bfbc00SFrederic Barrat #define XIVE_ESB_ADDR 0x0006050000000000ull 46*31bfbc00SFrederic Barrat #define XIVE_ESB_BAR ((0x3ull << 62) | XIVE_ESB_ADDR) 47*31bfbc00SFrederic Barrat #define XIVE_END_BAR 0xc006060000000000ull 48*31bfbc00SFrederic Barrat #define XIVE_NVPG_ADDR 0x0006040000000000ull 49*31bfbc00SFrederic Barrat #define XIVE_NVPG_BAR ((0x3ull << 62) | XIVE_NVPG_ADDR) 50*31bfbc00SFrederic Barrat #define XIVE_NVC_ADDR 0x0006030208000000ull 51*31bfbc00SFrederic Barrat #define XIVE_NVC_BAR ((0x3ull << 62) | XIVE_NVC_ADDR) 52*31bfbc00SFrederic Barrat 53*31bfbc00SFrederic Barrat /* 54*31bfbc00SFrederic Barrat * Memory layout 55*31bfbc00SFrederic Barrat * A check is done when a table is configured to ensure that the max 56*31bfbc00SFrederic Barrat * size of the resource fits in the table. 57*31bfbc00SFrederic Barrat */ 58*31bfbc00SFrederic Barrat #define XIVE_VST_SIZE 0x10000ull /* must be at least 4k */ 59*31bfbc00SFrederic Barrat 60*31bfbc00SFrederic Barrat #define XIVE_MEM_START 0x10000000ull 61*31bfbc00SFrederic Barrat #define XIVE_ESB_MEM XIVE_MEM_START 62*31bfbc00SFrederic Barrat #define XIVE_EAS_MEM (XIVE_ESB_MEM + XIVE_VST_SIZE) 63*31bfbc00SFrederic Barrat #define XIVE_END_MEM (XIVE_EAS_MEM + XIVE_VST_SIZE) 64*31bfbc00SFrederic Barrat #define XIVE_NVP_MEM (XIVE_END_MEM + XIVE_VST_SIZE) 65*31bfbc00SFrederic Barrat #define XIVE_NVG_MEM (XIVE_NVP_MEM + XIVE_VST_SIZE) 66*31bfbc00SFrederic Barrat #define XIVE_NVC_MEM (XIVE_NVG_MEM + XIVE_VST_SIZE) 67*31bfbc00SFrederic Barrat #define XIVE_SYNC_MEM (XIVE_NVC_MEM + XIVE_VST_SIZE) 68*31bfbc00SFrederic Barrat #define XIVE_QUEUE_MEM (XIVE_SYNC_MEM + XIVE_VST_SIZE) 69*31bfbc00SFrederic Barrat #define XIVE_QUEUE_SIZE 4096 /* per End */ 70*31bfbc00SFrederic Barrat #define XIVE_REPORT_MEM (XIVE_QUEUE_MEM + XIVE_QUEUE_SIZE * MAX_VPS) 71*31bfbc00SFrederic Barrat #define XIVE_REPORT_SIZE 256 /* two cache lines per NVP */ 72*31bfbc00SFrederic Barrat #define XIVE_MEM_END (XIVE_REPORT_MEM + XIVE_REPORT_SIZE * MAX_VPS) 73*31bfbc00SFrederic Barrat 74*31bfbc00SFrederic Barrat #define P10_XSCOM_BASE 0x000603fc00000000ull 75*31bfbc00SFrederic Barrat #define XIVE_XSCOM 0x2010800ull 76*31bfbc00SFrederic Barrat 77*31bfbc00SFrederic Barrat #define XIVE_ESB_RESET 0b00 78*31bfbc00SFrederic Barrat #define XIVE_ESB_OFF 0b01 79*31bfbc00SFrederic Barrat #define XIVE_ESB_PENDING 0b10 80*31bfbc00SFrederic Barrat #define XIVE_ESB_QUEUED 0b11 81*31bfbc00SFrederic Barrat 82*31bfbc00SFrederic Barrat #define XIVE_ESB_GET 0x800 83*31bfbc00SFrederic Barrat #define XIVE_ESB_SET_PQ_00 0xc00 /* Load */ 84*31bfbc00SFrederic Barrat #define XIVE_ESB_SET_PQ_01 0xd00 /* Load */ 85*31bfbc00SFrederic Barrat #define XIVE_ESB_SET_PQ_10 0xe00 /* Load */ 86*31bfbc00SFrederic Barrat #define XIVE_ESB_SET_PQ_11 0xf00 /* Load */ 87*31bfbc00SFrederic Barrat 88*31bfbc00SFrederic Barrat #define XIVE_ESB_STORE_EOI 0x400 /* Store */ 89*31bfbc00SFrederic Barrat 90*31bfbc00SFrederic Barrat 91*31bfbc00SFrederic Barrat extern uint64_t pnv_xive_xscom_read(QTestState *qts, uint32_t reg); 92*31bfbc00SFrederic Barrat extern void pnv_xive_xscom_write(QTestState *qts, uint32_t reg, uint64_t val); 93*31bfbc00SFrederic Barrat extern uint64_t xive_get_queue_addr(uint32_t end_index); 94*31bfbc00SFrederic Barrat extern uint8_t get_esb(QTestState *qts, uint32_t index, uint8_t page, 95*31bfbc00SFrederic Barrat uint32_t offset); 96*31bfbc00SFrederic Barrat extern void set_esb(QTestState *qts, uint32_t index, uint8_t page, 97*31bfbc00SFrederic Barrat uint32_t offset, uint32_t val); 98*31bfbc00SFrederic Barrat extern void get_nvp(QTestState *qts, uint32_t index, Xive2Nvp* nvp); 99*31bfbc00SFrederic Barrat extern void set_nvp(QTestState *qts, uint32_t index, uint8_t first); 100*31bfbc00SFrederic Barrat extern void get_cl_pair(QTestState *qts, Xive2Nvp *nvp, uint8_t *cl_pair); 101*31bfbc00SFrederic Barrat extern void set_cl_pair(QTestState *qts, Xive2Nvp *nvp, uint8_t *cl_pair); 102*31bfbc00SFrederic Barrat extern void set_nvg(QTestState *qts, uint32_t index, uint8_t next); 103*31bfbc00SFrederic Barrat extern void set_eas(QTestState *qts, uint32_t index, uint32_t end_index, 104*31bfbc00SFrederic Barrat uint32_t data); 105*31bfbc00SFrederic Barrat extern void set_end(QTestState *qts, uint32_t index, uint32_t nvp_index, 106*31bfbc00SFrederic Barrat uint8_t priority, bool i); 107*31bfbc00SFrederic Barrat 108*31bfbc00SFrederic Barrat 109*31bfbc00SFrederic Barrat void test_flush_sync_inject(QTestState *qts); 110*31bfbc00SFrederic Barrat 111*31bfbc00SFrederic Barrat #endif /* TEST_PNV_XIVE2_COMMON_H */ 112