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 "qapi/error.h"
13 #include "hw/devices.h"
14 #include "sysemu/sysemu.h"
15 #include "alpha_sys.h"
16 #include "exec/address-spaces.h"
19 #define TYPE_TYPHOON_PCI_HOST_BRIDGE "typhoon-pcihost"
21 typedef struct TyphoonCchip
{
30 typedef struct TyphoonWindow
{
36 typedef struct TyphoonPchip
{
38 MemoryRegion reg_iack
;
41 MemoryRegion reg_conf
;
43 AddressSpace iommu_as
;
50 #define TYPHOON_PCI_HOST_BRIDGE(obj) \
51 OBJECT_CHECK(TyphoonState, (obj), TYPE_TYPHOON_PCI_HOST_BRIDGE)
53 typedef struct TyphoonState
{
54 PCIHostState parent_obj
;
58 MemoryRegion dchip_region
;
59 MemoryRegion ram_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 uint64_t cchip_read(void *opaque
, hwaddr addr
, unsigned size
)
78 CPUState
*cpu
= current_cpu
;
79 TyphoonState
*s
= opaque
;
84 /* CSC: Cchip System Configuration Register. */
85 /* All sorts of data here; probably the only thing relevant is
86 PIP<14> Pchip 1 Present = 0. */
90 /* MTR: Memory Timing Register. */
91 /* All sorts of stuff related to real DRAM. */
95 /* MISC: Miscellaneous Register. */
96 ret
= s
->cchip
.misc
| (cpu
->cpu_index
& 3);
100 /* MPD: Memory Presence Detect Register. */
103 case 0x0100: /* AAR0 */
104 case 0x0140: /* AAR1 */
105 case 0x0180: /* AAR2 */
106 case 0x01c0: /* AAR3 */
107 /* AAR: Array Address Register. */
108 /* All sorts of information about DRAM. */
112 /* DIM0: Device Interrupt Mask Register, CPU0. */
113 ret
= s
->cchip
.dim
[0];
116 /* DIM1: Device Interrupt Mask Register, CPU1. */
117 ret
= s
->cchip
.dim
[1];
120 /* DIR0: Device Interrupt Request Register, CPU0. */
121 ret
= s
->cchip
.dim
[0] & s
->cchip
.drir
;
124 /* DIR1: Device Interrupt Request Register, CPU1. */
125 ret
= s
->cchip
.dim
[1] & s
->cchip
.drir
;
128 /* DRIR: Device Raw Interrupt Request Register. */
133 /* PRBEN: Probe Enable Register. */
137 /* IIC0: Interval Ignore Count Register, CPU0. */
138 ret
= s
->cchip
.iic
[0];
141 /* IIC1: Interval Ignore Count Register, CPU1. */
142 ret
= s
->cchip
.iic
[1];
145 case 0x0400: /* MPR0 */
146 case 0x0440: /* MPR1 */
147 case 0x0480: /* MPR2 */
148 case 0x04c0: /* MPR3 */
149 /* MPR: Memory Programming Register. */
153 /* TTR: TIGbus Timing Register. */
154 /* All sorts of stuff related to interrupt delivery timings. */
157 /* TDR: TIGbug Device Timing Register. */
161 /* DIM2: Device Interrupt Mask Register, CPU2. */
162 ret
= s
->cchip
.dim
[2];
165 /* DIM3: Device Interrupt Mask Register, CPU3. */
166 ret
= s
->cchip
.dim
[3];
169 /* DIR2: Device Interrupt Request Register, CPU2. */
170 ret
= s
->cchip
.dim
[2] & s
->cchip
.drir
;
173 /* DIR3: Device Interrupt Request Register, CPU3. */
174 ret
= s
->cchip
.dim
[3] & s
->cchip
.drir
;
178 /* IIC2: Interval Ignore Count Register, CPU2. */
179 ret
= s
->cchip
.iic
[2];
182 /* IIC3: Interval Ignore Count Register, CPU3. */
183 ret
= s
->cchip
.iic
[3];
187 /* PWR: Power Management Control. */
190 case 0x0c00: /* CMONCTLA */
191 case 0x0c40: /* CMONCTLB */
192 case 0x0c80: /* CMONCNT01 */
193 case 0x0cc0: /* CMONCNT23 */
197 cpu_unassigned_access(cpu
, addr
, false, false, 0, size
);
204 static uint64_t dchip_read(void *opaque
, hwaddr addr
, unsigned size
)
206 /* Skip this. It's all related to DRAM timing and setup. */
210 static uint64_t pchip_read(void *opaque
, hwaddr addr
, unsigned size
)
212 TyphoonState
*s
= opaque
;
217 /* WSBA0: Window Space Base Address Register. */
218 ret
= s
->pchip
.win
[0].wba
;
222 ret
= s
->pchip
.win
[1].wba
;
226 ret
= s
->pchip
.win
[2].wba
;
230 ret
= s
->pchip
.win
[3].wba
;
234 /* WSM0: Window Space Mask Register. */
235 ret
= s
->pchip
.win
[0].wsm
;
239 ret
= s
->pchip
.win
[1].wsm
;
243 ret
= s
->pchip
.win
[2].wsm
;
247 ret
= s
->pchip
.win
[3].wsm
;
251 /* TBA0: Translated Base Address Register. */
252 ret
= s
->pchip
.win
[0].tba
;
256 ret
= s
->pchip
.win
[1].tba
;
260 ret
= s
->pchip
.win
[2].tba
;
264 ret
= s
->pchip
.win
[3].tba
;
268 /* PCTL: Pchip Control Register. */
272 /* PLAT: Pchip Master Latency Register. */
275 /* PERROR: Pchip Error Register. */
278 /* PERRMASK: Pchip Error Mask Register. */
281 /* PERRSET: Pchip Error Set Register. */
284 /* TLBIV: Translation Buffer Invalidate Virtual Register (WO). */
287 /* TLBIA: Translation Buffer Invalidate All Register (WO). */
289 case 0x0500: /* PMONCTL */
290 case 0x0540: /* PMONCNT */
291 case 0x0800: /* SPRST */
295 cpu_unassigned_access(current_cpu
, addr
, false, false, 0, size
);
302 static void cchip_write(void *opaque
, hwaddr addr
,
303 uint64_t val
, unsigned size
)
305 TyphoonState
*s
= opaque
;
306 uint64_t oldval
, newval
;
310 /* CSC: Cchip System Configuration Register. */
311 /* All sorts of data here; nothing relevant RW. */
315 /* MTR: Memory Timing Register. */
316 /* All sorts of stuff related to real DRAM. */
320 /* MISC: Miscellaneous Register. */
321 newval
= oldval
= s
->cchip
.misc
;
322 newval
&= ~(val
& 0x10000ff0); /* W1C fields */
323 if (val
& 0x100000) {
324 newval
&= ~0xff0000ull
; /* ACL clears ABT and ABW */
326 newval
|= val
& 0x00f00000; /* ABT field is W1S */
327 if ((newval
& 0xf0000) == 0) {
328 newval
|= val
& 0xf0000; /* ABW field is W1S iff zero */
331 newval
|= (val
& 0xf000) >> 4; /* IPREQ field sets IPINTR. */
333 newval
&= ~0xf0000000000ull
; /* WO and RW fields */
334 newval
|= val
& 0xf0000000000ull
;
335 s
->cchip
.misc
= newval
;
337 /* Pass on changes to IPI and ITI state. */
338 if ((newval
^ oldval
) & 0xff0) {
340 for (i
= 0; i
< 4; ++i
) {
341 AlphaCPU
*cpu
= s
->cchip
.cpu
[i
];
343 CPUState
*cs
= CPU(cpu
);
344 /* IPI can be either cleared or set by the write. */
345 if (newval
& (1 << (i
+ 8))) {
346 cpu_interrupt(cs
, CPU_INTERRUPT_SMP
);
348 cpu_reset_interrupt(cs
, CPU_INTERRUPT_SMP
);
351 /* ITI can only be cleared by the write. */
352 if ((newval
& (1 << (i
+ 4))) == 0) {
353 cpu_reset_interrupt(cs
, CPU_INTERRUPT_TIMER
);
361 /* MPD: Memory Presence Detect Register. */
364 case 0x0100: /* AAR0 */
365 case 0x0140: /* AAR1 */
366 case 0x0180: /* AAR2 */
367 case 0x01c0: /* AAR3 */
368 /* AAR: Array Address Register. */
369 /* All sorts of information about DRAM. */
372 case 0x0200: /* DIM0 */
373 /* DIM: Device Interrupt Mask Register, CPU0. */
374 s
->cchip
.dim
[0] = val
;
375 cpu_irq_change(s
->cchip
.cpu
[0], val
& s
->cchip
.drir
);
377 case 0x0240: /* DIM1 */
378 /* DIM: Device Interrupt Mask Register, CPU1. */
379 s
->cchip
.dim
[0] = val
;
380 cpu_irq_change(s
->cchip
.cpu
[1], val
& s
->cchip
.drir
);
383 case 0x0280: /* DIR0 (RO) */
384 case 0x02c0: /* DIR1 (RO) */
385 case 0x0300: /* DRIR (RO) */
389 /* PRBEN: Probe Enable Register. */
392 case 0x0380: /* IIC0 */
393 s
->cchip
.iic
[0] = val
& 0xffffff;
395 case 0x03c0: /* IIC1 */
396 s
->cchip
.iic
[1] = val
& 0xffffff;
399 case 0x0400: /* MPR0 */
400 case 0x0440: /* MPR1 */
401 case 0x0480: /* MPR2 */
402 case 0x04c0: /* MPR3 */
403 /* MPR: Memory Programming Register. */
407 /* TTR: TIGbus Timing Register. */
408 /* All sorts of stuff related to interrupt delivery timings. */
411 /* TDR: TIGbug Device Timing Register. */
415 /* DIM2: Device Interrupt Mask Register, CPU2. */
416 s
->cchip
.dim
[2] = val
;
417 cpu_irq_change(s
->cchip
.cpu
[2], val
& s
->cchip
.drir
);
420 /* DIM3: Device Interrupt Mask Register, CPU3. */
421 s
->cchip
.dim
[3] = val
;
422 cpu_irq_change(s
->cchip
.cpu
[3], val
& s
->cchip
.drir
);
425 case 0x0680: /* DIR2 (RO) */
426 case 0x06c0: /* DIR3 (RO) */
429 case 0x0700: /* IIC2 */
430 s
->cchip
.iic
[2] = val
& 0xffffff;
432 case 0x0740: /* IIC3 */
433 s
->cchip
.iic
[3] = val
& 0xffffff;
437 /* PWR: Power Management Control. */
440 case 0x0c00: /* CMONCTLA */
441 case 0x0c40: /* CMONCTLB */
442 case 0x0c80: /* CMONCNT01 */
443 case 0x0cc0: /* CMONCNT23 */
447 cpu_unassigned_access(current_cpu
, addr
, true, false, 0, size
);
452 static void dchip_write(void *opaque
, hwaddr addr
,
453 uint64_t val
, unsigned size
)
455 /* Skip this. It's all related to DRAM timing and setup. */
458 static void pchip_write(void *opaque
, hwaddr addr
,
459 uint64_t val
, unsigned size
)
461 TyphoonState
*s
= opaque
;
466 /* WSBA0: Window Space Base Address Register. */
467 s
->pchip
.win
[0].wba
= val
& 0xfff00003u
;
471 s
->pchip
.win
[1].wba
= val
& 0xfff00003u
;
475 s
->pchip
.win
[2].wba
= val
& 0xfff00003u
;
479 s
->pchip
.win
[3].wba
= (val
& 0x80fff00001ull
) | 2;
483 /* WSM0: Window Space Mask Register. */
484 s
->pchip
.win
[0].wsm
= val
& 0xfff00000u
;
488 s
->pchip
.win
[1].wsm
= val
& 0xfff00000u
;
492 s
->pchip
.win
[2].wsm
= val
& 0xfff00000u
;
496 s
->pchip
.win
[3].wsm
= val
& 0xfff00000u
;
500 /* TBA0: Translated Base Address Register. */
501 s
->pchip
.win
[0].tba
= val
& 0x7fffffc00ull
;
505 s
->pchip
.win
[1].tba
= val
& 0x7fffffc00ull
;
509 s
->pchip
.win
[2].tba
= val
& 0x7fffffc00ull
;
513 s
->pchip
.win
[3].tba
= val
& 0x7fffffc00ull
;
517 /* PCTL: Pchip Control Register. */
518 oldval
= s
->pchip
.ctl
;
519 oldval
&= ~0x00001cff0fc7ffull
; /* RW fields */
520 oldval
|= val
& 0x00001cff0fc7ffull
;
521 s
->pchip
.ctl
= oldval
;
525 /* PLAT: Pchip Master Latency Register. */
528 /* PERROR: Pchip Error Register. */
531 /* PERRMASK: Pchip Error Mask Register. */
534 /* PERRSET: Pchip Error Set Register. */
538 /* TLBIV: Translation Buffer Invalidate Virtual Register. */
542 /* TLBIA: Translation Buffer Invalidate All Register (WO). */
554 cpu_unassigned_access(current_cpu
, addr
, true, false, 0, size
);
559 static const MemoryRegionOps cchip_ops
= {
561 .write
= cchip_write
,
562 .endianness
= DEVICE_LITTLE_ENDIAN
,
564 .min_access_size
= 8,
565 .max_access_size
= 8,
568 .min_access_size
= 8,
569 .max_access_size
= 8,
573 static const MemoryRegionOps dchip_ops
= {
575 .write
= dchip_write
,
576 .endianness
= DEVICE_LITTLE_ENDIAN
,
578 .min_access_size
= 8,
579 .max_access_size
= 8,
582 .min_access_size
= 8,
583 .max_access_size
= 8,
587 static const MemoryRegionOps pchip_ops
= {
589 .write
= pchip_write
,
590 .endianness
= DEVICE_LITTLE_ENDIAN
,
592 .min_access_size
= 8,
593 .max_access_size
= 8,
596 .min_access_size
= 8,
597 .max_access_size
= 8,
601 /* A subroutine of typhoon_translate_iommu that builds an IOMMUTLBEntry
602 using the given translated address and mask. */
603 static bool make_iommu_tlbe(hwaddr taddr
, hwaddr mask
, IOMMUTLBEntry
*ret
)
605 *ret
= (IOMMUTLBEntry
) {
606 .target_as
= &address_space_memory
,
607 .translated_addr
= taddr
,
614 /* A subroutine of typhoon_translate_iommu that handles scatter-gather
615 translation, given the address of the PTE. */
616 static bool pte_translate(hwaddr pte_addr
, IOMMUTLBEntry
*ret
)
618 uint64_t pte
= address_space_ldq(&address_space_memory
, pte_addr
,
619 MEMTXATTRS_UNSPECIFIED
, NULL
);
621 /* Check valid bit. */
622 if ((pte
& 1) == 0) {
626 return make_iommu_tlbe((pte
& 0x3ffffe) << 12, 0x1fff, ret
);
629 /* A subroutine of typhoon_translate_iommu that handles one of the
630 four single-address-cycle translation windows. */
631 static bool window_translate(TyphoonWindow
*win
, hwaddr addr
,
634 uint32_t wba
= win
->wba
;
635 uint64_t wsm
= win
->wsm
;
636 uint64_t tba
= win
->tba
;
637 uint64_t wsm_ext
= wsm
| 0xfffff;
639 /* Check for window disabled. */
640 if ((wba
& 1) == 0) {
644 /* Check for window hit. */
645 if ((addr
& ~wsm_ext
) != (wba
& 0xfff00000u
)) {
650 /* Scatter-gather translation. */
653 /* See table 10-6, Generating PTE address for PCI DMA Address. */
654 pte_addr
= tba
& ~(wsm
>> 10);
655 pte_addr
|= (addr
& (wsm
| 0xfe000)) >> 10;
656 return pte_translate(pte_addr
, ret
);
658 /* Direct-mapped translation. */
659 return make_iommu_tlbe(tba
& ~wsm_ext
, wsm_ext
, ret
);
663 /* Handle PCI-to-system address translation. */
664 /* TODO: A translation failure here ought to set PCI error codes on the
665 Pchip and generate a machine check interrupt. */
666 static IOMMUTLBEntry
typhoon_translate_iommu(MemoryRegion
*iommu
, hwaddr addr
,
669 TyphoonPchip
*pchip
= container_of(iommu
, TyphoonPchip
, iommu
);
673 if (addr
<= 0xffffffffu
) {
674 /* Single-address cycle. */
676 /* Check for the Window Hole, inhibiting matching. */
677 if ((pchip
->ctl
& 0x20)
679 && addr
<= 0xfffff) {
683 /* Check the first three windows. */
684 for (i
= 0; i
< 3; ++i
) {
685 if (window_translate(&pchip
->win
[i
], addr
, &ret
)) {
690 /* Check the fourth window for DAC disable. */
691 if ((pchip
->win
[3].wba
& 0x80000000000ull
) == 0
692 && window_translate(&pchip
->win
[3], addr
, &ret
)) {
696 /* Double-address cycle. */
698 if (addr
>= 0x10000000000ull
&& addr
< 0x20000000000ull
) {
699 /* Check for the DMA monster window. */
700 if (pchip
->ctl
& 0x40) {
701 /* See 10.1.4.4; in particular <39:35> is ignored. */
702 make_iommu_tlbe(0, 0x007ffffffffull
, &ret
);
707 if (addr
>= 0x80000000000ull
&& addr
<= 0xfffffffffffull
) {
708 /* Check the fourth window for DAC enable and window enable. */
709 if ((pchip
->win
[3].wba
& 0x80000000001ull
) == 0x80000000001ull
) {
712 pte_addr
= pchip
->win
[3].tba
& 0x7ffc00000ull
;
713 pte_addr
|= (addr
& 0xffffe000u
) >> 10;
714 if (pte_translate(pte_addr
, &ret
)) {
722 ret
= (IOMMUTLBEntry
) { .perm
= IOMMU_NONE
};
727 static const MemoryRegionIOMMUOps typhoon_iommu_ops
= {
728 .translate
= typhoon_translate_iommu
,
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 const uint64_t MB
= 1024 * 1024;
818 const uint64_t GB
= 1024 * MB
;
819 MemoryRegion
*addr_space
= get_system_memory();
826 dev
= qdev_create(NULL
, TYPE_TYPHOON_PCI_HOST_BRIDGE
);
827 qdev_init_nofail(dev
);
829 s
= TYPHOON_PCI_HOST_BRIDGE(dev
);
830 phb
= PCI_HOST_BRIDGE(dev
);
832 s
->cchip
.misc
= 0x800000000ull
; /* Revision: Typhoon. */
833 s
->pchip
.win
[3].wba
= 2; /* Window 3 SG always enabled. */
835 /* Remember the CPUs so that we can deliver interrupts to them. */
836 for (i
= 0; i
< 4; i
++) {
837 AlphaCPU
*cpu
= cpus
[i
];
838 s
->cchip
.cpu
[i
] = cpu
;
840 cpu
->alarm_timer
= timer_new_ns(QEMU_CLOCK_VIRTUAL
,
842 (void *)((uintptr_t)s
+ i
));
846 *p_rtc_irq
= qemu_allocate_irq(typhoon_set_timer_irq
, s
, 0);
848 /* Main memory region, 0x00.0000.0000. Real hardware supports 32GB,
849 but the address space hole reserved at this point is 8TB. */
850 memory_region_allocate_system_memory(&s
->ram_region
, OBJECT(s
), "ram",
852 memory_region_add_subregion(addr_space
, 0, &s
->ram_region
);
854 /* TIGbus, 0x801.0000.0000, 1GB. */
855 /* ??? The TIGbus is used for delivering interrupts, and access to
856 the flash ROM. I'm not sure that we need to implement it at all. */
858 /* Pchip0 CSRs, 0x801.8000.0000, 256MB. */
859 memory_region_init_io(&s
->pchip
.region
, OBJECT(s
), &pchip_ops
, s
, "pchip0",
861 memory_region_add_subregion(addr_space
, 0x80180000000ULL
,
864 /* Cchip CSRs, 0x801.A000.0000, 256MB. */
865 memory_region_init_io(&s
->cchip
.region
, OBJECT(s
), &cchip_ops
, s
, "cchip0",
867 memory_region_add_subregion(addr_space
, 0x801a0000000ULL
,
870 /* Dchip CSRs, 0x801.B000.0000, 256MB. */
871 memory_region_init_io(&s
->dchip_region
, OBJECT(s
), &dchip_ops
, s
, "dchip0",
873 memory_region_add_subregion(addr_space
, 0x801b0000000ULL
,
876 /* Pchip0 PCI memory, 0x800.0000.0000, 4GB. */
877 memory_region_init(&s
->pchip
.reg_mem
, OBJECT(s
), "pci0-mem", 4*GB
);
878 memory_region_add_subregion(addr_space
, 0x80000000000ULL
,
881 /* Pchip0 PCI I/O, 0x801.FC00.0000, 32MB. */
882 memory_region_init_io(&s
->pchip
.reg_io
, OBJECT(s
), &alpha_pci_ignore_ops
,
883 NULL
, "pci0-io", 32*MB
);
884 memory_region_add_subregion(addr_space
, 0x801fc000000ULL
,
887 b
= pci_register_bus(dev
, "pci",
888 typhoon_set_irq
, sys_map_irq
, s
,
889 &s
->pchip
.reg_mem
, &s
->pchip
.reg_io
,
890 0, 64, TYPE_PCI_BUS
);
893 /* Host memory as seen from the PCI side, via the IOMMU. */
894 memory_region_init_iommu(&s
->pchip
.iommu
, OBJECT(s
), &typhoon_iommu_ops
,
895 "iommu-typhoon", UINT64_MAX
);
896 address_space_init(&s
->pchip
.iommu_as
, &s
->pchip
.iommu
, "pchip0-pci");
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*MB
);
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*MB
);
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 int typhoon_pcihost_init(SysBusDevice
*dev
)
940 static void typhoon_pcihost_class_init(ObjectClass
*klass
, void *data
)
942 SysBusDeviceClass
*k
= SYS_BUS_DEVICE_CLASS(klass
);
944 k
->init
= typhoon_pcihost_init
;
947 static const TypeInfo typhoon_pcihost_info
= {
948 .name
= TYPE_TYPHOON_PCI_HOST_BRIDGE
,
949 .parent
= TYPE_PCI_HOST_BRIDGE
,
950 .instance_size
= sizeof(TyphoonState
),
951 .class_init
= typhoon_pcihost_class_init
,
954 static void typhoon_register_types(void)
956 type_register_static(&typhoon_pcihost_info
);
959 type_init(typhoon_register_types
)