|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 ! g* f3 d M6 w/ W( W8 b1 r
- [code]EDMA sample test application
% c% [; s& M9 j5 C* M8 I - /*/ k. r# f, [" H" T* w+ ]
- * edma_test.c6 j* J: D: l4 o
- *! j- Z/ {5 w) ~: h O8 ^, q
- * brief EDMA3 Test Application
; d5 @. o9 v4 N' g7 D - *
( ]3 X- T8 l4 J% [ - * This file contains EDMA3 Test code.
9 A5 q# v3 N* {# s5 O - *
, W0 ^, D5 L' P# P% T# | - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE& r# o" v2 U- S2 _, H3 _6 T
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
' i# z6 p$ V9 s' \5 t - * TO CHANGE.
' B8 K0 ^. m3 U4 q# z/ t - *
' T2 Z& Y* p/ ^* C4 O6 y4 ~" r# s, c - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/9 M& H2 \( Z( p
- *
1 j8 F8 ` o: T% Y$ y7 y h: f - * This program is free software; you can redistribute it and/or
* F7 W, Y3 f3 M1 }5 j2 f# S9 W - * modify it under the terms of the GNU General Public License as
: a0 Q/ x* ~6 U- _( J - * published by the Free Software Foundation version 2.
5 R; h2 ^8 u( f - *
" t5 i9 N _+ X: P5 c/ G0 B7 F - * This program is distributed "as is" WITHOUT ANY WARRANTY of any* K2 f4 K$ J: ~- c3 B% ?
- * kind, whether express or implied; without even the implied warranty7 {" p, c3 m% u- c6 Z& R/ ]
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the1 E8 `) B: O: l& k4 S
- * GNU General Public License for more details.
! h! F+ Z) r- |7 t6 G2 | - */& v' d' D5 r. @; v1 B
0 h, `" m0 }& [8 X- #include <linux/module.h>
- K" m/ D# Z: i% i- ~3 y - #include <linux/init.h>
# W8 C. h* g- _! N) |/ y - #include <linux/errno.h>
7 K( Y- S b6 o6 y6 D# q5 g |4 g - #include <linux/types.h>
, ~2 a4 ^; |* Q. P W5 A - #include <linux/interrupt.h>- j/ B! W n* B/ W* v
- #include <asm/io.h>* \, X4 U; u, }# i: R
- #include <linux/moduleparam.h>
, {0 H# o3 f b P - #include <linux/sysctl.h>7 W4 v# E1 ?5 u; C; b/ k/ b
- #include <linux/mm.h>
; j, w# ]8 @; p N' E - #include <linux/dma-mapping.h>' b* Y E4 M) X* u0 [4 e" V
1 \+ Q3 [1 Q$ y" R) P0 Y X- #include <mach/memory.h>, k0 `9 h3 }/ F) D: J
- #include <mach/hardware.h>
$ w' z) Z0 Q( m( s7 U3 { - #include <mach/irqs.h>
; v" G$ }3 [% X8 j - #include <asm/hardware/edma.h>
+ q$ @5 J! u% [
! M) ?" s* t' \5 X" j) X# _# k- #undef EDMA3_DEBUG9 @( p. \; `, J
- /*#define EDMA3_DEBUG*/
, W: x( _: Q% r6 u# F, o9 { - , D2 A2 E+ C+ |$ \2 ^
- #ifdef EDMA3_DEBUG- ]. {# P0 \! k
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS) X& [, m2 T: Z# Z4 L
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__): D; v5 m( Z) V
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
8 [8 E$ b E: U- x - #else
( N0 d) Z( F1 |' Z/ C3 u - #define DMA_PRINTK( x... )
+ g, k" b0 g2 ?+ G2 | - #define DMA_FN_IN
; j5 z* o% [( t( _4 {1 G - #define DMA_FN_OUT
) W1 _# U. ?. J+ d+ {4 {7 u p7 I2 ~ - #endif
& {# L( g i% R( T8 k - ( H1 w# q$ x, a
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
+ ?+ a+ a |6 Q+ s7 y - #define STATIC_SHIFT 3
4 k1 F' f- O0 c9 ], L - #define TCINTEN_SHIFT 20# b- w) Y; H' b4 u; |, \
- #define ITCINTEN_SHIFT 21
8 Y/ {; w& D/ X% V2 y - #define TCCHEN_SHIFT 22
: S% N2 f' l5 Y& g - #define ITCCHEN_SHIFT 23
) T$ p+ p, A; c3 W' a' \
+ q# x: ^' l$ i" A' J+ x5 A- static volatile int irqraised1 = 0;
2 ?7 h+ A7 | H5 C - static volatile int irqraised2 = 0;
2 {1 a% O# @& c* m8 B- f
+ Q7 }2 O4 I5 v9 M- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);6 y; E. I8 I- C: w
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);. _6 z2 U2 G5 \' w! e
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
4 C4 d' O2 ]3 [- y) U7 n- M: x$ V, g - 3 A0 _6 ]" F8 G# O* c# b
- dma_addr_t dmaphyssrc1 = 0;3 e) g% u; `$ l
- dma_addr_t dmaphyssrc2 = 0;) n! }" _0 C1 a$ C0 h$ I$ D
- dma_addr_t dmaphysdest1 = 0;
2 @4 n+ H6 P0 W/ B" b* t - dma_addr_t dmaphysdest2 = 0;4 v+ N; b p5 J5 @7 g$ }/ M7 L: C
+ q) t" G2 J W5 g2 h$ h- char *dmabufsrc1 = NULL;
# W0 z9 ^& L3 G% x) U/ D - char *dmabufsrc2 = NULL;! P& g# q* U+ I) k+ X
- char *dmabufdest1 = NULL;
7 e j) S! S: ~5 m8 y. c) @ - char *dmabufdest2 = NULL;2 ^- ]% M- c) e& {9 U: k
% T1 @* D% [4 S- k$ F. `4 t- C2 L. L- static int acnt = 512;. u. X" J0 T n! R& \
- static int bcnt = 8;
& I, ]& F6 Z9 C. u q) O - static int ccnt = 8;
- I2 w% ~( ~0 w
- t3 x; ?) n: C+ a- module_param(acnt, int, S_IRUGO);
9 ]9 I: _7 Q9 N6 E% b. N9 S - module_param(bcnt, int, S_IRUGO);
5 Q( t% q0 C. l: e1 g5 n - module_param(ccnt, int, S_IRUGO);
复制代码
3 f) S: b1 W) P& r* M+ G. I# |
, _. i/ @! S, ?. K: K 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
& U9 u+ G: v2 a, s3 Yarm-none-linux-gnueabi-gcc -I /home/tl/omapl138/linux-3.3/arch/arm/include -I /home/tl/omapl138/linux-3.3/include EDMA3test.cpp -o EDMA3这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。+ R9 x* K) r/ ~7 a0 c
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
4 T, A" P. W. |5 a5 z
* f, }) S4 Q! v0 C' S* t' m; H4 R/ P+ a3 ?1 m
|
|