OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [tags/] [nog_patch_39/] [or1ksim/] [peripheral/] [dma.c] - Diff between revs 261 and 418

Go to most recent revision | Show entire file | Details | Blame | View Log

Rev 261 Rev 418
Line 29... Line 29...
#include "trace.h"
#include "trace.h"
#include "pic.h"
#include "pic.h"
#include "abstract.h"
#include "abstract.h"
#include "fields.h"
#include "fields.h"
 
 
#define dprintf(x) printf x
 
 
 
/* The representation of the DMA controllers */
/* The representation of the DMA controllers */
static struct dma_controller dmas[NR_DMAS];
static struct dma_controller dmas[NR_DMAS];
 
 
static unsigned long dma_read32( unsigned long addr );
static unsigned long dma_read32( unsigned long addr );
static void dma_write32( unsigned long addr, unsigned long value );
static void dma_write32( unsigned long addr, unsigned long value );
Line 320... Line 318...
                if ( !TEST_FLAG( channel->regs.csr, DMA_CH_CSR, CH_EN ) )
                if ( !TEST_FLAG( channel->regs.csr, DMA_CH_CSR, CH_EN ) )
                        continue;
                        continue;
 
 
                /* Do we need to abort? */
                /* Do we need to abort? */
                if ( TEST_FLAG( channel->regs.csr, DMA_CH_CSR, STOP ) ) {
                if ( TEST_FLAG( channel->regs.csr, DMA_CH_CSR, STOP ) ) {
                        dprintf(( "DMA: STOP requested\n" ));
                        debug( 3,  "DMA: STOP requested\n" );
                        CLEAR_FLAG( channel->regs.csr, DMA_CH_CSR, CH_EN );
                        CLEAR_FLAG( channel->regs.csr, DMA_CH_CSR, CH_EN );
                        CLEAR_FLAG( channel->regs.csr, DMA_CH_CSR, BUSY );
                        CLEAR_FLAG( channel->regs.csr, DMA_CH_CSR, BUSY );
                        SET_FLAG( channel->regs.csr, DMA_CH_CSR, ERR );
                        SET_FLAG( channel->regs.csr, DMA_CH_CSR, ERR );
 
 
                        if ( TEST_FLAG( channel->regs.csr, DMA_CH_CSR, INE_ERR ) &&
                        if ( TEST_FLAG( channel->regs.csr, DMA_CH_CSR, INE_ERR ) &&
Line 343... Line 341...
                        continue;
                        continue;
                }
                }
 
 
                /* If this is the first cycle of the transfer, initialize our state */
                /* If this is the first cycle of the transfer, initialize our state */
                if ( !TEST_FLAG( channel->regs.csr, DMA_CH_CSR, BUSY ) ) {
                if ( !TEST_FLAG( channel->regs.csr, DMA_CH_CSR, BUSY ) ) {
                        dprintf(( "Starting new transfer\n" ));
                        debug( 4,  "DMA: Starting new transfer\n" );
 
 
                        CLEAR_FLAG( channel->regs.csr, DMA_CH_CSR, DONE );
                        CLEAR_FLAG( channel->regs.csr, DMA_CH_CSR, DONE );
                        CLEAR_FLAG( channel->regs.csr, DMA_CH_CSR, ERR );
                        CLEAR_FLAG( channel->regs.csr, DMA_CH_CSR, ERR );
                        SET_FLAG( channel->regs.csr, DMA_CH_CSR, BUSY );
                        SET_FLAG( channel->regs.csr, DMA_CH_CSR, BUSY );
 
 
Line 360... Line 358...
                        /* Set our internal status */
                        /* Set our internal status */
                        dma_init_transfer( channel );
                        dma_init_transfer( channel );
 
 
                        /* Might need to skip descriptor */
                        /* Might need to skip descriptor */
                        if ( CHANNEL_ND_I( channel ) ) {
                        if ( CHANNEL_ND_I( channel ) ) {
                                dprintf(( "DMA: dma_nd_i asserted before dma_req_i, skipping descriptor\n" ));
                                debug( 3,  "DMA: dma_nd_i asserted before dma_req_i, skipping descriptor\n" );
                                dma_channel_terminate_transfer( channel, 0 );
                                dma_channel_terminate_transfer( channel, 0 );
                                continue;
                                continue;
                        }
                        }
                }
                }
 
 
Line 379... Line 377...
                /* Have we finished a whole chunk? */
                /* Have we finished a whole chunk? */
                channel->dma_ack_o = (channel->words_transferred % channel->chunk_size == 0);
                channel->dma_ack_o = (channel->words_transferred % channel->chunk_size == 0);
 
 
                /* When done with a chunk, check for dma_nd_i */
                /* When done with a chunk, check for dma_nd_i */
                if ( CHANNEL_ND_I( channel ) ) {
                if ( CHANNEL_ND_I( channel ) ) {
                        dprintf(( "DMA: dma_nd_i asserted\n" ));
                        debug( 3,  "DMA: dma_nd_i asserted\n" );
                        dma_channel_terminate_transfer( channel, 0 );
                        dma_channel_terminate_transfer( channel, 0 );
                        continue;
                        continue;
                }
                }
 
 
                /* Are we done? */
                /* Are we done? */
Line 432... Line 430...
 
 
 
 
/* Take care of transfer termination */
/* Take care of transfer termination */
void dma_channel_terminate_transfer( struct dma_channel *channel, int generate_interrupt )
void dma_channel_terminate_transfer( struct dma_channel *channel, int generate_interrupt )
{
{
        dprintf(( "DMA: Terminating transfer\n" ));
        debug( 4,  "DMA: Terminating transfer\n" );
 
 
        /* Might be working in a linked list */
        /* Might be working in a linked list */
        if ( channel->load_next_descriptor_when_done ) {
        if ( channel->load_next_descriptor_when_done ) {
                dma_load_descriptor( channel );
                dma_load_descriptor( channel );
                dma_init_transfer( channel );
                dma_init_transfer( channel );

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.