i8257.c 15.3 KB
Newer Older
B
bellard 已提交
1 2
/*
 * QEMU DMA emulation
B
bellard 已提交
3 4 5
 *
 * Copyright (c) 2003-2004 Vassili Karpov (malc)
 *
B
bellard 已提交
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
 */
24
#include "hw/hw.h"
P
Paolo Bonzini 已提交
25
#include "hw/isa/isa.h"
26
#include "qemu/main-loop.h"
B
bellard 已提交
27

B
bellard 已提交
28
/* #define DEBUG_DMA */
B
debug  
bellard 已提交
29

B
bellard 已提交
30
#define dolog(...) fprintf (stderr, "dma: " __VA_ARGS__)
B
bellard 已提交
31 32 33 34 35 36 37 38 39 40 41 42 43
#ifdef DEBUG_DMA
#define linfo(...) fprintf (stderr, "dma: " __VA_ARGS__)
#define ldebug(...) fprintf (stderr, "dma: " __VA_ARGS__)
#else
#define linfo(...)
#define ldebug(...)
#endif

struct dma_regs {
    int now[2];
    uint16_t base[2];
    uint8_t mode;
    uint8_t page;
44
    uint8_t pageh;
B
bellard 已提交
45 46
    uint8_t dack;
    uint8_t eop;
B
bellard 已提交
47 48
    DMA_transfer_handler transfer_handler;
    void *opaque;
B
bellard 已提交
49 50 51 52 53 54 55 56 57 58
};

#define ADDR 0
#define COUNT 1

static struct dma_cont {
    uint8_t status;
    uint8_t command;
    uint8_t mask;
    uint8_t flip_flop;
59
    int dshift;
B
bellard 已提交
60
    struct dma_regs regs[4];
B
Blue Swirl 已提交
61
    qemu_irq *cpu_request_exit;
J
Julien Grall 已提交
62 63
    MemoryRegion channel_io;
    MemoryRegion cont_io;
B
bellard 已提交
64 65 66
} dma_controllers[2];

enum {
B
bellard 已提交
67 68 69 70 71 72 73 74 75 76 77
    CMD_MEMORY_TO_MEMORY = 0x01,
    CMD_FIXED_ADDRESS    = 0x02,
    CMD_BLOCK_CONTROLLER = 0x04,
    CMD_COMPRESSED_TIME  = 0x08,
    CMD_CYCLIC_PRIORITY  = 0x10,
    CMD_EXTENDED_WRITE   = 0x20,
    CMD_LOW_DREQ         = 0x40,
    CMD_LOW_DACK         = 0x80,
    CMD_NOT_SUPPORTED    = CMD_MEMORY_TO_MEMORY | CMD_FIXED_ADDRESS
    | CMD_COMPRESSED_TIME | CMD_CYCLIC_PRIORITY | CMD_EXTENDED_WRITE
    | CMD_LOW_DREQ | CMD_LOW_DACK
B
bellard 已提交
78 79 80

};

A
aliguori 已提交
81 82
static void DMA_run (void);

83 84
static int channels[8] = {-1, 2, 3, 1, -1, -1, -1, 0};

B
bellard 已提交
85
static void write_page (void *opaque, uint32_t nport, uint32_t data)
B
bellard 已提交
86
{
87
    struct dma_cont *d = opaque;
B
bellard 已提交
88 89
    int ichan;

90
    ichan = channels[nport & 7];
B
bellard 已提交
91
    if (-1 == ichan) {
B
bellard 已提交
92
        dolog ("invalid channel %#x %#x\n", nport, data);
B
bellard 已提交
93 94
        return;
    }
95 96 97
    d->regs[ichan].page = data;
}

98
static void write_pageh (void *opaque, uint32_t nport, uint32_t data)
99 100 101
{
    struct dma_cont *d = opaque;
    int ichan;
B
bellard 已提交
102

103
    ichan = channels[nport & 7];
104
    if (-1 == ichan) {
B
bellard 已提交
105
        dolog ("invalid channel %#x %#x\n", nport, data);
106 107 108 109
        return;
    }
    d->regs[ichan].pageh = data;
}
110

111 112 113 114 115 116
static uint32_t read_page (void *opaque, uint32_t nport)
{
    struct dma_cont *d = opaque;
    int ichan;

    ichan = channels[nport & 7];
117
    if (-1 == ichan) {
B
bellard 已提交
118
        dolog ("invalid channel read %#x\n", nport);
119 120 121
        return 0;
    }
    return d->regs[ichan].page;
B
bellard 已提交
122 123
}

124 125 126 127 128 129 130
static uint32_t read_pageh (void *opaque, uint32_t nport)
{
    struct dma_cont *d = opaque;
    int ichan;

    ichan = channels[nport & 7];
    if (-1 == ichan) {
B
bellard 已提交
131
        dolog ("invalid channel read %#x\n", nport);
132 133 134 135 136
        return 0;
    }
    return d->regs[ichan].pageh;
}

137
static inline void init_chan (struct dma_cont *d, int ichan)
B
bellard 已提交
138 139 140
{
    struct dma_regs *r;

141
    r = d->regs + ichan;
B
bellard 已提交
142
    r->now[ADDR] = r->base[ADDR] << d->dshift;
B
bellard 已提交
143 144 145
    r->now[COUNT] = 0;
}

146
static inline int getff (struct dma_cont *d)
B
bellard 已提交
147 148 149
{
    int ff;

150 151
    ff = d->flip_flop;
    d->flip_flop = !ff;
B
bellard 已提交
152 153 154
    return ff;
}

J
Julien Grall 已提交
155
static uint64_t read_chan(void *opaque, hwaddr nport, unsigned size)
B
bellard 已提交
156
{
157
    struct dma_cont *d = opaque;
B
bellard 已提交
158
    int ichan, nreg, iport, ff, val, dir;
B
bellard 已提交
159 160
    struct dma_regs *r;

161 162 163 164
    iport = (nport >> d->dshift) & 0x0f;
    ichan = iport >> 1;
    nreg = iport & 1;
    r = d->regs + ichan;
B
bellard 已提交
165

B
bellard 已提交
166
    dir = ((r->mode >> 5) & 1) ? -1 : 1;
167
    ff = getff (d);
B
bellard 已提交
168
    if (nreg)
169
        val = (r->base[COUNT] << d->dshift) - r->now[COUNT];
B
bellard 已提交
170
    else
B
bellard 已提交
171
        val = r->now[ADDR] + r->now[COUNT] * dir;
B
bellard 已提交
172

B
bellard 已提交
173
    ldebug ("read_chan %#x -> %d\n", iport, val);
174
    return (val >> (d->dshift + (ff << 3))) & 0xff;
B
bellard 已提交
175 176
}

J
Julien Grall 已提交
177 178
static void write_chan(void *opaque, hwaddr nport, uint64_t data,
                       unsigned size)
B
bellard 已提交
179
{
180 181
    struct dma_cont *d = opaque;
    int iport, ichan, nreg;
B
bellard 已提交
182 183
    struct dma_regs *r;

184 185 186 187 188
    iport = (nport >> d->dshift) & 0x0f;
    ichan = iport >> 1;
    nreg = iport & 1;
    r = d->regs + ichan;
    if (getff (d)) {
B
bellard 已提交
189
        r->base[nreg] = (r->base[nreg] & 0xff) | ((data << 8) & 0xff00);
190
        init_chan (d, ichan);
B
bellard 已提交
191 192
    } else {
        r->base[nreg] = (r->base[nreg] & 0xff00) | (data & 0xff);
B
bellard 已提交
193 194 195
    }
}

J
Julien Grall 已提交
196 197
static void write_cont(void *opaque, hwaddr nport, uint64_t data,
                       unsigned size)
B
bellard 已提交
198
{
199
    struct dma_cont *d = opaque;
B
bellard 已提交
200
    int iport, ichan = 0;
B
bellard 已提交
201

202
    iport = (nport >> d->dshift) & 0x0f;
B
bellard 已提交
203
    switch (iport) {
204
    case 0x00:                  /* command */
B
bellard 已提交
205
        if ((data != 0) && (data & CMD_NOT_SUPPORTED)) {
J
Julien Grall 已提交
206
            dolog("command %"PRIx64" not supported\n", data);
B
bellard 已提交
207
            return;
B
bellard 已提交
208 209 210 211
        }
        d->command = data;
        break;

212
    case 0x01:
B
bellard 已提交
213 214 215 216 217 218 219 220
        ichan = data & 3;
        if (data & 4) {
            d->status |= 1 << (ichan + 4);
        }
        else {
            d->status &= ~(1 << (ichan + 4));
        }
        d->status &= ~(1 << ichan);
A
aliguori 已提交
221
        DMA_run();
B
bellard 已提交
222 223
        break;

224
    case 0x02:                  /* single mask */
B
bellard 已提交
225 226 227 228
        if (data & 4)
            d->mask |= 1 << (data & 3);
        else
            d->mask &= ~(1 << (data & 3));
A
aliguori 已提交
229
        DMA_run();
B
bellard 已提交
230 231
        break;

232
    case 0x03:                  /* mode */
B
bellard 已提交
233
        {
B
bellard 已提交
234 235
            ichan = data & 3;
#ifdef DEBUG_DMA
B
bellard 已提交
236 237
            {
                int op, ai, dir, opmode;
B
bellard 已提交
238 239 240 241
                op = (data >> 2) & 3;
                ai = (data >> 4) & 1;
                dir = (data >> 5) & 1;
                opmode = (data >> 6) & 3;
B
bellard 已提交
242

B
bellard 已提交
243 244
                linfo ("ichan %d, op %d, ai %d, dir %d, opmode %d\n",
                       ichan, op, ai, dir, opmode);
B
bellard 已提交
245
            }
B
bellard 已提交
246 247 248 249 250
#endif
            d->regs[ichan].mode = data;
            break;
        }

251
    case 0x04:                  /* clear flip flop */
B
bellard 已提交
252 253 254
        d->flip_flop = 0;
        break;

255
    case 0x05:                  /* reset */
B
bellard 已提交
256 257 258 259 260 261
        d->flip_flop = 0;
        d->mask = ~0;
        d->status = 0;
        d->command = 0;
        break;

262
    case 0x06:                  /* clear mask for all channels */
B
bellard 已提交
263
        d->mask = 0;
A
aliguori 已提交
264
        DMA_run();
B
bellard 已提交
265 266
        break;

267
    case 0x07:                  /* write mask for all channels */
B
bellard 已提交
268
        d->mask = data;
A
aliguori 已提交
269
        DMA_run();
B
bellard 已提交
270 271 272
        break;

    default:
B
bellard 已提交
273
        dolog ("unknown iport %#x\n", iport);
B
bellard 已提交
274
        break;
B
bellard 已提交
275 276
    }

B
bellard 已提交
277
#ifdef DEBUG_DMA
B
bellard 已提交
278
    if (0xc != iport) {
B
bellard 已提交
279
        linfo ("write_cont: nport %#06x, ichan % 2d, val %#06x\n",
280
               nport, ichan, data);
B
bellard 已提交
281 282 283 284
    }
#endif
}

J
Julien Grall 已提交
285
static uint64_t read_cont(void *opaque, hwaddr nport, unsigned size)
286 287 288
{
    struct dma_cont *d = opaque;
    int iport, val;
B
bellard 已提交
289

290 291
    iport = (nport >> d->dshift) & 0x0f;
    switch (iport) {
292
    case 0x00:                  /* status */
293 294 295
        val = d->status;
        d->status &= 0xf0;
        break;
296
    case 0x01:                  /* mask */
297 298 299 300 301 302
        val = d->mask;
        break;
    default:
        val = 0;
        break;
    }
B
bellard 已提交
303 304

    ldebug ("read_cont: nport %#06x, iport %#04x val %#x\n", nport, iport, val);
305 306 307
    return val;
}

B
bellard 已提交
308 309 310 311 312 313 314 315 316 317 318 319 320
int DMA_get_channel_mode (int nchan)
{
    return dma_controllers[nchan > 3].regs[nchan & 3].mode;
}

void DMA_hold_DREQ (int nchan)
{
    int ncont, ichan;

    ncont = nchan > 3;
    ichan = nchan & 3;
    linfo ("held cont=%d chan=%d\n", ncont, ichan);
    dma_controllers[ncont].status |= 1 << (ichan + 4);
A
aliguori 已提交
321
    DMA_run();
B
bellard 已提交
322 323 324 325 326 327 328 329 330 331
}

void DMA_release_DREQ (int nchan)
{
    int ncont, ichan;

    ncont = nchan > 3;
    ichan = nchan & 3;
    linfo ("released cont=%d chan=%d\n", ncont, ichan);
    dma_controllers[ncont].status &= ~(1 << (ichan + 4));
A
aliguori 已提交
332
    DMA_run();
B
bellard 已提交
333 334 335 336 337
}

static void channel_run (int ncont, int ichan)
{
    int n;
B
bellard 已提交
338 339 340
    struct dma_regs *r = &dma_controllers[ncont].regs[ichan];
#ifdef DEBUG_DMA
    int dir, opmode;
B
bellard 已提交
341

B
bellard 已提交
342 343
    dir = (r->mode >> 5) & 1;
    opmode = (r->mode >> 6) & 3;
B
bellard 已提交
344

B
bellard 已提交
345 346 347 348 349 350 351
    if (dir) {
        dolog ("DMA in address decrement mode\n");
    }
    if (opmode != 1) {
        dolog ("DMA not in single mode select %#x\n", opmode);
    }
#endif
B
bellard 已提交
352

B
bellard 已提交
353 354 355 356
    n = r->transfer_handler (r->opaque, ichan + (ncont << 2),
                             r->now[COUNT], (r->base[COUNT] + 1) << ncont);
    r->now[COUNT] = n;
    ldebug ("dma_pos %d size %d\n", n, (r->base[COUNT] + 1) << ncont);
B
bellard 已提交
357 358
}

A
aliguori 已提交
359 360 361
static QEMUBH *dma_bh;

static void DMA_run (void)
B
bellard 已提交
362 363 364
{
    struct dma_cont *d;
    int icont, ichan;
A
aliguori 已提交
365
    int rearm = 0;
366 367 368 369 370 371 372 373
    static int running = 0;

    if (running) {
        rearm = 1;
        goto out;
    } else {
        running = 1;
    }
B
bellard 已提交
374 375 376 377 378 379 380 381 382

    d = dma_controllers;

    for (icont = 0; icont < 2; icont++, d++) {
        for (ichan = 0; ichan < 4; ichan++) {
            int mask;

            mask = 1 << ichan;

A
aliguori 已提交
383
            if ((0 == (d->mask & mask)) && (0 != (d->status & (mask << 4)))) {
B
bellard 已提交
384
                channel_run (icont, ichan);
A
aliguori 已提交
385 386
                rearm = 1;
            }
B
bellard 已提交
387 388
        }
    }
A
aliguori 已提交
389

390 391
    running = 0;
out:
A
aliguori 已提交
392 393 394 395 396 397 398
    if (rearm)
        qemu_bh_schedule_idle(dma_bh);
}

static void DMA_run_bh(void *unused)
{
    DMA_run();
B
bellard 已提交
399 400 401
}

void DMA_register_channel (int nchan,
B
bellard 已提交
402
                           DMA_transfer_handler transfer_handler,
B
bellard 已提交
403
                           void *opaque)
B
bellard 已提交
404 405 406 407 408 409 410 411
{
    struct dma_regs *r;
    int ichan, ncont;

    ncont = nchan > 3;
    ichan = nchan & 3;

    r = dma_controllers[ncont].regs + ichan;
B
bellard 已提交
412 413 414 415
    r->transfer_handler = transfer_handler;
    r->opaque = opaque;
}

B
bellard 已提交
416 417 418
int DMA_read_memory (int nchan, void *buf, int pos, int len)
{
    struct dma_regs *r = &dma_controllers[nchan > 3].regs[nchan & 3];
A
Avi Kivity 已提交
419
    hwaddr addr = ((r->pageh & 0x7f) << 24) | (r->page << 16) | r->now[ADDR];
B
bellard 已提交
420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440

    if (r->mode & 0x20) {
        int i;
        uint8_t *p = buf;

        cpu_physical_memory_read (addr - pos - len, buf, len);
        /* What about 16bit transfers? */
        for (i = 0; i < len >> 1; i++) {
            uint8_t b = p[len - i - 1];
            p[i] = b;
        }
    }
    else
        cpu_physical_memory_read (addr + pos, buf, len);

    return len;
}

int DMA_write_memory (int nchan, void *buf, int pos, int len)
{
    struct dma_regs *r = &dma_controllers[nchan > 3].regs[nchan & 3];
A
Avi Kivity 已提交
441
    hwaddr addr = ((r->pageh & 0x7f) << 24) | (r->page << 16) | r->now[ADDR];
B
bellard 已提交
442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459

    if (r->mode & 0x20) {
        int i;
        uint8_t *p = buf;

        cpu_physical_memory_write (addr - pos - len, buf, len);
        /* What about 16bit transfers? */
        for (i = 0; i < len; i++) {
            uint8_t b = p[len - i - 1];
            p[i] = b;
        }
    }
    else
        cpu_physical_memory_write (addr + pos, buf, len);

    return len;
}

B
bellard 已提交
460 461 462
/* request the emulator to transfer a new DMA memory block ASAP */
void DMA_schedule(int nchan)
{
B
Blue Swirl 已提交
463 464 465
    struct dma_cont *d = &dma_controllers[nchan > 3];

    qemu_irq_pulse(*d->cpu_request_exit);
B
bellard 已提交
466 467
}

B
bellard 已提交
468 469 470
static void dma_reset(void *opaque)
{
    struct dma_cont *d = opaque;
471
    write_cont(d, (0x05 << d->dshift), 0, 1);
B
bellard 已提交
472 473
}

474 475 476 477 478 479 480
static int dma_phony_handler (void *opaque, int nchan, int dma_pos, int dma_len)
{
    dolog ("unregistered DMA channel used nchan=%d dma_pos=%d dma_len=%d\n",
           nchan, dma_pos, dma_len);
    return dma_pos;
}

J
Julien Grall 已提交
481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515

static const MemoryRegionOps channel_io_ops = {
    .read = read_chan,
    .write = write_chan,
    .endianness = DEVICE_NATIVE_ENDIAN,
    .impl = {
        .min_access_size = 1,
        .max_access_size = 1,
    },
};

/* IOport from page_base */
static const MemoryRegionPortio page_portio_list[] = {
    { 0x01, 3, 1, .write = write_page, .read = read_page, },
    { 0x07, 1, 1, .write = write_page, .read = read_page, },
    PORTIO_END_OF_LIST(),
};

/* IOport from pageh_base */
static const MemoryRegionPortio pageh_portio_list[] = {
    { 0x01, 3, 1, .write = write_pageh, .read = read_pageh, },
    { 0x07, 3, 1, .write = write_pageh, .read = read_pageh, },
    PORTIO_END_OF_LIST(),
};

static const MemoryRegionOps cont_io_ops = {
    .read = read_cont,
    .write = write_cont,
    .endianness = DEVICE_NATIVE_ENDIAN,
    .impl = {
        .min_access_size = 1,
        .max_access_size = 1,
    },
};

516
/* dshift = 0: 8 bit DMA, 1 = 16 bit DMA */
B
bellard 已提交
517
static void dma_init2(struct dma_cont *d, int base, int dshift,
B
Blue Swirl 已提交
518 519
                      int page_base, int pageh_base,
                      qemu_irq *cpu_request_exit)
B
bellard 已提交
520 521 522
{
    int i;

523
    d->dshift = dshift;
B
Blue Swirl 已提交
524
    d->cpu_request_exit = cpu_request_exit;
J
Julien Grall 已提交
525 526 527 528 529 530 531 532 533 534 535

    memory_region_init_io(&d->channel_io, &channel_io_ops, d,
                          "dma-chan", 8 << d->dshift);
    memory_region_add_subregion(isa_address_space_io(NULL),
                                base, &d->channel_io);

    isa_register_portio_list(NULL, page_base, page_portio_list, d,
                             "dma-page");
    if (pageh_base >= 0) {
        isa_register_portio_list(NULL, pageh_base, pageh_portio_list, d,
                                 "dma-pageh");
B
bellard 已提交
536
    }
J
Julien Grall 已提交
537 538 539 540 541 542

    memory_region_init_io(&d->cont_io, &cont_io_ops, d, "dma-cont",
                          8 << d->dshift);
    memory_region_add_subregion(isa_address_space_io(NULL),
                                base + (8 << d->dshift), &d->cont_io);

543
    qemu_register_reset(dma_reset, d);
B
bellard 已提交
544
    dma_reset(d);
545
    for (i = 0; i < ARRAY_SIZE (d->regs); ++i) {
546 547
        d->regs[i].transfer_handler = dma_phony_handler;
    }
548
}
B
bellard 已提交
549

J
Juan Quintela 已提交
550 551 552 553 554 555 556 557 558 559 560 561 562 563
static const VMStateDescription vmstate_dma_regs = {
    .name = "dma_regs",
    .version_id = 1,
    .minimum_version_id = 1,
    .minimum_version_id_old = 1,
    .fields      = (VMStateField []) {
        VMSTATE_INT32_ARRAY(now, struct dma_regs, 2),
        VMSTATE_UINT16_ARRAY(base, struct dma_regs, 2),
        VMSTATE_UINT8(mode, struct dma_regs),
        VMSTATE_UINT8(page, struct dma_regs),
        VMSTATE_UINT8(pageh, struct dma_regs),
        VMSTATE_UINT8(dack, struct dma_regs),
        VMSTATE_UINT8(eop, struct dma_regs),
        VMSTATE_END_OF_LIST()
B
bellard 已提交
564
    }
J
Juan Quintela 已提交
565
};
B
bellard 已提交
566

567
static int dma_post_load(void *opaque, int version_id)
B
bellard 已提交
568
{
A
aliguori 已提交
569 570
    DMA_run();

B
bellard 已提交
571 572 573
    return 0;
}

J
Juan Quintela 已提交
574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589
static const VMStateDescription vmstate_dma = {
    .name = "dma",
    .version_id = 1,
    .minimum_version_id = 1,
    .minimum_version_id_old = 1,
    .post_load = dma_post_load,
    .fields      = (VMStateField []) {
        VMSTATE_UINT8(command, struct dma_cont),
        VMSTATE_UINT8(mask, struct dma_cont),
        VMSTATE_UINT8(flip_flop, struct dma_cont),
        VMSTATE_INT32(dshift, struct dma_cont),
        VMSTATE_STRUCT_ARRAY(regs, struct dma_cont, 4, 1, vmstate_dma_regs, struct dma_regs),
        VMSTATE_END_OF_LIST()
    }
};

B
Blue Swirl 已提交
590
void DMA_init(int high_page_enable, qemu_irq *cpu_request_exit)
591
{
B
bellard 已提交
592
    dma_init2(&dma_controllers[0], 0x00, 0, 0x80,
B
Blue Swirl 已提交
593
              high_page_enable ? 0x480 : -1, cpu_request_exit);
594
    dma_init2(&dma_controllers[1], 0xc0, 1, 0x88,
B
Blue Swirl 已提交
595
              high_page_enable ? 0x488 : -1, cpu_request_exit);
A
Alex Williamson 已提交
596 597
    vmstate_register (NULL, 0, &vmstate_dma, &dma_controllers[0]);
    vmstate_register (NULL, 1, &vmstate_dma, &dma_controllers[1]);
A
aliguori 已提交
598 599

    dma_bh = qemu_bh_new(DMA_run_bh, NULL);
B
bellard 已提交
600
}