~vcs-imports/qemu/git

« back to all changes in this revision

Viewing changes to hw/versatilepb.c

  • Committer: pbrook
  • Date: 2006-10-22 00:18:54 UTC
  • Revision ID: git-v1:e6e5906b6e0a81718066ca43aef57515026c6624
ColdFire target.


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

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
 
1
/* 
2
2
 * ARM Versatile Platform/Application Baseboard System emulation.
3
3
 *
4
 
 * Copyright (c) 2005-2007 CodeSourcery.
 
4
 * Copyright (c) 2005-2006 CodeSourcery.
5
5
 * Written by Paul Brook
6
6
 *
7
7
 * This code is licenced under the GPL.
8
8
 */
9
9
 
10
 
#include "hw.h"
11
 
#include "arm-misc.h"
12
 
#include "primecell.h"
13
 
#include "devices.h"
14
 
#include "net.h"
15
 
#include "sysemu.h"
16
 
#include "pci.h"
17
 
#include "boards.h"
 
10
#include "vl.h"
 
11
#include "arm_pic.h"
18
12
 
19
13
/* Primary interrupt controller.  */
20
14
 
21
15
typedef struct vpb_sic_state
22
16
{
 
17
  arm_pic_handler handler;
23
18
  uint32_t base;
24
19
  uint32_t level;
25
20
  uint32_t mask;
26
21
  uint32_t pic_enable;
27
 
  qemu_irq *parent;
 
22
  void *parent;
28
23
  int irq;
29
24
} vpb_sic_state;
30
25
 
33
28
    uint32_t flags;
34
29
 
35
30
    flags = s->level & s->mask;
36
 
    qemu_set_irq(s->parent[s->irq], flags != 0);
 
31
    pic_set_irq_new(s->parent, s->irq, flags != 0);
37
32
}
38
33
 
39
34
static void vpb_sic_update_pic(vpb_sic_state *s)
45
40
        mask = 1u << i;
46
41
        if (!(s->pic_enable & mask))
47
42
            continue;
48
 
        qemu_set_irq(s->parent[i], (s->level & mask) != 0);
 
43
        pic_set_irq_new(s->parent, i, (s->level & mask) != 0);
49
44
    }
50
45
}
51
46
 
57
52
    else
58
53
        s->level &= ~(1u << irq);
59
54
    if (s->pic_enable & (1u << irq))
60
 
        qemu_set_irq(s->parent[irq], level);
 
55
        pic_set_irq_new(s->parent, irq, level);
61
56
    vpb_sic_update(s);
62
57
}
63
58
 
131
126
   vpb_sic_write
132
127
};
133
128
 
134
 
static qemu_irq *vpb_sic_init(uint32_t base, qemu_irq *parent, int irq)
 
129
static vpb_sic_state *vpb_sic_init(uint32_t base, void *parent, int irq)
135
130
{
136
131
    vpb_sic_state *s;
137
 
    qemu_irq *qi;
138
132
    int iomemtype;
139
133
 
140
134
    s = (vpb_sic_state *)qemu_mallocz(sizeof(vpb_sic_state));
141
135
    if (!s)
142
136
        return NULL;
143
 
    qi = qemu_allocate_irqs(vpb_sic_set_irq, s, 32);
 
137
    s->handler = vpb_sic_set_irq;
144
138
    s->base = base;
145
139
    s->parent = parent;
146
140
    s->irq = irq;
147
141
    iomemtype = cpu_register_io_memory(0, vpb_sic_readfn,
148
142
                                       vpb_sic_writefn, s);
149
 
    cpu_register_physical_memory(base, 0x00001000, iomemtype);
 
143
    cpu_register_physical_memory(base, 0x00000fff, iomemtype);
150
144
    /* ??? Save/restore.  */
151
 
    return qi;
 
145
    return s;
152
146
}
153
147
 
154
148
/* Board init.  */
157
151
   peripherans and expansion busses.  For now we emulate a subset of the
158
152
   PB peripherals and just change the board ID.  */
159
153
 
160
 
static struct arm_boot_info versatile_binfo;
161
 
 
162
 
static void versatile_init(ram_addr_t ram_size, int vga_ram_size,
163
 
                     const char *boot_device, DisplayState *ds,
 
154
static void versatile_init(int ram_size, int vga_ram_size, int boot_device,
 
155
                     DisplayState *ds, const char **fd_filename, int snapshot,
164
156
                     const char *kernel_filename, const char *kernel_cmdline,
165
 
                     const char *initrd_filename, const char *cpu_model,
166
 
                     int board_id)
 
157
                     const char *initrd_filename, int board_id)
167
158
{
168
159
    CPUState *env;
169
 
    qemu_irq *pic;
170
 
    qemu_irq *sic;
 
160
    void *pic;
 
161
    void *sic;
171
162
    void *scsi_hba;
172
163
    PCIBus *pci_bus;
173
164
    NICInfo *nd;
174
165
    int n;
175
166
    int done_smc = 0;
176
 
    int index;
177
167
 
178
 
    if (!cpu_model)
179
 
        cpu_model = "arm926";
180
 
    env = cpu_init(cpu_model);
181
 
    if (!env) {
182
 
        fprintf(stderr, "Unable to find CPU definition\n");
183
 
        exit(1);
184
 
    }
185
 
    /* ??? RAM should repeat to fill physical memory space.  */
 
168
    env = cpu_init();
 
169
    cpu_arm_set_model(env, ARM_CPUID_ARM926);
 
170
    /* ??? RAM shoud repeat to fill physical memory space.  */
186
171
    /* SDRAM at address zero.  */
187
172
    cpu_register_physical_memory(0, ram_size, IO_MEM_RAM);
188
173
 
189
174
    arm_sysctl_init(0x10000000, 0x41007004);
190
175
    pic = arm_pic_init_cpu(env);
191
 
    pic = pl190_init(0x10140000, pic[0], pic[1]);
 
176
    pic = pl190_init(0x10140000, pic, ARM_PIC_CPU_IRQ, ARM_PIC_CPU_FIQ);
192
177
    sic = vpb_sic_init(0x10003000, pic, 31);
193
 
    pl050_init(0x10006000, sic[3], 0);
194
 
    pl050_init(0x10007000, sic[4], 1);
 
178
    pl050_init(0x10006000, sic, 3, 0);
 
179
    pl050_init(0x10007000, sic, 4, 1);
195
180
 
196
181
    pci_bus = pci_vpb_init(sic, 27, 0);
197
182
    /* The Versatile PCI bridge does not provide access to PCI IO space,
201
186
        if (!nd->model)
202
187
            nd->model = done_smc ? "rtl8139" : "smc91c111";
203
188
        if (strcmp(nd->model, "smc91c111") == 0) {
204
 
            smc91c111_init(nd, 0x10010000, sic[25]);
 
189
            smc91c111_init(nd, 0x10010000, sic, 25);
205
190
        } else {
206
 
            pci_nic_init(pci_bus, nd, -1);
 
191
            pci_nic_init(pci_bus, nd);
207
192
        }
208
193
    }
209
194
    if (usb_enabled) {
210
 
        usb_ohci_init_pci(pci_bus, 3, -1);
211
 
    }
212
 
    if (drive_get_max_bus(IF_SCSI) > 0) {
213
 
        fprintf(stderr, "qemu: too many SCSI bus\n");
214
 
        exit(1);
 
195
        usb_ohci_init(pci_bus, 3, -1);
215
196
    }
216
197
    scsi_hba = lsi_scsi_init(pci_bus, -1);
217
 
    for (n = 0; n < LSI_MAX_DEVS; n++) {
218
 
        index = drive_get_index(IF_SCSI, 0, n);
219
 
        if (index == -1)
220
 
            continue;
221
 
        lsi_scsi_attach(scsi_hba, drives_table[index].bdrv, n);
 
198
    for (n = 0; n < MAX_DISKS; n++) {
 
199
        if (bs_table[n]) {
 
200
            lsi_scsi_attach(scsi_hba, bs_table[n], n);
 
201
        }
222
202
    }
223
203
 
224
 
    pl011_init(0x101f1000, pic[12], serial_hds[0], PL011_ARM);
225
 
    pl011_init(0x101f2000, pic[13], serial_hds[1], PL011_ARM);
226
 
    pl011_init(0x101f3000, pic[14], serial_hds[2], PL011_ARM);
227
 
    pl011_init(0x10009000, sic[6], serial_hds[3], PL011_ARM);
 
204
    pl011_init(0x101f1000, pic, 12, serial_hds[0]);
 
205
    pl011_init(0x101f2000, pic, 13, serial_hds[1]);
 
206
    pl011_init(0x101f3000, pic, 14, serial_hds[2]);
 
207
    pl011_init(0x10009000, sic, 6, serial_hds[3]);
228
208
 
229
 
    pl080_init(0x10130000, pic[17], 8);
230
 
    sp804_init(0x101e2000, pic[4]);
231
 
    sp804_init(0x101e3000, pic[5]);
 
209
    pl080_init(0x10130000, pic, 17, 8);
 
210
    sp804_init(0x101e2000, pic, 4);
 
211
    sp804_init(0x101e3000, pic, 5);
232
212
 
233
213
    /* The versatile/PB actually has a modified Color LCD controller
234
214
       that includes hardware cursor support from the PL111.  */
235
 
    pl110_init(ds, 0x10120000, pic[16], 1);
236
 
 
237
 
    index = drive_get_index(IF_SD, 0, 0);
238
 
    if (index == -1) {
239
 
        fprintf(stderr, "qemu: missing SecureDigital card\n");
240
 
        exit(1);
241
 
    }
242
 
 
243
 
    pl181_init(0x10005000, drives_table[index].bdrv, sic[22], sic[1]);
244
 
#if 0
245
 
    /* Disabled because there's no way of specifying a block device.  */
246
 
    pl181_init(0x1000b000, NULL, sic, 23, 2);
247
 
#endif
248
 
 
249
 
    /* Add PL031 Real Time Clock. */
250
 
    pl031_init(0x101e8000,pic[10]);
 
215
    pl110_init(ds, 0x10120000, pic, 16, 1);
251
216
 
252
217
    /* Memory map for Versatile/PB:  */
253
218
    /* 0x10000000 System registers.  */
255
220
    /* 0x10002000 Serial bus interface.  */
256
221
    /*  0x10003000 Secondary interrupt controller.  */
257
222
    /* 0x10004000 AACI (audio).  */
258
 
    /*  0x10005000 MMCI0.  */
 
223
    /* 0x10005000 MMCI0.  */
259
224
    /*  0x10006000 KMI0 (keyboard).  */
260
225
    /*  0x10007000 KMI1 (mouse).  */
261
226
    /* 0x10008000 Character LCD Interface.  */
262
227
    /*  0x10009000 UART3.  */
263
228
    /* 0x1000a000 Smart card 1.  */
264
 
    /*  0x1000b000 MMCI1.  */
 
229
    /* 0x1000b000 MMCI1.  */
265
230
    /*  0x10010000 Ethernet.  */
266
231
    /* 0x10020000 USB.  */
267
232
    /* 0x10100000 SSMC.  */
285
250
    /*  0x101f3000 UART2.  */
286
251
    /* 0x101f4000 SSPI.  */
287
252
 
288
 
    versatile_binfo.ram_size = ram_size;
289
 
    versatile_binfo.kernel_filename = kernel_filename;
290
 
    versatile_binfo.kernel_cmdline = kernel_cmdline;
291
 
    versatile_binfo.initrd_filename = initrd_filename;
292
 
    versatile_binfo.board_id = board_id;
293
 
    arm_load_kernel(env, &versatile_binfo);
294
 
}
295
 
 
296
 
static void vpb_init(ram_addr_t ram_size, int vga_ram_size,
297
 
                     const char *boot_device, DisplayState *ds,
298
 
                     const char *kernel_filename, const char *kernel_cmdline,
299
 
                     const char *initrd_filename, const char *cpu_model)
300
 
{
301
 
    versatile_init(ram_size, vga_ram_size,
302
 
                   boot_device, ds,
303
 
                   kernel_filename, kernel_cmdline,
304
 
                   initrd_filename, cpu_model, 0x183);
305
 
}
306
 
 
307
 
static void vab_init(ram_addr_t ram_size, int vga_ram_size,
308
 
                     const char *boot_device, DisplayState *ds,
309
 
                     const char *kernel_filename, const char *kernel_cmdline,
310
 
                     const char *initrd_filename, const char *cpu_model)
311
 
{
312
 
    versatile_init(ram_size, vga_ram_size,
313
 
                   boot_device, ds,
314
 
                   kernel_filename, kernel_cmdline,
315
 
                   initrd_filename, cpu_model, 0x25e);
 
253
    arm_load_kernel(ram_size, kernel_filename, kernel_cmdline,
 
254
                    initrd_filename, board_id);
 
255
}
 
256
 
 
257
static void vpb_init(int ram_size, int vga_ram_size, int boot_device,
 
258
                     DisplayState *ds, const char **fd_filename, int snapshot,
 
259
                     const char *kernel_filename, const char *kernel_cmdline,
 
260
                     const char *initrd_filename)
 
261
{
 
262
    versatile_init(ram_size, vga_ram_size, boot_device,
 
263
                   ds, fd_filename, snapshot,
 
264
                   kernel_filename, kernel_cmdline,
 
265
                   initrd_filename, 0x183);
 
266
}
 
267
 
 
268
static void vab_init(int ram_size, int vga_ram_size, int boot_device,
 
269
                     DisplayState *ds, const char **fd_filename, int snapshot,
 
270
                     const char *kernel_filename, const char *kernel_cmdline,
 
271
                     const char *initrd_filename)
 
272
{
 
273
    versatile_init(ram_size, vga_ram_size, boot_device,
 
274
                   ds, fd_filename, snapshot,
 
275
                   kernel_filename, kernel_cmdline,
 
276
                   initrd_filename, 0x25e);
316
277
}
317
278
 
318
279
QEMUMachine versatilepb_machine = {