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"
14 #include "hw/boards.h"
16 #include "alpha_sys.h"
17 #include "exec/address-spaces.h"
18 #include "qom/object.h"
21 #define TYPE_TYPHOON_PCI_HOST_BRIDGE "typhoon-pcihost"
22 #define TYPE_TYPHOON_IOMMU_MEMORY_REGION "typhoon-iommu-memory-region"
24 typedef struct TyphoonCchip
{
33 typedef struct TyphoonWindow
{
39 typedef struct TyphoonPchip
{
41 MemoryRegion reg_iack
;
44 MemoryRegion reg_conf
;
46 AddressSpace iommu_as
;
47 IOMMUMemoryRegion iommu
;
53 typedef struct TyphoonState TyphoonState
;
54 #define TYPHOON_PCI_HOST_BRIDGE(obj) \
55 OBJECT_CHECK(TyphoonState, (obj), TYPE_TYPHOON_PCI_HOST_BRIDGE)
58 PCIHostState parent_obj
;
62 MemoryRegion dchip_region
;
65 /* Called when one of DRIR or DIM changes. */
66 static void cpu_irq_change(AlphaCPU
*cpu
, uint64_t req
)
68 /* If there are any non-masked interrupts, tell the cpu. */
70 CPUState
*cs
= CPU(cpu
);
72 cpu_interrupt(cs
, CPU_INTERRUPT_HARD
);
74 cpu_reset_interrupt(cs
, CPU_INTERRUPT_HARD
);
79 static MemTxResult
cchip_read(void *opaque
, hwaddr addr
,
80 uint64_t *data
, unsigned size
,
83 CPUState
*cpu
= current_cpu
;
84 TyphoonState
*s
= opaque
;
89 /* CSC: Cchip System Configuration Register. */
90 /* All sorts of data here; probably the only thing relevant is
91 PIP<14> Pchip 1 Present = 0. */
95 /* MTR: Memory Timing Register. */
96 /* All sorts of stuff related to real DRAM. */
100 /* MISC: Miscellaneous Register. */
101 ret
= s
->cchip
.misc
| (cpu
->cpu_index
& 3);
105 /* MPD: Memory Presence Detect Register. */
108 case 0x0100: /* AAR0 */
109 case 0x0140: /* AAR1 */
110 case 0x0180: /* AAR2 */
111 case 0x01c0: /* AAR3 */
112 /* AAR: Array Address Register. */
113 /* All sorts of information about DRAM. */
117 /* DIM0: Device Interrupt Mask Register, CPU0. */
118 ret
= s
->cchip
.dim
[0];
121 /* DIM1: Device Interrupt Mask Register, CPU1. */
122 ret
= s
->cchip
.dim
[1];
125 /* DIR0: Device Interrupt Request Register, CPU0. */
126 ret
= s
->cchip
.dim
[0] & s
->cchip
.drir
;
129 /* DIR1: Device Interrupt Request Register, CPU1. */
130 ret
= s
->cchip
.dim
[1] & s
->cchip
.drir
;
133 /* DRIR: Device Raw Interrupt Request Register. */
138 /* PRBEN: Probe Enable Register. */
142 /* IIC0: Interval Ignore Count Register, CPU0. */
143 ret
= s
->cchip
.iic
[0];
146 /* IIC1: Interval Ignore Count Register, CPU1. */
147 ret
= s
->cchip
.iic
[1];
150 case 0x0400: /* MPR0 */
151 case 0x0440: /* MPR1 */
152 case 0x0480: /* MPR2 */
153 case 0x04c0: /* MPR3 */
154 /* MPR: Memory Programming Register. */
158 /* TTR: TIGbus Timing Register. */
159 /* All sorts of stuff related to interrupt delivery timings. */
162 /* TDR: TIGbug Device Timing Register. */
166 /* DIM2: Device Interrupt Mask Register, CPU2. */
167 ret
= s
->cchip
.dim
[2];
170 /* DIM3: Device Interrupt Mask Register, CPU3. */
171 ret
= s
->cchip
.dim
[3];
174 /* DIR2: Device Interrupt Request Register, CPU2. */
175 ret
= s
->cchip
.dim
[2] & s
->cchip
.drir
;
178 /* DIR3: Device Interrupt Request Register, CPU3. */
179 ret
= s
->cchip
.dim
[3] & s
->cchip
.drir
;
183 /* IIC2: Interval Ignore Count Register, CPU2. */
184 ret
= s
->cchip
.iic
[2];
187 /* IIC3: Interval Ignore Count Register, CPU3. */
188 ret
= s
->cchip
.iic
[3];
192 /* PWR: Power Management Control. */
195 case 0x0c00: /* CMONCTLA */
196 case 0x0c40: /* CMONCTLB */
197 case 0x0c80: /* CMONCNT01 */
198 case 0x0cc0: /* CMONCNT23 */
209 static uint64_t dchip_read(void *opaque
, hwaddr addr
, unsigned size
)
211 /* Skip this. It's all related to DRAM timing and setup. */
215 static MemTxResult
pchip_read(void *opaque
, hwaddr addr
, uint64_t *data
,
216 unsigned size
, MemTxAttrs attrs
)
218 TyphoonState
*s
= opaque
;
223 /* WSBA0: Window Space Base Address Register. */
224 ret
= s
->pchip
.win
[0].wba
;
228 ret
= s
->pchip
.win
[1].wba
;
232 ret
= s
->pchip
.win
[2].wba
;
236 ret
= s
->pchip
.win
[3].wba
;
240 /* WSM0: Window Space Mask Register. */
241 ret
= s
->pchip
.win
[0].wsm
;
245 ret
= s
->pchip
.win
[1].wsm
;
249 ret
= s
->pchip
.win
[2].wsm
;
253 ret
= s
->pchip
.win
[3].wsm
;
257 /* TBA0: Translated Base Address Register. */
258 ret
= s
->pchip
.win
[0].tba
;
262 ret
= s
->pchip
.win
[1].tba
;
266 ret
= s
->pchip
.win
[2].tba
;
270 ret
= s
->pchip
.win
[3].tba
;
274 /* PCTL: Pchip Control Register. */
278 /* PLAT: Pchip Master Latency Register. */
281 /* PERROR: Pchip Error Register. */
284 /* PERRMASK: Pchip Error Mask Register. */
287 /* PERRSET: Pchip Error Set Register. */
290 /* TLBIV: Translation Buffer Invalidate Virtual Register (WO). */
293 /* TLBIA: Translation Buffer Invalidate All Register (WO). */
295 case 0x0500: /* PMONCTL */
296 case 0x0540: /* PMONCNT */
297 case 0x0800: /* SPRST */
308 static MemTxResult
cchip_write(void *opaque
, hwaddr addr
,
309 uint64_t val
, unsigned size
,
312 TyphoonState
*s
= opaque
;
313 uint64_t oldval
, newval
;
317 /* CSC: Cchip System Configuration Register. */
318 /* All sorts of data here; nothing relevant RW. */
322 /* MTR: Memory Timing Register. */
323 /* All sorts of stuff related to real DRAM. */
327 /* MISC: Miscellaneous Register. */
328 newval
= oldval
= s
->cchip
.misc
;
329 newval
&= ~(val
& 0x10000ff0); /* W1C fields */
330 if (val
& 0x100000) {
331 newval
&= ~0xff0000ull
; /* ACL clears ABT and ABW */
333 newval
|= val
& 0x00f00000; /* ABT field is W1S */
334 if ((newval
& 0xf0000) == 0) {
335 newval
|= val
& 0xf0000; /* ABW field is W1S iff zero */
338 newval
|= (val
& 0xf000) >> 4; /* IPREQ field sets IPINTR. */
340 newval
&= ~0xf0000000000ull
; /* WO and RW fields */
341 newval
|= val
& 0xf0000000000ull
;
342 s
->cchip
.misc
= newval
;
344 /* Pass on changes to IPI and ITI state. */
345 if ((newval
^ oldval
) & 0xff0) {
347 for (i
= 0; i
< 4; ++i
) {
348 AlphaCPU
*cpu
= s
->cchip
.cpu
[i
];
350 CPUState
*cs
= CPU(cpu
);
351 /* IPI can be either cleared or set by the write. */
352 if (newval
& (1 << (i
+ 8))) {
353 cpu_interrupt(cs
, CPU_INTERRUPT_SMP
);
355 cpu_reset_interrupt(cs
, CPU_INTERRUPT_SMP
);
358 /* ITI can only be cleared by the write. */
359 if ((newval
& (1 << (i
+ 4))) == 0) {
360 cpu_reset_interrupt(cs
, CPU_INTERRUPT_TIMER
);
368 /* MPD: Memory Presence Detect Register. */
371 case 0x0100: /* AAR0 */
372 case 0x0140: /* AAR1 */
373 case 0x0180: /* AAR2 */
374 case 0x01c0: /* AAR3 */
375 /* AAR: Array Address Register. */
376 /* All sorts of information about DRAM. */
379 case 0x0200: /* DIM0 */
380 /* DIM: Device Interrupt Mask Register, CPU0. */
381 s
->cchip
.dim
[0] = val
;
382 cpu_irq_change(s
->cchip
.cpu
[0], val
& s
->cchip
.drir
);
384 case 0x0240: /* DIM1 */
385 /* DIM: Device Interrupt Mask Register, CPU1. */
386 s
->cchip
.dim
[1] = val
;
387 cpu_irq_change(s
->cchip
.cpu
[1], val
& s
->cchip
.drir
);
390 case 0x0280: /* DIR0 (RO) */
391 case 0x02c0: /* DIR1 (RO) */
392 case 0x0300: /* DRIR (RO) */
396 /* PRBEN: Probe Enable Register. */
399 case 0x0380: /* IIC0 */
400 s
->cchip
.iic
[0] = val
& 0xffffff;
402 case 0x03c0: /* IIC1 */
403 s
->cchip
.iic
[1] = val
& 0xffffff;
406 case 0x0400: /* MPR0 */
407 case 0x0440: /* MPR1 */
408 case 0x0480: /* MPR2 */
409 case 0x04c0: /* MPR3 */
410 /* MPR: Memory Programming Register. */
414 /* TTR: TIGbus Timing Register. */
415 /* All sorts of stuff related to interrupt delivery timings. */
418 /* TDR: TIGbug Device Timing Register. */
422 /* DIM2: Device Interrupt Mask Register, CPU2. */
423 s
->cchip
.dim
[2] = val
;
424 cpu_irq_change(s
->cchip
.cpu
[2], val
& s
->cchip
.drir
);
427 /* DIM3: Device Interrupt Mask Register, CPU3. */
428 s
->cchip
.dim
[3] = val
;
429 cpu_irq_change(s
->cchip
.cpu
[3], val
& s
->cchip
.drir
);
432 case 0x0680: /* DIR2 (RO) */
433 case 0x06c0: /* DIR3 (RO) */
436 case 0x0700: /* IIC2 */
437 s
->cchip
.iic
[2] = val
& 0xffffff;
439 case 0x0740: /* IIC3 */
440 s
->cchip
.iic
[3] = val
& 0xffffff;
444 /* PWR: Power Management Control. */
447 case 0x0c00: /* CMONCTLA */
448 case 0x0c40: /* CMONCTLB */
449 case 0x0c80: /* CMONCNT01 */
450 case 0x0cc0: /* CMONCNT23 */
460 static void dchip_write(void *opaque
, hwaddr addr
,
461 uint64_t val
, unsigned size
)
463 /* Skip this. It's all related to DRAM timing and setup. */
466 static MemTxResult
pchip_write(void *opaque
, hwaddr addr
,
467 uint64_t val
, unsigned size
,
470 TyphoonState
*s
= opaque
;
475 /* WSBA0: Window Space Base Address Register. */
476 s
->pchip
.win
[0].wba
= val
& 0xfff00003u
;
480 s
->pchip
.win
[1].wba
= val
& 0xfff00003u
;
484 s
->pchip
.win
[2].wba
= val
& 0xfff00003u
;
488 s
->pchip
.win
[3].wba
= (val
& 0x80fff00001ull
) | 2;
492 /* WSM0: Window Space Mask Register. */
493 s
->pchip
.win
[0].wsm
= val
& 0xfff00000u
;
497 s
->pchip
.win
[1].wsm
= val
& 0xfff00000u
;
501 s
->pchip
.win
[2].wsm
= val
& 0xfff00000u
;
505 s
->pchip
.win
[3].wsm
= val
& 0xfff00000u
;
509 /* TBA0: Translated Base Address Register. */
510 s
->pchip
.win
[0].tba
= val
& 0x7fffffc00ull
;
514 s
->pchip
.win
[1].tba
= val
& 0x7fffffc00ull
;
518 s
->pchip
.win
[2].tba
= val
& 0x7fffffc00ull
;
522 s
->pchip
.win
[3].tba
= val
& 0x7fffffc00ull
;
526 /* PCTL: Pchip Control Register. */
527 oldval
= s
->pchip
.ctl
;
528 oldval
&= ~0x00001cff0fc7ffull
; /* RW fields */
529 oldval
|= val
& 0x00001cff0fc7ffull
;
530 s
->pchip
.ctl
= oldval
;
534 /* PLAT: Pchip Master Latency Register. */
537 /* PERROR: Pchip Error Register. */
540 /* PERRMASK: Pchip Error Mask Register. */
543 /* PERRSET: Pchip Error Set Register. */
547 /* TLBIV: Translation Buffer Invalidate Virtual Register. */
551 /* TLBIA: Translation Buffer Invalidate All Register (WO). */
569 static const MemoryRegionOps cchip_ops
= {
570 .read_with_attrs
= cchip_read
,
571 .write_with_attrs
= cchip_write
,
572 .endianness
= DEVICE_LITTLE_ENDIAN
,
574 .min_access_size
= 8,
575 .max_access_size
= 8,
578 .min_access_size
= 8,
579 .max_access_size
= 8,
583 static const MemoryRegionOps dchip_ops
= {
585 .write
= dchip_write
,
586 .endianness
= DEVICE_LITTLE_ENDIAN
,
588 .min_access_size
= 8,
589 .max_access_size
= 8,
592 .min_access_size
= 8,
593 .max_access_size
= 8,
597 static const MemoryRegionOps pchip_ops
= {
598 .read_with_attrs
= pchip_read
,
599 .write_with_attrs
= pchip_write
,
600 .endianness
= DEVICE_LITTLE_ENDIAN
,
602 .min_access_size
= 8,
603 .max_access_size
= 8,
606 .min_access_size
= 8,
607 .max_access_size
= 8,
611 /* A subroutine of typhoon_translate_iommu that builds an IOMMUTLBEntry
612 using the given translated address and mask. */
613 static bool make_iommu_tlbe(hwaddr taddr
, hwaddr mask
, IOMMUTLBEntry
*ret
)
615 *ret
= (IOMMUTLBEntry
) {
616 .target_as
= &address_space_memory
,
617 .translated_addr
= taddr
,
624 /* A subroutine of typhoon_translate_iommu that handles scatter-gather
625 translation, given the address of the PTE. */
626 static bool pte_translate(hwaddr pte_addr
, IOMMUTLBEntry
*ret
)
628 uint64_t pte
= address_space_ldq(&address_space_memory
, pte_addr
,
629 MEMTXATTRS_UNSPECIFIED
, NULL
);
631 /* Check valid bit. */
632 if ((pte
& 1) == 0) {
636 return make_iommu_tlbe((pte
& 0x3ffffe) << 12, 0x1fff, ret
);
639 /* A subroutine of typhoon_translate_iommu that handles one of the
640 four single-address-cycle translation windows. */
641 static bool window_translate(TyphoonWindow
*win
, hwaddr addr
,
644 uint32_t wba
= win
->wba
;
645 uint64_t wsm
= win
->wsm
;
646 uint64_t tba
= win
->tba
;
647 uint64_t wsm_ext
= wsm
| 0xfffff;
649 /* Check for window disabled. */
650 if ((wba
& 1) == 0) {
654 /* Check for window hit. */
655 if ((addr
& ~wsm_ext
) != (wba
& 0xfff00000u
)) {
660 /* Scatter-gather translation. */
663 /* See table 10-6, Generating PTE address for PCI DMA Address. */
664 pte_addr
= tba
& ~(wsm
>> 10);
665 pte_addr
|= (addr
& (wsm
| 0xfe000)) >> 10;
666 return pte_translate(pte_addr
, ret
);
668 /* Direct-mapped translation. */
669 return make_iommu_tlbe(tba
& ~wsm_ext
, wsm_ext
, ret
);
673 /* Handle PCI-to-system address translation. */
674 /* TODO: A translation failure here ought to set PCI error codes on the
675 Pchip and generate a machine check interrupt. */
676 static IOMMUTLBEntry
typhoon_translate_iommu(IOMMUMemoryRegion
*iommu
,
678 IOMMUAccessFlags flag
,
681 TyphoonPchip
*pchip
= container_of(iommu
, TyphoonPchip
, iommu
);
685 if (addr
<= 0xffffffffu
) {
686 /* Single-address cycle. */
688 /* Check for the Window Hole, inhibiting matching. */
689 if ((pchip
->ctl
& 0x20)
691 && addr
<= 0xfffff) {
695 /* Check the first three windows. */
696 for (i
= 0; i
< 3; ++i
) {
697 if (window_translate(&pchip
->win
[i
], addr
, &ret
)) {
702 /* Check the fourth window for DAC disable. */
703 if ((pchip
->win
[3].wba
& 0x80000000000ull
) == 0
704 && window_translate(&pchip
->win
[3], addr
, &ret
)) {
708 /* Double-address cycle. */
710 if (addr
>= 0x10000000000ull
&& addr
< 0x20000000000ull
) {
711 /* Check for the DMA monster window. */
712 if (pchip
->ctl
& 0x40) {
713 /* See 10.1.4.4; in particular <39:35> is ignored. */
714 make_iommu_tlbe(0, 0x007ffffffffull
, &ret
);
719 if (addr
>= 0x80000000000ull
&& addr
<= 0xfffffffffffull
) {
720 /* Check the fourth window for DAC enable and window enable. */
721 if ((pchip
->win
[3].wba
& 0x80000000001ull
) == 0x80000000001ull
) {
724 pte_addr
= pchip
->win
[3].tba
& 0x7ffc00000ull
;
725 pte_addr
|= (addr
& 0xffffe000u
) >> 10;
726 if (pte_translate(pte_addr
, &ret
)) {
734 ret
= (IOMMUTLBEntry
) { .perm
= IOMMU_NONE
};
739 static AddressSpace
*typhoon_pci_dma_iommu(PCIBus
*bus
, void *opaque
, int devfn
)
741 TyphoonState
*s
= opaque
;
742 return &s
->pchip
.iommu_as
;
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
, ISABus
**isa_bus
, qemu_irq
*p_rtc_irq
,
822 AlphaCPU
*cpus
[4], pci_map_irq_fn sys_map_irq
)
824 MemoryRegion
*addr_space
= get_system_memory();
831 dev
= qdev_new(TYPE_TYPHOON_PCI_HOST_BRIDGE
);
833 s
= TYPHOON_PCI_HOST_BRIDGE(dev
);
834 phb
= PCI_HOST_BRIDGE(dev
);
836 s
->cchip
.misc
= 0x800000000ull
; /* Revision: Typhoon. */
837 s
->pchip
.win
[3].wba
= 2; /* Window 3 SG always enabled. */
839 /* Remember the CPUs so that we can deliver interrupts to them. */
840 for (i
= 0; i
< 4; i
++) {
841 AlphaCPU
*cpu
= cpus
[i
];
842 s
->cchip
.cpu
[i
] = cpu
;
844 cpu
->alarm_timer
= timer_new_ns(QEMU_CLOCK_VIRTUAL
,
846 (void *)((uintptr_t)s
+ i
));
850 *p_rtc_irq
= qemu_allocate_irq(typhoon_set_timer_irq
, s
, 0);
852 /* Main memory region, 0x00.0000.0000. Real hardware supports 32GB,
853 but the address space hole reserved at this point is 8TB. */
854 memory_region_add_subregion(addr_space
, 0, ram
);
856 /* TIGbus, 0x801.0000.0000, 1GB. */
857 /* ??? The TIGbus is used for delivering interrupts, and access to
858 the flash ROM. I'm not sure that we need to implement it at all. */
860 /* Pchip0 CSRs, 0x801.8000.0000, 256MB. */
861 memory_region_init_io(&s
->pchip
.region
, OBJECT(s
), &pchip_ops
, s
, "pchip0",
863 memory_region_add_subregion(addr_space
, 0x80180000000ULL
,
866 /* Cchip CSRs, 0x801.A000.0000, 256MB. */
867 memory_region_init_io(&s
->cchip
.region
, OBJECT(s
), &cchip_ops
, s
, "cchip0",
869 memory_region_add_subregion(addr_space
, 0x801a0000000ULL
,
872 /* Dchip CSRs, 0x801.B000.0000, 256MB. */
873 memory_region_init_io(&s
->dchip_region
, OBJECT(s
), &dchip_ops
, s
, "dchip0",
875 memory_region_add_subregion(addr_space
, 0x801b0000000ULL
,
878 /* Pchip0 PCI memory, 0x800.0000.0000, 4GB. */
879 memory_region_init(&s
->pchip
.reg_mem
, OBJECT(s
), "pci0-mem", 4 * GiB
);
880 memory_region_add_subregion(addr_space
, 0x80000000000ULL
,
883 /* Pchip0 PCI I/O, 0x801.FC00.0000, 32MB. */
884 memory_region_init_io(&s
->pchip
.reg_io
, OBJECT(s
), &alpha_pci_ignore_ops
,
885 NULL
, "pci0-io", 32 * MiB
);
886 memory_region_add_subregion(addr_space
, 0x801fc000000ULL
,
889 b
= pci_register_root_bus(dev
, "pci",
890 typhoon_set_irq
, sys_map_irq
, s
,
891 &s
->pchip
.reg_mem
, &s
->pchip
.reg_io
,
892 0, 64, TYPE_PCI_BUS
);
894 sysbus_realize_and_unref(SYS_BUS_DEVICE(dev
), &error_fatal
);
896 /* Host memory as seen from the PCI side, via the IOMMU. */
897 memory_region_init_iommu(&s
->pchip
.iommu
, sizeof(s
->pchip
.iommu
),
898 TYPE_TYPHOON_IOMMU_MEMORY_REGION
, OBJECT(s
),
899 "iommu-typhoon", UINT64_MAX
);
900 address_space_init(&s
->pchip
.iommu_as
, MEMORY_REGION(&s
->pchip
.iommu
),
902 pci_setup_iommu(b
, typhoon_pci_dma_iommu
, s
);
904 /* Pchip0 PCI special/interrupt acknowledge, 0x801.F800.0000, 64MB. */
905 memory_region_init_io(&s
->pchip
.reg_iack
, OBJECT(s
), &alpha_pci_iack_ops
,
906 b
, "pci0-iack", 64 * MiB
);
907 memory_region_add_subregion(addr_space
, 0x801f8000000ULL
,
910 /* Pchip0 PCI configuration, 0x801.FE00.0000, 16MB. */
911 memory_region_init_io(&s
->pchip
.reg_conf
, OBJECT(s
), &alpha_pci_conf1_ops
,
912 b
, "pci0-conf", 16 * MiB
);
913 memory_region_add_subregion(addr_space
, 0x801fe000000ULL
,
916 /* For the record, these are the mappings for the second PCI bus.
917 We can get away with not implementing them because we indicate
918 via the Cchip.CSC<PIP> bit that Pchip1 is not present. */
919 /* Pchip1 PCI memory, 0x802.0000.0000, 4GB. */
920 /* Pchip1 CSRs, 0x802.8000.0000, 256MB. */
921 /* Pchip1 PCI special/interrupt acknowledge, 0x802.F800.0000, 64MB. */
922 /* Pchip1 PCI I/O, 0x802.FC00.0000, 32MB. */
923 /* Pchip1 PCI configuration, 0x802.FE00.0000, 16MB. */
925 /* Init the ISA bus. */
926 /* ??? Technically there should be a cy82c693ub pci-isa bridge. */
930 *isa_bus
= isa_bus_new(NULL
, get_system_memory(), &s
->pchip
.reg_io
,
932 isa_irqs
= i8259_init(*isa_bus
,
933 qemu_allocate_irq(typhoon_set_isa_irq
, s
, 0));
934 isa_bus_irqs(*isa_bus
, isa_irqs
);
940 static const TypeInfo typhoon_pcihost_info
= {
941 .name
= TYPE_TYPHOON_PCI_HOST_BRIDGE
,
942 .parent
= TYPE_PCI_HOST_BRIDGE
,
943 .instance_size
= sizeof(TyphoonState
),
946 static void typhoon_iommu_memory_region_class_init(ObjectClass
*klass
,
949 IOMMUMemoryRegionClass
*imrc
= IOMMU_MEMORY_REGION_CLASS(klass
);
951 imrc
->translate
= typhoon_translate_iommu
;
954 static const TypeInfo typhoon_iommu_memory_region_info
= {
955 .parent
= TYPE_IOMMU_MEMORY_REGION
,
956 .name
= TYPE_TYPHOON_IOMMU_MEMORY_REGION
,
957 .class_init
= typhoon_iommu_memory_region_class_init
,
960 static void typhoon_register_types(void)
962 type_register_static(&typhoon_pcihost_info
);
963 type_register_static(&typhoon_iommu_memory_region_info
);
966 type_init(typhoon_register_types
)