- Main Page
- Modules
- Data Structures
- Files

- File List
- Globals

# /space/home/slher/rel/Beken/v6_4_5/macsw/plf/refip/src/driver/dma/dma.c

Go to the documentation of this file.

    00001
    00013 /*
    00014  * INCLUDE FILES
    00015  ****************************************************************************************
    00016  */
    00017 // for NULL
    00018 #include <stddef.h>
    00019 #include <string.h>
    00020
    00021 #include "dma.h"
    00022 #include "reg_dma.h"
    00023 #include "co_utils.h"
    00024
    00025 struct dma_env_tag dma_env;
    00026
    00027 void dma_init(void)
    00028 {
    00029     memset(dma_env.last_dma, 0, sizeof(dma_env.last_dma));
    00030
    00031     // configure the channel priorities
    00032     dma_arbitration_set(0x0C);
    00033
    00034     // configure the interrupts (enable all interrupts)
    00035     dma_int_unmask_set(DMA_ERROR_BIT | DMA_LLI_IRQ_MASK);
    00036 }
    00037
    00038 void dma_push(struct dma_desc *first, struct dma_desc *last, int channel_idx)
    00039 {
    00040     uint32_t value;
    00041
    00042     // current DMA descriptor is pushed at the end of the list
    00043     last->next = 0;
    00044
    00045     // prevent accesses to the same DMA channel from both BK and IRQ simultaneously
    00046     GLOBAL_INT_DISABLE();
    00047
    00048     // set the MUTEX
    00049     dma_channel_mutex_set(1 << channel_idx);
    00050
    00051     // read the root in the DMA HW
    00052     if (channel_idx == IPC_DMA_CHANNEL_INTERNAL)
    00053         value = dma_ch4_lli_root_get();
    00054     else
    00055         value = dma_ch_lli_root_get(channel_idx);
    00056
    00057     // check if the root is empty
    00058     if (value)
    00059     {
    00060         // sanity check: the last MUST be valid because the root is not empty
    00061         ASSERT_ERR(dma_env.last_dma[channel_idx] != 0);
    00062
    00063         // append the descriptor to the last LLI of the list
    00064         dma_env.last_dma[channel_idx]->next = CPU2HW(first);
    00065
    00066         // clear the MUTEX
    00067         dma_channel_mutex_clear(1 << channel_idx);
    00068     }
    00069     else
    00070     {
    00071         // write directly the DMA to the root
    00072         if (channel_idx == IPC_DMA_CHANNEL_INTERNAL)
    00073             dma_ch4_lli_root_set(CPU2HW(first));
    00074         else
    00075             dma_ch_lli_root_set(channel_idx, CPU2HW(first));
    00076     }
    00077
    00078     // save the new last LLI descriptor on this channel
    00079     dma_env.last_dma[channel_idx] = last;
    00080
    00081     // restore interrupts
    00082     GLOBAL_INT_RESTORE();
    00083 }
    00084
    00085 void dma_buserr_isr(void)
    00086 {
    00087     // For now consider this error as a fatal one
    00088     ASSERT_ERR(0);
    00089 }
    00090
    00091
    00092