|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 % W9 [& z" B% n0 S' y
- [code]EDMA sample test application
, P: f t' Q: A# W# ^! T6 n - /*; f1 T1 F+ c5 w
- * edma_test.c( W) \# U% m7 y. @- Z$ f. ~; r
- *
! p' B! n8 @8 ~2 c, l# u+ f - * brief EDMA3 Test Application
2 Q/ _: H; [- a+ w# D$ m- R8 o - *
" t+ F, i9 A6 o4 c5 \4 J9 S. P - * This file contains EDMA3 Test code.
! j9 t& n# T+ D* a/ ~ - *( ^: q. J9 R V; {5 t# f
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE3 m6 q9 n& ]+ z$ ~/ Q; h& R
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
% z) O' j1 `5 Q - * TO CHANGE.- ~& g$ D% q G+ {+ k. l
- ** y6 }$ ?: z Z2 _& l7 b! K
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/! `/ q! o3 U) `4 Z2 r& \
- *8 @% J% m) b3 W
- * This program is free software; you can redistribute it and/or1 n$ h: n5 _8 T* X- y9 ?0 T! ^
- * modify it under the terms of the GNU General Public License as
$ H# T: i- b) D! i8 D* ] P+ j$ k - * published by the Free Software Foundation version 2.
1 d. C& n3 v0 Q/ t - *
6 o$ _2 X+ a& E& b - * This program is distributed "as is" WITHOUT ANY WARRANTY of any0 U5 C4 w7 {/ h3 W# ]
- * kind, whether express or implied; without even the implied warranty7 e' H8 H% R3 t1 S% `3 z- a, |* `0 i
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9 D8 X* }" O$ Y. `) c$ r - * GNU General Public License for more details." t! m% ]" p) l6 \9 a9 Z- n7 m/ O9 ^( c7 |
- */- a* F" ?+ Q8 g. y) x8 V' j" G
/ I" T' p, J5 S" C( f- #include <linux/module.h>; P* X+ N. B9 \8 ^' j2 d
- #include <linux/init.h>
9 e& q0 d/ \- ^% j- s1 p8 j: a - #include <linux/errno.h>! f5 q6 f5 D- q% H( j
- #include <linux/types.h>8 T% J& j+ m, r- }, t' ^- ], g
- #include <linux/interrupt.h>4 W5 A4 c- l2 N' W+ T/ J, W& e
- #include <asm/io.h>; B( M0 | ?" d: T6 o) c8 v3 u
- #include <linux/moduleparam.h>
* o+ o7 \# G1 n - #include <linux/sysctl.h>
! C% J- k; ~, H4 W$ [ - #include <linux/mm.h>/ o; _) x8 B9 p5 }3 b; @; B
- #include <linux/dma-mapping.h> |! \4 c" j3 p! C* }3 ?
! P0 X9 _9 `( B8 Z3 \: d- #include <mach/memory.h>7 @( D. L d; \5 V. C
- #include <mach/hardware.h>5 {1 w+ g7 ]9 H6 [: X
- #include <mach/irqs.h>1 _0 v: Z. r) e6 O3 G: `
- #include <asm/hardware/edma.h>) C8 ?. X3 w! A, q
- 7 o& K$ C' ~9 G P8 v _
- #undef EDMA3_DEBUG
! f% \! ~) G- h5 i. i! x - /*#define EDMA3_DEBUG*/
o/ M! J$ U: Z, v0 W! Y! m
4 W& I+ D5 p. R7 L0 }- #ifdef EDMA3_DEBUG5 W0 a, ^& a- [
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)" k# a7 n) q v9 R
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
5 y) S' u) s# W% s& S5 s( C. ]7 X - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)9 I' t3 @- @8 C5 S# G
- #else _$ f; T3 ^5 h5 m
- #define DMA_PRINTK( x... )
7 J( H6 K, d0 x6 w1 o2 r8 L+ w# \ - #define DMA_FN_IN
. D% u( v7 C+ Y - #define DMA_FN_OUT! I! L7 p8 U/ T! Y+ } ?- b
- #endif" C5 i& l( n& o- t- m
. B/ Z# j3 `" I- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
' ?4 Z! r5 p8 i [8 t - #define STATIC_SHIFT 38 y4 v: F. u% D0 G! l3 C9 `
- #define TCINTEN_SHIFT 20
2 ?/ K6 A$ {7 Q7 M8 N" w - #define ITCINTEN_SHIFT 21
! l, m! q& R! m( c( o9 p' W2 O - #define TCCHEN_SHIFT 22
7 a; m% @; m3 M' j. Y - #define ITCCHEN_SHIFT 23% B7 `. R( w4 w9 x8 w/ q
- " A5 T+ _! ~$ @" L/ q) z
- static volatile int irqraised1 = 0;
# R3 G( u) K* i/ Z3 W! H! x$ q+ { - static volatile int irqraised2 = 0;9 t7 R& ^ f: O9 u/ a
" H& W) A s5 Y, v( o- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
/ P9 R1 ]; J0 E) f- z- ^1 |1 W- f# { - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);$ y* H+ h$ I7 o
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
0 D& o# p* K9 w
8 W+ m2 s; S o5 v4 h- dma_addr_t dmaphyssrc1 = 0;9 m" W' R4 o1 }8 F+ N
- dma_addr_t dmaphyssrc2 = 0;. P8 Y7 b2 E, t# }/ j, p
- dma_addr_t dmaphysdest1 = 0;/ S. ^0 v# b! y( D: d. U2 l8 p
- dma_addr_t dmaphysdest2 = 0;
) E/ `4 u: Y; r9 P - * E' } J0 o) s
- char *dmabufsrc1 = NULL;
Y2 p' l- j4 _/ w6 B6 k - char *dmabufsrc2 = NULL;$ R: U- z' A( l! h+ {$ z
- char *dmabufdest1 = NULL;7 l( ]$ C5 z' C4 J
- char *dmabufdest2 = NULL;
! x1 K2 X* O) O, G - 7 g0 D0 `0 P; G2 y% z9 ]! q* X
- static int acnt = 512;( z w# Q! Q0 a) t) g
- static int bcnt = 8;( b5 B9 W" }1 q+ S6 ~% p1 F
- static int ccnt = 8;
B5 }8 I% E+ x) ]6 O - & I1 K4 r: K6 L: t
- module_param(acnt, int, S_IRUGO);% I/ q( X& l9 @ K9 k! \
- module_param(bcnt, int, S_IRUGO);
8 V' }. f( o) ^! h) W - module_param(ccnt, int, S_IRUGO);
复制代码 ' l/ J$ |( ~% ^( @
- j) ~# W6 Y+ Z# ^
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用6 i& {. a- ^" S5 ~/ Q& a( R
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
0 I3 ]! `# x. W$ S4 f8 {# N 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
: e1 S: P& r. a. B) Q: T- l* C2 F
7 A5 W3 X) y+ r2 o8 t7 U# d |
|