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"
15 #include "alpha_sys.h"
16 #include "exec/address-spaces.h"
17 #include "qom/object.h"
20 #define TYPE_TYPHOON_PCI_HOST_BRIDGE "typhoon-pcihost"
21 #define TYPE_TYPHOON_IOMMU_MEMORY_REGION "typhoon-iommu-memory-region"
23 typedef struct TyphoonCchip
{
32 typedef struct TyphoonWindow
{
38 typedef struct TyphoonPchip
{
40 MemoryRegion reg_iack
;
43 MemoryRegion reg_conf
;
45 AddressSpace iommu_as
;
46 IOMMUMemoryRegion iommu
;
52 OBJECT_DECLARE_SIMPLE_TYPE(TyphoonState
, TYPHOON_PCI_HOST_BRIDGE
)
55 PCIHostState parent_obj
;
59 MemoryRegion dchip_region
;
62 /* Called when one of DRIR or DIM changes. */
63 static void cpu_irq_change(AlphaCPU
*cpu
, uint64_t req
)
65 /* If there are any non-masked interrupts, tell the cpu. */
67 CPUState
*cs
= CPU(cpu
);
69 cpu_interrupt(cs
, CPU_INTERRUPT_HARD
);
71 cpu_reset_interrupt(cs
, CPU_INTERRUPT_HARD
);
76 static MemTxResult
cchip_read(void *opaque
, hwaddr addr
,
77 uint64_t *data
, unsigned size
,
80 CPUState
*cpu
= current_cpu
;
81 TyphoonState
*s
= opaque
;
86 /* CSC: Cchip System Configuration Register. */
87 /* All sorts of data here; probably the only thing relevant is
88 PIP<14> Pchip 1 Present = 0. */
92 /* MTR: Memory Timing Register. */
93 /* All sorts of stuff related to real DRAM. */
97 /* MISC: Miscellaneous Register. */
98 ret
= s
->cchip
.misc
| (cpu
->cpu_index
& 3);
102 /* MPD: Memory Presence Detect Register. */
105 case 0x0100: /* AAR0 */
106 case 0x0140: /* AAR1 */
107 case 0x0180: /* AAR2 */
108 case 0x01c0: /* AAR3 */
109 /* AAR: Array Address Register. */
110 /* All sorts of information about DRAM. */
114 /* DIM0: Device Interrupt Mask Register, CPU0. */
115 ret
= s
->cchip
.dim
[0];
118 /* DIM1: Device Interrupt Mask Register, CPU1. */
119 ret
= s
->cchip
.dim
[1];
122 /* DIR0: Device Interrupt Request Register, CPU0. */
123 ret
= s
->cchip
.dim
[0] & s
->cchip
.drir
;
126 /* DIR1: Device Interrupt Request Register, CPU1. */
127 ret
= s
->cchip
.dim
[1] & s
->cchip
.drir
;
130 /* DRIR: Device Raw Interrupt Request Register. */
135 /* PRBEN: Probe Enable Register. */
139 /* IIC0: Interval Ignore Count Register, CPU0. */
140 ret
= s
->cchip
.iic
[0];
143 /* IIC1: Interval Ignore Count Register, CPU1. */
144 ret
= s
->cchip
.iic
[1];
147 case 0x0400: /* MPR0 */
148 case 0x0440: /* MPR1 */
149 case 0x0480: /* MPR2 */
150 case 0x04c0: /* MPR3 */
151 /* MPR: Memory Programming Register. */
155 /* TTR: TIGbus Timing Register. */
156 /* All sorts of stuff related to interrupt delivery timings. */
159 /* TDR: TIGbug Device Timing Register. */
163 /* DIM2: Device Interrupt Mask Register, CPU2. */
164 ret
= s
->cchip
.dim
[2];
167 /* DIM3: Device Interrupt Mask Register, CPU3. */
168 ret
= s
->cchip
.dim
[3];
171 /* DIR2: Device Interrupt Request Register, CPU2. */
172 ret
= s
->cchip
.dim
[2] & s
->cchip
.drir
;
175 /* DIR3: Device Interrupt Request Register, CPU3. */
176 ret
= s
->cchip
.dim
[3] & s
->cchip
.drir
;
180 /* IIC2: Interval Ignore Count Register, CPU2. */
181 ret
= s
->cchip
.iic
[2];
184 /* IIC3: Interval Ignore Count Register, CPU3. */
185 ret
= s
->cchip
.iic
[3];
189 /* PWR: Power Management Control. */
192 case 0x0c00: /* CMONCTLA */
193 case 0x0c40: /* CMONCTLB */
194 case 0x0c80: /* CMONCNT01 */
195 case 0x0cc0: /* CMONCNT23 */
206 static uint64_t dchip_read(void *opaque
, hwaddr addr
, unsigned size
)
208 /* Skip this. It's all related to DRAM timing and setup. */
212 static MemTxResult
pchip_read(void *opaque
, hwaddr addr
, uint64_t *data
,
213 unsigned size
, MemTxAttrs attrs
)
215 TyphoonState
*s
= opaque
;
220 /* WSBA0: Window Space Base Address Register. */
221 ret
= s
->pchip
.win
[0].wba
;
225 ret
= s
->pchip
.win
[1].wba
;
229 ret
= s
->pchip
.win
[2].wba
;
233 ret
= s
->pchip
.win
[3].wba
;
237 /* WSM0: Window Space Mask Register. */
238 ret
= s
->pchip
.win
[0].wsm
;
242 ret
= s
->pchip
.win
[1].wsm
;
246 ret
= s
->pchip
.win
[2].wsm
;
250 ret
= s
->pchip
.win
[3].wsm
;
254 /* TBA0: Translated Base Address Register. */
255 ret
= s
->pchip
.win
[0].tba
;
259 ret
= s
->pchip
.win
[1].tba
;
263 ret
= s
->pchip
.win
[2].tba
;
267 ret
= s
->pchip
.win
[3].tba
;
271 /* PCTL: Pchip Control Register. */
275 /* PLAT: Pchip Master Latency Register. */
278 /* PERROR: Pchip Error Register. */
281 /* PERRMASK: Pchip Error Mask Register. */
284 /* PERRSET: Pchip Error Set Register. */
287 /* TLBIV: Translation Buffer Invalidate Virtual Register (WO). */
290 /* TLBIA: Translation Buffer Invalidate All Register (WO). */
292 case 0x0500: /* PMONCTL */
293 case 0x0540: /* PMONCNT */
294 case 0x0800: /* SPRST */
305 static MemTxResult
cchip_write(void *opaque
, hwaddr addr
,
306 uint64_t val
, unsigned size
,
309 TyphoonState
*s
= opaque
;
310 uint64_t oldval
, newval
;
314 /* CSC: Cchip System Configuration Register. */
315 /* All sorts of data here; nothing relevant RW. */
319 /* MTR: Memory Timing Register. */
320 /* All sorts of stuff related to real DRAM. */
324 /* MISC: Miscellaneous Register. */
325 newval
= oldval
= s
->cchip
.misc
;
326 newval
&= ~(val
& 0x10000ff0); /* W1C fields */
327 if (val
& 0x100000) {
328 newval
&= ~0xff0000ull
; /* ACL clears ABT and ABW */
330 newval
|= val
& 0x00f00000; /* ABT field is W1S */
331 if ((newval
& 0xf0000) == 0) {
332 newval
|= val
& 0xf0000; /* ABW field is W1S iff zero */
335 newval
|= (val
& 0xf000) >> 4; /* IPREQ field sets IPINTR. */
337 newval
&= ~0xf0000000000ull
; /* WO and RW fields */
338 newval
|= val
& 0xf0000000000ull
;
339 s
->cchip
.misc
= newval
;
341 /* Pass on changes to IPI and ITI state. */
342 if ((newval
^ oldval
) & 0xff0) {
344 for (i
= 0; i
< 4; ++i
) {
345 AlphaCPU
*cpu
= s
->cchip
.cpu
[i
];
347 CPUState
*cs
= CPU(cpu
);
348 /* IPI can be either cleared or set by the write. */
349 if (newval
& (1 << (i
+ 8))) {
350 cpu_interrupt(cs
, CPU_INTERRUPT_SMP
);
352 cpu_reset_interrupt(cs
, CPU_INTERRUPT_SMP
);
355 /* ITI can only be cleared by the write. */
356 if ((newval
& (1 << (i
+ 4))) == 0) {
357 cpu_reset_interrupt(cs
, CPU_INTERRUPT_TIMER
);
365 /* MPD: Memory Presence Detect Register. */
368 case 0x0100: /* AAR0 */
369 case 0x0140: /* AAR1 */
370 case 0x0180: /* AAR2 */
371 case 0x01c0: /* AAR3 */
372 /* AAR: Array Address Register. */
373 /* All sorts of information about DRAM. */
376 case 0x0200: /* DIM0 */
377 /* DIM: Device Interrupt Mask Register, CPU0. */
378 s
->cchip
.dim
[0] = val
;
379 cpu_irq_change(s
->cchip
.cpu
[0], val
& s
->cchip
.drir
);
381 case 0x0240: /* DIM1 */
382 /* DIM: Device Interrupt Mask Register, CPU1. */
383 s
->cchip
.dim
[1] = val
;
384 cpu_irq_change(s
->cchip
.cpu
[1], val
& s
->cchip
.drir
);
387 case 0x0280: /* DIR0 (RO) */
388 case 0x02c0: /* DIR1 (RO) */
389 case 0x0300: /* DRIR (RO) */
393 /* PRBEN: Probe Enable Register. */
396 case 0x0380: /* IIC0 */
397 s
->cchip
.iic
[0] = val
& 0xffffff;
399 case 0x03c0: /* IIC1 */
400 s
->cchip
.iic
[1] = val
& 0xffffff;
403 case 0x0400: /* MPR0 */
404 case 0x0440: /* MPR1 */
405 case 0x0480: /* MPR2 */
406 case 0x04c0: /* MPR3 */
407 /* MPR: Memory Programming Register. */
411 /* TTR: TIGbus Timing Register. */
412 /* All sorts of stuff related to interrupt delivery timings. */
415 /* TDR: TIGbug Device Timing Register. */
419 /* DIM2: Device Interrupt Mask Register, CPU2. */
420 s
->cchip
.dim
[2] = val
;
421 cpu_irq_change(s
->cchip
.cpu
[2], val
& s
->cchip
.drir
);
424 /* DIM3: Device Interrupt Mask Register, CPU3. */
425 s
->cchip
.dim
[3] = val
;
426 cpu_irq_change(s
->cchip
.cpu
[3], val
& s
->cchip
.drir
);
429 case 0x0680: /* DIR2 (RO) */
430 case 0x06c0: /* DIR3 (RO) */
433 case 0x0700: /* IIC2 */
434 s
->cchip
.iic
[2] = val
& 0xffffff;
436 case 0x0740: /* IIC3 */
437 s
->cchip
.iic
[3] = val
& 0xffffff;
441 /* PWR: Power Management Control. */
444 case 0x0c00: /* CMONCTLA */
445 case 0x0c40: /* CMONCTLB */
446 case 0x0c80: /* CMONCNT01 */
447 case 0x0cc0: /* CMONCNT23 */
457 static void dchip_write(void *opaque
, hwaddr addr
,
458 uint64_t val
, unsigned size
)
460 /* Skip this. It's all related to DRAM timing and setup. */
463 static MemTxResult
pchip_write(void *opaque
, hwaddr addr
,
464 uint64_t val
, unsigned size
,
467 TyphoonState
*s
= opaque
;
472 /* WSBA0: Window Space Base Address Register. */
473 s
->pchip
.win
[0].wba
= val
& 0xfff00003u
;
477 s
->pchip
.win
[1].wba
= val
& 0xfff00003u
;
481 s
->pchip
.win
[2].wba
= val
& 0xfff00003u
;
485 s
->pchip
.win
[3].wba
= (val
& 0x80fff00001ull
) | 2;
489 /* WSM0: Window Space Mask Register. */
490 s
->pchip
.win
[0].wsm
= val
& 0xfff00000u
;
494 s
->pchip
.win
[1].wsm
= val
& 0xfff00000u
;
498 s
->pchip
.win
[2].wsm
= val
& 0xfff00000u
;
502 s
->pchip
.win
[3].wsm
= val
& 0xfff00000u
;
506 /* TBA0: Translated Base Address Register. */
507 s
->pchip
.win
[0].tba
= val
& 0x7fffffc00ull
;
511 s
->pchip
.win
[1].tba
= val
& 0x7fffffc00ull
;
515 s
->pchip
.win
[2].tba
= val
& 0x7fffffc00ull
;
519 s
->pchip
.win
[3].tba
= val
& 0x7fffffc00ull
;
523 /* PCTL: Pchip Control Register. */
524 oldval
= s
->pchip
.ctl
;
525 oldval
&= ~0x00001cff0fc7ffull
; /* RW fields */
526 oldval
|= val
& 0x00001cff0fc7ffull
;
527 s
->pchip
.ctl
= oldval
;
531 /* PLAT: Pchip Master Latency Register. */
534 /* PERROR: Pchip Error Register. */
537 /* PERRMASK: Pchip Error Mask Register. */
540 /* PERRSET: Pchip Error Set Register. */
544 /* TLBIV: Translation Buffer Invalidate Virtual Register. */
548 /* TLBIA: Translation Buffer Invalidate All Register (WO). */
566 static const MemoryRegionOps cchip_ops
= {
567 .read_with_attrs
= cchip_read
,
568 .write_with_attrs
= cchip_write
,
569 .endianness
= DEVICE_LITTLE_ENDIAN
,
571 .min_access_size
= 8,
572 .max_access_size
= 8,
575 .min_access_size
= 8,
576 .max_access_size
= 8,
580 static const MemoryRegionOps dchip_ops
= {
582 .write
= dchip_write
,
583 .endianness
= DEVICE_LITTLE_ENDIAN
,
585 .min_access_size
= 8,
586 .max_access_size
= 8,
589 .min_access_size
= 8,
590 .max_access_size
= 8,
594 static const MemoryRegionOps pchip_ops
= {
595 .read_with_attrs
= pchip_read
,
596 .write_with_attrs
= pchip_write
,
597 .endianness
= DEVICE_LITTLE_ENDIAN
,
599 .min_access_size
= 8,
600 .max_access_size
= 8,
603 .min_access_size
= 8,
604 .max_access_size
= 8,
608 /* A subroutine of typhoon_translate_iommu that builds an IOMMUTLBEntry
609 using the given translated address and mask. */
610 static bool make_iommu_tlbe(hwaddr taddr
, hwaddr mask
, IOMMUTLBEntry
*ret
)
612 *ret
= (IOMMUTLBEntry
) {
613 .target_as
= &address_space_memory
,
614 .translated_addr
= taddr
,
621 /* A subroutine of typhoon_translate_iommu that handles scatter-gather
622 translation, given the address of the PTE. */
623 static bool pte_translate(hwaddr pte_addr
, IOMMUTLBEntry
*ret
)
625 uint64_t pte
= address_space_ldq(&address_space_memory
, pte_addr
,
626 MEMTXATTRS_UNSPECIFIED
, NULL
);
628 /* Check valid bit. */
629 if ((pte
& 1) == 0) {
633 return make_iommu_tlbe((pte
& 0x3ffffe) << 12, 0x1fff, ret
);
636 /* A subroutine of typhoon_translate_iommu that handles one of the
637 four single-address-cycle translation windows. */
638 static bool window_translate(TyphoonWindow
*win
, hwaddr addr
,
641 uint32_t wba
= win
->wba
;
642 uint64_t wsm
= win
->wsm
;
643 uint64_t tba
= win
->tba
;
644 uint64_t wsm_ext
= wsm
| 0xfffff;
646 /* Check for window disabled. */
647 if ((wba
& 1) == 0) {
651 /* Check for window hit. */
652 if ((addr
& ~wsm_ext
) != (wba
& 0xfff00000u
)) {
657 /* Scatter-gather translation. */
660 /* See table 10-6, Generating PTE address for PCI DMA Address. */
661 pte_addr
= tba
& ~(wsm
>> 10);
662 pte_addr
|= (addr
& (wsm
| 0xfe000)) >> 10;
663 return pte_translate(pte_addr
, ret
);
665 /* Direct-mapped translation. */
666 return make_iommu_tlbe(tba
& ~wsm_ext
, wsm_ext
, ret
);
670 /* Handle PCI-to-system address translation. */
671 /* TODO: A translation failure here ought to set PCI error codes on the
672 Pchip and generate a machine check interrupt. */
673 static IOMMUTLBEntry
typhoon_translate_iommu(IOMMUMemoryRegion
*iommu
,
675 IOMMUAccessFlags flag
,
678 TyphoonPchip
*pchip
= container_of(iommu
, TyphoonPchip
, iommu
);
682 if (addr
<= 0xffffffffu
) {
683 /* Single-address cycle. */
685 /* Check for the Window Hole, inhibiting matching. */
686 if ((pchip
->ctl
& 0x20)
688 && addr
<= 0xfffff) {
692 /* Check the first three windows. */
693 for (i
= 0; i
< 3; ++i
) {
694 if (window_translate(&pchip
->win
[i
], addr
, &ret
)) {
699 /* Check the fourth window for DAC disable. */
700 if ((pchip
->win
[3].wba
& 0x80000000000ull
) == 0
701 && window_translate(&pchip
->win
[3], addr
, &ret
)) {
705 /* Double-address cycle. */
707 if (addr
>= 0x10000000000ull
&& addr
< 0x20000000000ull
) {
708 /* Check for the DMA monster window. */
709 if (pchip
->ctl
& 0x40) {
710 /* See 10.1.4.4; in particular <39:35> is ignored. */
711 make_iommu_tlbe(0, 0x007ffffffffull
, &ret
);
716 if (addr
>= 0x80000000000ull
&& addr
<= 0xfffffffffffull
) {
717 /* Check the fourth window for DAC enable and window enable. */
718 if ((pchip
->win
[3].wba
& 0x80000000001ull
) == 0x80000000001ull
) {
721 pte_addr
= pchip
->win
[3].tba
& 0x7ffc00000ull
;
722 pte_addr
|= (addr
& 0xffffe000u
) >> 10;
723 if (pte_translate(pte_addr
, &ret
)) {
731 ret
= (IOMMUTLBEntry
) { .perm
= IOMMU_NONE
};
736 static AddressSpace
*typhoon_pci_dma_iommu(PCIBus
*bus
, void *opaque
, int devfn
)
738 TyphoonState
*s
= opaque
;
739 return &s
->pchip
.iommu_as
;
742 static void typhoon_set_irq(void *opaque
, int irq
, int level
)
744 TyphoonState
*s
= opaque
;
748 /* Set/Reset the bit in CCHIP.DRIR based on IRQ+LEVEL. */
749 drir
= s
->cchip
.drir
;
753 drir
&= ~(1ull << irq
);
755 s
->cchip
.drir
= drir
;
757 for (i
= 0; i
< 4; ++i
) {
758 cpu_irq_change(s
->cchip
.cpu
[i
], s
->cchip
.dim
[i
] & drir
);
762 static void typhoon_set_isa_irq(void *opaque
, int irq
, int level
)
764 typhoon_set_irq(opaque
, 55, level
);
767 static void typhoon_set_timer_irq(void *opaque
, int irq
, int level
)
769 TyphoonState
*s
= opaque
;
772 /* Thankfully, the mc146818rtc code doesn't track the IRQ state,
773 and so we don't have to worry about missing interrupts just
774 because we never actually ACK the interrupt. Just ignore any
775 case of the interrupt level going low. */
780 /* Deliver the interrupt to each CPU, considering each CPU's IIC. */
781 for (i
= 0; i
< 4; ++i
) {
782 AlphaCPU
*cpu
= s
->cchip
.cpu
[i
];
784 uint32_t iic
= s
->cchip
.iic
[i
];
786 /* ??? The verbage in Section 10.2.2.10 isn't 100% clear.
787 Bit 24 is the OverFlow bit, RO, and set when the count
788 decrements past 0. When is OF cleared? My guess is that
789 OF is actually cleared when the IIC is written, and that
790 the ICNT field always decrements. At least, that's an
791 interpretation that makes sense, and "allows the CPU to
792 determine exactly how mant interval timer ticks were
793 skipped". At least within the next 4M ticks... */
795 iic
= ((iic
- 1) & 0x1ffffff) | (iic
& 0x1000000);
796 s
->cchip
.iic
[i
] = iic
;
798 if (iic
& 0x1000000) {
799 /* Set the ITI bit for this cpu. */
800 s
->cchip
.misc
|= 1 << (i
+ 4);
801 /* And signal the interrupt. */
802 cpu_interrupt(CPU(cpu
), CPU_INTERRUPT_TIMER
);
808 static void typhoon_alarm_timer(void *opaque
)
810 TyphoonState
*s
= (TyphoonState
*)((uintptr_t)opaque
& ~3);
811 int cpu
= (uintptr_t)opaque
& 3;
813 /* Set the ITI bit for this cpu. */
814 s
->cchip
.misc
|= 1 << (cpu
+ 4);
815 cpu_interrupt(CPU(s
->cchip
.cpu
[cpu
]), CPU_INTERRUPT_TIMER
);
818 PCIBus
*typhoon_init(MemoryRegion
*ram
, ISABus
**isa_bus
, qemu_irq
*p_rtc_irq
,
819 AlphaCPU
*cpus
[4], pci_map_irq_fn sys_map_irq
)
821 MemoryRegion
*addr_space
= get_system_memory();
828 dev
= qdev_new(TYPE_TYPHOON_PCI_HOST_BRIDGE
);
830 s
= TYPHOON_PCI_HOST_BRIDGE(dev
);
831 phb
= PCI_HOST_BRIDGE(dev
);
833 s
->cchip
.misc
= 0x800000000ull
; /* Revision: Typhoon. */
834 s
->pchip
.win
[3].wba
= 2; /* Window 3 SG always enabled. */
836 /* Remember the CPUs so that we can deliver interrupts to them. */
837 for (i
= 0; i
< 4; i
++) {
838 AlphaCPU
*cpu
= cpus
[i
];
839 s
->cchip
.cpu
[i
] = cpu
;
841 cpu
->alarm_timer
= timer_new_ns(QEMU_CLOCK_VIRTUAL
,
843 (void *)((uintptr_t)s
+ i
));
847 *p_rtc_irq
= qemu_allocate_irq(typhoon_set_timer_irq
, s
, 0);
849 /* Main memory region, 0x00.0000.0000. Real hardware supports 32GB,
850 but the address space hole reserved at this point is 8TB. */
851 memory_region_add_subregion(addr_space
, 0, ram
);
853 /* TIGbus, 0x801.0000.0000, 1GB. */
854 /* ??? The TIGbus is used for delivering interrupts, and access to
855 the flash ROM. I'm not sure that we need to implement it at all. */
857 /* Pchip0 CSRs, 0x801.8000.0000, 256MB. */
858 memory_region_init_io(&s
->pchip
.region
, OBJECT(s
), &pchip_ops
, s
, "pchip0",
860 memory_region_add_subregion(addr_space
, 0x80180000000ULL
,
863 /* Cchip CSRs, 0x801.A000.0000, 256MB. */
864 memory_region_init_io(&s
->cchip
.region
, OBJECT(s
), &cchip_ops
, s
, "cchip0",
866 memory_region_add_subregion(addr_space
, 0x801a0000000ULL
,
869 /* Dchip CSRs, 0x801.B000.0000, 256MB. */
870 memory_region_init_io(&s
->dchip_region
, OBJECT(s
), &dchip_ops
, s
, "dchip0",
872 memory_region_add_subregion(addr_space
, 0x801b0000000ULL
,
875 /* Pchip0 PCI memory, 0x800.0000.0000, 4GB. */
876 memory_region_init(&s
->pchip
.reg_mem
, OBJECT(s
), "pci0-mem", 4 * GiB
);
877 memory_region_add_subregion(addr_space
, 0x80000000000ULL
,
880 /* Pchip0 PCI I/O, 0x801.FC00.0000, 32MB. */
881 memory_region_init_io(&s
->pchip
.reg_io
, OBJECT(s
), &alpha_pci_ignore_ops
,
882 NULL
, "pci0-io", 32 * MiB
);
883 memory_region_add_subregion(addr_space
, 0x801fc000000ULL
,
886 b
= pci_register_root_bus(dev
, "pci",
887 typhoon_set_irq
, sys_map_irq
, s
,
888 &s
->pchip
.reg_mem
, &s
->pchip
.reg_io
,
889 0, 64, TYPE_PCI_BUS
);
891 sysbus_realize_and_unref(SYS_BUS_DEVICE(dev
), &error_fatal
);
893 /* Host memory as seen from the PCI side, via the IOMMU. */
894 memory_region_init_iommu(&s
->pchip
.iommu
, sizeof(s
->pchip
.iommu
),
895 TYPE_TYPHOON_IOMMU_MEMORY_REGION
, OBJECT(s
),
896 "iommu-typhoon", UINT64_MAX
);
897 address_space_init(&s
->pchip
.iommu_as
, MEMORY_REGION(&s
->pchip
.iommu
),
899 pci_setup_iommu(b
, typhoon_pci_dma_iommu
, s
);
901 /* Pchip0 PCI special/interrupt acknowledge, 0x801.F800.0000, 64MB. */
902 memory_region_init_io(&s
->pchip
.reg_iack
, OBJECT(s
), &alpha_pci_iack_ops
,
903 b
, "pci0-iack", 64 * MiB
);
904 memory_region_add_subregion(addr_space
, 0x801f8000000ULL
,
907 /* Pchip0 PCI configuration, 0x801.FE00.0000, 16MB. */
908 memory_region_init_io(&s
->pchip
.reg_conf
, OBJECT(s
), &alpha_pci_conf1_ops
,
909 b
, "pci0-conf", 16 * MiB
);
910 memory_region_add_subregion(addr_space
, 0x801fe000000ULL
,
913 /* For the record, these are the mappings for the second PCI bus.
914 We can get away with not implementing them because we indicate
915 via the Cchip.CSC<PIP> bit that Pchip1 is not present. */
916 /* Pchip1 PCI memory, 0x802.0000.0000, 4GB. */
917 /* Pchip1 CSRs, 0x802.8000.0000, 256MB. */
918 /* Pchip1 PCI special/interrupt acknowledge, 0x802.F800.0000, 64MB. */
919 /* Pchip1 PCI I/O, 0x802.FC00.0000, 32MB. */
920 /* Pchip1 PCI configuration, 0x802.FE00.0000, 16MB. */
922 /* Init the ISA bus. */
923 /* ??? Technically there should be a cy82c693ub pci-isa bridge. */
927 *isa_bus
= isa_bus_new(NULL
, get_system_memory(), &s
->pchip
.reg_io
,
929 isa_irqs
= i8259_init(*isa_bus
,
930 qemu_allocate_irq(typhoon_set_isa_irq
, s
, 0));
931 isa_bus_irqs(*isa_bus
, isa_irqs
);
937 static const TypeInfo typhoon_pcihost_info
= {
938 .name
= TYPE_TYPHOON_PCI_HOST_BRIDGE
,
939 .parent
= TYPE_PCI_HOST_BRIDGE
,
940 .instance_size
= sizeof(TyphoonState
),
943 static void typhoon_iommu_memory_region_class_init(ObjectClass
*klass
,
946 IOMMUMemoryRegionClass
*imrc
= IOMMU_MEMORY_REGION_CLASS(klass
);
948 imrc
->translate
= typhoon_translate_iommu
;
951 static const TypeInfo typhoon_iommu_memory_region_info
= {
952 .parent
= TYPE_IOMMU_MEMORY_REGION
,
953 .name
= TYPE_TYPHOON_IOMMU_MEMORY_REGION
,
954 .class_init
= typhoon_iommu_memory_region_class_init
,
957 static void typhoon_register_types(void)
959 type_register_static(&typhoon_pcihost_info
);
960 type_register_static(&typhoon_iommu_memory_region_info
);
963 type_init(typhoon_register_types
)