|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 % K3 _& m& U% d p" ~" X+ B
- [code]EDMA sample test application
! f; q' A) |, o6 P - /*
1 G$ s; ^: J: ~2 T6 l: v - * edma_test.c
% q% Z6 y7 a5 N3 ~0 \% U - *
# k4 L* B5 C0 |$ h1 B - * brief EDMA3 Test Application+ u. `8 M9 ~! ?5 T7 V. ^
- *8 \; x' I& j0 X; g+ }/ I, s3 `
- * This file contains EDMA3 Test code., u* D* U" k4 A7 n$ V8 N
- *& J4 j, b1 S0 _/ M% i
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
8 x3 u) b. ^ a% h \) N - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT% T/ g" A$ a9 X
- * TO CHANGE.* ]" j* m# v/ S' c( O
- *
: G* R4 v) L# r- x9 A7 k7 ^ - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
u/ ] j' X+ q" Y - *
( n0 m8 ]. E; t1 E4 Q - * This program is free software; you can redistribute it and/or: j7 O# J& m: E% \3 F ]" R
- * modify it under the terms of the GNU General Public License as1 S: J* n8 ^! p4 ^5 z
- * published by the Free Software Foundation version 2.8 Y, `+ ?. n8 ?
- *, }- R% Y( W1 E' B$ k/ _
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any
) d7 U% |* z' S - * kind, whether express or implied; without even the implied warranty/ I5 w. E$ c+ B% T
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
& |) v- G G( L# O - * GNU General Public License for more details.
6 d/ r: {( {- j9 R& {6 D# I6 T - */
9 d" n1 s4 |3 K. ]1 s9 ~
+ N& s5 G2 A) F2 r2 a8 ?& o6 C- #include <linux/module.h>! e+ _! M% L2 C( V& I% h/ A
- #include <linux/init.h>
3 r# {' h* h2 N- f0 I' b. H - #include <linux/errno.h>
" t `3 P3 R$ ?9 k - #include <linux/types.h>9 f* k \8 E8 J$ N0 r) t
- #include <linux/interrupt.h>
( B( Y2 c3 W3 W - #include <asm/io.h>4 b- i: L* S% @1 s% F8 C
- #include <linux/moduleparam.h>( }$ w& ], ^2 @& H% k8 e( ?. ^
- #include <linux/sysctl.h>
, X; b8 V+ ^+ |" H5 d# G1 ^4 ^ - #include <linux/mm.h>
3 n, v* I* R$ A: e4 x# ]4 p% H' u - #include <linux/dma-mapping.h>
. r* y3 x( Z$ o. L5 W( w
/ |8 E/ Q/ |: L/ x3 F; i; z5 V- #include <mach/memory.h>
; ]6 D+ P ~1 ^/ a& n - #include <mach/hardware.h>" V# R+ ]4 b w4 w. e. g
- #include <mach/irqs.h> t+ T+ C8 M5 z x
- #include <asm/hardware/edma.h>
6 f% v1 R% w2 m4 S% _: O+ R3 K
7 D" A" N. R4 w! i4 l8 R5 A( h7 X- #undef EDMA3_DEBUG
- G/ Y# _) B9 h- |, `6 h - /*#define EDMA3_DEBUG*/
0 j7 [. ?6 @* r" F3 F1 ?& `
# f3 p/ Y2 E t0 U4 r0 v- #ifdef EDMA3_DEBUG
6 j* A/ v' ~) E" c - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)5 W* P" }6 z8 j3 D z' J
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)/ f" K4 v- P# N" [8 v d
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
. m2 o- x. f8 j - #else- z0 L/ B5 N% E, W m
- #define DMA_PRINTK( x... )3 R+ l1 S! u" t9 P1 B; R& O; n
- #define DMA_FN_IN$ `1 P1 y6 o7 O$ C6 b7 R
- #define DMA_FN_OUT9 d* B# ^6 T1 t% ^3 a% s
- #endif% ?/ o' i( i! k6 i: T
- 6 z) ?2 i* i) L8 r5 Y' m
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
2 X" x+ P: D6 E" W) e" o - #define STATIC_SHIFT 3
8 U, y0 f( z0 b, d1 v7 _ - #define TCINTEN_SHIFT 20. ~6 J" ~% p1 M5 W
- #define ITCINTEN_SHIFT 21) I1 t+ F+ {+ {, n7 l3 b
- #define TCCHEN_SHIFT 22
1 m+ S5 Q7 Z! J' G - #define ITCCHEN_SHIFT 23
5 p9 r6 L: x9 i. p( a# u
' u4 S9 `6 U' s, S- static volatile int irqraised1 = 0;
g+ O# \8 ~! J6 D - static volatile int irqraised2 = 0;3 R- B" Y% C" m& B
- 1 u K/ j* Z& L3 x: S" v0 v5 H) b
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);& E, J" Z& H) L m E
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
$ {3 Y) p1 e* T9 u) p4 O. I - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);3 C& ~, Q- c+ b& H3 }
- - K ?* c6 S3 S# N* w
- dma_addr_t dmaphyssrc1 = 0;! l! p) p: |: o* _1 T
- dma_addr_t dmaphyssrc2 = 0;
% K4 o, v$ z* c4 @# k+ {* n - dma_addr_t dmaphysdest1 = 0;* Y4 A4 _: i* ?7 I1 i; u3 A
- dma_addr_t dmaphysdest2 = 0;
. V' f4 u7 ~4 Z% \
* V4 k0 E9 C2 d6 b6 k- char *dmabufsrc1 = NULL;
: T, f0 s# ]* N `+ D; n+ F - char *dmabufsrc2 = NULL;
( D; j" D. o( a: p' o, ?2 [ - char *dmabufdest1 = NULL;
! j' @& x9 @6 H+ G6 N0 o8 t/ s* x - char *dmabufdest2 = NULL;
E+ T2 y; V$ r3 X `
- Y! ]* ?& K% L$ g- J) J0 e7 w, k6 V6 d- static int acnt = 512;
5 M. @" x1 L4 O3 t8 [6 ?& Y2 ~ M5 @1 ~ - static int bcnt = 8;3 v G; l5 }5 L
- static int ccnt = 8;( [$ i& {" Y+ I7 h
+ r0 t3 Y# V4 K$ s2 T' A& ]- module_param(acnt, int, S_IRUGO);7 o: B5 k5 X" A$ ^$ P# t' Y
- module_param(bcnt, int, S_IRUGO);. a) J6 I9 J( w: y
- module_param(ccnt, int, S_IRUGO);
复制代码 ! X( |! B, s! L3 j
- D3 O4 }" H( J5 ^" }
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
$ X" G: T* t8 O# x/ A3 A u5 _arm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
5 O1 h- {$ J- B9 F+ ~' f 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。# ~, _5 Y$ L. F9 x& E: R- O
8 ?/ g1 ?# _ Z' |; e7 p- R* E1 R" Q y
|
|