~vcs-imports/qemu/git

« back to all changes in this revision

Viewing changes to hw/ppc405_uc.c

  • Committer: j_mayer
  • Date: 2007-11-24 02:56:36 UTC
  • Revision ID: git-v1:aae9366a036b813d58fad2d99d28a2a478109f75
More PowerPC debug print fixes - hardware emulation pass.


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

Show diffs side-by-side

added added

removed removed

Lines of Context:
40
40
#define DEBUG_GPT
41
41
#define DEBUG_MAL
42
42
#define DEBUG_CLOCKS
43
 
//#define DEBUG_UNASSIGNED
 
43
//#define DEBUG_CLOCKS_LL
44
44
 
45
45
ram_addr_t ppc405_set_bootinfo (CPUState *env, ppc4xx_bd_info_t *bd,
46
46
                                uint32_t flags)
298
298
    ppc4xx_opba_t *opba;
299
299
 
300
300
#ifdef DEBUG_OPBA
301
 
    printf("%s: addr " PADDRX " val %08x\n", __func__, addr, value);
 
301
    printf("%s: addr " PADDRX " val %08" PRIx32 "\n", __func__, addr, value);
302
302
#endif
303
303
    opba = opaque;
304
304
    switch (addr - opba->base) {
330
330
                         target_phys_addr_t addr, uint32_t value)
331
331
{
332
332
#ifdef DEBUG_OPBA
333
 
    printf("%s: addr " PADDRX " val %08x\n", __func__, addr, value);
 
333
    printf("%s: addr " PADDRX " val %08" PRIx32 "\n", __func__, addr, value);
334
334
#endif
335
335
    opba_writeb(opaque, addr, value >> 8);
336
336
    opba_writeb(opaque, addr + 1, value);
353
353
                         target_phys_addr_t addr, uint32_t value)
354
354
{
355
355
#ifdef DEBUG_OPBA
356
 
    printf("%s: addr " PADDRX " val %08x\n", __func__, addr, value);
 
356
    printf("%s: addr " PADDRX " val %08" PRIx32 "\n", __func__, addr, value);
357
357
#endif
358
358
    opba_writeb(opaque, addr, value >> 24);
359
359
    opba_writeb(opaque, addr + 1, value >> 16);
389
389
    if (opba != NULL) {
390
390
        opba->base = offset;
391
391
#ifdef DEBUG_OPBA
392
 
        printf("%s: offset=" PADDRX "\n", __func__, offset);
 
392
        printf("%s: offset " PADDRX "\n", __func__, offset);
393
393
#endif
394
394
        ppc4xx_mmio_register(env, mmio, offset, 0x002,
395
395
                             opba_read, opba_write, opba);
429
429
    SDRAM0_CFGDATA = 0x011,
430
430
};
431
431
 
 
432
/* XXX: TOFIX: some patches have made this code become inconsistent:
 
433
 *      there are type inconsistencies, mixing target_phys_addr_t, target_ulong
 
434
 *      and uint32_t
 
435
 */
432
436
static uint32_t sdram_bcr (target_phys_addr_t ram_base,
433
437
                           target_phys_addr_t ram_size)
434
438
{
457
461
        bcr = 0x000C0000;
458
462
        break;
459
463
    default:
460
 
        printf("%s: invalid RAM size " TARGET_FMT_plx "\n",
461
 
               __func__, ram_size);
 
464
        printf("%s: invalid RAM size " PADDRX "\n", __func__, ram_size);
462
465
        return 0x00000000;
463
466
    }
464
467
    bcr |= ram_base & 0xFF800000;
491
494
    if (*bcrp & 0x00000001) {
492
495
        /* Unmap RAM */
493
496
#ifdef DEBUG_SDRAM
494
 
        printf("%s: unmap RAM area " TARGET_FMT_plx " " TARGET_FMT_lx "\n",
 
497
        printf("%s: unmap RAM area " PADDRX " " ADDRX "\n",
495
498
               __func__, sdram_base(*bcrp), sdram_size(*bcrp));
496
499
#endif
497
500
        cpu_register_physical_memory(sdram_base(*bcrp), sdram_size(*bcrp),
500
503
    *bcrp = bcr & 0xFFDEE001;
501
504
    if (enabled && (bcr & 0x00000001)) {
502
505
#ifdef DEBUG_SDRAM
503
 
        printf("%s: Map RAM area " TARGET_FMT_plx " " TARGET_FMT_lx "\n",
 
506
        printf("%s: Map RAM area " PADDRX " " ADDRX "\n",
504
507
               __func__, sdram_base(bcr), sdram_size(bcr));
505
508
#endif
506
509
        cpu_register_physical_memory(sdram_base(bcr), sdram_size(bcr),
529
532
 
530
533
    for (i = 0; i < sdram->nbanks; i++) {
531
534
#ifdef DEBUG_SDRAM
532
 
        printf("%s: Unmap RAM area " TARGET_FMT_plx " " TARGET_FMT_lx "\n",
 
535
        printf("%s: Unmap RAM area " PADDRX " " ADDRX "\n",
533
536
               __func__, sdram_base(sdram->bcr[i]), sdram_size(sdram->bcr[i]));
534
537
#endif
535
538
        cpu_register_physical_memory(sdram_base(sdram->bcr[i]),
1110
1113
 
1111
1114
    gpio = opaque;
1112
1115
#ifdef DEBUG_GPIO
1113
 
    printf("%s: addr " PADDRX " val %08x\n", __func__, addr, value);
 
1116
    printf("%s: addr " PADDRX " val %08" PRIx32 "\n", __func__, addr, value);
1114
1117
#endif
1115
1118
}
1116
1119
 
1133
1136
 
1134
1137
    gpio = opaque;
1135
1138
#ifdef DEBUG_GPIO
1136
 
    printf("%s: addr " PADDRX " val %08x\n", __func__, addr, value);
 
1139
    printf("%s: addr " PADDRX " val %08" PRIx32 "\n", __func__, addr, value);
1137
1140
#endif
1138
1141
}
1139
1142
 
1156
1159
 
1157
1160
    gpio = opaque;
1158
1161
#ifdef DEBUG_GPIO
1159
 
    printf("%s: addr " PADDRX " val %08x\n", __func__, addr, value);
 
1162
    printf("%s: addr " PADDRX " val %08" PRIx32 "\n", __func__, addr, value);
1160
1163
#endif
1161
1164
}
1162
1165
 
1190
1193
        ppc405_gpio_reset(gpio);
1191
1194
        qemu_register_reset(&ppc405_gpio_reset, gpio);
1192
1195
#ifdef DEBUG_GPIO
1193
 
        printf("%s: offset=" PADDRX "\n", __func__, offset);
 
1196
        printf("%s: offset " PADDRX "\n", __func__, offset);
1194
1197
#endif
1195
1198
        ppc4xx_mmio_register(env, mmio, offset, 0x038,
1196
1199
                             ppc405_gpio_read, ppc405_gpio_write, gpio);
1218
1221
    void *serial;
1219
1222
 
1220
1223
#ifdef DEBUG_SERIAL
1221
 
    printf("%s: offset=" PADDRX "\n", __func__, offset);
 
1224
    printf("%s: offset " PADDRX "\n", __func__, offset);
1222
1225
#endif
1223
1226
    serial = serial_mm_init(offset, 0, irq, chr, 0);
1224
1227
    ppc4xx_mmio_register(env, mmio, offset, 0x008,
1248
1251
                                 uint32_t dsarc, uint32_t dsacntl)
1249
1252
{
1250
1253
#ifdef DEBUG_OCM
1251
 
    printf("OCM update ISA %08x %08x (%08x %08x) DSA %08x %08x (%08x %08x)\n",
 
1254
    printf("OCM update ISA %08" PRIx32 " %08" PRIx32 " (%08" PRIx32
 
1255
           " %08" PRIx32 ") DSA %08" PRIx32 " %08" PRIx32
 
1256
           " (%08" PRIx32 " %08" PRIx32 ")\n",
1252
1257
           isarc, isacntl, dsarc, dsacntl,
1253
1258
           ocm->isarc, ocm->isacntl, ocm->dsarc, ocm->dsacntl);
1254
1259
#endif
1256
1261
        (ocm->isacntl & 0x80000000) != (isacntl & 0x80000000)) {
1257
1262
        if (ocm->isacntl & 0x80000000) {
1258
1263
            /* Unmap previously assigned memory region */
1259
 
            printf("OCM unmap ISA %08x\n", ocm->isarc);
 
1264
            printf("OCM unmap ISA %08" PRIx32 "\n", ocm->isarc);
1260
1265
            cpu_register_physical_memory(ocm->isarc, 0x04000000,
1261
1266
                                         IO_MEM_UNASSIGNED);
1262
1267
        }
1263
1268
        if (isacntl & 0x80000000) {
1264
1269
            /* Map new instruction memory region */
1265
1270
#ifdef DEBUG_OCM
1266
 
            printf("OCM map ISA %08x\n", isarc);
 
1271
            printf("OCM map ISA %08" PRIx32 "\n", isarc);
1267
1272
#endif
1268
1273
            cpu_register_physical_memory(isarc, 0x04000000,
1269
1274
                                         ocm->offset | IO_MEM_RAM);
1276
1281
            if (!(isacntl & 0x80000000) || ocm->dsarc != isarc) {
1277
1282
                /* Unmap previously assigned memory region */
1278
1283
#ifdef DEBUG_OCM
1279
 
                printf("OCM unmap DSA %08x\n", ocm->dsarc);
 
1284
                printf("OCM unmap DSA %08" PRIx32 "\n", ocm->dsarc);
1280
1285
#endif
1281
1286
                cpu_register_physical_memory(ocm->dsarc, 0x04000000,
1282
1287
                                             IO_MEM_UNASSIGNED);
1287
1292
            if (!(isacntl & 0x80000000) || dsarc != isarc) {
1288
1293
                /* Map new data memory region */
1289
1294
#ifdef DEBUG_OCM
1290
 
                printf("OCM map DSA %08x\n", dsarc);
 
1295
                printf("OCM map DSA %08" PRIx32 "\n", dsarc);
1291
1296
#endif
1292
1297
                cpu_register_physical_memory(dsarc, 0x04000000,
1293
1298
                                             ocm->offset | IO_MEM_RAM);
1475
1480
        break;
1476
1481
    }
1477
1482
#ifdef DEBUG_I2C
1478
 
    printf("%s: addr " PADDRX " %02x\n", __func__, addr, ret);
 
1483
    printf("%s: addr " PADDRX " %02" PRIx32 "\n", __func__, addr, ret);
1479
1484
#endif
1480
1485
 
1481
1486
    return ret;
1487
1492
    ppc4xx_i2c_t *i2c;
1488
1493
 
1489
1494
#ifdef DEBUG_I2C
1490
 
    printf("%s: addr " PADDRX " val %08x\n", __func__, addr, value);
 
1495
    printf("%s: addr " PADDRX " val %08" PRIx32 "\n", __func__, addr, value);
1491
1496
#endif
1492
1497
    i2c = opaque;
1493
1498
    switch (addr - i2c->base) {
1557
1562
                               target_phys_addr_t addr, uint32_t value)
1558
1563
{
1559
1564
#ifdef DEBUG_I2C
1560
 
    printf("%s: addr " PADDRX " val %08x\n", __func__, addr, value);
 
1565
    printf("%s: addr " PADDRX " val %08" PRIx32 "\n", __func__, addr, value);
1561
1566
#endif
1562
1567
    ppc4xx_i2c_writeb(opaque, addr, value >> 8);
1563
1568
    ppc4xx_i2c_writeb(opaque, addr + 1, value);
1582
1587
                               target_phys_addr_t addr, uint32_t value)
1583
1588
{
1584
1589
#ifdef DEBUG_I2C
1585
 
    printf("%s: addr " PADDRX " val %08x\n", __func__, addr, value);
 
1590
    printf("%s: addr " PADDRX " val %08" PRIx32 "\n", __func__, addr, value);
1586
1591
#endif
1587
1592
    ppc4xx_i2c_writeb(opaque, addr, value >> 24);
1588
1593
    ppc4xx_i2c_writeb(opaque, addr + 1, value >> 16);
1629
1634
        i2c->irq = irq;
1630
1635
        ppc4xx_i2c_reset(i2c);
1631
1636
#ifdef DEBUG_I2C
1632
 
        printf("%s: offset=" PADDRX "\n", __func__, offset);
 
1637
        printf("%s: offset " PADDRX "\n", __func__, offset);
1633
1638
#endif
1634
1639
        ppc4xx_mmio_register(env, mmio, offset, 0x011,
1635
1640
                             i2c_read, i2c_write, i2c);
1668
1673
                               target_phys_addr_t addr, uint32_t value)
1669
1674
{
1670
1675
#ifdef DEBUG_I2C
1671
 
    printf("%s: addr " PADDRX " val %08x\n", __func__, addr, value);
 
1676
    printf("%s: addr " PADDRX " val %08" PRIx32 "\n", __func__, addr, value);
1672
1677
#endif
1673
1678
    /* XXX: generate a bus fault */
1674
1679
}
1686
1691
                               target_phys_addr_t addr, uint32_t value)
1687
1692
{
1688
1693
#ifdef DEBUG_I2C
1689
 
    printf("%s: addr " PADDRX " val %08x\n", __func__, addr, value);
 
1694
    printf("%s: addr " PADDRX " val %08" PRIx32 "\n", __func__, addr, value);
1690
1695
#endif
1691
1696
    /* XXX: generate a bus fault */
1692
1697
}
1805
1810
    int idx;
1806
1811
 
1807
1812
#ifdef DEBUG_I2C
1808
 
    printf("%s: addr " PADDRX " val %08x\n", __func__, addr, value);
 
1813
    printf("%s: addr " PADDRX " val %08" PRIx32 "\n", __func__, addr, value);
1809
1814
#endif
1810
1815
    gpt = opaque;
1811
1816
    switch (addr - gpt->base) {
1913
1918
        gpt->timer = qemu_new_timer(vm_clock, &ppc4xx_gpt_cb, gpt);
1914
1919
        ppc4xx_gpt_reset(gpt);
1915
1920
#ifdef DEBUG_GPT
1916
 
        printf("%s: offset=" PADDRX "\n", __func__, offset);
 
1921
        printf("%s: offset " PADDRX "\n", __func__, offset);
1917
1922
#endif
1918
1923
        ppc4xx_mmio_register(env, mmio, offset, 0x0D4,
1919
1924
                             gpt_read, gpt_write, gpt);
2656
2661
    VCO_out = 0;
2657
2662
    if ((cpc->pllmr[1] & 0x80000000) && !(cpc->pllmr[1] & 0x40000000)) {
2658
2663
        M = (((cpc->pllmr[1] >> 20) - 1) & 0xF) + 1; /* FBMUL */
2659
 
        //        printf("FBMUL %01x %d\n", (cpc->pllmr[1] >> 20) & 0xF, M);
 
2664
#ifdef DEBUG_CLOCKS_LL
 
2665
        printf("FBMUL %01" PRIx32 " %d\n", (cpc->pllmr[1] >> 20) & 0xF, M);
 
2666
#endif
2660
2667
        D = 8 - ((cpc->pllmr[1] >> 16) & 0x7); /* FWDA */
2661
 
        //        printf("FWDA %01x %d\n", (cpc->pllmr[1] >> 16) & 0x7, D);
 
2668
#ifdef DEBUG_CLOCKS_LL
 
2669
        printf("FWDA %01" PRIx32 " %d\n", (cpc->pllmr[1] >> 16) & 0x7, D);
 
2670
#endif
2662
2671
        VCO_out = cpc->sysclk * M * D;
2663
2672
        if (VCO_out < 500000000UL || VCO_out > 1000000000UL) {
2664
2673
            /* Error - unlock the PLL */
2683
2692
    }
2684
2693
    /* Now, compute all other clocks */
2685
2694
    D = ((cpc->pllmr[0] >> 20) & 0x3) + 1; /* CCDV */
2686
 
#ifdef DEBUG_CLOCKS
2687
 
    //    printf("CCDV %01x %d\n", (cpc->pllmr[0] >> 20) & 0x3, D);
 
2695
#ifdef DEBUG_CLOCKS_LL
 
2696
    printf("CCDV %01" PRIx32 " %d\n", (cpc->pllmr[0] >> 20) & 0x3, D);
2688
2697
#endif
2689
2698
    CPU_clk = PLL_out / D;
2690
2699
    D = ((cpc->pllmr[0] >> 16) & 0x3) + 1; /* CBDV */
2691
 
#ifdef DEBUG_CLOCKS
2692
 
    //    printf("CBDV %01x %d\n", (cpc->pllmr[0] >> 16) & 0x3, D);
 
2700
#ifdef DEBUG_CLOCKS_LL
 
2701
    printf("CBDV %01" PRIx32 " %d\n", (cpc->pllmr[0] >> 16) & 0x3, D);
2693
2702
#endif
2694
2703
    PLB_clk = CPU_clk / D;
2695
2704
    D = ((cpc->pllmr[0] >> 12) & 0x3) + 1; /* OPDV */
2696
 
#ifdef DEBUG_CLOCKS
2697
 
    //    printf("OPDV %01x %d\n", (cpc->pllmr[0] >> 12) & 0x3, D);
 
2705
#ifdef DEBUG_CLOCKS_LL
 
2706
    printf("OPDV %01" PRIx32 " %d\n", (cpc->pllmr[0] >> 12) & 0x3, D);
2698
2707
#endif
2699
2708
    OPB_clk = PLB_clk / D;
2700
2709
    D = ((cpc->pllmr[0] >> 8) & 0x3) + 2; /* EPDV */
2701
 
#ifdef DEBUG_CLOCKS
2702
 
    //    printf("EPDV %01x %d\n", (cpc->pllmr[0] >> 8) & 0x3, D);
 
2710
#ifdef DEBUG_CLOCKS_LL
 
2711
    printf("EPDV %01" PRIx32 " %d\n", (cpc->pllmr[0] >> 8) & 0x3, D);
2703
2712
#endif
2704
2713
    EBC_clk = PLB_clk / D;
2705
2714
    D = ((cpc->pllmr[0] >> 4) & 0x3) + 1; /* MPDV */
2706
 
#ifdef DEBUG_CLOCKS
2707
 
    //    printf("MPDV %01x %d\n", (cpc->pllmr[0] >> 4) & 0x3, D);
 
2715
#ifdef DEBUG_CLOCKS_LL
 
2716
    printf("MPDV %01" PRIx32 " %d\n", (cpc->pllmr[0] >> 4) & 0x3, D);
2708
2717
#endif
2709
2718
    MAL_clk = PLB_clk / D;
2710
2719
    D = (cpc->pllmr[0] & 0x3) + 1; /* PPDV */
2711
 
#ifdef DEBUG_CLOCKS
2712
 
    //    printf("PPDV %01x %d\n", cpc->pllmr[0] & 0x3, D);
 
2720
#ifdef DEBUG_CLOCKS_LL
 
2721
    printf("PPDV %01" PRIx32 " %d\n", cpc->pllmr[0] & 0x3, D);
2713
2722
#endif
2714
2723
    PCI_clk = PLB_clk / D;
2715
2724
    D = ((cpc->ucr - 1) & 0x7F) + 1; /* U0DIV */
2716
 
#ifdef DEBUG_CLOCKS
2717
 
    //    printf("U0DIV %01x %d\n", cpc->ucr & 0x7F, D);
 
2725
#ifdef DEBUG_CLOCKS_LL
 
2726
    printf("U0DIV %01" PRIx32 " %d\n", cpc->ucr & 0x7F, D);
2718
2727
#endif
2719
2728
    UART0_clk = PLL_out / D;
2720
2729
    D = (((cpc->ucr >> 8) - 1) & 0x7F) + 1; /* U1DIV */
2721
 
#ifdef DEBUG_CLOCKS
2722
 
    //    printf("U1DIV %01x %d\n", (cpc->ucr >> 8) & 0x7F, D);
 
2730
#ifdef DEBUG_CLOCKS_LL
 
2731
    printf("U1DIV %01" PRIx32 " %d\n", (cpc->ucr >> 8) & 0x7F, D);
2723
2732
#endif
2724
2733
    UART1_clk = PLL_out / D;
2725
2734
#ifdef DEBUG_CLOCKS
2726
 
    printf("Setup PPC405EP clocks - sysclk %d VCO %" PRIu64
 
2735
    printf("Setup PPC405EP clocks - sysclk %" PRIu32 " VCO %" PRIu64
2727
2736
           " PLL out %" PRIu64 " Hz\n", cpc->sysclk, VCO_out, PLL_out);
2728
 
    printf("CPU %d PLB %d OPB %d EBC %d MAL %d PCI %d UART0 %d UART1 %d\n",
 
2737
    printf("CPU %" PRIu32 " PLB %" PRIu32 " OPB %" PRIu32 " EBC %" PRIu32
 
2738
           " MAL %" PRIu32 " PCI %" PRIu32 " UART0 %" PRIu32
 
2739
           " UART1 %" PRIu32 "\n",
2729
2740
           CPU_clk, PLB_clk, OPB_clk, EBC_clk, MAL_clk, PCI_clk,
2730
2741
           UART0_clk, UART1_clk);
2731
 
    printf("CB %p opaque %p\n", cpc->clk_setup[PPC405EP_CPU_CLK].cb,
2732
 
           cpc->clk_setup[PPC405EP_CPU_CLK].opaque);
2733
2742
#endif
2734
2743
    /* Setup CPU clocks */
2735
2744
    clk_setup(&cpc->clk_setup[PPC405EP_CPU_CLK], CPU_clk);