Revision d7585251 hw/mips_malta.c

b/hw/mips_malta.c
521 521
     a3 - RAM size in bytes
522 522
*/
523 523

  
524
static void write_bootloader (CPUState *env, unsigned long bios_offset, int64_t kernel_entry)
524
static void write_bootloader (CPUState *env, uint8_t *base,
525
                              int64_t kernel_entry)
525 526
{
526 527
    uint32_t *p;
527 528

  
528 529
    /* Small bootloader */
529
    p = (uint32_t *) (phys_ram_base + bios_offset);
530
    p = (uint32_t *)base;
530 531
    stl_raw(p++, 0x0bf00160);                                      /* j 0x1fc00580 */
531 532
    stl_raw(p++, 0x00000000);                                      /* nop */
532 533

  
533 534
    /* YAMON service vector */
534
    stl_raw(phys_ram_base + bios_offset + 0x500, 0xbfc00580);      /* start: */
535
    stl_raw(phys_ram_base + bios_offset + 0x504, 0xbfc0083c);      /* print_count: */
536
    stl_raw(phys_ram_base + bios_offset + 0x520, 0xbfc00580);      /* start: */
537
    stl_raw(phys_ram_base + bios_offset + 0x52c, 0xbfc00800);      /* flush_cache: */
538
    stl_raw(phys_ram_base + bios_offset + 0x534, 0xbfc00808);      /* print: */
539
    stl_raw(phys_ram_base + bios_offset + 0x538, 0xbfc00800);      /* reg_cpu_isr: */
540
    stl_raw(phys_ram_base + bios_offset + 0x53c, 0xbfc00800);      /* unred_cpu_isr: */
541
    stl_raw(phys_ram_base + bios_offset + 0x540, 0xbfc00800);      /* reg_ic_isr: */
542
    stl_raw(phys_ram_base + bios_offset + 0x544, 0xbfc00800);      /* unred_ic_isr: */
543
    stl_raw(phys_ram_base + bios_offset + 0x548, 0xbfc00800);      /* reg_esr: */
544
    stl_raw(phys_ram_base + bios_offset + 0x54c, 0xbfc00800);      /* unreg_esr: */
545
    stl_raw(phys_ram_base + bios_offset + 0x550, 0xbfc00800);      /* getchar: */
546
    stl_raw(phys_ram_base + bios_offset + 0x554, 0xbfc00800);      /* syscon_read: */
535
    stl_raw(base + 0x500, 0xbfc00580);      /* start: */
536
    stl_raw(base + 0x504, 0xbfc0083c);      /* print_count: */
537
    stl_raw(base + 0x520, 0xbfc00580);      /* start: */
538
    stl_raw(base + 0x52c, 0xbfc00800);      /* flush_cache: */
539
    stl_raw(base + 0x534, 0xbfc00808);      /* print: */
540
    stl_raw(base + 0x538, 0xbfc00800);      /* reg_cpu_isr: */
541
    stl_raw(base + 0x53c, 0xbfc00800);      /* unred_cpu_isr: */
542
    stl_raw(base + 0x540, 0xbfc00800);      /* reg_ic_isr: */
543
    stl_raw(base + 0x544, 0xbfc00800);      /* unred_ic_isr: */
544
    stl_raw(base + 0x548, 0xbfc00800);      /* reg_esr: */
545
    stl_raw(base + 0x54c, 0xbfc00800);      /* unreg_esr: */
546
    stl_raw(base + 0x550, 0xbfc00800);      /* getchar: */
547
    stl_raw(base + 0x554, 0xbfc00800);      /* syscon_read: */
547 548

  
548 549

  
549 550
    /* Second part of the bootloader */
550
    p = (uint32_t *) (phys_ram_base + bios_offset + 0x580);
551
    p = (uint32_t *) (base + 0x580);
551 552
    stl_raw(p++, 0x24040002);                                      /* addiu a0, zero, 2 */
552 553
    stl_raw(p++, 0x3c1d0000 | (((ENVP_ADDR - 64) >> 16) & 0xffff)); /* lui sp, high(ENVP_ADDR) */
553 554
    stl_raw(p++, 0x37bd0000 | ((ENVP_ADDR - 64) & 0xffff));        /* ori sp, sp, low(ENVP_ADDR) */
......
616 617
    stl_raw(p++, 0x00000000);                                      /* nop */
617 618

  
618 619
    /* YAMON subroutines */
619
    p = (uint32_t *) (phys_ram_base + bios_offset + 0x800);
620
    p = (uint32_t *) (base + 0x800);
620 621
    stl_raw(p++, 0x03e00008);                                     /* jr ra */
621 622
    stl_raw(p++, 0x24020000);                                     /* li v0,0 */
622 623
   /* 808 YAMON print */
......
662 663

  
663 664
static void prom_set(int index, const char *string, ...)
664 665
{
666
    char buf[ENVP_ENTRY_SIZE];
667
    target_phys_addr_t p;
665 668
    va_list ap;
666
    int32_t *p;
667 669
    int32_t table_addr;
668
    char *s;
669 670

  
670 671
    if (index >= ENVP_NB_ENTRIES)
671 672
        return;
672 673

  
673
    p = (int32_t *) (phys_ram_base + ENVP_ADDR + VIRT_TO_PHYS_ADDEND);
674
    p += index;
674
    p = ENVP_ADDR + VIRT_TO_PHYS_ADDEND + index * 4;
675 675

  
676 676
    if (string == NULL) {
677
        stl_raw(p, 0);
677
        stl_phys(p, 0);
678 678
        return;
679 679
    }
680 680

  
681
    table_addr = ENVP_ADDR + sizeof(int32_t) * ENVP_NB_ENTRIES + index * ENVP_ENTRY_SIZE;
682
    s = (char *) (phys_ram_base + VIRT_TO_PHYS_ADDEND + table_addr);
683

  
681
    table_addr = ENVP_ADDR + sizeof(int32_t) * ENVP_NB_ENTRIES
682
                 + index * ENVP_ENTRY_SIZE + VIRT_TO_PHYS_ADDEND;
684 683
    stl_raw(p, table_addr);
685 684

  
686 685
    va_start(ap, string);
687
    vsnprintf (s, ENVP_ENTRY_SIZE, string, ap);
686
    vsnprintf(buf, ENVP_ENTRY_SIZE, string, ap);
688 687
    va_end(ap);
688
    pstrcpy_targphys(table_addr, ENVP_ENTRY_SIZE, buf);
689 689
}
690 690

  
691 691
/* Kernel */
......
834 834
        loaderparams.initrd_filename = initrd_filename;
835 835
        kernel_entry = load_kernel(env);
836 836
        env->CP0_Status &= ~((1 << CP0St_BEV) | (1 << CP0St_ERL));
837
        write_bootloader(env, bios_offset, kernel_entry);
837
        write_bootloader(env, qemu_get_ram_ptr(bios_offset), kernel_entry);
838 838
    } else {
839 839
        index = drive_get_index(IF_PFLASH, 0, fl_idx);
840 840
        if (index != -1) {
......
868 868
           a neat trick which allows bi-endian firmware. */
869 869
#ifndef TARGET_WORDS_BIGENDIAN
870 870
        {
871
            uint32_t *addr;
872
            for (addr = (uint32_t *)(phys_ram_base + bios_offset);
873
                 addr < (uint32_t *)(phys_ram_base + bios_offset + bios_size);
874
                 addr++) {
875
                *addr = bswap32(*addr);
871
            uint32_t *addr = qemu_get_ram_ptr(bios_offset);;
872
            uint32_t *end = addr + bios_size;
873
            while (addr < end) {
874
                bswap32s(addr);
876 875
            }
877 876
        }
878 877
#endif
......
881 880
    /* Board ID = 0x420 (Malta Board with CoreLV)
882 881
       XXX: theoretically 0x1e000010 should map to flash and 0x1fc00010 should
883 882
       map to the board ID. */
884
    stl_raw(phys_ram_base + bios_offset + 0x10, 0x00000420);
883
    stl_phys(0x1fc00010LL, 0x00000420);
885 884

  
886 885
    /* Init internal devices */
887 886
    cpu_mips_irq_init_cpu(env);

Also available in: Unified diff