DevDMA.cpp revision 4434d438566406e2a7fe0215bc24a210e1d3dbd6
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync * DMA Controller Device.
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync * Copyright (C) 2006 InnoTek Systemberatung GmbH
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync * available from http://www.virtualbox.org. This file is free software;
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync * you can redistribute it and/or modify it under the terms of the GNU
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync * General Public License as published by the Free Software Foundation,
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync * in version 2 as it comes in the "COPYING" file of the VirtualBox OSE
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync * distribution. VirtualBox OSE is distributed in the hope that it will
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync * be useful, but WITHOUT ANY WARRANTY of any kind.
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync * If you received this file as part of a commercial VirtualBox
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync * distribution, then only the terms of your commercial VirtualBox
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync * license agreement apply instead of the previous paragraph.
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync * --------------------------------------------------------------------
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync * This code is based on:
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync * QEMU DMA emulation
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync * Copyright (c) 2003 Vassili Karpov (malc)
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync * Permission is hereby granted, free of charge, to any person obtaining a copy
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync * of this software and associated documentation files (the "Software"), to deal
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync * in the Software without restriction, including without limitation the rights
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync * copies of the Software, and to permit persons to whom the Software is
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync * furnished to do so, subject to the following conditions:
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync * The above copyright notice and this permission notice shall be included in
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync * all copies or substantial portions of the Software.
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync * THE SOFTWARE.
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync/*******************************************************************************
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync* Header Files *
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync*******************************************************************************/
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync#define LOG_GROUP LOG_GROUP_DEFAULT ///@todo LOG_GROUP_DEV_DMA
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync#else /* !VBOX */
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync/* #define DEBUG_DMA */
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync#define dolog(...) fprintf (stderr, "dma: " __VA_ARGS__)
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync#define lwarn(...) fprintf (stderr, "dma: " __VA_ARGS__)
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync#define linfo(...) fprintf (stderr, "dma: " __VA_ARGS__)
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync#define ldebug(...) fprintf (stderr, "dma: " __VA_ARGS__)
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync#else /* VBOX */
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync RTLogLogger (NULL, NULL, "dma: %N", fmt, &args); /* %N - nested va_list * type formatting call. */
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync DECLINLINE(void) DMA_DPRINTF(const char *pszFmt, ...) {}
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync#endif /* VBOX */
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync#define LENOFA(a) ((int) (sizeof(a)/sizeof(a[0])))
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync unsigned int dshift;
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsynctypedef struct {
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync CMD_NOT_SUPPORTED = CMD_MEMORY_TO_MEMORY | CMD_FIXED_ADDRESS
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync | CMD_COMPRESSED_TIME | CMD_CYCLIC_PRIORITY | CMD_EXTENDED_WRITE
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsyncstatic int channels[8] = {-1, 2, 3, 1, -1, -1, -1, 0};
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsyncstatic void write_page (void *opaque, uint32_t nport, uint32_t data)
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsyncstatic void write_pageh (void *opaque, uint32_t nport, uint32_t data)
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsyncstatic uint32_t read_page (void *opaque, uint32_t nport)
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsyncstatic uint32_t read_pageh (void *opaque, uint32_t nport)
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsyncstatic inline void init_chan (struct dma_cont *d, int ichan)
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsyncstatic uint32_t read_chan (void *opaque, uint32_t nport)
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync val = (r->base[COUNT] << d->dshift) - r->now[COUNT];
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsyncstatic void write_chan (void *opaque, uint32_t nport, uint32_t data)
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync r->base[nreg] = (r->base[nreg] & 0xff) | ((data << 8) & 0xff00);
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync r->base[nreg] = (r->base[nreg] & 0xff00) | (data & 0xff);
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsyncstatic void write_cont (void *opaque, uint32_t nport, uint32_t data)
#ifdef DEBUG_DMA
d->flip_flop = 0;
d->flip_flop = 0;
d->mask = ~0;
d->status = 0;
d->command = 0;
d->mask = 0;
#ifdef DEBUG_DMA
switch (iport) {
val = 0;
return val;
#ifdef DEBUG_DMA
if (dir) {
struct dma_cont *d;
d = s->dma_controllers;
int mask;
void *opaque)
struct dma_regs *r;
unsigned nchan,
void *buf,
#ifdef VBOX
#ifdef VBOX
return len;
unsigned nchan,
const void *buf,
#ifdef VBOX
for (i = 0; i < len; i++) {
#ifdef VBOX
return len;
#ifndef VBOX
#ifdef VBOX
#define IO_READ_PROTO(n) \
void *pvUser, \
unsigned cb)
#define IO_WRITE_PROTO(n) \
void *pvUser, \
unsigned cb)
#ifdef PARANOID
return VINF_SUCCESS;
#ifdef PARANOID
return VINF_SUCCESS;
#ifdef PARANOID
return VINF_SUCCESS;
#ifdef PARANOID
return VINF_SUCCESS;
return VINF_SUCCESS;
return VERR_IOM_IOPORT_UNUSED;
return VINF_SUCCESS;
return VERR_IOM_IOPORT_UNUSED;
return VINF_SUCCESS;
return VERR_IOM_IOPORT_UNUSED;
return VINF_SUCCESS;
return VERR_IOM_IOPORT_UNUSED;
#ifdef VBOX
#ifdef VBOX
write_page, d);
read_page, d);
if (pageh_base >= 0) {
#ifdef VBOX
write_pageh, d);
read_pageh, d);
#ifdef VBOX
write_cont, d);
read_cont, d);
#ifndef VBOX
dma_reset(d);
#ifdef VBOX
return -EINVAL;
#ifndef VBOX
#ifdef VBOX
unsigned nchan,
void *opaque)
unsigned nchan,
void *buf,
unsigned nchan,
const void *buf,
unsigned nchan,
unsigned level)
if (level) {
return VINF_SUCCESS;
AssertFailed ();
int iInstance,
bool high_page_enable = 0;
int rc;
return rc;
return rc;
return rc;
return VINF_SUCCESS;
sizeof(DMAState),
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,