1 #ifndef PCI_HOST_APB_H 2 #define PCI_HOST_APB_H 3 4 #include "qemu-common.h" 5 #include "hw/pci/pci_host.h" 6 7 #define IOMMU_NREGS 3 8 9 #define IOMMU_PAGE_SIZE_8K (1ULL << 13) 10 #define IOMMU_PAGE_MASK_8K (~(IOMMU_PAGE_SIZE_8K - 1)) 11 #define IOMMU_PAGE_SIZE_64K (1ULL << 16) 12 #define IOMMU_PAGE_MASK_64K (~(IOMMU_PAGE_SIZE_64K - 1)) 13 14 #define IOMMU_CTRL 0x0 15 #define IOMMU_CTRL_TBW_SIZE (1ULL << 2) 16 #define IOMMU_CTRL_MMU_EN (1ULL) 17 18 #define IOMMU_CTRL_TSB_SHIFT 16 19 20 #define IOMMU_BASE 0x8 21 #define IOMMU_FLUSH 0x10 22 23 #define IOMMU_TTE_DATA_V (1ULL << 63) 24 #define IOMMU_TTE_DATA_SIZE (1ULL << 61) 25 #define IOMMU_TTE_DATA_W (1ULL << 1) 26 27 #define IOMMU_TTE_PHYS_MASK_8K 0x1ffffffe000ULL 28 #define IOMMU_TTE_PHYS_MASK_64K 0x1ffffff8000ULL 29 30 #define IOMMU_TSB_8K_OFFSET_MASK_8M 0x00000000007fe000ULL 31 #define IOMMU_TSB_8K_OFFSET_MASK_16M 0x0000000000ffe000ULL 32 #define IOMMU_TSB_8K_OFFSET_MASK_32M 0x0000000001ffe000ULL 33 #define IOMMU_TSB_8K_OFFSET_MASK_64M 0x0000000003ffe000ULL 34 #define IOMMU_TSB_8K_OFFSET_MASK_128M 0x0000000007ffe000ULL 35 #define IOMMU_TSB_8K_OFFSET_MASK_256M 0x000000000fffe000ULL 36 #define IOMMU_TSB_8K_OFFSET_MASK_512M 0x000000001fffe000ULL 37 #define IOMMU_TSB_8K_OFFSET_MASK_1G 0x000000003fffe000ULL 38 39 #define IOMMU_TSB_64K_OFFSET_MASK_64M 0x0000000003ff0000ULL 40 #define IOMMU_TSB_64K_OFFSET_MASK_128M 0x0000000007ff0000ULL 41 #define IOMMU_TSB_64K_OFFSET_MASK_256M 0x000000000fff0000ULL 42 #define IOMMU_TSB_64K_OFFSET_MASK_512M 0x000000001fff0000ULL 43 #define IOMMU_TSB_64K_OFFSET_MASK_1G 0x000000003fff0000ULL 44 #define IOMMU_TSB_64K_OFFSET_MASK_2G 0x000000007fff0000ULL 45 46 typedef struct IOMMUState { 47 SysBusDevice parent_obj; 48 49 AddressSpace iommu_as; 50 IOMMUMemoryRegion iommu; 51 52 MemoryRegion iomem; 53 uint64_t regs[IOMMU_NREGS]; 54 } IOMMUState; 55 56 #define TYPE_SUN4U_IOMMU "sun4u-iommu" 57 #define SUN4U_IOMMU(obj) OBJECT_CHECK(IOMMUState, (obj), TYPE_SUN4U_IOMMU) 58 59 #define MAX_IVEC 0x40 60 61 /* OBIO IVEC IRQs */ 62 #define OBIO_HDD_IRQ 0x20 63 #define OBIO_NIC_IRQ 0x21 64 #define OBIO_LPT_IRQ 0x22 65 #define OBIO_FDD_IRQ 0x27 66 #define OBIO_KBD_IRQ 0x29 67 #define OBIO_MSE_IRQ 0x2a 68 #define OBIO_SER_IRQ 0x2b 69 70 #define TYPE_APB "pbm" 71 72 #define APB_DEVICE(obj) \ 73 OBJECT_CHECK(APBState, (obj), TYPE_APB) 74 75 #define TYPE_APB_IOMMU_MEMORY_REGION "pbm-iommu-memory-region" 76 77 typedef struct APBState { 78 PCIHostState parent_obj; 79 80 hwaddr special_base; 81 hwaddr mem_base; 82 MemoryRegion apb_config; 83 MemoryRegion pci_config; 84 MemoryRegion pci_mmio; 85 MemoryRegion pci_ioport; 86 uint64_t pci_irq_in; 87 IOMMUState *iommu; 88 PCIBridge *bridgeA; 89 PCIBridge *bridgeB; 90 uint32_t pci_control[16]; 91 uint32_t pci_irq_map[8]; 92 uint32_t pci_err_irq_map[4]; 93 uint32_t obio_irq_map[32]; 94 qemu_irq ivec_irqs[MAX_IVEC]; 95 unsigned int irq_request; 96 uint32_t reset_control; 97 unsigned int nr_resets; 98 } APBState; 99 100 typedef struct PBMPCIBridge { 101 /*< private >*/ 102 PCIBridge parent_obj; 103 } PBMPCIBridge; 104 105 #define TYPE_PBM_PCI_BRIDGE "pbm-bridge" 106 #define PBM_PCI_BRIDGE(obj) \ 107 OBJECT_CHECK(PBMPCIBridge, (obj), TYPE_PBM_PCI_BRIDGE) 108 109 #endif 110