~jderose/ubuntu/raring/qemu/vde-again

« back to all changes in this revision

Viewing changes to hw/integratorcp.c

Tags: upstream-0.9.0+20070816
ImportĀ upstreamĀ versionĀ 0.9.0+20070816

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* 
2
2
 * ARM Integrator CP System emulation.
3
3
 *
4
 
 * Copyright (c) 2005-2006 CodeSourcery.
 
4
 * Copyright (c) 2005-2007 CodeSourcery.
5
5
 * Written by Paul Brook
6
6
 *
7
7
 * This code is licenced under the GPL
257
257
 
258
258
    iomemtype = cpu_register_io_memory(0, integratorcm_readfn,
259
259
                                       integratorcm_writefn, s);
260
 
    cpu_register_physical_memory(0x10000000, 0x007fffff, iomemtype);
 
260
    cpu_register_physical_memory(0x10000000, 0x00800000, iomemtype);
261
261
    integratorcm_do_remap(s, 1);
262
262
    /* ??? Save/restore.  */
263
263
}
267
267
 
268
268
typedef struct icp_pic_state
269
269
{
270
 
  arm_pic_handler handler;
271
270
  uint32_t base;
272
271
  uint32_t level;
273
272
  uint32_t irq_enabled;
274
273
  uint32_t fiq_enabled;
275
 
  void *parent;
276
 
  int parent_irq;
277
 
  int parent_fiq;
 
274
  qemu_irq parent_irq;
 
275
  qemu_irq parent_fiq;
278
276
} icp_pic_state;
279
277
 
280
278
static void icp_pic_update(icp_pic_state *s)
281
279
{
282
280
    uint32_t flags;
283
281
 
284
 
    if (s->parent_irq != -1) {
285
 
        flags = (s->level & s->irq_enabled);
286
 
        pic_set_irq_new(s->parent, s->parent_irq, flags != 0);
287
 
    }
288
 
    if (s->parent_fiq != -1) {
289
 
        flags = (s->level & s->fiq_enabled);
290
 
        pic_set_irq_new(s->parent, s->parent_fiq, flags != 0);
291
 
    }
 
282
    flags = (s->level & s->irq_enabled);
 
283
    qemu_set_irq(s->parent_irq, flags != 0);
 
284
    flags = (s->level & s->fiq_enabled);
 
285
    qemu_set_irq(s->parent_fiq, flags != 0);
292
286
}
293
287
 
294
288
static void icp_pic_set_irq(void *opaque, int irq, int level)
345
339
        break;
346
340
    case 4: /* INT_SOFTSET */
347
341
        if (value & 1)
348
 
            pic_set_irq_new(s, 0, 1);
 
342
            icp_pic_set_irq(s, 0, 1);
349
343
        break;
350
344
    case 5: /* INT_SOFTCLR */
351
345
        if (value & 1)
352
 
            pic_set_irq_new(s, 0, 0);
 
346
            icp_pic_set_irq(s, 0, 0);
353
347
        break;
354
348
    case 10: /* FRQ_ENABLESET */
355
349
        s->fiq_enabled |= value;
380
374
   icp_pic_write
381
375
};
382
376
 
383
 
static icp_pic_state *icp_pic_init(uint32_t base, void *parent,
384
 
                                   int parent_irq, int parent_fiq)
 
377
static qemu_irq *icp_pic_init(uint32_t base,
 
378
                              qemu_irq parent_irq, qemu_irq parent_fiq)
385
379
{
386
380
    icp_pic_state *s;
387
381
    int iomemtype;
 
382
    qemu_irq *qi;
388
383
 
389
384
    s = (icp_pic_state *)qemu_mallocz(sizeof(icp_pic_state));
390
385
    if (!s)
391
386
        return NULL;
392
 
    s->handler = icp_pic_set_irq;
 
387
    qi = qemu_allocate_irqs(icp_pic_set_irq, s, 32);
393
388
    s->base = base;
394
 
    s->parent = parent;
395
389
    s->parent_irq = parent_irq;
396
390
    s->parent_fiq = parent_fiq;
397
391
    iomemtype = cpu_register_io_memory(0, icp_pic_readfn,
398
392
                                       icp_pic_writefn, s);
399
 
    cpu_register_physical_memory(base, 0x007fffff, iomemtype);
 
393
    cpu_register_physical_memory(base, 0x00800000, iomemtype);
400
394
    /* ??? Save/restore.  */
401
 
    return s;
 
395
    return qi;
402
396
}
403
397
 
404
398
/* CP control registers.  */
460
454
    s = (icp_control_state *)qemu_mallocz(sizeof(icp_control_state));
461
455
    iomemtype = cpu_register_io_memory(0, icp_control_readfn,
462
456
                                       icp_control_writefn, s);
463
 
    cpu_register_physical_memory(base, 0x007fffff, iomemtype);
 
457
    cpu_register_physical_memory(base, 0x00800000, iomemtype);
464
458
    s->base = base;
465
459
    /* ??? Save/restore.  */
466
460
}
471
465
static void integratorcp_init(int ram_size, int vga_ram_size, int boot_device,
472
466
                     DisplayState *ds, const char **fd_filename, int snapshot,
473
467
                     const char *kernel_filename, const char *kernel_cmdline,
474
 
                     const char *initrd_filename, uint32_t cpuid)
 
468
                     const char *initrd_filename, const char *cpu_model)
475
469
{
476
470
    CPUState *env;
477
471
    uint32_t bios_offset;
478
 
    icp_pic_state *pic;
479
 
    void *cpu_pic;
 
472
    qemu_irq *pic;
 
473
    qemu_irq *cpu_pic;
480
474
 
481
475
    env = cpu_init();
482
 
    cpu_arm_set_model(env, cpuid);
 
476
    if (!cpu_model)
 
477
        cpu_model = "arm926";
 
478
    cpu_arm_set_model(env, cpu_model);
483
479
    bios_offset = ram_size + vga_ram_size;
484
480
    /* ??? On a real system the first 1Mb is mapped as SSRAM or boot flash.  */
485
481
    /* ??? RAM shoud repeat to fill physical memory space.  */
490
486
 
491
487
    integratorcm_init(ram_size >> 20, bios_offset);
492
488
    cpu_pic = arm_pic_init_cpu(env);
493
 
    pic = icp_pic_init(0x14000000, cpu_pic, ARM_PIC_CPU_IRQ, ARM_PIC_CPU_FIQ);
494
 
    icp_pic_init(0xca000000, pic, 26, -1);
 
489
    pic = icp_pic_init(0x14000000, cpu_pic[ARM_PIC_CPU_IRQ],
 
490
                       cpu_pic[ARM_PIC_CPU_FIQ]);
 
491
    icp_pic_init(0xca000000, pic[26], NULL);
495
492
    icp_pit_init(0x13000000, pic, 5);
496
 
    pl011_init(0x16000000, pic, 1, serial_hds[0]);
497
 
    pl011_init(0x17000000, pic, 2, serial_hds[1]);
 
493
    pl031_init(0x15000000, pic[8]);
 
494
    pl011_init(0x16000000, pic[1], serial_hds[0]);
 
495
    pl011_init(0x17000000, pic[2], serial_hds[1]);
498
496
    icp_control_init(0xcb000000);
499
 
    pl050_init(0x18000000, pic, 3, 0);
500
 
    pl050_init(0x19000000, pic, 4, 1);
 
497
    pl050_init(0x18000000, pic[3], 0);
 
498
    pl050_init(0x19000000, pic[4], 1);
 
499
    pl181_init(0x1c000000, sd_bdrv, pic[23], pic[24]);
501
500
    if (nd_table[0].vlan) {
502
501
        if (nd_table[0].model == NULL
503
502
            || strcmp(nd_table[0].model, "smc91c111") == 0) {
504
 
            smc91c111_init(&nd_table[0], 0xc8000000, pic, 27);
 
503
            smc91c111_init(&nd_table[0], 0xc8000000, pic[27]);
 
504
        } else if (strcmp(nd_table[0].model, "?") == 0) {
 
505
            fprintf(stderr, "qemu: Supported NICs: smc91c111\n");
 
506
            exit (1);
505
507
        } else {
506
508
            fprintf(stderr, "qemu: Unsupported NIC: %s\n", nd_table[0].model);
507
509
            exit (1);
508
510
        }
509
511
    }
510
 
    pl110_init(ds, 0xc0000000, pic, 22, 0);
 
512
    pl110_init(ds, 0xc0000000, pic[22], 0);
511
513
 
512
514
    arm_load_kernel(env, ram_size, kernel_filename, kernel_cmdline,
513
 
                    initrd_filename, 0x113);
514
 
}
515
 
 
516
 
static void integratorcp926_init(int ram_size, int vga_ram_size,
517
 
    int boot_device, DisplayState *ds, const char **fd_filename, int snapshot,
518
 
    const char *kernel_filename, const char *kernel_cmdline,
519
 
    const char *initrd_filename)
520
 
{
521
 
    integratorcp_init(ram_size, vga_ram_size, boot_device, ds, fd_filename,
522
 
                      snapshot, kernel_filename, kernel_cmdline,
523
 
                      initrd_filename, ARM_CPUID_ARM926);
524
 
}
525
 
 
526
 
static void integratorcp1026_init(int ram_size, int vga_ram_size,
527
 
    int boot_device, DisplayState *ds, const char **fd_filename, int snapshot,
528
 
    const char *kernel_filename, const char *kernel_cmdline,
529
 
    const char *initrd_filename)
530
 
{
531
 
    integratorcp_init(ram_size, vga_ram_size, boot_device, ds, fd_filename,
532
 
                      snapshot, kernel_filename, kernel_cmdline,
533
 
                      initrd_filename, ARM_CPUID_ARM1026);
534
 
}
535
 
 
536
 
QEMUMachine integratorcp926_machine = {
537
 
    "integratorcp926",
 
515
                    initrd_filename, 0x113, 0x0);
 
516
}
 
517
 
 
518
QEMUMachine integratorcp_machine = {
 
519
    "integratorcp",
538
520
    "ARM Integrator/CP (ARM926EJ-S)",
539
 
    integratorcp926_init,
540
 
};
541
 
 
542
 
QEMUMachine integratorcp1026_machine = {
543
 
    "integratorcp1026",
544
 
    "ARM Integrator/CP (ARM1026EJ-S)",
545
 
    integratorcp1026_init,
 
521
    integratorcp_init,
546
522
};