]> Git Repo - qemu.git/blob - hw/alpha_typhoon.c
7bfde5771cf1831cf9a42d38e155f6239075473f
[qemu.git] / hw / alpha_typhoon.c
1 /*
2  * DEC 21272 (TSUNAMI/TYPHOON) chipset emulation.
3  *
4  * Written by Richard Henderson.
5  *
6  * This work is licensed under the GNU GPL license version 2 or later.
7  */
8
9 #include "cpu.h"
10 #include "exec/exec-all.h"
11 #include "hw/hw.h"
12 #include "hw/devices.h"
13 #include "sysemu/sysemu.h"
14 #include "hw/alpha_sys.h"
15 #include "exec/address-spaces.h"
16
17
18 #define TYPE_TYPHOON_PCI_HOST_BRIDGE "typhoon-pcihost"
19
20 typedef struct TyphoonCchip {
21     MemoryRegion region;
22     uint64_t misc;
23     uint64_t drir;
24     uint64_t dim[4];
25     uint32_t iic[4];
26     AlphaCPU *cpu[4];
27 } TyphoonCchip;
28
29 typedef struct TyphoonWindow {
30     uint32_t base_addr;
31     uint32_t mask;
32     uint32_t translated_base_pfn;
33 } TyphoonWindow;
34  
35 typedef struct TyphoonPchip {
36     MemoryRegion region;
37     MemoryRegion reg_iack;
38     MemoryRegion reg_mem;
39     MemoryRegion reg_io;
40     MemoryRegion reg_conf;
41     uint64_t ctl;
42     TyphoonWindow win[4];
43 } TyphoonPchip;
44
45 #define TYPHOON_PCI_HOST_BRIDGE(obj) \
46     OBJECT_CHECK(TyphoonState, (obj), TYPE_TYPHOON_PCI_HOST_BRIDGE)
47
48 typedef struct TyphoonState {
49     PCIHostState parent_obj;
50
51     TyphoonCchip cchip;
52     TyphoonPchip pchip;
53     MemoryRegion dchip_region;
54     MemoryRegion ram_region;
55
56     /* QEMU emulation state.  */
57     uint32_t latch_tmp;
58 } TyphoonState;
59
60 /* Called when one of DRIR or DIM changes.  */
61 static void cpu_irq_change(AlphaCPU *cpu, uint64_t req)
62 {
63     /* If there are any non-masked interrupts, tell the cpu.  */
64     if (cpu != NULL) {
65         CPUAlphaState *env = &cpu->env;
66         CPUState *cs = CPU(cpu);
67         if (req) {
68             cpu_interrupt(env, CPU_INTERRUPT_HARD);
69         } else {
70             cpu_reset_interrupt(cs, CPU_INTERRUPT_HARD);
71         }
72     }
73 }
74
75 static uint64_t cchip_read(void *opaque, hwaddr addr, unsigned size)
76 {
77     CPUAlphaState *env = cpu_single_env;
78     TyphoonState *s = opaque;
79     CPUState *cpu;
80     uint64_t ret = 0;
81
82     if (addr & 4) {
83         return s->latch_tmp;
84     }
85
86     switch (addr) {
87     case 0x0000:
88         /* CSC: Cchip System Configuration Register.  */
89         /* All sorts of data here; probably the only thing relevant is
90            PIP<14> Pchip 1 Present = 0.  */
91         break;
92
93     case 0x0040:
94         /* MTR: Memory Timing Register.  */
95         /* All sorts of stuff related to real DRAM.  */
96         break;
97
98     case 0x0080:
99         /* MISC: Miscellaneous Register.  */
100         cpu = ENV_GET_CPU(env);
101         ret = s->cchip.misc | (cpu->cpu_index & 3);
102         break;
103
104     case 0x00c0:
105         /* MPD: Memory Presence Detect Register.  */
106         break;
107
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.  */
114         break;
115
116     case 0x0200:
117         /* DIM0: Device Interrupt Mask Register, CPU0.  */
118         ret = s->cchip.dim[0];
119         break;
120     case 0x0240:
121         /* DIM1: Device Interrupt Mask Register, CPU1.  */
122         ret = s->cchip.dim[1];
123         break;
124     case 0x0280:
125         /* DIR0: Device Interrupt Request Register, CPU0.  */
126         ret = s->cchip.dim[0] & s->cchip.drir;
127         break;
128     case 0x02c0:
129         /* DIR1: Device Interrupt Request Register, CPU1.  */
130         ret = s->cchip.dim[1] & s->cchip.drir;
131         break;
132     case 0x0300:
133         /* DRIR: Device Raw Interrupt Request Register.  */
134         ret = s->cchip.drir;
135         break;
136
137     case 0x0340:
138         /* PRBEN: Probe Enable Register.  */
139         break;
140
141     case 0x0380:
142         /* IIC0: Interval Ignore Count Register, CPU0.  */
143         ret = s->cchip.iic[0];
144         break;
145     case 0x03c0:
146         /* IIC1: Interval Ignore Count Register, CPU1.  */
147         ret = s->cchip.iic[1];
148         break;
149
150     case 0x0400: /* MPR0 */
151     case 0x0440: /* MPR1 */
152     case 0x0480: /* MPR2 */
153     case 0x04c0: /* MPR3 */
154         /* MPR: Memory Programming Register.  */
155         break;
156
157     case 0x0580:
158         /* TTR: TIGbus Timing Register.  */
159         /* All sorts of stuff related to interrupt delivery timings.  */
160         break;
161     case 0x05c0:
162         /* TDR: TIGbug Device Timing Register.  */
163         break;
164
165     case 0x0600:
166         /* DIM2: Device Interrupt Mask Register, CPU2.  */
167         ret = s->cchip.dim[2];
168         break;
169     case 0x0640:
170         /* DIM3: Device Interrupt Mask Register, CPU3.  */
171         ret = s->cchip.dim[3];
172         break;
173     case 0x0680:
174         /* DIR2: Device Interrupt Request Register, CPU2.  */
175         ret = s->cchip.dim[2] & s->cchip.drir;
176         break;
177     case 0x06c0:
178         /* DIR3: Device Interrupt Request Register, CPU3.  */
179         ret = s->cchip.dim[3] & s->cchip.drir;
180         break;
181
182     case 0x0700:
183         /* IIC2: Interval Ignore Count Register, CPU2.  */
184         ret = s->cchip.iic[2];
185         break;
186     case 0x0740:
187         /* IIC3: Interval Ignore Count Register, CPU3.  */
188         ret = s->cchip.iic[3];
189         break;
190
191     case 0x0780:
192         /* PWR: Power Management Control.   */
193         break;
194     
195     case 0x0c00: /* CMONCTLA */
196     case 0x0c40: /* CMONCTLB */
197     case 0x0c80: /* CMONCNT01 */
198     case 0x0cc0: /* CMONCNT23 */
199         break;
200
201     default:
202         cpu_unassigned_access(cpu_single_env, addr, 0, 0, 0, size);
203         return -1;
204     }
205
206     s->latch_tmp = ret >> 32;
207     return ret;
208 }
209
210 static uint64_t dchip_read(void *opaque, hwaddr addr, unsigned size)
211 {
212     /* Skip this.  It's all related to DRAM timing and setup.  */
213     return 0;
214 }
215
216 static uint64_t pchip_read(void *opaque, hwaddr addr, unsigned size)
217 {
218     TyphoonState *s = opaque;
219     uint64_t ret = 0;
220
221     if (addr & 4) {
222         return s->latch_tmp;
223     }
224
225     switch (addr) {
226     case 0x0000:
227         /* WSBA0: Window Space Base Address Register.  */
228         ret = s->pchip.win[0].base_addr;
229         break;
230     case 0x0040:
231         /* WSBA1 */
232         ret = s->pchip.win[1].base_addr;
233         break;
234     case 0x0080:
235         /* WSBA2 */
236         ret = s->pchip.win[2].base_addr;
237         break;
238     case 0x00c0:
239         /* WSBA3 */
240         ret = s->pchip.win[3].base_addr;
241         break;
242
243     case 0x0100:
244         /* WSM0: Window Space Mask Register.  */
245         ret = s->pchip.win[0].mask;
246         break;
247     case 0x0140:
248         /* WSM1 */
249         ret = s->pchip.win[1].mask;
250         break;
251     case 0x0180:
252         /* WSM2 */
253         ret = s->pchip.win[2].mask;
254         break;
255     case 0x01c0:
256         /* WSM3 */
257         ret = s->pchip.win[3].mask;
258         break;
259
260     case 0x0200:
261         /* TBA0: Translated Base Address Register.  */
262         ret = (uint64_t)s->pchip.win[0].translated_base_pfn << 10;
263         break;
264     case 0x0240:
265         /* TBA1 */
266         ret = (uint64_t)s->pchip.win[1].translated_base_pfn << 10;
267         break;
268     case 0x0280:
269         /* TBA2 */
270         ret = (uint64_t)s->pchip.win[2].translated_base_pfn << 10;
271         break;
272     case 0x02c0:
273         /* TBA3 */
274         ret = (uint64_t)s->pchip.win[3].translated_base_pfn << 10;
275         break;
276
277     case 0x0300:
278         /* PCTL: Pchip Control Register.  */
279         ret = s->pchip.ctl;
280         break;
281     case 0x0340:
282         /* PLAT: Pchip Master Latency Register.  */
283         break;
284     case 0x03c0:
285         /* PERROR: Pchip Error Register.  */
286         break;
287     case 0x0400:
288         /* PERRMASK: Pchip Error Mask Register.  */
289         break;
290     case 0x0440:
291         /* PERRSET: Pchip Error Set Register.  */
292         break;
293     case 0x0480:
294         /* TLBIV: Translation Buffer Invalidate Virtual Register (WO).  */
295         break;
296     case 0x04c0:
297         /* TLBIA: Translation Buffer Invalidate All Register (WO).  */
298         break;
299     case 0x0500: /* PMONCTL */
300     case 0x0540: /* PMONCNT */
301     case 0x0800: /* SPRST */
302         break;
303
304     default:
305         cpu_unassigned_access(cpu_single_env, addr, 0, 0, 0, size);
306         return -1;
307     }
308
309     s->latch_tmp = ret >> 32;
310     return ret;
311 }
312
313 static void cchip_write(void *opaque, hwaddr addr,
314                         uint64_t v32, unsigned size)
315 {
316     TyphoonState *s = opaque;
317     uint64_t val, oldval, newval;
318
319     if (addr & 4) {
320         val = v32 << 32 | s->latch_tmp;
321         addr ^= 4;
322     } else {
323         s->latch_tmp = v32;
324         return;
325     }
326
327     switch (addr) {
328     case 0x0000:
329         /* CSC: Cchip System Configuration Register.  */
330         /* All sorts of data here; nothing relevant RW.  */
331         break;
332
333     case 0x0040:
334         /* MTR: Memory Timing Register.  */
335         /* All sorts of stuff related to real DRAM.  */
336         break;
337
338     case 0x0080:
339         /* MISC: Miscellaneous Register.  */
340         newval = oldval = s->cchip.misc;
341         newval &= ~(val & 0x10000ff0);     /* W1C fields */
342         if (val & 0x100000) {
343             newval &= ~0xff0000ull;        /* ACL clears ABT and ABW */
344         } else {
345             newval |= val & 0x00f00000;    /* ABT field is W1S */
346             if ((newval & 0xf0000) == 0) {
347                 newval |= val & 0xf0000;   /* ABW field is W1S iff zero */
348             }
349         }
350         newval |= (val & 0xf000) >> 4;     /* IPREQ field sets IPINTR.  */
351
352         newval &= ~0xf0000000000ull;       /* WO and RW fields */
353         newval |= val & 0xf0000000000ull;
354         s->cchip.misc = newval;
355
356         /* Pass on changes to IPI and ITI state.  */
357         if ((newval ^ oldval) & 0xff0) {
358             int i;
359             for (i = 0; i < 4; ++i) {
360                 AlphaCPU *cpu = s->cchip.cpu[i];
361                 if (cpu != NULL) {
362                     CPUAlphaState *env = &cpu->env;
363                     CPUState *cs = CPU(cpu);
364                     /* IPI can be either cleared or set by the write.  */
365                     if (newval & (1 << (i + 8))) {
366                         cpu_interrupt(env, CPU_INTERRUPT_SMP);
367                     } else {
368                         cpu_reset_interrupt(cs, CPU_INTERRUPT_SMP);
369                     }
370
371                     /* ITI can only be cleared by the write.  */
372                     if ((newval & (1 << (i + 4))) == 0) {
373                         cpu_reset_interrupt(cs, CPU_INTERRUPT_TIMER);
374                     }
375                 }
376             }
377         }
378         break;
379
380     case 0x00c0:
381         /* MPD: Memory Presence Detect Register.  */
382         break;
383
384     case 0x0100: /* AAR0 */
385     case 0x0140: /* AAR1 */
386     case 0x0180: /* AAR2 */
387     case 0x01c0: /* AAR3 */
388         /* AAR: Array Address Register.  */
389         /* All sorts of information about DRAM.  */
390         break;
391
392     case 0x0200: /* DIM0 */
393         /* DIM: Device Interrupt Mask Register, CPU0.  */
394         s->cchip.dim[0] = val;
395         cpu_irq_change(s->cchip.cpu[0], val & s->cchip.drir);
396         break;
397     case 0x0240: /* DIM1 */
398         /* DIM: Device Interrupt Mask Register, CPU1.  */
399         s->cchip.dim[0] = val;
400         cpu_irq_change(s->cchip.cpu[1], val & s->cchip.drir);
401         break;
402
403     case 0x0280: /* DIR0 (RO) */
404     case 0x02c0: /* DIR1 (RO) */
405     case 0x0300: /* DRIR (RO) */
406         break;
407
408     case 0x0340:
409         /* PRBEN: Probe Enable Register.  */
410         break;
411
412     case 0x0380: /* IIC0 */
413         s->cchip.iic[0] = val & 0xffffff;
414         break;
415     case 0x03c0: /* IIC1 */
416         s->cchip.iic[1] = val & 0xffffff;
417         break;
418
419     case 0x0400: /* MPR0 */
420     case 0x0440: /* MPR1 */
421     case 0x0480: /* MPR2 */
422     case 0x04c0: /* MPR3 */
423         /* MPR: Memory Programming Register.  */
424         break;
425
426     case 0x0580:
427         /* TTR: TIGbus Timing Register.  */
428         /* All sorts of stuff related to interrupt delivery timings.  */
429         break;
430     case 0x05c0:
431         /* TDR: TIGbug Device Timing Register.  */
432         break;
433
434     case 0x0600:
435         /* DIM2: Device Interrupt Mask Register, CPU2.  */
436         s->cchip.dim[2] = val;
437         cpu_irq_change(s->cchip.cpu[2], val & s->cchip.drir);
438         break;
439     case 0x0640:
440         /* DIM3: Device Interrupt Mask Register, CPU3.  */
441         s->cchip.dim[3] = val;
442         cpu_irq_change(s->cchip.cpu[3], val & s->cchip.drir);
443         break;
444
445     case 0x0680: /* DIR2 (RO) */
446     case 0x06c0: /* DIR3 (RO) */
447         break;
448
449     case 0x0700: /* IIC2 */
450         s->cchip.iic[2] = val & 0xffffff;
451         break;
452     case 0x0740: /* IIC3 */
453         s->cchip.iic[3] = val & 0xffffff;
454         break;
455
456     case 0x0780:
457         /* PWR: Power Management Control.   */
458         break;
459     
460     case 0x0c00: /* CMONCTLA */
461     case 0x0c40: /* CMONCTLB */
462     case 0x0c80: /* CMONCNT01 */
463     case 0x0cc0: /* CMONCNT23 */
464         break;
465
466     default:
467         cpu_unassigned_access(cpu_single_env, addr, 1, 0, 0, size);
468         return;
469     }
470 }
471
472 static void dchip_write(void *opaque, hwaddr addr,
473                         uint64_t val, unsigned size)
474 {
475     /* Skip this.  It's all related to DRAM timing and setup.  */
476 }
477
478 static void pchip_write(void *opaque, hwaddr addr,
479                         uint64_t v32, unsigned size)
480 {
481     TyphoonState *s = opaque;
482     uint64_t val, oldval;
483
484     if (addr & 4) {
485         val = v32 << 32 | s->latch_tmp;
486         addr ^= 4;
487     } else {
488         s->latch_tmp = v32;
489         return;
490     }
491
492     switch (addr) {
493     case 0x0000:
494         /* WSBA0: Window Space Base Address Register.  */
495         s->pchip.win[0].base_addr = val;
496         break;
497     case 0x0040:
498         /* WSBA1 */
499         s->pchip.win[1].base_addr = val;
500         break;
501     case 0x0080:
502         /* WSBA2 */
503         s->pchip.win[2].base_addr = val;
504         break;
505     case 0x00c0:
506         /* WSBA3 */
507         s->pchip.win[3].base_addr = val;
508         break;
509
510     case 0x0100:
511         /* WSM0: Window Space Mask Register.  */
512         s->pchip.win[0].mask = val;
513         break;
514     case 0x0140:
515         /* WSM1 */
516         s->pchip.win[1].mask = val;
517         break;
518     case 0x0180:
519         /* WSM2 */
520         s->pchip.win[2].mask = val;
521         break;
522     case 0x01c0:
523         /* WSM3 */
524         s->pchip.win[3].mask = val;
525         break;
526
527     case 0x0200:
528         /* TBA0: Translated Base Address Register.  */
529         s->pchip.win[0].translated_base_pfn = val >> 10;
530         break;
531     case 0x0240:
532         /* TBA1 */
533         s->pchip.win[1].translated_base_pfn = val >> 10;
534         break;
535     case 0x0280:
536         /* TBA2 */
537         s->pchip.win[2].translated_base_pfn = val >> 10;
538         break;
539     case 0x02c0:
540         /* TBA3 */
541         s->pchip.win[3].translated_base_pfn = val >> 10;
542         break;
543
544     case 0x0300:
545         /* PCTL: Pchip Control Register.  */
546         oldval = s->pchip.ctl;
547         oldval &= ~0x00001cff0fc7ffull;       /* RW fields */
548         oldval |= val & 0x00001cff0fc7ffull;
549
550         s->pchip.ctl = oldval;
551         break;
552
553     case 0x0340:
554         /* PLAT: Pchip Master Latency Register.  */
555         break;
556     case 0x03c0:
557         /* PERROR: Pchip Error Register.  */
558         break;
559     case 0x0400:
560         /* PERRMASK: Pchip Error Mask Register.  */
561         break;
562     case 0x0440:
563         /* PERRSET: Pchip Error Set Register.  */
564         break;
565
566     case 0x0480:
567         /* TLBIV: Translation Buffer Invalidate Virtual Register.  */
568         break;
569
570     case 0x04c0:
571         /* TLBIA: Translation Buffer Invalidate All Register (WO).  */
572         break;
573
574     case 0x0500:
575         /* PMONCTL */
576     case 0x0540:
577         /* PMONCNT */
578     case 0x0800:
579         /* SPRST */
580         break;
581
582     default:
583         cpu_unassigned_access(cpu_single_env, addr, 1, 0, 0, size);
584         return;
585     }
586 }
587
588 static const MemoryRegionOps cchip_ops = {
589     .read = cchip_read,
590     .write = cchip_write,
591     .endianness = DEVICE_LITTLE_ENDIAN,
592     .valid = {
593         .min_access_size = 4,  /* ??? Should be 8.  */
594         .max_access_size = 8,
595     },
596     .impl = {
597         .min_access_size = 4,
598         .max_access_size = 4,
599     },
600 };
601
602 static const MemoryRegionOps dchip_ops = {
603     .read = dchip_read,
604     .write = dchip_write,
605     .endianness = DEVICE_LITTLE_ENDIAN,
606     .valid = {
607         .min_access_size = 4,  /* ??? Should be 8.  */
608         .max_access_size = 8,
609     },
610     .impl = {
611         .min_access_size = 4,
612         .max_access_size = 8,
613     },
614 };
615
616 static const MemoryRegionOps pchip_ops = {
617     .read = pchip_read,
618     .write = pchip_write,
619     .endianness = DEVICE_LITTLE_ENDIAN,
620     .valid = {
621         .min_access_size = 4,  /* ??? Should be 8.  */
622         .max_access_size = 8,
623     },
624     .impl = {
625         .min_access_size = 4,
626         .max_access_size = 4,
627     },
628 };
629
630 static void typhoon_set_irq(void *opaque, int irq, int level)
631 {
632     TyphoonState *s = opaque;
633     uint64_t drir;
634     int i;
635
636     /* Set/Reset the bit in CCHIP.DRIR based on IRQ+LEVEL.  */
637     drir = s->cchip.drir;
638     if (level) {
639         drir |= 1ull << irq;
640     } else {
641         drir &= ~(1ull << irq);
642     }
643     s->cchip.drir = drir;
644
645     for (i = 0; i < 4; ++i) {
646         cpu_irq_change(s->cchip.cpu[i], s->cchip.dim[i] & drir);
647     }
648 }
649
650 static void typhoon_set_isa_irq(void *opaque, int irq, int level)
651 {
652     typhoon_set_irq(opaque, 55, level);
653 }
654
655 static void typhoon_set_timer_irq(void *opaque, int irq, int level)
656 {
657     TyphoonState *s = opaque;
658     int i;
659
660     /* Thankfully, the mc146818rtc code doesn't track the IRQ state,
661        and so we don't have to worry about missing interrupts just
662        because we never actually ACK the interrupt.  Just ignore any
663        case of the interrupt level going low.  */
664     if (level == 0) {
665         return;
666     }
667
668     /* Deliver the interrupt to each CPU, considering each CPU's IIC.  */
669     for (i = 0; i < 4; ++i) {
670         AlphaCPU *cpu = s->cchip.cpu[i];
671         if (cpu != NULL) {
672             uint32_t iic = s->cchip.iic[i];
673
674             /* ??? The verbage in Section 10.2.2.10 isn't 100% clear.
675                Bit 24 is the OverFlow bit, RO, and set when the count
676                decrements past 0.  When is OF cleared?  My guess is that
677                OF is actually cleared when the IIC is written, and that
678                the ICNT field always decrements.  At least, that's an
679                interpretation that makes sense, and "allows the CPU to
680                determine exactly how mant interval timer ticks were
681                skipped".  At least within the next 4M ticks...  */
682
683             iic = ((iic - 1) & 0x1ffffff) | (iic & 0x1000000);
684             s->cchip.iic[i] = iic;
685
686             if (iic & 0x1000000) {
687                 /* Set the ITI bit for this cpu.  */
688                 s->cchip.misc |= 1 << (i + 4);
689                 /* And signal the interrupt.  */
690                 cpu_interrupt(&cpu->env, CPU_INTERRUPT_TIMER);
691             }
692         }
693     }
694 }
695
696 static void typhoon_alarm_timer(void *opaque)
697 {
698     TyphoonState *s = (TyphoonState *)((uintptr_t)opaque & ~3);
699     int cpu = (uintptr_t)opaque & 3;
700
701     /* Set the ITI bit for this cpu.  */
702     s->cchip.misc |= 1 << (cpu + 4);
703     cpu_interrupt(&s->cchip.cpu[cpu]->env, CPU_INTERRUPT_TIMER);
704 }
705
706 PCIBus *typhoon_init(ram_addr_t ram_size, ISABus **isa_bus,
707                      qemu_irq *p_rtc_irq,
708                      AlphaCPU *cpus[4], pci_map_irq_fn sys_map_irq)
709 {
710     const uint64_t MB = 1024 * 1024;
711     const uint64_t GB = 1024 * MB;
712     MemoryRegion *addr_space = get_system_memory();
713     MemoryRegion *addr_space_io = get_system_io();
714     DeviceState *dev;
715     TyphoonState *s;
716     PCIHostState *phb;
717     PCIBus *b;
718     int i;
719
720     dev = qdev_create(NULL, TYPE_TYPHOON_PCI_HOST_BRIDGE);
721     qdev_init_nofail(dev);
722
723     s = TYPHOON_PCI_HOST_BRIDGE(dev);
724     phb = PCI_HOST_BRIDGE(dev);
725
726     /* Remember the CPUs so that we can deliver interrupts to them.  */
727     for (i = 0; i < 4; i++) {
728         AlphaCPU *cpu = cpus[i];
729         s->cchip.cpu[i] = cpu;
730         if (cpu != NULL) {
731             cpu->alarm_timer = qemu_new_timer_ns(rtc_clock,
732                                                  typhoon_alarm_timer,
733                                                  (void *)((uintptr_t)s + i));
734         }
735     }
736
737     *p_rtc_irq = *qemu_allocate_irqs(typhoon_set_timer_irq, s, 1);
738
739     /* Main memory region, 0x00.0000.0000.  Real hardware supports 32GB,
740        but the address space hole reserved at this point is 8TB.  */
741     memory_region_init_ram(&s->ram_region, "ram", ram_size);
742     vmstate_register_ram_global(&s->ram_region);
743     memory_region_add_subregion(addr_space, 0, &s->ram_region);
744
745     /* TIGbus, 0x801.0000.0000, 1GB.  */
746     /* ??? The TIGbus is used for delivering interrupts, and access to
747        the flash ROM.  I'm not sure that we need to implement it at all.  */
748
749     /* Pchip0 CSRs, 0x801.8000.0000, 256MB.  */
750     memory_region_init_io(&s->pchip.region, &pchip_ops, s, "pchip0", 256*MB);
751     memory_region_add_subregion(addr_space, 0x80180000000ULL,
752                                 &s->pchip.region);
753
754     /* Cchip CSRs, 0x801.A000.0000, 256MB.  */
755     memory_region_init_io(&s->cchip.region, &cchip_ops, s, "cchip0", 256*MB);
756     memory_region_add_subregion(addr_space, 0x801a0000000ULL,
757                                 &s->cchip.region);
758
759     /* Dchip CSRs, 0x801.B000.0000, 256MB.  */
760     memory_region_init_io(&s->dchip_region, &dchip_ops, s, "dchip0", 256*MB);
761     memory_region_add_subregion(addr_space, 0x801b0000000ULL,
762                                 &s->dchip_region);
763
764     /* Pchip0 PCI memory, 0x800.0000.0000, 4GB.  */
765     memory_region_init(&s->pchip.reg_mem, "pci0-mem", 4*GB);
766     memory_region_add_subregion(addr_space, 0x80000000000ULL,
767                                 &s->pchip.reg_mem);
768
769     /* Pchip0 PCI I/O, 0x801.FC00.0000, 32MB.  */
770     /* ??? Ideally we drop the "system" i/o space on the floor and give the
771        PCI subsystem the full address space reserved by the chipset.
772        We can't do that until the MEM and IO paths in memory.c are unified.  */
773     memory_region_init_io(&s->pchip.reg_io, &alpha_pci_bw_io_ops, NULL,
774                           "pci0-io", 32*MB);
775     memory_region_add_subregion(addr_space, 0x801fc000000ULL,
776                                 &s->pchip.reg_io);
777
778     b = pci_register_bus(dev, "pci",
779                          typhoon_set_irq, sys_map_irq, s,
780                          &s->pchip.reg_mem, addr_space_io, 0, 64);
781     phb->bus = b;
782
783     /* Pchip0 PCI special/interrupt acknowledge, 0x801.F800.0000, 64MB.  */
784     memory_region_init_io(&s->pchip.reg_iack, &alpha_pci_iack_ops, b,
785                           "pci0-iack", 64*MB);
786     memory_region_add_subregion(addr_space, 0x801f8000000ULL,
787                                 &s->pchip.reg_iack);
788
789     /* Pchip0 PCI configuration, 0x801.FE00.0000, 16MB.  */
790     memory_region_init_io(&s->pchip.reg_conf, &alpha_pci_conf1_ops, b,
791                           "pci0-conf", 16*MB);
792     memory_region_add_subregion(addr_space, 0x801fe000000ULL,
793                                 &s->pchip.reg_conf);
794
795     /* For the record, these are the mappings for the second PCI bus.
796        We can get away with not implementing them because we indicate
797        via the Cchip.CSC<PIP> bit that Pchip1 is not present.  */
798     /* Pchip1 PCI memory, 0x802.0000.0000, 4GB.  */
799     /* Pchip1 CSRs, 0x802.8000.0000, 256MB.  */
800     /* Pchip1 PCI special/interrupt acknowledge, 0x802.F800.0000, 64MB.  */
801     /* Pchip1 PCI I/O, 0x802.FC00.0000, 32MB.  */
802     /* Pchip1 PCI configuration, 0x802.FE00.0000, 16MB.  */
803
804     /* Init the ISA bus.  */
805     /* ??? Technically there should be a cy82c693ub pci-isa bridge.  */
806     {
807         qemu_irq isa_pci_irq, *isa_irqs;
808
809         *isa_bus = isa_bus_new(NULL, addr_space_io);
810         isa_pci_irq = *qemu_allocate_irqs(typhoon_set_isa_irq, s, 1);
811         isa_irqs = i8259_init(*isa_bus, isa_pci_irq);
812         isa_bus_irqs(*isa_bus, isa_irqs);
813     }
814
815     return b;
816 }
817
818 static int typhoon_pcihost_init(SysBusDevice *dev)
819 {
820     return 0;
821 }
822
823 static void typhoon_pcihost_class_init(ObjectClass *klass, void *data)
824 {
825     DeviceClass *dc = DEVICE_CLASS(klass);
826     SysBusDeviceClass *k = SYS_BUS_DEVICE_CLASS(klass);
827
828     k->init = typhoon_pcihost_init;
829     dc->no_user = 1;
830 }
831
832 static const TypeInfo typhoon_pcihost_info = {
833     .name          = TYPE_TYPHOON_PCI_HOST_BRIDGE,
834     .parent        = TYPE_PCI_HOST_BRIDGE,
835     .instance_size = sizeof(TyphoonState),
836     .class_init    = typhoon_pcihost_class_init,
837 };
838
839 static void typhoon_register_types(void)
840 {
841     type_register_static(&typhoon_pcihost_info);
842 }
843
844 type_init(typhoon_register_types)
This page took 0.064155 seconds and 2 git commands to generate.