|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 3 S% C; a- ~7 |8 M+ U
- [code]EDMA sample test application- N. u4 n1 A) M8 u+ x Y
- /*
- E, p8 ^- S( J3 Y; L/ o# t( T - * edma_test.c
- x7 ?: Z8 B, m% a! r5 } l t - *2 Q: O" _$ Z( g1 c) m
- * brief EDMA3 Test Application5 R, y7 L2 B# Y9 j) N% V X7 s1 ^
- *; F g2 c& `0 C
- * This file contains EDMA3 Test code.+ R3 e1 b% W4 [, u' N. w) t+ c5 {
- *+ `; j- n1 A9 r
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE+ {+ [) K8 q- c
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT# {* j8 ^* `' h+ H, Y
- * TO CHANGE.
7 p! q7 e! F& ?# J - ** _1 V# Y5 S8 z6 s3 m
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/7 [2 ^ C, D6 }" Q8 N- V5 j2 _
- *# j8 T k3 A* N
- * This program is free software; you can redistribute it and/or
# {# m2 K S+ N& v4 R7 Y - * modify it under the terms of the GNU General Public License as
, K6 i, Z2 {5 T3 D - * published by the Free Software Foundation version 2./ B$ n. y6 d; Z2 g4 q1 Y8 L
- *- C; b, j- A1 e9 G
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any9 z6 H) K& \" U8 @0 n
- * kind, whether express or implied; without even the implied warranty# F$ k! |0 V. A8 o
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1 i0 u/ T! j9 Y4 I- Y/ ` - * GNU General Public License for more details.
# t& ^2 A2 f/ g# h4 E# Y - */ m. C% A( E2 G S' l W% ?
- ; f. f% I7 _& f2 @
- #include <linux/module.h>
5 @& B' D( V, J& \9 [ - #include <linux/init.h>
! n+ p" T. `( \, }6 C- `4 E) Q - #include <linux/errno.h>3 H( u) U3 G c0 b1 J/ _5 F7 q
- #include <linux/types.h>1 p: e, Z, v0 ^
- #include <linux/interrupt.h>$ r H% |2 n D4 i z, v
- #include <asm/io.h>
- L* E* e& z9 Q: q* i4 W2 h - #include <linux/moduleparam.h>" o1 k: ^& G* C2 D r
- #include <linux/sysctl.h>
1 u" r. @; \& G; p3 k: Q. B - #include <linux/mm.h>) |4 X6 z- v4 E w. `
- #include <linux/dma-mapping.h>
) s. v; M9 K. e9 ~! \2 g. C4 g
" n7 Q; }3 T2 U3 A- #include <mach/memory.h>
9 g+ ]2 K5 l+ Z) k8 w' p# ^ - #include <mach/hardware.h>6 t+ A1 X' y0 s3 U
- #include <mach/irqs.h>
* B! ~! L5 g: q/ z) e# U - #include <asm/hardware/edma.h>% o) k6 V2 m( ]
- 8 M7 K' L' w' }3 o6 c+ P
- #undef EDMA3_DEBUG, z- b1 U# H/ }
- /*#define EDMA3_DEBUG*/
- p1 W: t* c) S$ b4 z' M8 y - % B0 D j0 n% n' a
- #ifdef EDMA3_DEBUG
+ V2 D& j% i1 L - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)! e6 b* P% w3 W3 z/ R0 y7 |* ]
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
$ T, r& E% c* S - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
+ `0 P" _9 g/ G6 f - #else6 v4 O8 b2 R. T' Z) O2 h0 [, g
- #define DMA_PRINTK( x... )
5 n8 D% J$ X& @* t! C0 u - #define DMA_FN_IN# P, ~$ `- A/ k, v1 R' x3 B
- #define DMA_FN_OUT
; X( r8 |. f! ~" R! i! ~0 s - #endif
* W" ]6 p# [+ R' W+ U3 [ - ' X- n: y$ M1 ~
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)! v M, o [7 M' Z, {" a
- #define STATIC_SHIFT 3# r+ N) l' T7 h$ V' p d0 z
- #define TCINTEN_SHIFT 20
' g4 G" q# Y- W+ I( S3 ~ - #define ITCINTEN_SHIFT 21
& Y y2 Y+ [* p% }/ k - #define TCCHEN_SHIFT 22
. }' n1 n4 b' m3 p+ c( L. O - #define ITCCHEN_SHIFT 23
+ l2 D+ |" U( j- l9 a - 9 j' Y; Z: L$ j2 U+ v- Z
- static volatile int irqraised1 = 0;
: d; P! E5 d7 c% ^6 T - static volatile int irqraised2 = 0;
" ^1 C. M- n9 N6 @" K
$ o+ K2 M7 s1 K, p/ F6 G: w: v- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);$ Z, T8 ?; d; n* u: O
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
0 R! j/ Q6 h5 E9 s - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);9 l8 F0 u' Y% ]: S
' [4 _$ S" Z0 u- dma_addr_t dmaphyssrc1 = 0;' o0 d5 R& T$ [; b4 t x
- dma_addr_t dmaphyssrc2 = 0;7 o n4 W7 F3 D$ b9 _3 k
- dma_addr_t dmaphysdest1 = 0;7 l; P) C- Z+ _/ e( i3 G; w
- dma_addr_t dmaphysdest2 = 0;
: X0 }4 S4 i7 P/ o8 a1 Q
+ w( B& e& q R4 [- char *dmabufsrc1 = NULL;) B$ W/ J9 l: d7 b9 O0 s* o9 \
- char *dmabufsrc2 = NULL;
; a$ g7 n& [% n( h - char *dmabufdest1 = NULL;" K: B. |* c1 v
- char *dmabufdest2 = NULL;
/ e* B: k6 [, {( J2 G
& l# U+ ^( q7 }4 b% v- static int acnt = 512;
; s4 T* f. ~4 g w2 u8 \$ }: B - static int bcnt = 8;
+ w7 [) Z0 n, M8 o - static int ccnt = 8;5 [; ?4 Y1 L5 q# H" a
$ |/ ~% o" m1 r- j/ ]9 P: Y- module_param(acnt, int, S_IRUGO);
! p; U. {. b$ z q9 ?( U- G - module_param(bcnt, int, S_IRUGO);
: `! H0 i7 z# z$ n# d. G - module_param(ccnt, int, S_IRUGO);
复制代码 , C$ v5 `9 U* M8 A% [6 D
, v5 b. ~( D: E! s, s- K1 n z' a- ~' @
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
& R" }/ U# C- ?- D! H7 c$ K& ?; Carm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
" J+ s9 v/ p1 u0 D0 Z, c 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。' y( Y, Q1 ~8 S7 ]
' Y# D' _% N/ ~! r* j
8 X$ V4 Y d% U% Z& r9 o, G: ] |
|