/* Blackfin Direct Memory Access (DMA) Channel model.
- Copyright (C) 2010-2011 Free Software Foundation, Inc.
+ Copyright (C) 2010-2024 Free Software Foundation, Inc.
Contributed by Analog Devices, Inc.
This file is part of simulators.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
-#include "config.h"
+/* This must come before any other includes. */
+#include "defs.h"
+
+#include <stdlib.h>
#include "sim-main.h"
#include "devices.h"
case DMAFLOW_ARRAY:
if (ndsize == 0 || ndsize > 7)
hw_abort (me, "DMA config error: DMAFLOW_ARRAY requires NDSIZE 1...7");
- sim_read (hw_system (me), dma->curr_desc_ptr, (void *)flows, ndsize * 2);
+ sim_read (hw_system (me), dma->curr_desc_ptr, flows, ndsize * 2);
break;
case DMAFLOW_SMALL:
if (ndsize == 0 || ndsize > 8)
hw_abort (me, "DMA config error: DMAFLOW_SMALL requires NDSIZE 1...8");
- sim_read (hw_system (me), dma->next_desc_ptr, (void *)flows, ndsize * 2);
+ sim_read (hw_system (me), dma->next_desc_ptr, flows, ndsize * 2);
break;
case DMAFLOW_LARGE:
if (ndsize == 0 || ndsize > 9)
hw_abort (me, "DMA config error: DMAFLOW_LARGE requires NDSIZE 1...9");
- sim_read (hw_system (me), dma->next_desc_ptr, (void *)flows, ndsize * 2);
+ sim_read (hw_system (me), dma->next_desc_ptr, flows, ndsize * 2);
break;
default:
hw_abort (me, "DMA config error: invalid DMAFLOW %#x", dma->config);
dma->ndph = _flows[1];
--ndsize;
++flows;
+ ATTRIBUTE_FALLTHROUGH;
case DMAFLOW_SMALL:
dma->ndpl = _flows[0];
--ndsize;
/* XXX: This sucks performance wise. */
nr_bytes = dma->ele_size;
else
- nr_bytes = MIN (sizeof (buf), dma->curr_x_count * dma->ele_size);
+ nr_bytes = min (sizeof (buf), dma->curr_x_count * dma->ele_size);
/* Pumping a chunk! */
bfin_peer->dma_master = me;
bu32 *value32p;
void *valuep;
+ /* Invalid access mode is higher priority than missing register. */
+ if (!dv_bfin_mmr_require_16_32 (me, addr, nr_bytes, true))
+ return 0;
+
if (nr_bytes == 4)
value = dv_load_4 (source);
else
value = dv_load_2 (source);
mmr_off = addr % dma->base;
- valuep = (void *)((unsigned long)dma + mmr_base() + mmr_off);
+ valuep = (void *)((uintptr_t)dma + mmr_base() + mmr_off);
value16p = valuep;
value32p = valuep;
if (nr_bytes == 4)
*value32p = value;
else
- *value16p = value;
+ *value16p = value;
}
else
HW_TRACE ((me, "discarding write while dma running"));
default:
/* XXX: The HW lets the pad regions be read/written ... */
dv_bfin_mmr_invalid (me, addr, nr_bytes, true);
- break;
+ return 0;
}
return nr_bytes;
bu32 *value32p;
void *valuep;
+ /* Invalid access mode is higher priority than missing register. */
+ if (!dv_bfin_mmr_require_16_32 (me, addr, nr_bytes, false))
+ return 0;
+
mmr_off = addr % dma->base;
- valuep = (void *)((unsigned long)dma + mmr_base() + mmr_off);
+ valuep = (void *)((uintptr_t)dma + mmr_base() + mmr_off);
value16p = valuep;
value32p = valuep;