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

« back to all changes in this revision

Viewing changes to hw/dma.c

  • Committer: Bazaar Package Importer
  • Author(s): Aurelien Jarno, Aurelien Jarno
  • Date: 2009-03-07 06:20:34 UTC
  • mfrom: (1.1.9 upstream)
  • mto: This revision was merged to the branch mainline in revision 7.
  • Revision ID: james.westby@ubuntu.com-20090307062034-i3pead4mw653v2el
Tags: 0.10.0-1
[ Aurelien Jarno ]
* New upstream release:
  - Fix fr-be keyboard mapping (closes: bug#514462).
  - Fix stat64 structure on ppc-linux-user (closes: bug#470231).
  - Add a chroot option (closes: bug#415996).
  - Add evdev support (closes: bug#513210).
  - Fix loop on symlinks in user mode (closes: bug#297572).
  - Bump depends on openbios-sparc.
  - Depends on openbios-ppc.
  - Update 12_signal_powerpc_support.patch.
  - Update 21_net_soopts.patch.
  - Drop 44_socklen_t_check.patch (merged upstream).
  - Drop 49_null_check.patch (merged upstream).
  - Update 64_ppc_asm_constraints.patch.
  - Drop security/CVE-2008-0928-fedora.patch (merged upstream).
  - Drop security/CVE-2007-5730.patch (merged upstream).
* patches/80_stable-branch.patch: add patches from stable branch:
  - Fix race condition between signal handler/execution loop (closes:
    bug#474386, bug#501731).
* debian/copyright: update.
* Compile and install .dtb files:
  - debian/control: build-depends on device-tree-compiler.
  - debian/patches/81_compile_dtb.patch: new patch from upstream.
  - debian/rules: compile and install bamboo.dtb and mpc8544.dtb.

Show diffs side-by-side

added added

removed removed

Lines of Context:
37
37
#define ldebug(...)
38
38
#endif
39
39
 
40
 
#define LENOFA(a) ((int) (sizeof(a)/sizeof(a[0])))
41
 
 
42
40
struct dma_regs {
43
41
    int now[2];
44
42
    uint16_t base[2];
78
76
 
79
77
};
80
78
 
 
79
static void DMA_run (void);
 
80
 
81
81
static int channels[8] = {-1, 2, 3, 1, -1, -1, -1, 0};
82
82
 
83
83
static void write_page (void *opaque, uint32_t nport, uint32_t data)
214
214
            d->status &= ~(1 << (ichan + 4));
215
215
        }
216
216
        d->status &= ~(1 << ichan);
 
217
        DMA_run();
217
218
        break;
218
219
 
219
220
    case 0x0a:                  /* single mask */
221
222
            d->mask |= 1 << (data & 3);
222
223
        else
223
224
            d->mask &= ~(1 << (data & 3));
 
225
        DMA_run();
224
226
        break;
225
227
 
226
228
    case 0x0b:                  /* mode */
255
257
 
256
258
    case 0x0e:                  /* clear mask for all channels */
257
259
        d->mask = 0;
 
260
        DMA_run();
258
261
        break;
259
262
 
260
263
    case 0x0f:                  /* write mask for all channels */
261
264
        d->mask = data;
 
265
        DMA_run();
262
266
        break;
263
267
 
264
268
    default:
310
314
    ichan = nchan & 3;
311
315
    linfo ("held cont=%d chan=%d\n", ncont, ichan);
312
316
    dma_controllers[ncont].status |= 1 << (ichan + 4);
 
317
    DMA_run();
313
318
}
314
319
 
315
320
void DMA_release_DREQ (int nchan)
320
325
    ichan = nchan & 3;
321
326
    linfo ("released cont=%d chan=%d\n", ncont, ichan);
322
327
    dma_controllers[ncont].status &= ~(1 << (ichan + 4));
 
328
    DMA_run();
323
329
}
324
330
 
325
331
static void channel_run (int ncont, int ichan)
347
353
    ldebug ("dma_pos %d size %d\n", n, (r->base[COUNT] + 1) << ncont);
348
354
}
349
355
 
350
 
void DMA_run (void)
 
356
static QEMUBH *dma_bh;
 
357
 
 
358
static void DMA_run (void)
351
359
{
352
360
    struct dma_cont *d;
353
361
    int icont, ichan;
 
362
    int rearm = 0;
354
363
 
355
364
    d = dma_controllers;
356
365
 
360
369
 
361
370
            mask = 1 << ichan;
362
371
 
363
 
            if ((0 == (d->mask & mask)) && (0 != (d->status & (mask << 4))))
 
372
            if ((0 == (d->mask & mask)) && (0 != (d->status & (mask << 4)))) {
364
373
                channel_run (icont, ichan);
 
374
                rearm = 1;
 
375
            }
365
376
        }
366
377
    }
 
378
 
 
379
    if (rearm)
 
380
        qemu_bh_schedule_idle(dma_bh);
 
381
}
 
382
 
 
383
static void DMA_run_bh(void *unused)
 
384
{
 
385
    DMA_run();
367
386
}
368
387
 
369
388
void DMA_register_channel (int nchan,
439
458
    write_cont (d, (0x0d << d->dshift), 0);
440
459
}
441
460
 
 
461
static int dma_phony_handler (void *opaque, int nchan, int dma_pos, int dma_len)
 
462
{
 
463
    dolog ("unregistered DMA channel used nchan=%d dma_pos=%d dma_len=%d\n",
 
464
           nchan, dma_pos, dma_len);
 
465
    return dma_pos;
 
466
}
 
467
 
442
468
/* dshift = 0: 8 bit DMA, 1 = 16 bit DMA */
443
469
static void dma_init2(struct dma_cont *d, int base, int dshift,
444
470
                      int page_base, int pageh_base)
445
471
{
446
 
    const static int page_port_list[] = { 0x1, 0x2, 0x3, 0x7 };
 
472
    static const int page_port_list[] = { 0x1, 0x2, 0x3, 0x7 };
447
473
    int i;
448
474
 
449
475
    d->dshift = dshift;
451
477
        register_ioport_write (base + (i << dshift), 1, 1, write_chan, d);
452
478
        register_ioport_read (base + (i << dshift), 1, 1, read_chan, d);
453
479
    }
454
 
    for (i = 0; i < LENOFA (page_port_list); i++) {
 
480
    for (i = 0; i < ARRAY_SIZE (page_port_list); i++) {
455
481
        register_ioport_write (page_base + page_port_list[i], 1, 1,
456
482
                               write_page, d);
457
483
        register_ioport_read (page_base + page_port_list[i], 1, 1,
471
497
    }
472
498
    qemu_register_reset(dma_reset, d);
473
499
    dma_reset(d);
 
500
    for (i = 0; i < ARRAY_SIZE (d->regs); ++i) {
 
501
        d->regs[i].transfer_handler = dma_phony_handler;
 
502
    }
474
503
}
475
504
 
476
505
static void dma_save (QEMUFile *f, void *opaque)
524
553
        qemu_get_8s (f, &r->dack);
525
554
        qemu_get_8s (f, &r->eop);
526
555
    }
 
556
 
 
557
    DMA_run();
 
558
 
527
559
    return 0;
528
560
}
529
561
 
535
567
              high_page_enable ? 0x488 : -1);
536
568
    register_savevm ("dma", 0, 1, dma_save, dma_load, &dma_controllers[0]);
537
569
    register_savevm ("dma", 1, 1, dma_save, dma_load, &dma_controllers[1]);
 
570
 
 
571
    dma_bh = qemu_bh_new(DMA_run_bh, NULL);
538
572
}