Statistics
| Branch: | Revision:

root / hw / realview.c @ 87ecb68b

History | View | Annotate | Download (5.5 kB)

1
/*
2
 * ARM RealView Baseboard System emulation.
3
 *
4
 * Copyright (c) 2006-2007 CodeSourcery.
5
 * Written by Paul Brook
6
 *
7
 * This code is licenced under the GPL.
8
 */
9

    
10
#include "hw.h"
11
#include "arm-misc.h"
12
#include "primecell.h"
13
#include "devices.h"
14
#include "pci.h"
15
#include "net.h"
16
#include "sysemu.h"
17
#include "boards.h"
18

    
19
/* Board init.  */
20

    
21
static void realview_init(int ram_size, int vga_ram_size,
22
                     const char *boot_device, DisplayState *ds,
23
                     const char **fd_filename, int snapshot,
24
                     const char *kernel_filename, const char *kernel_cmdline,
25
                     const char *initrd_filename, const char *cpu_model)
26
{
27
    CPUState *env;
28
    qemu_irq *pic;
29
    void *scsi_hba;
30
    PCIBus *pci_bus;
31
    NICInfo *nd;
32
    int n;
33
    int done_smc = 0;
34
    qemu_irq cpu_irq[4];
35
    int ncpu;
36

    
37
    if (!cpu_model)
38
        cpu_model = "arm926";
39
    /* FIXME: obey smp_cpus.  */
40
    if (strcmp(cpu_model, "arm11mpcore") == 0) {
41
        ncpu = 4;
42
    } else {
43
        ncpu = 1;
44
    }
45

    
46
    for (n = 0; n < ncpu; n++) {
47
        env = cpu_init(cpu_model);
48
        if (!env) {
49
            fprintf(stderr, "Unable to find CPU definition\n");
50
            exit(1);
51
        }
52
        pic = arm_pic_init_cpu(env);
53
        cpu_irq[n] = pic[ARM_PIC_CPU_IRQ];
54
        if (n > 0) {
55
            /* Set entry point for secondary CPUs.  This assumes we're using
56
               the init code from arm_boot.c.  Real hardware resets all CPUs
57
               the same.  */
58
            env->regs[15] = 0x80000000;
59
        }
60
    }
61

    
62
    /* ??? RAM shoud repeat to fill physical memory space.  */
63
    /* SDRAM at address zero.  */
64
    cpu_register_physical_memory(0, ram_size, IO_MEM_RAM);
65

    
66
    arm_sysctl_init(0x10000000, 0xc1400400);
67

    
68
    if (ncpu == 1) {
69
        /* ??? The documentation says GIC1 is nFIQ and either GIC2 or GIC3
70
           is nIRQ (there are inconsistencies).  However Linux 2.6.17 expects
71
           GIC1 to be nIRQ and ignores all the others, so do that for now.  */
72
        pic = realview_gic_init(0x10040000, cpu_irq[0]);
73
    } else {
74
        pic = mpcore_irq_init(cpu_irq);
75
    }
76

    
77
    pl050_init(0x10006000, pic[20], 0);
78
    pl050_init(0x10007000, pic[21], 1);
79

    
80
    pl011_init(0x10009000, pic[12], serial_hds[0], PL011_ARM);
81
    pl011_init(0x1000a000, pic[13], serial_hds[1], PL011_ARM);
82
    pl011_init(0x1000b000, pic[14], serial_hds[2], PL011_ARM);
83
    pl011_init(0x1000c000, pic[15], serial_hds[3], PL011_ARM);
84

    
85
    /* DMA controller is optional, apparently.  */
86
    pl080_init(0x10030000, pic[24], 2);
87

    
88
    sp804_init(0x10011000, pic[4]);
89
    sp804_init(0x10012000, pic[5]);
90

    
91
    pl110_init(ds, 0x10020000, pic[23], 1);
92

    
93
    pl181_init(0x10005000, sd_bdrv, pic[17], pic[18]);
94

    
95
    pl031_init(0x10017000, pic[10]);
96

    
97
    pci_bus = pci_vpb_init(pic, 48, 1);
98
    if (usb_enabled) {
99
        usb_ohci_init_pci(pci_bus, 3, -1);
100
    }
101
    scsi_hba = lsi_scsi_init(pci_bus, -1);
102
    for (n = 0; n < MAX_DISKS; n++) {
103
        if (bs_table[n]) {
104
            lsi_scsi_attach(scsi_hba, bs_table[n], n);
105
        }
106
    }
107
    for(n = 0; n < nb_nics; n++) {
108
        nd = &nd_table[n];
109
        if (!nd->model)
110
            nd->model = done_smc ? "rtl8139" : "smc91c111";
111
        if (strcmp(nd->model, "smc91c111") == 0) {
112
            smc91c111_init(nd, 0x4e000000, pic[28]);
113
        } else {
114
            pci_nic_init(pci_bus, nd, -1);
115
        }
116
    }
117

    
118
    /* Memory map for RealView Emulation Baseboard:  */
119
    /* 0x10000000 System registers.  */
120
    /*  0x10001000 System controller.  */
121
    /*  0x10002000 Two-Wire Serial Bus.  */
122
    /* 0x10003000 Reserved.  */
123
    /*  0x10004000 AACI.  */
124
    /*  0x10005000 MCI.  */
125
    /* 0x10006000 KMI0.  */
126
    /* 0x10007000 KMI1.  */
127
    /*  0x10008000 Character LCD.  */
128
    /* 0x10009000 UART0.  */
129
    /* 0x1000a000 UART1.  */
130
    /* 0x1000b000 UART2.  */
131
    /* 0x1000c000 UART3.  */
132
    /*  0x1000d000 SSPI.  */
133
    /*  0x1000e000 SCI.  */
134
    /* 0x1000f000 Reserved.  */
135
    /*  0x10010000 Watchdog.  */
136
    /* 0x10011000 Timer 0+1.  */
137
    /* 0x10012000 Timer 2+3.  */
138
    /*  0x10013000 GPIO 0.  */
139
    /*  0x10014000 GPIO 1.  */
140
    /*  0x10015000 GPIO 2.  */
141
    /* 0x10016000 Reserved.  */
142
    /* 0x10017000 RTC.  */
143
    /*  0x10018000 DMC.  */
144
    /*  0x10019000 PCI controller config.  */
145
    /*  0x10020000 CLCD.  */
146
    /* 0x10030000 DMA Controller.  */
147
    /* 0x10040000 GIC1.  */
148
    /* 0x10050000 GIC2.  */
149
    /* 0x10060000 GIC3.  */
150
    /* 0x10070000 GIC4.  */
151
    /*  0x10080000 SMC.  */
152
    /*  0x40000000 NOR flash.  */
153
    /*  0x44000000 DoC flash.  */
154
    /*  0x48000000 SRAM.  */
155
    /*  0x4c000000 Configuration flash.  */
156
    /* 0x4e000000 Ethernet.  */
157
    /*  0x4f000000 USB.  */
158
    /*  0x50000000 PISMO.  */
159
    /*  0x54000000 PISMO.  */
160
    /*  0x58000000 PISMO.  */
161
    /*  0x5c000000 PISMO.  */
162
    /* 0x60000000 PCI.  */
163
    /* 0x61000000 PCI Self Config.  */
164
    /* 0x62000000 PCI Config.  */
165
    /* 0x63000000 PCI IO.  */
166
    /* 0x64000000 PCI mem 0.  */
167
    /* 0x68000000 PCI mem 1.  */
168
    /* 0x6c000000 PCI mem 2.  */
169

    
170
    arm_load_kernel(first_cpu, ram_size, kernel_filename, kernel_cmdline,
171
                    initrd_filename, 0x33b, 0x0);
172

    
173
    /* ??? Hack to map an additional page of ram for the secondary CPU
174
       startup code.  I guess this works on real hardware because the
175
       BootROM happens to be in ROM/flash or in memory that isn't clobbered
176
       until after Linux boots the secondary CPUs.  */
177
    cpu_register_physical_memory(0x80000000, 0x1000, IO_MEM_RAM + ram_size);
178
}
179

    
180
QEMUMachine realview_machine = {
181
    "realview",
182
    "ARM RealView Emulation Baseboard (ARM926EJ-S)",
183
    realview_init
184
};