2 * DEC 21272 (TSUNAMI/TYPHOON) chipset emulation.
4 * Written by Richard Henderson.
6 * This work is licensed under the GNU GPL license version 2 or later.
9 #include "qemu/osdep.h"
10 #include "qemu/module.h"
11 #include "qemu/units.h"
12 #include "qapi/error.h"
13 #include "hw/pci/pci_host.h"
16 #include "alpha_sys.h"
19 #define TYPE_TYPHOON_PCI_HOST_BRIDGE "typhoon-pcihost"
20 #define TYPE_TYPHOON_IOMMU_MEMORY_REGION "typhoon-iommu-memory-region"
22 typedef struct TyphoonCchip
{
31 typedef struct TyphoonWindow
{
37 typedef struct TyphoonPchip
{
39 MemoryRegion reg_iack
;
42 MemoryRegion reg_conf
;
44 AddressSpace iommu_as
;
45 IOMMUMemoryRegion iommu
;
51 OBJECT_DECLARE_SIMPLE_TYPE(TyphoonState
, TYPHOON_PCI_HOST_BRIDGE
)
54 PCIHostState parent_obj
;
58 MemoryRegion dchip_region
;
61 /* Called when one of DRIR or DIM changes. */
62 static void cpu_irq_change(AlphaCPU
*cpu
, uint64_t req
)
64 /* If there are any non-masked interrupts, tell the cpu. */
66 CPUState
*cs
= CPU(cpu
);
68 cpu_interrupt(cs
, CPU_INTERRUPT_HARD
);
70 cpu_reset_interrupt(cs
, CPU_INTERRUPT_HARD
);
75 static MemTxResult
cchip_read(void *opaque
, hwaddr addr
,
76 uint64_t *data
, unsigned size
,
79 CPUState
*cpu
= current_cpu
;
80 TyphoonState
*s
= opaque
;
85 /* CSC: Cchip System Configuration Register. */
86 /* All sorts of data here; probably the only thing relevant is
87 PIP<14> Pchip 1 Present = 0. */
91 /* MTR: Memory Timing Register. */
92 /* All sorts of stuff related to real DRAM. */
96 /* MISC: Miscellaneous Register. */
97 ret
= s
->cchip
.misc
| (cpu
->cpu_index
& 3);
101 /* MPD: Memory Presence Detect Register. */
104 case 0x0100: /* AAR0 */
105 case 0x0140: /* AAR1 */
106 case 0x0180: /* AAR2 */
107 case 0x01c0: /* AAR3 */
108 /* AAR: Array Address Register. */
109 /* All sorts of information about DRAM. */
113 /* DIM0: Device Interrupt Mask Register, CPU0. */
114 ret
= s
->cchip
.dim
[0];
117 /* DIM1: Device Interrupt Mask Register, CPU1. */
118 ret
= s
->cchip
.dim
[1];
121 /* DIR0: Device Interrupt Request Register, CPU0. */
122 ret
= s
->cchip
.dim
[0] & s
->cchip
.drir
;
125 /* DIR1: Device Interrupt Request Register, CPU1. */
126 ret
= s
->cchip
.dim
[1] & s
->cchip
.drir
;
129 /* DRIR: Device Raw Interrupt Request Register. */
134 /* PRBEN: Probe Enable Register. */
138 /* IIC0: Interval Ignore Count Register, CPU0. */
139 ret
= s
->cchip
.iic
[0];
142 /* IIC1: Interval Ignore Count Register, CPU1. */
143 ret
= s
->cchip
.iic
[1];
146 case 0x0400: /* MPR0 */
147 case 0x0440: /* MPR1 */
148 case 0x0480: /* MPR2 */
149 case 0x04c0: /* MPR3 */
150 /* MPR: Memory Programming Register. */
154 /* TTR: TIGbus Timing Register. */
155 /* All sorts of stuff related to interrupt delivery timings. */
158 /* TDR: TIGbug Device Timing Register. */
162 /* DIM2: Device Interrupt Mask Register, CPU2. */
163 ret
= s
->cchip
.dim
[2];
166 /* DIM3: Device Interrupt Mask Register, CPU3. */
167 ret
= s
->cchip
.dim
[3];
170 /* DIR2: Device Interrupt Request Register, CPU2. */
171 ret
= s
->cchip
.dim
[2] & s
->cchip
.drir
;
174 /* DIR3: Device Interrupt Request Register, CPU3. */
175 ret
= s
->cchip
.dim
[3] & s
->cchip
.drir
;
179 /* IIC2: Interval Ignore Count Register, CPU2. */
180 ret
= s
->cchip
.iic
[2];
183 /* IIC3: Interval Ignore Count Register, CPU3. */
184 ret
= s
->cchip
.iic
[3];
188 /* PWR: Power Management Control. */
191 case 0x0c00: /* CMONCTLA */
192 case 0x0c40: /* CMONCTLB */
193 case 0x0c80: /* CMONCNT01 */
194 case 0x0cc0: /* CMONCNT23 */
205 static uint64_t dchip_read(void *opaque
, hwaddr addr
, unsigned size
)
207 /* Skip this. It's all related to DRAM timing and setup. */
211 static MemTxResult
pchip_read(void *opaque
, hwaddr addr
, uint64_t *data
,
212 unsigned size
, MemTxAttrs attrs
)
214 TyphoonState
*s
= opaque
;
219 /* WSBA0: Window Space Base Address Register. */
220 ret
= s
->pchip
.win
[0].wba
;
224 ret
= s
->pchip
.win
[1].wba
;
228 ret
= s
->pchip
.win
[2].wba
;
232 ret
= s
->pchip
.win
[3].wba
;
236 /* WSM0: Window Space Mask Register. */
237 ret
= s
->pchip
.win
[0].wsm
;
241 ret
= s
->pchip
.win
[1].wsm
;
245 ret
= s
->pchip
.win
[2].wsm
;
249 ret
= s
->pchip
.win
[3].wsm
;
253 /* TBA0: Translated Base Address Register. */
254 ret
= s
->pchip
.win
[0].tba
;
258 ret
= s
->pchip
.win
[1].tba
;
262 ret
= s
->pchip
.win
[2].tba
;
266 ret
= s
->pchip
.win
[3].tba
;
270 /* PCTL: Pchip Control Register. */
274 /* PLAT: Pchip Master Latency Register. */
277 /* PERROR: Pchip Error Register. */
280 /* PERRMASK: Pchip Error Mask Register. */
283 /* PERRSET: Pchip Error Set Register. */
286 /* TLBIV: Translation Buffer Invalidate Virtual Register (WO). */
289 /* TLBIA: Translation Buffer Invalidate All Register (WO). */
291 case 0x0500: /* PMONCTL */
292 case 0x0540: /* PMONCNT */
293 case 0x0800: /* SPRST */
304 static MemTxResult
cchip_write(void *opaque
, hwaddr addr
,
305 uint64_t val
, unsigned size
,
308 TyphoonState
*s
= opaque
;
309 uint64_t oldval
, newval
;
313 /* CSC: Cchip System Configuration Register. */
314 /* All sorts of data here; nothing relevant RW. */
318 /* MTR: Memory Timing Register. */
319 /* All sorts of stuff related to real DRAM. */
323 /* MISC: Miscellaneous Register. */
324 newval
= oldval
= s
->cchip
.misc
;
325 newval
&= ~(val
& 0x10000ff0); /* W1C fields */
326 if (val
& 0x100000) {
327 newval
&= ~0xff0000ull
; /* ACL clears ABT and ABW */
329 newval
|= val
& 0x00f00000; /* ABT field is W1S */
330 if ((newval
& 0xf0000) == 0) {
331 newval
|= val
& 0xf0000; /* ABW field is W1S iff zero */
334 newval
|= (val
& 0xf000) >> 4; /* IPREQ field sets IPINTR. */
336 newval
&= ~0xf0000000000ull
; /* WO and RW fields */
337 newval
|= val
& 0xf0000000000ull
;
338 s
->cchip
.misc
= newval
;
340 /* Pass on changes to IPI and ITI state. */
341 if ((newval
^ oldval
) & 0xff0) {
343 for (i
= 0; i
< 4; ++i
) {
344 AlphaCPU
*cpu
= s
->cchip
.cpu
[i
];
346 CPUState
*cs
= CPU(cpu
);
347 /* IPI can be either cleared or set by the write. */
348 if (newval
& (1 << (i
+ 8))) {
349 cpu_interrupt(cs
, CPU_INTERRUPT_SMP
);
351 cpu_reset_interrupt(cs
, CPU_INTERRUPT_SMP
);
354 /* ITI can only be cleared by the write. */
355 if ((newval
& (1 << (i
+ 4))) == 0) {
356 cpu_reset_interrupt(cs
, CPU_INTERRUPT_TIMER
);
364 /* MPD: Memory Presence Detect Register. */
367 case 0x0100: /* AAR0 */
368 case 0x0140: /* AAR1 */
369 case 0x0180: /* AAR2 */
370 case 0x01c0: /* AAR3 */
371 /* AAR: Array Address Register. */
372 /* All sorts of information about DRAM. */
375 case 0x0200: /* DIM0 */
376 /* DIM: Device Interrupt Mask Register, CPU0. */
377 s
->cchip
.dim
[0] = val
;
378 cpu_irq_change(s
->cchip
.cpu
[0], val
& s
->cchip
.drir
);
380 case 0x0240: /* DIM1 */
381 /* DIM: Device Interrupt Mask Register, CPU1. */
382 s
->cchip
.dim
[1] = val
;
383 cpu_irq_change(s
->cchip
.cpu
[1], val
& s
->cchip
.drir
);
386 case 0x0280: /* DIR0 (RO) */
387 case 0x02c0: /* DIR1 (RO) */
388 case 0x0300: /* DRIR (RO) */
392 /* PRBEN: Probe Enable Register. */
395 case 0x0380: /* IIC0 */
396 s
->cchip
.iic
[0] = val
& 0xffffff;
398 case 0x03c0: /* IIC1 */
399 s
->cchip
.iic
[1] = val
& 0xffffff;
402 case 0x0400: /* MPR0 */
403 case 0x0440: /* MPR1 */
404 case 0x0480: /* MPR2 */
405 case 0x04c0: /* MPR3 */
406 /* MPR: Memory Programming Register. */
410 /* TTR: TIGbus Timing Register. */
411 /* All sorts of stuff related to interrupt delivery timings. */
414 /* TDR: TIGbug Device Timing Register. */
418 /* DIM2: Device Interrupt Mask Register, CPU2. */
419 s
->cchip
.dim
[2] = val
;
420 cpu_irq_change(s
->cchip
.cpu
[2], val
& s
->cchip
.drir
);
423 /* DIM3: Device Interrupt Mask Register, CPU3. */
424 s
->cchip
.dim
[3] = val
;
425 cpu_irq_change(s
->cchip
.cpu
[3], val
& s
->cchip
.drir
);
428 case 0x0680: /* DIR2 (RO) */
429 case 0x06c0: /* DIR3 (RO) */
432 case 0x0700: /* IIC2 */
433 s
->cchip
.iic
[2] = val
& 0xffffff;
435 case 0x0740: /* IIC3 */
436 s
->cchip
.iic
[3] = val
& 0xffffff;
440 /* PWR: Power Management Control. */
443 case 0x0c00: /* CMONCTLA */
444 case 0x0c40: /* CMONCTLB */
445 case 0x0c80: /* CMONCNT01 */
446 case 0x0cc0: /* CMONCNT23 */
456 static void dchip_write(void *opaque
, hwaddr addr
,
457 uint64_t val
, unsigned size
)
459 /* Skip this. It's all related to DRAM timing and setup. */
462 static MemTxResult
pchip_write(void *opaque
, hwaddr addr
,
463 uint64_t val
, unsigned size
,
466 TyphoonState
*s
= opaque
;
471 /* WSBA0: Window Space Base Address Register. */
472 s
->pchip
.win
[0].wba
= val
& 0xfff00003u
;
476 s
->pchip
.win
[1].wba
= val
& 0xfff00003u
;
480 s
->pchip
.win
[2].wba
= val
& 0xfff00003u
;
484 s
->pchip
.win
[3].wba
= (val
& 0x80fff00001ull
) | 2;
488 /* WSM0: Window Space Mask Register. */
489 s
->pchip
.win
[0].wsm
= val
& 0xfff00000u
;
493 s
->pchip
.win
[1].wsm
= val
& 0xfff00000u
;
497 s
->pchip
.win
[2].wsm
= val
& 0xfff00000u
;
501 s
->pchip
.win
[3].wsm
= val
& 0xfff00000u
;
505 /* TBA0: Translated Base Address Register. */
506 s
->pchip
.win
[0].tba
= val
& 0x7fffffc00ull
;
510 s
->pchip
.win
[1].tba
= val
& 0x7fffffc00ull
;
514 s
->pchip
.win
[2].tba
= val
& 0x7fffffc00ull
;
518 s
->pchip
.win
[3].tba
= val
& 0x7fffffc00ull
;
522 /* PCTL: Pchip Control Register. */
523 oldval
= s
->pchip
.ctl
;
524 oldval
&= ~0x00001cff0fc7ffull
; /* RW fields */
525 oldval
|= val
& 0x00001cff0fc7ffull
;
526 s
->pchip
.ctl
= oldval
;
530 /* PLAT: Pchip Master Latency Register. */
533 /* PERROR: Pchip Error Register. */
536 /* PERRMASK: Pchip Error Mask Register. */
539 /* PERRSET: Pchip Error Set Register. */
543 /* TLBIV: Translation Buffer Invalidate Virtual Register. */
547 /* TLBIA: Translation Buffer Invalidate All Register (WO). */
565 static const MemoryRegionOps cchip_ops
= {
566 .read_with_attrs
= cchip_read
,
567 .write_with_attrs
= cchip_write
,
568 .endianness
= DEVICE_LITTLE_ENDIAN
,
570 .min_access_size
= 8,
571 .max_access_size
= 8,
574 .min_access_size
= 8,
575 .max_access_size
= 8,
579 static const MemoryRegionOps dchip_ops
= {
581 .write
= dchip_write
,
582 .endianness
= DEVICE_LITTLE_ENDIAN
,
584 .min_access_size
= 8,
585 .max_access_size
= 8,
588 .min_access_size
= 8,
589 .max_access_size
= 8,
593 static const MemoryRegionOps pchip_ops
= {
594 .read_with_attrs
= pchip_read
,
595 .write_with_attrs
= pchip_write
,
596 .endianness
= DEVICE_LITTLE_ENDIAN
,
598 .min_access_size
= 8,
599 .max_access_size
= 8,
602 .min_access_size
= 8,
603 .max_access_size
= 8,
607 /* A subroutine of typhoon_translate_iommu that builds an IOMMUTLBEntry
608 using the given translated address and mask. */
609 static bool make_iommu_tlbe(hwaddr taddr
, hwaddr mask
, IOMMUTLBEntry
*ret
)
611 *ret
= (IOMMUTLBEntry
) {
612 .target_as
= &address_space_memory
,
613 .translated_addr
= taddr
,
620 /* A subroutine of typhoon_translate_iommu that handles scatter-gather
621 translation, given the address of the PTE. */
622 static bool pte_translate(hwaddr pte_addr
, IOMMUTLBEntry
*ret
)
624 uint64_t pte
= address_space_ldq(&address_space_memory
, pte_addr
,
625 MEMTXATTRS_UNSPECIFIED
, NULL
);
627 /* Check valid bit. */
628 if ((pte
& 1) == 0) {
632 return make_iommu_tlbe((pte
& 0x3ffffe) << 12, 0x1fff, ret
);
635 /* A subroutine of typhoon_translate_iommu that handles one of the
636 four single-address-cycle translation windows. */
637 static bool window_translate(TyphoonWindow
*win
, hwaddr addr
,
640 uint32_t wba
= win
->wba
;
641 uint64_t wsm
= win
->wsm
;
642 uint64_t tba
= win
->tba
;
643 uint64_t wsm_ext
= wsm
| 0xfffff;
645 /* Check for window disabled. */
646 if ((wba
& 1) == 0) {
650 /* Check for window hit. */
651 if ((addr
& ~wsm_ext
) != (wba
& 0xfff00000u
)) {
656 /* Scatter-gather translation. */
659 /* See table 10-6, Generating PTE address for PCI DMA Address. */
660 pte_addr
= tba
& ~(wsm
>> 10);
661 pte_addr
|= (addr
& (wsm
| 0xfe000)) >> 10;
662 return pte_translate(pte_addr
, ret
);
664 /* Direct-mapped translation. */
665 return make_iommu_tlbe(tba
& ~wsm_ext
, wsm_ext
, ret
);
669 /* Handle PCI-to-system address translation. */
670 /* TODO: A translation failure here ought to set PCI error codes on the
671 Pchip and generate a machine check interrupt. */
672 static IOMMUTLBEntry
typhoon_translate_iommu(IOMMUMemoryRegion
*iommu
,
674 IOMMUAccessFlags flag
,
677 TyphoonPchip
*pchip
= container_of(iommu
, TyphoonPchip
, iommu
);
681 if (addr
<= 0xffffffffu
) {
682 /* Single-address cycle. */
684 /* Check for the Window Hole, inhibiting matching. */
685 if ((pchip
->ctl
& 0x20)
687 && addr
<= 0xfffff) {
691 /* Check the first three windows. */
692 for (i
= 0; i
< 3; ++i
) {
693 if (window_translate(&pchip
->win
[i
], addr
, &ret
)) {
698 /* Check the fourth window for DAC disable. */
699 if ((pchip
->win
[3].wba
& 0x80000000000ull
) == 0
700 && window_translate(&pchip
->win
[3], addr
, &ret
)) {
704 /* Double-address cycle. */
706 if (addr
>= 0x10000000000ull
&& addr
< 0x20000000000ull
) {
707 /* Check for the DMA monster window. */
708 if (pchip
->ctl
& 0x40) {
709 /* See 10.1.4.4; in particular <39:35> is ignored. */
710 make_iommu_tlbe(0, 0x007ffffffffull
, &ret
);
715 if (addr
>= 0x80000000000ull
&& addr
<= 0xfffffffffffull
) {
716 /* Check the fourth window for DAC enable and window enable. */
717 if ((pchip
->win
[3].wba
& 0x80000000001ull
) == 0x80000000001ull
) {
720 pte_addr
= pchip
->win
[3].tba
& 0x7ffc00000ull
;
721 pte_addr
|= (addr
& 0xffffe000u
) >> 10;
722 if (pte_translate(pte_addr
, &ret
)) {
730 ret
= (IOMMUTLBEntry
) { .perm
= IOMMU_NONE
};
735 static AddressSpace
*typhoon_pci_dma_iommu(PCIBus
*bus
, void *opaque
, int devfn
)
737 TyphoonState
*s
= opaque
;
738 return &s
->pchip
.iommu_as
;
741 static const PCIIOMMUOps typhoon_iommu_ops
= {
742 .get_address_space
= typhoon_pci_dma_iommu
,
745 static void typhoon_set_irq(void *opaque
, int irq
, int level
)
747 TyphoonState
*s
= opaque
;
751 /* Set/Reset the bit in CCHIP.DRIR based on IRQ+LEVEL. */
752 drir
= s
->cchip
.drir
;
756 drir
&= ~(1ull << irq
);
758 s
->cchip
.drir
= drir
;
760 for (i
= 0; i
< 4; ++i
) {
761 cpu_irq_change(s
->cchip
.cpu
[i
], s
->cchip
.dim
[i
] & drir
);
765 static void typhoon_set_isa_irq(void *opaque
, int irq
, int level
)
767 typhoon_set_irq(opaque
, 55, level
);
770 static void typhoon_set_timer_irq(void *opaque
, int irq
, int level
)
772 TyphoonState
*s
= opaque
;
775 /* Thankfully, the mc146818rtc code doesn't track the IRQ state,
776 and so we don't have to worry about missing interrupts just
777 because we never actually ACK the interrupt. Just ignore any
778 case of the interrupt level going low. */
783 /* Deliver the interrupt to each CPU, considering each CPU's IIC. */
784 for (i
= 0; i
< 4; ++i
) {
785 AlphaCPU
*cpu
= s
->cchip
.cpu
[i
];
787 uint32_t iic
= s
->cchip
.iic
[i
];
789 /* ??? The verbage in Section 10.2.2.10 isn't 100% clear.
790 Bit 24 is the OverFlow bit, RO, and set when the count
791 decrements past 0. When is OF cleared? My guess is that
792 OF is actually cleared when the IIC is written, and that
793 the ICNT field always decrements. At least, that's an
794 interpretation that makes sense, and "allows the CPU to
795 determine exactly how mant interval timer ticks were
796 skipped". At least within the next 4M ticks... */
798 iic
= ((iic
- 1) & 0x1ffffff) | (iic
& 0x1000000);
799 s
->cchip
.iic
[i
] = iic
;
801 if (iic
& 0x1000000) {
802 /* Set the ITI bit for this cpu. */
803 s
->cchip
.misc
|= 1 << (i
+ 4);
804 /* And signal the interrupt. */
805 cpu_interrupt(CPU(cpu
), CPU_INTERRUPT_TIMER
);
811 static void typhoon_alarm_timer(void *opaque
)
813 TyphoonState
*s
= (TyphoonState
*)((uintptr_t)opaque
& ~3);
814 int cpu
= (uintptr_t)opaque
& 3;
816 /* Set the ITI bit for this cpu. */
817 s
->cchip
.misc
|= 1 << (cpu
+ 4);
818 cpu_interrupt(CPU(s
->cchip
.cpu
[cpu
]), CPU_INTERRUPT_TIMER
);
821 PCIBus
*typhoon_init(MemoryRegion
*ram
, qemu_irq
*p_isa_irq
,
822 qemu_irq
*p_rtc_irq
, AlphaCPU
*cpus
[4],
823 pci_map_irq_fn sys_map_irq
, uint8_t devfn_min
)
825 MemoryRegion
*addr_space
= get_system_memory();
832 dev
= qdev_new(TYPE_TYPHOON_PCI_HOST_BRIDGE
);
834 s
= TYPHOON_PCI_HOST_BRIDGE(dev
);
835 phb
= PCI_HOST_BRIDGE(dev
);
837 s
->cchip
.misc
= 0x800000000ull
; /* Revision: Typhoon. */
838 s
->pchip
.win
[3].wba
= 2; /* Window 3 SG always enabled. */
840 /* Remember the CPUs so that we can deliver interrupts to them. */
841 for (i
= 0; i
< 4; i
++) {
842 AlphaCPU
*cpu
= cpus
[i
];
843 s
->cchip
.cpu
[i
] = cpu
;
845 cpu
->alarm_timer
= timer_new_ns(QEMU_CLOCK_VIRTUAL
,
847 (void *)((uintptr_t)s
+ i
));
851 *p_isa_irq
= qemu_allocate_irq(typhoon_set_isa_irq
, s
, 0);
852 *p_rtc_irq
= qemu_allocate_irq(typhoon_set_timer_irq
, s
, 0);
854 /* Main memory region, 0x00.0000.0000. Real hardware supports 32GB,
855 but the address space hole reserved at this point is 8TB. */
856 memory_region_add_subregion(addr_space
, 0, ram
);
858 /* TIGbus, 0x801.0000.0000, 1GB. */
859 /* ??? The TIGbus is used for delivering interrupts, and access to
860 the flash ROM. I'm not sure that we need to implement it at all. */
862 /* Pchip0 CSRs, 0x801.8000.0000, 256MB. */
863 memory_region_init_io(&s
->pchip
.region
, OBJECT(s
), &pchip_ops
, s
, "pchip0",
865 memory_region_add_subregion(addr_space
, 0x80180000000ULL
,
868 /* Cchip CSRs, 0x801.A000.0000, 256MB. */
869 memory_region_init_io(&s
->cchip
.region
, OBJECT(s
), &cchip_ops
, s
, "cchip0",
871 memory_region_add_subregion(addr_space
, 0x801a0000000ULL
,
874 /* Dchip CSRs, 0x801.B000.0000, 256MB. */
875 memory_region_init_io(&s
->dchip_region
, OBJECT(s
), &dchip_ops
, s
, "dchip0",
877 memory_region_add_subregion(addr_space
, 0x801b0000000ULL
,
880 /* Pchip0 PCI memory, 0x800.0000.0000, 4GB. */
881 memory_region_init(&s
->pchip
.reg_mem
, OBJECT(s
), "pci0-mem", 4 * GiB
);
882 memory_region_add_subregion(addr_space
, 0x80000000000ULL
,
885 /* Pchip0 PCI I/O, 0x801.FC00.0000, 32MB. */
886 memory_region_init_io(&s
->pchip
.reg_io
, OBJECT(s
), &alpha_pci_ignore_ops
,
887 NULL
, "pci0-io", 32 * MiB
);
888 memory_region_add_subregion(addr_space
, 0x801fc000000ULL
,
891 b
= pci_register_root_bus(dev
, "pci",
892 typhoon_set_irq
, sys_map_irq
, s
,
893 &s
->pchip
.reg_mem
, &s
->pchip
.reg_io
,
894 devfn_min
, 64, TYPE_PCI_BUS
);
896 sysbus_realize_and_unref(SYS_BUS_DEVICE(dev
), &error_fatal
);
898 /* Host memory as seen from the PCI side, via the IOMMU. */
899 memory_region_init_iommu(&s
->pchip
.iommu
, sizeof(s
->pchip
.iommu
),
900 TYPE_TYPHOON_IOMMU_MEMORY_REGION
, OBJECT(s
),
901 "iommu-typhoon", UINT64_MAX
);
902 address_space_init(&s
->pchip
.iommu_as
, MEMORY_REGION(&s
->pchip
.iommu
),
904 pci_setup_iommu(b
, &typhoon_iommu_ops
, s
);
906 /* Pchip0 PCI special/interrupt acknowledge, 0x801.F800.0000, 64MB. */
907 memory_region_init_io(&s
->pchip
.reg_iack
, OBJECT(s
), &alpha_pci_iack_ops
,
908 b
, "pci0-iack", 64 * MiB
);
909 memory_region_add_subregion(addr_space
, 0x801f8000000ULL
,
912 /* Pchip0 PCI configuration, 0x801.FE00.0000, 16MB. */
913 memory_region_init_io(&s
->pchip
.reg_conf
, OBJECT(s
), &alpha_pci_conf1_ops
,
914 b
, "pci0-conf", 16 * MiB
);
915 memory_region_add_subregion(addr_space
, 0x801fe000000ULL
,
918 /* For the record, these are the mappings for the second PCI bus.
919 We can get away with not implementing them because we indicate
920 via the Cchip.CSC<PIP> bit that Pchip1 is not present. */
921 /* Pchip1 PCI memory, 0x802.0000.0000, 4GB. */
922 /* Pchip1 CSRs, 0x802.8000.0000, 256MB. */
923 /* Pchip1 PCI special/interrupt acknowledge, 0x802.F800.0000, 64MB. */
924 /* Pchip1 PCI I/O, 0x802.FC00.0000, 32MB. */
925 /* Pchip1 PCI configuration, 0x802.FE00.0000, 16MB. */
930 static const TypeInfo typhoon_pcihost_info
= {
931 .name
= TYPE_TYPHOON_PCI_HOST_BRIDGE
,
932 .parent
= TYPE_PCI_HOST_BRIDGE
,
933 .instance_size
= sizeof(TyphoonState
),
936 static void typhoon_iommu_memory_region_class_init(ObjectClass
*klass
,
939 IOMMUMemoryRegionClass
*imrc
= IOMMU_MEMORY_REGION_CLASS(klass
);
941 imrc
->translate
= typhoon_translate_iommu
;
944 static const TypeInfo typhoon_iommu_memory_region_info
= {
945 .parent
= TYPE_IOMMU_MEMORY_REGION
,
946 .name
= TYPE_TYPHOON_IOMMU_MEMORY_REGION
,
947 .class_init
= typhoon_iommu_memory_region_class_init
,
950 static void typhoon_register_types(void)
952 type_register_static(&typhoon_pcihost_info
);
953 type_register_static(&typhoon_iommu_memory_region_info
);
956 type_init(typhoon_register_types
)