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/units.h"
11 #include "qapi/error.h"
14 #include "hw/devices.h"
15 #include "sysemu/sysemu.h"
16 #include "alpha_sys.h"
17 #include "exec/address-spaces.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 #define TYPHOON_PCI_HOST_BRIDGE(obj) \
53 OBJECT_CHECK(TyphoonState, (obj), TYPE_TYPHOON_PCI_HOST_BRIDGE)
55 typedef struct TyphoonState
{
56 PCIHostState parent_obj
;
60 MemoryRegion dchip_region
;
61 MemoryRegion ram_region
;
64 /* Called when one of DRIR or DIM changes. */
65 static void cpu_irq_change(AlphaCPU
*cpu
, uint64_t req
)
67 /* If there are any non-masked interrupts, tell the cpu. */
69 CPUState
*cs
= CPU(cpu
);
71 cpu_interrupt(cs
, CPU_INTERRUPT_HARD
);
73 cpu_reset_interrupt(cs
, CPU_INTERRUPT_HARD
);
78 static uint64_t cchip_read(void *opaque
, hwaddr addr
, 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 */
199 cpu_unassigned_access(cpu
, addr
, false, false, 0, size
);
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 uint64_t pchip_read(void *opaque
, hwaddr addr
, unsigned size
)
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 */
297 cpu_unassigned_access(current_cpu
, addr
, false, false, 0, size
);
304 static void cchip_write(void *opaque
, hwaddr addr
,
305 uint64_t val
, unsigned size
)
307 TyphoonState
*s
= opaque
;
308 uint64_t oldval
, newval
;
312 /* CSC: Cchip System Configuration Register. */
313 /* All sorts of data here; nothing relevant RW. */
317 /* MTR: Memory Timing Register. */
318 /* All sorts of stuff related to real DRAM. */
322 /* MISC: Miscellaneous Register. */
323 newval
= oldval
= s
->cchip
.misc
;
324 newval
&= ~(val
& 0x10000ff0); /* W1C fields */
325 if (val
& 0x100000) {
326 newval
&= ~0xff0000ull
; /* ACL clears ABT and ABW */
328 newval
|= val
& 0x00f00000; /* ABT field is W1S */
329 if ((newval
& 0xf0000) == 0) {
330 newval
|= val
& 0xf0000; /* ABW field is W1S iff zero */
333 newval
|= (val
& 0xf000) >> 4; /* IPREQ field sets IPINTR. */
335 newval
&= ~0xf0000000000ull
; /* WO and RW fields */
336 newval
|= val
& 0xf0000000000ull
;
337 s
->cchip
.misc
= newval
;
339 /* Pass on changes to IPI and ITI state. */
340 if ((newval
^ oldval
) & 0xff0) {
342 for (i
= 0; i
< 4; ++i
) {
343 AlphaCPU
*cpu
= s
->cchip
.cpu
[i
];
345 CPUState
*cs
= CPU(cpu
);
346 /* IPI can be either cleared or set by the write. */
347 if (newval
& (1 << (i
+ 8))) {
348 cpu_interrupt(cs
, CPU_INTERRUPT_SMP
);
350 cpu_reset_interrupt(cs
, CPU_INTERRUPT_SMP
);
353 /* ITI can only be cleared by the write. */
354 if ((newval
& (1 << (i
+ 4))) == 0) {
355 cpu_reset_interrupt(cs
, CPU_INTERRUPT_TIMER
);
363 /* MPD: Memory Presence Detect Register. */
366 case 0x0100: /* AAR0 */
367 case 0x0140: /* AAR1 */
368 case 0x0180: /* AAR2 */
369 case 0x01c0: /* AAR3 */
370 /* AAR: Array Address Register. */
371 /* All sorts of information about DRAM. */
374 case 0x0200: /* DIM0 */
375 /* DIM: Device Interrupt Mask Register, CPU0. */
376 s
->cchip
.dim
[0] = val
;
377 cpu_irq_change(s
->cchip
.cpu
[0], val
& s
->cchip
.drir
);
379 case 0x0240: /* DIM1 */
380 /* DIM: Device Interrupt Mask Register, CPU1. */
381 s
->cchip
.dim
[1] = val
;
382 cpu_irq_change(s
->cchip
.cpu
[1], val
& s
->cchip
.drir
);
385 case 0x0280: /* DIR0 (RO) */
386 case 0x02c0: /* DIR1 (RO) */
387 case 0x0300: /* DRIR (RO) */
391 /* PRBEN: Probe Enable Register. */
394 case 0x0380: /* IIC0 */
395 s
->cchip
.iic
[0] = val
& 0xffffff;
397 case 0x03c0: /* IIC1 */
398 s
->cchip
.iic
[1] = val
& 0xffffff;
401 case 0x0400: /* MPR0 */
402 case 0x0440: /* MPR1 */
403 case 0x0480: /* MPR2 */
404 case 0x04c0: /* MPR3 */
405 /* MPR: Memory Programming Register. */
409 /* TTR: TIGbus Timing Register. */
410 /* All sorts of stuff related to interrupt delivery timings. */
413 /* TDR: TIGbug Device Timing Register. */
417 /* DIM2: Device Interrupt Mask Register, CPU2. */
418 s
->cchip
.dim
[2] = val
;
419 cpu_irq_change(s
->cchip
.cpu
[2], val
& s
->cchip
.drir
);
422 /* DIM3: Device Interrupt Mask Register, CPU3. */
423 s
->cchip
.dim
[3] = val
;
424 cpu_irq_change(s
->cchip
.cpu
[3], val
& s
->cchip
.drir
);
427 case 0x0680: /* DIR2 (RO) */
428 case 0x06c0: /* DIR3 (RO) */
431 case 0x0700: /* IIC2 */
432 s
->cchip
.iic
[2] = val
& 0xffffff;
434 case 0x0740: /* IIC3 */
435 s
->cchip
.iic
[3] = val
& 0xffffff;
439 /* PWR: Power Management Control. */
442 case 0x0c00: /* CMONCTLA */
443 case 0x0c40: /* CMONCTLB */
444 case 0x0c80: /* CMONCNT01 */
445 case 0x0cc0: /* CMONCNT23 */
449 cpu_unassigned_access(current_cpu
, addr
, true, false, 0, size
);
454 static void dchip_write(void *opaque
, hwaddr addr
,
455 uint64_t val
, unsigned size
)
457 /* Skip this. It's all related to DRAM timing and setup. */
460 static void pchip_write(void *opaque
, hwaddr addr
,
461 uint64_t val
, unsigned size
)
463 TyphoonState
*s
= opaque
;
468 /* WSBA0: Window Space Base Address Register. */
469 s
->pchip
.win
[0].wba
= val
& 0xfff00003u
;
473 s
->pchip
.win
[1].wba
= val
& 0xfff00003u
;
477 s
->pchip
.win
[2].wba
= val
& 0xfff00003u
;
481 s
->pchip
.win
[3].wba
= (val
& 0x80fff00001ull
) | 2;
485 /* WSM0: Window Space Mask Register. */
486 s
->pchip
.win
[0].wsm
= val
& 0xfff00000u
;
490 s
->pchip
.win
[1].wsm
= val
& 0xfff00000u
;
494 s
->pchip
.win
[2].wsm
= val
& 0xfff00000u
;
498 s
->pchip
.win
[3].wsm
= val
& 0xfff00000u
;
502 /* TBA0: Translated Base Address Register. */
503 s
->pchip
.win
[0].tba
= val
& 0x7fffffc00ull
;
507 s
->pchip
.win
[1].tba
= val
& 0x7fffffc00ull
;
511 s
->pchip
.win
[2].tba
= val
& 0x7fffffc00ull
;
515 s
->pchip
.win
[3].tba
= val
& 0x7fffffc00ull
;
519 /* PCTL: Pchip Control Register. */
520 oldval
= s
->pchip
.ctl
;
521 oldval
&= ~0x00001cff0fc7ffull
; /* RW fields */
522 oldval
|= val
& 0x00001cff0fc7ffull
;
523 s
->pchip
.ctl
= oldval
;
527 /* PLAT: Pchip Master Latency Register. */
530 /* PERROR: Pchip Error Register. */
533 /* PERRMASK: Pchip Error Mask Register. */
536 /* PERRSET: Pchip Error Set Register. */
540 /* TLBIV: Translation Buffer Invalidate Virtual Register. */
544 /* TLBIA: Translation Buffer Invalidate All Register (WO). */
556 cpu_unassigned_access(current_cpu
, addr
, true, false, 0, size
);
561 static const MemoryRegionOps cchip_ops
= {
563 .write
= cchip_write
,
564 .endianness
= DEVICE_LITTLE_ENDIAN
,
566 .min_access_size
= 8,
567 .max_access_size
= 8,
570 .min_access_size
= 8,
571 .max_access_size
= 8,
575 static const MemoryRegionOps dchip_ops
= {
577 .write
= dchip_write
,
578 .endianness
= DEVICE_LITTLE_ENDIAN
,
580 .min_access_size
= 8,
581 .max_access_size
= 8,
584 .min_access_size
= 8,
585 .max_access_size
= 8,
589 static const MemoryRegionOps pchip_ops
= {
591 .write
= pchip_write
,
592 .endianness
= DEVICE_LITTLE_ENDIAN
,
594 .min_access_size
= 8,
595 .max_access_size
= 8,
598 .min_access_size
= 8,
599 .max_access_size
= 8,
603 /* A subroutine of typhoon_translate_iommu that builds an IOMMUTLBEntry
604 using the given translated address and mask. */
605 static bool make_iommu_tlbe(hwaddr taddr
, hwaddr mask
, IOMMUTLBEntry
*ret
)
607 *ret
= (IOMMUTLBEntry
) {
608 .target_as
= &address_space_memory
,
609 .translated_addr
= taddr
,
616 /* A subroutine of typhoon_translate_iommu that handles scatter-gather
617 translation, given the address of the PTE. */
618 static bool pte_translate(hwaddr pte_addr
, IOMMUTLBEntry
*ret
)
620 uint64_t pte
= address_space_ldq(&address_space_memory
, pte_addr
,
621 MEMTXATTRS_UNSPECIFIED
, NULL
);
623 /* Check valid bit. */
624 if ((pte
& 1) == 0) {
628 return make_iommu_tlbe((pte
& 0x3ffffe) << 12, 0x1fff, ret
);
631 /* A subroutine of typhoon_translate_iommu that handles one of the
632 four single-address-cycle translation windows. */
633 static bool window_translate(TyphoonWindow
*win
, hwaddr addr
,
636 uint32_t wba
= win
->wba
;
637 uint64_t wsm
= win
->wsm
;
638 uint64_t tba
= win
->tba
;
639 uint64_t wsm_ext
= wsm
| 0xfffff;
641 /* Check for window disabled. */
642 if ((wba
& 1) == 0) {
646 /* Check for window hit. */
647 if ((addr
& ~wsm_ext
) != (wba
& 0xfff00000u
)) {
652 /* Scatter-gather translation. */
655 /* See table 10-6, Generating PTE address for PCI DMA Address. */
656 pte_addr
= tba
& ~(wsm
>> 10);
657 pte_addr
|= (addr
& (wsm
| 0xfe000)) >> 10;
658 return pte_translate(pte_addr
, ret
);
660 /* Direct-mapped translation. */
661 return make_iommu_tlbe(tba
& ~wsm_ext
, wsm_ext
, ret
);
665 /* Handle PCI-to-system address translation. */
666 /* TODO: A translation failure here ought to set PCI error codes on the
667 Pchip and generate a machine check interrupt. */
668 static IOMMUTLBEntry
typhoon_translate_iommu(IOMMUMemoryRegion
*iommu
,
670 IOMMUAccessFlags flag
,
673 TyphoonPchip
*pchip
= container_of(iommu
, TyphoonPchip
, iommu
);
677 if (addr
<= 0xffffffffu
) {
678 /* Single-address cycle. */
680 /* Check for the Window Hole, inhibiting matching. */
681 if ((pchip
->ctl
& 0x20)
683 && addr
<= 0xfffff) {
687 /* Check the first three windows. */
688 for (i
= 0; i
< 3; ++i
) {
689 if (window_translate(&pchip
->win
[i
], addr
, &ret
)) {
694 /* Check the fourth window for DAC disable. */
695 if ((pchip
->win
[3].wba
& 0x80000000000ull
) == 0
696 && window_translate(&pchip
->win
[3], addr
, &ret
)) {
700 /* Double-address cycle. */
702 if (addr
>= 0x10000000000ull
&& addr
< 0x20000000000ull
) {
703 /* Check for the DMA monster window. */
704 if (pchip
->ctl
& 0x40) {
705 /* See 10.1.4.4; in particular <39:35> is ignored. */
706 make_iommu_tlbe(0, 0x007ffffffffull
, &ret
);
711 if (addr
>= 0x80000000000ull
&& addr
<= 0xfffffffffffull
) {
712 /* Check the fourth window for DAC enable and window enable. */
713 if ((pchip
->win
[3].wba
& 0x80000000001ull
) == 0x80000000001ull
) {
716 pte_addr
= pchip
->win
[3].tba
& 0x7ffc00000ull
;
717 pte_addr
|= (addr
& 0xffffe000u
) >> 10;
718 if (pte_translate(pte_addr
, &ret
)) {
726 ret
= (IOMMUTLBEntry
) { .perm
= IOMMU_NONE
};
731 static AddressSpace
*typhoon_pci_dma_iommu(PCIBus
*bus
, void *opaque
, int devfn
)
733 TyphoonState
*s
= opaque
;
734 return &s
->pchip
.iommu_as
;
737 static void typhoon_set_irq(void *opaque
, int irq
, int level
)
739 TyphoonState
*s
= opaque
;
743 /* Set/Reset the bit in CCHIP.DRIR based on IRQ+LEVEL. */
744 drir
= s
->cchip
.drir
;
748 drir
&= ~(1ull << irq
);
750 s
->cchip
.drir
= drir
;
752 for (i
= 0; i
< 4; ++i
) {
753 cpu_irq_change(s
->cchip
.cpu
[i
], s
->cchip
.dim
[i
] & drir
);
757 static void typhoon_set_isa_irq(void *opaque
, int irq
, int level
)
759 typhoon_set_irq(opaque
, 55, level
);
762 static void typhoon_set_timer_irq(void *opaque
, int irq
, int level
)
764 TyphoonState
*s
= opaque
;
767 /* Thankfully, the mc146818rtc code doesn't track the IRQ state,
768 and so we don't have to worry about missing interrupts just
769 because we never actually ACK the interrupt. Just ignore any
770 case of the interrupt level going low. */
775 /* Deliver the interrupt to each CPU, considering each CPU's IIC. */
776 for (i
= 0; i
< 4; ++i
) {
777 AlphaCPU
*cpu
= s
->cchip
.cpu
[i
];
779 uint32_t iic
= s
->cchip
.iic
[i
];
781 /* ??? The verbage in Section 10.2.2.10 isn't 100% clear.
782 Bit 24 is the OverFlow bit, RO, and set when the count
783 decrements past 0. When is OF cleared? My guess is that
784 OF is actually cleared when the IIC is written, and that
785 the ICNT field always decrements. At least, that's an
786 interpretation that makes sense, and "allows the CPU to
787 determine exactly how mant interval timer ticks were
788 skipped". At least within the next 4M ticks... */
790 iic
= ((iic
- 1) & 0x1ffffff) | (iic
& 0x1000000);
791 s
->cchip
.iic
[i
] = iic
;
793 if (iic
& 0x1000000) {
794 /* Set the ITI bit for this cpu. */
795 s
->cchip
.misc
|= 1 << (i
+ 4);
796 /* And signal the interrupt. */
797 cpu_interrupt(CPU(cpu
), CPU_INTERRUPT_TIMER
);
803 static void typhoon_alarm_timer(void *opaque
)
805 TyphoonState
*s
= (TyphoonState
*)((uintptr_t)opaque
& ~3);
806 int cpu
= (uintptr_t)opaque
& 3;
808 /* Set the ITI bit for this cpu. */
809 s
->cchip
.misc
|= 1 << (cpu
+ 4);
810 cpu_interrupt(CPU(s
->cchip
.cpu
[cpu
]), CPU_INTERRUPT_TIMER
);
813 PCIBus
*typhoon_init(ram_addr_t ram_size
, ISABus
**isa_bus
,
815 AlphaCPU
*cpus
[4], pci_map_irq_fn sys_map_irq
)
817 MemoryRegion
*addr_space
= get_system_memory();
824 dev
= qdev_create(NULL
, TYPE_TYPHOON_PCI_HOST_BRIDGE
);
826 s
= TYPHOON_PCI_HOST_BRIDGE(dev
);
827 phb
= PCI_HOST_BRIDGE(dev
);
829 s
->cchip
.misc
= 0x800000000ull
; /* Revision: Typhoon. */
830 s
->pchip
.win
[3].wba
= 2; /* Window 3 SG always enabled. */
832 /* Remember the CPUs so that we can deliver interrupts to them. */
833 for (i
= 0; i
< 4; i
++) {
834 AlphaCPU
*cpu
= cpus
[i
];
835 s
->cchip
.cpu
[i
] = cpu
;
837 cpu
->alarm_timer
= timer_new_ns(QEMU_CLOCK_VIRTUAL
,
839 (void *)((uintptr_t)s
+ i
));
843 *p_rtc_irq
= qemu_allocate_irq(typhoon_set_timer_irq
, s
, 0);
845 /* Main memory region, 0x00.0000.0000. Real hardware supports 32GB,
846 but the address space hole reserved at this point is 8TB. */
847 memory_region_allocate_system_memory(&s
->ram_region
, OBJECT(s
), "ram",
849 memory_region_add_subregion(addr_space
, 0, &s
->ram_region
);
851 /* TIGbus, 0x801.0000.0000, 1GB. */
852 /* ??? The TIGbus is used for delivering interrupts, and access to
853 the flash ROM. I'm not sure that we need to implement it at all. */
855 /* Pchip0 CSRs, 0x801.8000.0000, 256MB. */
856 memory_region_init_io(&s
->pchip
.region
, OBJECT(s
), &pchip_ops
, s
, "pchip0",
858 memory_region_add_subregion(addr_space
, 0x80180000000ULL
,
861 /* Cchip CSRs, 0x801.A000.0000, 256MB. */
862 memory_region_init_io(&s
->cchip
.region
, OBJECT(s
), &cchip_ops
, s
, "cchip0",
864 memory_region_add_subregion(addr_space
, 0x801a0000000ULL
,
867 /* Dchip CSRs, 0x801.B000.0000, 256MB. */
868 memory_region_init_io(&s
->dchip_region
, OBJECT(s
), &dchip_ops
, s
, "dchip0",
870 memory_region_add_subregion(addr_space
, 0x801b0000000ULL
,
873 /* Pchip0 PCI memory, 0x800.0000.0000, 4GB. */
874 memory_region_init(&s
->pchip
.reg_mem
, OBJECT(s
), "pci0-mem", 4 * GiB
);
875 memory_region_add_subregion(addr_space
, 0x80000000000ULL
,
878 /* Pchip0 PCI I/O, 0x801.FC00.0000, 32MB. */
879 memory_region_init_io(&s
->pchip
.reg_io
, OBJECT(s
), &alpha_pci_ignore_ops
,
880 NULL
, "pci0-io", 32 * MiB
);
881 memory_region_add_subregion(addr_space
, 0x801fc000000ULL
,
884 b
= pci_register_root_bus(dev
, "pci",
885 typhoon_set_irq
, sys_map_irq
, s
,
886 &s
->pchip
.reg_mem
, &s
->pchip
.reg_io
,
887 0, 64, TYPE_PCI_BUS
);
889 qdev_init_nofail(dev
);
891 /* Host memory as seen from the PCI side, via the IOMMU. */
892 memory_region_init_iommu(&s
->pchip
.iommu
, sizeof(s
->pchip
.iommu
),
893 TYPE_TYPHOON_IOMMU_MEMORY_REGION
, OBJECT(s
),
894 "iommu-typhoon", UINT64_MAX
);
895 address_space_init(&s
->pchip
.iommu_as
, MEMORY_REGION(&s
->pchip
.iommu
),
897 pci_setup_iommu(b
, typhoon_pci_dma_iommu
, s
);
899 /* Pchip0 PCI special/interrupt acknowledge, 0x801.F800.0000, 64MB. */
900 memory_region_init_io(&s
->pchip
.reg_iack
, OBJECT(s
), &alpha_pci_iack_ops
,
901 b
, "pci0-iack", 64 * MiB
);
902 memory_region_add_subregion(addr_space
, 0x801f8000000ULL
,
905 /* Pchip0 PCI configuration, 0x801.FE00.0000, 16MB. */
906 memory_region_init_io(&s
->pchip
.reg_conf
, OBJECT(s
), &alpha_pci_conf1_ops
,
907 b
, "pci0-conf", 16 * MiB
);
908 memory_region_add_subregion(addr_space
, 0x801fe000000ULL
,
911 /* For the record, these are the mappings for the second PCI bus.
912 We can get away with not implementing them because we indicate
913 via the Cchip.CSC<PIP> bit that Pchip1 is not present. */
914 /* Pchip1 PCI memory, 0x802.0000.0000, 4GB. */
915 /* Pchip1 CSRs, 0x802.8000.0000, 256MB. */
916 /* Pchip1 PCI special/interrupt acknowledge, 0x802.F800.0000, 64MB. */
917 /* Pchip1 PCI I/O, 0x802.FC00.0000, 32MB. */
918 /* Pchip1 PCI configuration, 0x802.FE00.0000, 16MB. */
920 /* Init the ISA bus. */
921 /* ??? Technically there should be a cy82c693ub pci-isa bridge. */
925 *isa_bus
= isa_bus_new(NULL
, get_system_memory(), &s
->pchip
.reg_io
,
927 isa_irqs
= i8259_init(*isa_bus
,
928 qemu_allocate_irq(typhoon_set_isa_irq
, s
, 0));
929 isa_bus_irqs(*isa_bus
, isa_irqs
);
935 static const TypeInfo typhoon_pcihost_info
= {
936 .name
= TYPE_TYPHOON_PCI_HOST_BRIDGE
,
937 .parent
= TYPE_PCI_HOST_BRIDGE
,
938 .instance_size
= sizeof(TyphoonState
),
941 static void typhoon_iommu_memory_region_class_init(ObjectClass
*klass
,
944 IOMMUMemoryRegionClass
*imrc
= IOMMU_MEMORY_REGION_CLASS(klass
);
946 imrc
->translate
= typhoon_translate_iommu
;
949 static const TypeInfo typhoon_iommu_memory_region_info
= {
950 .parent
= TYPE_IOMMU_MEMORY_REGION
,
951 .name
= TYPE_TYPHOON_IOMMU_MEMORY_REGION
,
952 .class_init
= typhoon_iommu_memory_region_class_init
,
955 static void typhoon_register_types(void)
957 type_register_static(&typhoon_pcihost_info
);
958 type_register_static(&typhoon_iommu_memory_region_info
);
961 type_init(typhoon_register_types
)