Statistics
| Branch: | Revision:

root / hw / realview.c @ abcebc7e

History | View | Annotate | Download (4.2 kB)

1 e69954b9 pbrook
/* 
2 e69954b9 pbrook
 * ARM RealView Baseboard System emulation.
3 e69954b9 pbrook
 *
4 e69954b9 pbrook
 * Copyright (c) 2006 CodeSourcery.
5 e69954b9 pbrook
 * Written by Paul Brook
6 e69954b9 pbrook
 *
7 e69954b9 pbrook
 * This code is licenced under the GPL.
8 e69954b9 pbrook
 */
9 e69954b9 pbrook
10 e69954b9 pbrook
#include "vl.h"
11 e69954b9 pbrook
#include "arm_pic.h"
12 e69954b9 pbrook
13 e69954b9 pbrook
/* Board init.  */
14 e69954b9 pbrook
15 e69954b9 pbrook
static void realview_init(int ram_size, int vga_ram_size, int boot_device,
16 e69954b9 pbrook
                     DisplayState *ds, const char **fd_filename, int snapshot,
17 e69954b9 pbrook
                     const char *kernel_filename, const char *kernel_cmdline,
18 e69954b9 pbrook
                     const char *initrd_filename)
19 e69954b9 pbrook
{
20 e69954b9 pbrook
    CPUState *env;
21 e69954b9 pbrook
    void *pic;
22 e69954b9 pbrook
    void *scsi_hba;
23 e69954b9 pbrook
    PCIBus *pci_bus;
24 e69954b9 pbrook
    NICInfo *nd;
25 e69954b9 pbrook
    int n;
26 e69954b9 pbrook
    int done_smc = 0;
27 e69954b9 pbrook
28 e69954b9 pbrook
    env = cpu_init();
29 e69954b9 pbrook
    cpu_arm_set_model(env, ARM_CPUID_ARM926);
30 e69954b9 pbrook
    //cpu_arm_set_model(env, ARM_CPUID_ARM11MPCORE);
31 e69954b9 pbrook
    /* ??? RAM shoud repeat to fill physical memory space.  */
32 e69954b9 pbrook
    /* SDRAM at address zero.  */
33 e69954b9 pbrook
    cpu_register_physical_memory(0, ram_size, IO_MEM_RAM);
34 e69954b9 pbrook
35 e69954b9 pbrook
    arm_sysctl_init(0x10000000, 0xc1400400);
36 e69954b9 pbrook
    pic = arm_pic_init_cpu(env);
37 e69954b9 pbrook
    /* ??? The documentation says GIC1 is nFIQ and either GIC2 or GIC3
38 e69954b9 pbrook
       is nIRQ (there are inconsistencies).  However Linux 2.6.17 expects
39 e69954b9 pbrook
       GIC1 to be nIRQ and ignores all the others, so do that for now.  */
40 e69954b9 pbrook
    pic = arm_gic_init(0x10040000, pic, ARM_PIC_CPU_IRQ);
41 e69954b9 pbrook
    pl050_init(0x10006000, pic, 20, 0);
42 e69954b9 pbrook
    pl050_init(0x10007000, pic, 21, 1);
43 e69954b9 pbrook
44 e69954b9 pbrook
    pl011_init(0x10009000, pic, 12, serial_hds[0]);
45 e69954b9 pbrook
    pl011_init(0x1000a000, pic, 13, serial_hds[1]);
46 e69954b9 pbrook
    pl011_init(0x1000b000, pic, 14, serial_hds[2]);
47 e69954b9 pbrook
    pl011_init(0x1000c000, pic, 15, serial_hds[3]);
48 e69954b9 pbrook
49 e69954b9 pbrook
    /* DMA controller is optional, apparently.  */
50 e69954b9 pbrook
    pl080_init(0x10030000, pic, 24, 2);
51 e69954b9 pbrook
52 e69954b9 pbrook
    sp804_init(0x10011000, pic, 4);
53 e69954b9 pbrook
    sp804_init(0x10012000, pic, 5);
54 e69954b9 pbrook
55 e69954b9 pbrook
    pl110_init(ds, 0x10020000, pic, 23, 1);
56 e69954b9 pbrook
57 e69954b9 pbrook
    pci_bus = pci_vpb_init(pic, 48, 1);
58 e69954b9 pbrook
    if (usb_enabled) {
59 e69954b9 pbrook
        usb_ohci_init(pci_bus, 3, -1);
60 e69954b9 pbrook
    }
61 e69954b9 pbrook
    scsi_hba = lsi_scsi_init(pci_bus, -1);
62 e69954b9 pbrook
    for (n = 0; n < MAX_DISKS; n++) {
63 e69954b9 pbrook
        if (bs_table[n]) {
64 e69954b9 pbrook
            lsi_scsi_attach(scsi_hba, bs_table[n], n);
65 e69954b9 pbrook
        }
66 e69954b9 pbrook
    }
67 e69954b9 pbrook
    for(n = 0; n < nb_nics; n++) {
68 e69954b9 pbrook
        nd = &nd_table[n];
69 e69954b9 pbrook
        if (!nd->model)
70 e69954b9 pbrook
            nd->model = done_smc ? "rtl8139" : "smc91c111";
71 e69954b9 pbrook
        if (strcmp(nd->model, "smc91c111") == 0) {
72 e69954b9 pbrook
            smc91c111_init(nd, 0x4e000000, pic, 28);
73 e69954b9 pbrook
        } else {
74 abcebc7e ths
            pci_nic_init(pci_bus, nd, -1);
75 e69954b9 pbrook
        }
76 e69954b9 pbrook
    }
77 e69954b9 pbrook
78 e69954b9 pbrook
    /* Memory map for RealView Emulation Baseboard:  */
79 e69954b9 pbrook
    /* 0x10000000 System registers.  */
80 e69954b9 pbrook
    /*  0x10001000 System controller.  */
81 e69954b9 pbrook
    /*  0x10002000 Two-Wire Serial Bus.  */
82 e69954b9 pbrook
    /* 0x10003000 Reserved.  */
83 e69954b9 pbrook
    /*  0x10004000 AACI.  */
84 e69954b9 pbrook
    /*  0x10005000 MCI.  */
85 e69954b9 pbrook
    /* 0x10006000 KMI0.  */
86 e69954b9 pbrook
    /* 0x10007000 KMI1.  */
87 e69954b9 pbrook
    /*  0x10008000 Character LCD.  */
88 e69954b9 pbrook
    /* 0x10009000 UART0.  */
89 e69954b9 pbrook
    /* 0x1000a000 UART1.  */
90 e69954b9 pbrook
    /* 0x1000b000 UART2.  */
91 e69954b9 pbrook
    /* 0x1000c000 UART3.  */
92 e69954b9 pbrook
    /*  0x1000d000 SSPI.  */
93 e69954b9 pbrook
    /*  0x1000e000 SCI.  */
94 e69954b9 pbrook
    /* 0x1000f000 Reserved.  */
95 e69954b9 pbrook
    /*  0x10010000 Watchdog.  */
96 e69954b9 pbrook
    /* 0x10011000 Timer 0+1.  */
97 e69954b9 pbrook
    /* 0x10012000 Timer 2+3.  */
98 e69954b9 pbrook
    /*  0x10013000 GPIO 0.  */
99 e69954b9 pbrook
    /*  0x10014000 GPIO 1.  */
100 e69954b9 pbrook
    /*  0x10015000 GPIO 2.  */
101 e69954b9 pbrook
    /* 0x10016000 Reserved.  */
102 e69954b9 pbrook
    /*  0x10017000 RTC.  */
103 e69954b9 pbrook
    /*  0x10018000 DMC.  */
104 e69954b9 pbrook
    /*  0x10019000 PCI controller config.  */
105 e69954b9 pbrook
    /*  0x10020000 CLCD.  */
106 e69954b9 pbrook
    /* 0x10030000 DMA Controller.  */
107 e69954b9 pbrook
    /* 0x10040000 GIC1 (FIQ1).  */
108 e69954b9 pbrook
    /* 0x10050000 GIC2 (IRQ1).  */
109 e69954b9 pbrook
    /*  0x10060000 GIC3 (FIQ2).  */
110 e69954b9 pbrook
    /*  0x10070000 GIC4 (IRQ2).  */
111 e69954b9 pbrook
    /*  0x10080000 SMC.  */
112 e69954b9 pbrook
    /*  0x40000000 NOR flash.  */
113 e69954b9 pbrook
    /*  0x44000000 DoC flash.  */
114 e69954b9 pbrook
    /*  0x48000000 SRAM.  */
115 e69954b9 pbrook
    /*  0x4c000000 Configuration flash.  */
116 e69954b9 pbrook
    /* 0x4e000000 Ethernet.  */
117 e69954b9 pbrook
    /*  0x4f000000 USB.  */
118 e69954b9 pbrook
    /*  0x50000000 PISMO.  */
119 e69954b9 pbrook
    /*  0x54000000 PISMO.  */
120 e69954b9 pbrook
    /*  0x58000000 PISMO.  */
121 e69954b9 pbrook
    /*  0x5c000000 PISMO.  */
122 e69954b9 pbrook
    /* 0x60000000 PCI.  */
123 e69954b9 pbrook
    /* 0x61000000 PCI Self Config.  */
124 e69954b9 pbrook
    /* 0x62000000 PCI Config.  */
125 e69954b9 pbrook
    /* 0x63000000 PCI IO.  */
126 e69954b9 pbrook
    /* 0x64000000 PCI mem 0.  */
127 e69954b9 pbrook
    /* 0x68000000 PCI mem 1.  */
128 e69954b9 pbrook
    /* 0x6c000000 PCI mem 2.  */
129 e69954b9 pbrook
130 e69954b9 pbrook
    arm_load_kernel(ram_size, kernel_filename, kernel_cmdline,
131 e69954b9 pbrook
                    initrd_filename, 0x33b);
132 e69954b9 pbrook
}
133 e69954b9 pbrook
134 e69954b9 pbrook
QEMUMachine realview_machine = {
135 e69954b9 pbrook
    "realview",
136 e69954b9 pbrook
    "ARM RealView Emulation Baseboard (ARM926EJ-S)",
137 e69954b9 pbrook
    realview_init
138 e69954b9 pbrook
};