~fboudra/qemu-linaro/new-upstream-release-1.2.0-2012.09-0ubuntu1

« back to all changes in this revision

Viewing changes to hw/mips_malta.c

  • Committer: Fathi Boudra
  • Author(s): Fathi Boudra
  • Date: 2012-08-21 06:47:11 UTC
  • mfrom: (0.1.16)
  • Revision ID: fathi.boudra@linaro.org-20120821064711-7yxmubp2v8a44xce
Tags: 1.1.50-2012.08-0ubuntu1
* New upstream release.
  - support emulated systems with more than 2G of memory. (LP: #1030588)
* Drop powerpc-missing-include.patch - merged upstream.
* Update debian/control: 
  - drop perl build dependency.
  - add libfdt-dev build dependency.
* Update debian/qemu-keymaps.install file.
* Update debian/rules:
  - update QEMU_CPU for ARM architecture: armv4l -> armv7l.
  - update conf_audio_drv: default to PulseAudio since PA is the default on
    Ubuntu.
  - enable KVM on ARM architecture.
  - enable flat device tree support (--enable-fdt). (LP: #1030594)

Show diffs side-by-side

added added

removed removed

Lines of Context:
33
33
#include "mips.h"
34
34
#include "mips_cpudevs.h"
35
35
#include "pci.h"
36
 
#include "usb-uhci.h"
37
36
#include "vmware_vga.h"
38
37
#include "qemu-char.h"
39
38
#include "sysemu.h"
56
55
#define ENVP_NB_ENTRIES         16
57
56
#define ENVP_ENTRY_SIZE         256
58
57
 
 
58
/* Hardware addresses */
 
59
#define FLASH_ADDRESS 0x1e000000ULL
 
60
#define FPGA_ADDRESS  0x1f000000ULL
 
61
#define RESET_ADDRESS 0x1fc00000ULL
 
62
 
 
63
#define FLASH_SIZE    0x400000
 
64
 
59
65
#define MAX_IDE_BUS 2
60
66
 
61
67
typedef struct {
332
338
        break;
333
339
 
334
340
    /* LEDBAR Register */
335
 
    /* XXX: implement a 8-LED array */
336
341
    case 0x00408:
337
342
        s->leds = val & 0xff;
 
343
        malta_fpga_update_display(s);
338
344
        break;
339
345
 
340
346
    /* ASCIIWORD Register */
501
507
     a3 - RAM size in bytes
502
508
*/
503
509
 
504
 
static void write_bootloader (CPUState *env, uint8_t *base,
 
510
static void write_bootloader (CPUMIPSState *env, uint8_t *base,
505
511
                              int64_t kernel_entry)
506
512
{
507
513
    uint32_t *p;
737
743
    return kernel_entry;
738
744
}
739
745
 
740
 
static void malta_mips_config(CPUState *env)
 
746
static void malta_mips_config(CPUMIPSState *env)
741
747
{
742
748
    env->mvp->CP0_MVPConf0 |= ((smp_cpus - 1) << CP0MVPC0_PVPE) |
743
749
                         ((smp_cpus * env->nr_threads - 1) << CP0MVPC0_PTC);
745
751
 
746
752
static void main_cpu_reset(void *opaque)
747
753
{
748
 
    CPUState *env = opaque;
749
 
    cpu_reset(env);
 
754
    MIPSCPU *cpu = opaque;
 
755
    CPUMIPSState *env = &cpu->env;
 
756
 
 
757
    cpu_reset(CPU(cpu));
750
758
 
751
759
    /* The bootloader does not need to be rewritten as it is located in a
752
760
       read only location. The kernel location and the arguments table
760
768
 
761
769
static void cpu_request_exit(void *opaque, int irq, int level)
762
770
{
763
 
    CPUState *env = cpu_single_env;
 
771
    CPUMIPSState *env = cpu_single_env;
764
772
 
765
773
    if (env && level) {
766
774
        cpu_exit(env);
778
786
    MemoryRegion *system_memory = get_system_memory();
779
787
    MemoryRegion *ram = g_new(MemoryRegion, 1);
780
788
    MemoryRegion *bios, *bios_alias = g_new(MemoryRegion, 1);
781
 
    target_long bios_size;
 
789
    target_long bios_size = FLASH_SIZE;
782
790
    int64_t kernel_entry;
783
791
    PCIBus *pci_bus;
784
792
    ISABus *isa_bus;
785
 
    CPUState *env;
 
793
    MIPSCPU *cpu;
 
794
    CPUMIPSState *env;
786
795
    qemu_irq *isa_irq;
787
796
    qemu_irq *cpu_exit_irq;
788
797
    int piix4_devfn;
792
801
    DriveInfo *hd[MAX_IDE_BUS * MAX_IDE_DEVS];
793
802
    DriveInfo *fd[MAX_FD];
794
803
    int fl_idx = 0;
795
 
    int fl_sectors = 0;
 
804
    int fl_sectors = bios_size >> 16;
796
805
    int be;
797
806
 
798
807
    DeviceState *dev = qdev_create(NULL, "mips-malta");
819
828
    }
820
829
 
821
830
    for (i = 0; i < smp_cpus; i++) {
822
 
        env = cpu_init(cpu_model);
823
 
        if (!env) {
 
831
        cpu = cpu_mips_init(cpu_model);
 
832
        if (cpu == NULL) {
824
833
            fprintf(stderr, "Unable to find CPU definition\n");
825
834
            exit(1);
826
835
        }
 
836
        env = &cpu->env;
 
837
 
827
838
        /* Init internal devices */
828
839
        cpu_mips_irq_init_cpu(env);
829
840
        cpu_mips_clock_init(env);
830
 
        qemu_register_reset(main_cpu_reset, env);
 
841
        qemu_register_reset(main_cpu_reset, cpu);
831
842
    }
832
843
    env = first_cpu;
833
844
 
848
859
    be = 0;
849
860
#endif
850
861
    /* FPGA */
851
 
    malta_fpga_init(system_memory, 0x1f000000LL, env->irq[2], serial_hds[2]);
 
862
    malta_fpga_init(system_memory, FPGA_ADDRESS, env->irq[2], serial_hds[2]);
852
863
 
853
 
    /* Load firmware in flash / BIOS unless we boot directly into a kernel. */
 
864
    /* Load firmware in flash / BIOS. */
 
865
    dinfo = drive_get(IF_PFLASH, 0, fl_idx);
 
866
#ifdef DEBUG_BOARD_INIT
 
867
    if (dinfo) {
 
868
        printf("Register parallel flash %d size " TARGET_FMT_lx " at "
 
869
               "addr %08llx '%s' %x\n",
 
870
               fl_idx, bios_size, FLASH_ADDRESS,
 
871
               bdrv_get_device_name(dinfo->bdrv), fl_sectors);
 
872
    }
 
873
#endif
 
874
    fl = pflash_cfi01_register(FLASH_ADDRESS, NULL, "mips_malta.bios",
 
875
                               BIOS_SIZE, dinfo ? dinfo->bdrv : NULL,
 
876
                               65536, fl_sectors,
 
877
                               4, 0x0000, 0x0000, 0x0000, 0x0000, be);
 
878
    bios = pflash_cfi01_get_memory(fl);
 
879
    fl_idx++;
854
880
    if (kernel_filename) {
855
881
        /* Write a small bootloader to the flash location. */
856
 
        bios = g_new(MemoryRegion, 1);
857
 
        memory_region_init_ram(bios, "mips_malta.bios", BIOS_SIZE);
858
 
        vmstate_register_ram_global(bios);
859
 
        memory_region_set_readonly(bios, true);
860
 
        memory_region_init_alias(bios_alias, "bios.1fc", bios, 0, BIOS_SIZE);
861
 
        /* Map the bios at two physical locations, as on the real board. */
862
 
        memory_region_add_subregion(system_memory, 0x1e000000LL, bios);
863
 
        memory_region_add_subregion(system_memory, 0x1fc00000LL, bios_alias);
864
882
        loaderparams.ram_size = ram_size;
865
883
        loaderparams.kernel_filename = kernel_filename;
866
884
        loaderparams.kernel_cmdline = kernel_cmdline;
868
886
        kernel_entry = load_kernel();
869
887
        write_bootloader(env, memory_region_get_ram_ptr(bios), kernel_entry);
870
888
    } else {
871
 
        dinfo = drive_get(IF_PFLASH, 0, fl_idx);
872
 
        if (dinfo) {
873
 
            /* Load firmware from flash. */
874
 
            bios_size = 0x400000;
875
 
            fl_sectors = bios_size >> 16;
876
 
#ifdef DEBUG_BOARD_INIT
877
 
            printf("Register parallel flash %d size " TARGET_FMT_lx " at "
878
 
                   "addr %08llx '%s' %x\n",
879
 
                   fl_idx, bios_size, 0x1e000000LL,
880
 
                   bdrv_get_device_name(dinfo->bdrv), fl_sectors);
881
 
#endif
882
 
            fl = pflash_cfi01_register(0x1e000000LL,
883
 
                                       NULL, "mips_malta.bios", BIOS_SIZE,
884
 
                                       dinfo->bdrv, 65536, fl_sectors,
885
 
                                       4, 0x0000, 0x0000, 0x0000, 0x0000, be);
886
 
            bios = pflash_cfi01_get_memory(fl);
887
 
            /* Map the bios at two physical locations, as on the real board. */
888
 
            memory_region_init_alias(bios_alias, "bios.1fc",
889
 
                                     bios, 0, BIOS_SIZE);
890
 
            memory_region_add_subregion(system_memory, 0x1fc00000LL,
891
 
                                        bios_alias);
892
 
           fl_idx++;
893
 
        } else {
894
 
            bios = g_new(MemoryRegion, 1);
895
 
            memory_region_init_ram(bios, "mips_malta.bios", BIOS_SIZE);
896
 
            vmstate_register_ram_global(bios);
897
 
            memory_region_set_readonly(bios, true);
898
 
            memory_region_init_alias(bios_alias, "bios.1fc",
899
 
                                     bios, 0, BIOS_SIZE);
900
 
            /* Map the bios at two physical locations, as on the real board. */
901
 
            memory_region_add_subregion(system_memory, 0x1e000000LL, bios);
902
 
            memory_region_add_subregion(system_memory, 0x1fc00000LL,
903
 
                                        bios_alias);
 
889
        /* Load firmware from flash. */
 
890
        if (!dinfo) {
904
891
            /* Load a BIOS image. */
905
 
            if (bios_name == NULL)
 
892
            if (bios_name == NULL) {
906
893
                bios_name = BIOS_FILENAME;
 
894
            }
907
895
            filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name);
908
896
            if (filename) {
909
 
                bios_size = load_image_targphys(filename, 0x1fc00000LL,
 
897
                bios_size = load_image_targphys(filename, FLASH_ADDRESS,
910
898
                                                BIOS_SIZE);
911
899
                g_free(filename);
912
900
            } else {
933
921
#endif
934
922
    }
935
923
 
 
924
    /* Map the BIOS at a 2nd physical location, as on the real board. */
 
925
    memory_region_init_alias(bios_alias, "bios.1fc", bios, 0, BIOS_SIZE);
 
926
    memory_region_add_subregion(system_memory, RESET_ADDRESS, bios_alias);
 
927
 
936
928
    /* Board ID = 0x420 (Malta Board with CoreLV)
937
929
       XXX: theoretically 0x1e000010 should map to flash and 0x1fc00010 should
938
930
       map to the board ID. */
965
957
 
966
958
    isa_bus_irqs(isa_bus, s->i8259);
967
959
    pci_piix4_ide_init(pci_bus, hd, piix4_devfn + 1);
968
 
    usb_uhci_piix4_init(pci_bus, piix4_devfn + 2);
 
960
    pci_create_simple(pci_bus, piix4_devfn + 2, "piix4-usb-uhci");
969
961
    smbus = piix4_pm_init(pci_bus, piix4_devfn + 3, 0x1100,
970
 
                          isa_get_irq(NULL, 9), NULL, 0);
 
962
                          isa_get_irq(NULL, 9), NULL, 0, NULL);
971
963
    /* TODO: Populate SPD eeprom data.  */
972
964
    smbus_eeprom_init(smbus, 8, NULL, 0);
973
965
    pit = pit_init(isa_bus, 0x40, 0, NULL);