~vcs-imports/qemu/git

« back to all changes in this revision

Viewing changes to hw/sh7750.c

  • Committer: blueswir1
  • Date: 2007-11-25 08:48:16 UTC
  • Revision ID: git-v1:b76482e76560345c00e7d6c89199ced204a926d2
 Fix buffer mux handling for unconnected serial ports


git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3737 c046a42c-6fe2-441c-8c8c-71466251a162

Show diffs side-by-side

added added

removed removed

Lines of Context:
30
30
#include "sh7750_regs.h"
31
31
#include "sh7750_regnames.h"
32
32
#include "sh_intc.h"
33
 
#include "exec-all.h"
34
 
#include "cpu.h"
35
33
 
36
34
#define NB_DEVICES 4
37
35
 
184
182
 
185
183
static void error_access(const char *kind, target_phys_addr_t addr)
186
184
{
187
 
    fprintf(stderr, "%s to %s (0x" TARGET_FMT_plx ") not supported\n",
 
185
    fprintf(stderr, "%s to %s (0x%08x) not supported\n",
188
186
            kind, regname(addr), addr);
189
187
}
190
188
 
191
189
static void ignore_access(const char *kind, target_phys_addr_t addr)
192
190
{
193
 
    fprintf(stderr, "%s to %s (0x" TARGET_FMT_plx ") ignored\n",
 
191
    fprintf(stderr, "%s to %s (0x%08x) ignored\n",
194
192
            kind, regname(addr), addr);
195
193
}
196
194
 
249
247
        return s->cpu->intevt;
250
248
    case SH7750_CCR_A7:
251
249
        return s->ccr;
252
 
    case 0x1f000030:            /* Processor version */
253
 
        return s->cpu->pvr;
254
 
    case 0x1f000040:            /* Cache version */
255
 
        return s->cpu->cvr;
256
 
    case 0x1f000044:            /* Processor revision */
257
 
        return s->cpu->prr;
 
250
    case 0x1f000030:            /* Processor version PVR */
 
251
        return 0x00050000;      /* SH7750R */
 
252
    case 0x1f000040:            /* Processor version CVR */
 
253
        return 0x00110000;      /* Minimum caches */
 
254
    case 0x1f000044:            /* Processor version PRR */
 
255
        return 0x00000100;      /* SH7750R */
258
256
    default:
259
257
        error_access("long read", addr);
260
258
        assert(0);
357
355
        s->cpu->mmucr = mem_value;
358
356
        return;
359
357
    case SH7750_PTEH_A7:
360
 
        /* If asid changes, clear all registered tlb entries. */
361
 
        if ((s->cpu->pteh & 0xff) != (mem_value & 0xff))
362
 
            tlb_flush(s->cpu, 1);
363
358
        s->cpu->pteh = mem_value;
364
359
        return;
365
360
    case SH7750_PTEL_A7:
366
361
        s->cpu->ptel = mem_value;
367
362
        return;
368
 
    case SH7750_PTEA_A7:
369
 
        s->cpu->ptea = mem_value & 0x0000000f;
370
 
        return;
371
363
    case SH7750_TTB_A7:
372
364
        s->cpu->ttb = mem_value;
373
365
        return;
529
521
                   PCIC1_PCIDMA0, PCIC1_PCIDMA1, PCIC1_PCIDMA2, PCIC1_PCIDMA3),
530
522
};
531
523
 
532
 
/**********************************************************************
533
 
 Memory mapped cache and TLB
534
 
**********************************************************************/
535
 
 
536
 
#define MM_REGION_MASK   0x07000000
537
 
#define MM_ICACHE_ADDR   (0)
538
 
#define MM_ICACHE_DATA   (1)
539
 
#define MM_ITLB_ADDR     (2)
540
 
#define MM_ITLB_DATA     (3)
541
 
#define MM_OCACHE_ADDR   (4)
542
 
#define MM_OCACHE_DATA   (5)
543
 
#define MM_UTLB_ADDR     (6)
544
 
#define MM_UTLB_DATA     (7)
545
 
#define MM_REGION_TYPE(addr)  ((addr & MM_REGION_MASK) >> 24)
546
 
 
547
 
static uint32_t invalid_read(void *opaque, target_phys_addr_t addr)
548
 
{
549
 
    assert(0);
550
 
 
551
 
    return 0;
552
 
}
553
 
 
554
 
static uint32_t sh7750_mmct_readl(void *opaque, target_phys_addr_t addr)
555
 
{
556
 
    uint32_t ret = 0;
557
 
 
558
 
    switch (MM_REGION_TYPE(addr)) {
559
 
    case MM_ICACHE_ADDR:
560
 
    case MM_ICACHE_DATA:
561
 
        /* do nothing */
562
 
        break;
563
 
    case MM_ITLB_ADDR:
564
 
    case MM_ITLB_DATA:
565
 
        /* XXXXX */
566
 
        assert(0);
567
 
        break;
568
 
    case MM_OCACHE_ADDR:
569
 
    case MM_OCACHE_DATA:
570
 
        /* do nothing */
571
 
        break;
572
 
    case MM_UTLB_ADDR:
573
 
    case MM_UTLB_DATA:
574
 
        /* XXXXX */
575
 
        assert(0);
576
 
        break;
577
 
    default:
578
 
        assert(0);
579
 
    }
580
 
 
581
 
    return ret;
582
 
}
583
 
 
584
 
static void invalid_write(void *opaque, target_phys_addr_t addr,
585
 
                          uint32_t mem_value)
586
 
{
587
 
    assert(0);
588
 
}
589
 
 
590
 
static void sh7750_mmct_writel(void *opaque, target_phys_addr_t addr,
591
 
                                uint32_t mem_value)
592
 
{
593
 
    SH7750State *s = opaque;
594
 
 
595
 
    switch (MM_REGION_TYPE(addr)) {
596
 
    case MM_ICACHE_ADDR:
597
 
    case MM_ICACHE_DATA:
598
 
        /* do nothing */
599
 
        break;
600
 
    case MM_ITLB_ADDR:
601
 
    case MM_ITLB_DATA:
602
 
        /* XXXXX */
603
 
        assert(0);
604
 
        break;
605
 
    case MM_OCACHE_ADDR:
606
 
    case MM_OCACHE_DATA:
607
 
        /* do nothing */
608
 
        break;
609
 
    case MM_UTLB_ADDR:
610
 
        cpu_sh4_write_mmaped_utlb_addr(s->cpu, addr, mem_value);
611
 
        break;
612
 
    case MM_UTLB_DATA:
613
 
        /* XXXXX */
614
 
        assert(0);
615
 
        break;
616
 
    default:
617
 
        assert(0);
618
 
        break;
619
 
    }
620
 
}
621
 
 
622
 
static CPUReadMemoryFunc *sh7750_mmct_read[] = {
623
 
    invalid_read,
624
 
    invalid_read,
625
 
    sh7750_mmct_readl
626
 
};
627
 
 
628
 
static CPUWriteMemoryFunc *sh7750_mmct_write[] = {
629
 
    invalid_write,
630
 
    invalid_write,
631
 
    sh7750_mmct_writel
632
 
};
 
524
#define SH_CPU_SH7750  (1 << 0)
 
525
#define SH_CPU_SH7750S (1 << 1)
 
526
#define SH_CPU_SH7750R (1 << 2)
 
527
#define SH_CPU_SH7751  (1 << 3)
 
528
#define SH_CPU_SH7751R (1 << 4)
 
529
#define SH_CPU_SH7750_ALL (SH_CPU_SH7750 | SH_CPU_SH7750S | SH_CPU_SH7750R)
 
530
#define SH_CPU_SH7751_ALL (SH_CPU_SH7751 | SH_CPU_SH7751R)
633
531
 
634
532
SH7750State *sh7750_init(CPUSH4State * cpu)
635
533
{
636
534
    SH7750State *s;
637
535
    int sh7750_io_memory;
638
 
    int sh7750_mm_cache_and_tlb; /* memory mapped cache and tlb */
 
536
    int cpu_model = SH_CPU_SH7751R; /* for now */
639
537
 
640
538
    s = qemu_mallocz(sizeof(SH7750State));
641
539
    s->cpu = cpu;
645
543
                                              sh7750_mem_write, s);
646
544
    cpu_register_physical_memory(0x1c000000, 0x04000000, sh7750_io_memory);
647
545
 
648
 
    sh7750_mm_cache_and_tlb = cpu_register_io_memory(0,
649
 
                                                     sh7750_mmct_read,
650
 
                                                     sh7750_mmct_write, s);
651
 
    cpu_register_physical_memory(0xf0000000, 0x08000000,
652
 
                                 sh7750_mm_cache_and_tlb);
653
 
 
654
546
    sh_intc_init(&s->intc, NR_SOURCES,
655
547
                 _INTC_ARRAY(mask_registers),
656
548
                 _INTC_ARRAY(prio_registers));
657
549
 
658
 
    sh_intc_register_sources(&s->intc,
 
550
    sh_intc_register_sources(&s->intc, 
659
551
                             _INTC_ARRAY(vectors),
660
552
                             _INTC_ARRAY(groups));
661
553
 
662
 
    cpu->intc_handle = &s->intc;
663
 
 
664
 
    sh_serial_init(0x1fe00000, 0, s->periph_freq, serial_hds[0],
665
 
                   sh_intc_source(&s->intc, SCI1_ERI),
666
 
                   sh_intc_source(&s->intc, SCI1_RXI),
667
 
                   sh_intc_source(&s->intc, SCI1_TXI),
668
 
                   sh_intc_source(&s->intc, SCI1_TEI),
669
 
                   NULL);
 
554
    sh_serial_init(0x1fe00000, 0, s->periph_freq, serial_hds[0]);
670
555
    sh_serial_init(0x1fe80000, SH_SERIAL_FEAT_SCIF,
671
 
                   s->periph_freq, serial_hds[1],
672
 
                   sh_intc_source(&s->intc, SCIF_ERI),
673
 
                   sh_intc_source(&s->intc, SCIF_RXI),
674
 
                   sh_intc_source(&s->intc, SCIF_TXI),
675
 
                   NULL,
676
 
                   sh_intc_source(&s->intc, SCIF_BRI));
 
556
                   s->periph_freq, serial_hds[1]);
677
557
 
678
558
    tmu012_init(0x1fd80000,
679
559
                TMU012_FEAT_TOCR | TMU012_FEAT_3CHAN | TMU012_FEAT_EXTCLK,
680
 
                s->periph_freq,
681
 
                sh_intc_source(&s->intc, TMU0),
682
 
                sh_intc_source(&s->intc, TMU1),
683
 
                sh_intc_source(&s->intc, TMU2_TUNI),
684
 
                sh_intc_source(&s->intc, TMU2_TICPI));
685
 
 
686
 
    if (cpu->id & (SH_CPU_SH7750 | SH_CPU_SH7750S | SH_CPU_SH7751)) {
687
 
        sh_intc_register_sources(&s->intc,
 
560
                s->periph_freq);
 
561
 
 
562
 
 
563
    if (cpu_model & (SH_CPU_SH7750 | SH_CPU_SH7750S | SH_CPU_SH7751)) {
 
564
        sh_intc_register_sources(&s->intc, 
688
565
                                 _INTC_ARRAY(vectors_dma4),
689
566
                                 _INTC_ARRAY(groups_dma4));
690
567
    }
691
568
 
692
 
    if (cpu->id & (SH_CPU_SH7750R | SH_CPU_SH7751R)) {
693
 
        sh_intc_register_sources(&s->intc,
 
569
    if (cpu_model & (SH_CPU_SH7750R | SH_CPU_SH7751R)) {
 
570
        sh_intc_register_sources(&s->intc, 
694
571
                                 _INTC_ARRAY(vectors_dma8),
695
572
                                 _INTC_ARRAY(groups_dma8));
696
573
    }
697
574
 
698
 
    if (cpu->id & (SH_CPU_SH7750R | SH_CPU_SH7751 | SH_CPU_SH7751R)) {
699
 
        sh_intc_register_sources(&s->intc,
 
575
    if (cpu_model & (SH_CPU_SH7750R | SH_CPU_SH7751 | SH_CPU_SH7751R)) {
 
576
        sh_intc_register_sources(&s->intc, 
700
577
                                 _INTC_ARRAY(vectors_tmu34),
701
578
                                 NULL, 0);
702
 
        tmu012_init(0x1e100000, 0, s->periph_freq,
703
 
                    sh_intc_source(&s->intc, TMU3),
704
 
                    sh_intc_source(&s->intc, TMU4),
705
 
                    NULL, NULL);
 
579
        tmu012_init(0x1e100000, 0, s->periph_freq);
706
580
    }
707
581
 
708
 
    if (cpu->id & (SH_CPU_SH7751_ALL)) {
709
 
        sh_intc_register_sources(&s->intc,
 
582
    if (cpu_model & (SH_CPU_SH7751_ALL)) {
 
583
        sh_intc_register_sources(&s->intc, 
710
584
                                 _INTC_ARRAY(vectors_pci),
711
585
                                 _INTC_ARRAY(groups_pci));
712
586
    }
713
587
 
714
 
    if (cpu->id & (SH_CPU_SH7750S | SH_CPU_SH7750R | SH_CPU_SH7751_ALL)) {
715
 
        sh_intc_register_sources(&s->intc,
 
588
    if (cpu_model & (SH_CPU_SH7750S | SH_CPU_SH7750R | SH_CPU_SH7751_ALL)) {
 
589
        sh_intc_register_sources(&s->intc, 
716
590
                                 _INTC_ARRAY(vectors_irlm),
717
591
                                 NULL, 0);
718
592
    }