|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 ( P( ?/ o3 G! N; @- m. a
- [code]EDMA sample test application
2 f0 W2 {+ a# x3 z2 I7 W! r F - /*
5 Y' q- T! ^! S0 Q* ~& E' H( c! y - * edma_test.c. X) }; O3 ~! L
- *& |9 H+ I! j; h) m( m: G( {) e
- * brief EDMA3 Test Application9 `# N3 z( R* I: z/ d
- * @" Q. G3 O# j4 K% c
- * This file contains EDMA3 Test code.
, m8 u4 H) J" L) p# N( K - *# F! r1 `; E3 q# j9 [! ^& c$ A
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE) q9 E; W/ ?; V# }* h. N
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT) [' \; U7 O$ N% @' T1 \
- * TO CHANGE.
5 R. @- M* G+ y: W - *! p* y3 j, m# T/ \* b
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/% g, o3 \4 r' L% ~0 W, R8 L5 c+ A0 y
- *7 D m+ C* G" W. x; X2 c
- * This program is free software; you can redistribute it and/or* {; i: g' v1 _
- * modify it under the terms of the GNU General Public License as u5 ?) [; P! a+ r6 E
- * published by the Free Software Foundation version 2.
# _" r, \: P! K& P - *' B0 {2 y0 a/ j( }
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any
! Y. _ u4 i, c5 w2 k - * kind, whether express or implied; without even the implied warranty
a9 i9 o$ T; I8 E5 ? - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
$ ?8 f9 K) E: ^! Q- g9 f2 z( M0 C- T - * GNU General Public License for more details.
7 z5 s `1 }- ~7 m6 A% F5 c- c - */
9 m' L4 I5 @+ B( ^( w
: ]6 V* \) s9 f1 y# D1 z9 ^- #include <linux/module.h>8 \1 u- `; @0 P A8 A+ v7 f: a' P; O
- #include <linux/init.h>
" d) O3 \8 R5 I! h( R - #include <linux/errno.h>
% \6 ^, _( k: K0 f" D& b - #include <linux/types.h>
( y% @( K0 B0 @- R - #include <linux/interrupt.h>! A8 y' B# y; k) ~3 L4 q
- #include <asm/io.h>: H+ C. Z, s5 V9 p
- #include <linux/moduleparam.h>5 |8 }0 ^4 ~( M9 X
- #include <linux/sysctl.h>3 n3 Y9 c' B5 \6 A
- #include <linux/mm.h>
, ?9 P+ R4 }, ^5 N6 Q - #include <linux/dma-mapping.h>9 l, {3 L1 U/ [
2 y, X2 y; ?2 T9 F+ M7 y% L- #include <mach/memory.h>: V3 ]+ G, D9 W, z$ m
- #include <mach/hardware.h>
! D+ ?) H% }! _2 q5 I5 y0 \# M- x - #include <mach/irqs.h>5 o6 I Y+ ~& [
- #include <asm/hardware/edma.h>, C6 F$ j7 _0 @+ @. V
1 S8 ]7 {/ t: q7 _8 [& ]' k- #undef EDMA3_DEBUG+ q% w% L9 M2 j$ e4 [' u
- /*#define EDMA3_DEBUG*/* {9 L1 c, F8 g+ y9 u+ ?+ t1 [
4 n6 A2 p9 A. R, J5 _$ ?- #ifdef EDMA3_DEBUG1 }* l4 P. S* P$ |
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
, J7 U; g' G/ w J/ u* i- t - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)8 h9 |% ~! b% @: T) h
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
( N5 y3 v$ T) f; g) s - #else
5 \ C4 e9 p' i! [# m - #define DMA_PRINTK( x... )
4 q- }) m2 @* m - #define DMA_FN_IN
7 d; `& i5 ~1 s% {9 h - #define DMA_FN_OUT$ `$ B8 d" h5 O9 ?, A% m- f
- #endif {$ L4 P9 t; H2 N+ V; p
8 v9 v5 N6 p! i$ b N' W- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
1 F5 y: D% R- I# {5 L' T: [- W - #define STATIC_SHIFT 3
, ]& Q) d6 ~* O' w) u$ P5 F - #define TCINTEN_SHIFT 20
: n' e/ P& L) C% W4 T) Q - #define ITCINTEN_SHIFT 21: l" ~( M& |! W% a! j1 T
- #define TCCHEN_SHIFT 22
) \: A, ~$ f* k/ } - #define ITCCHEN_SHIFT 236 T* I1 R) Y) R# W+ Q& B1 G
; V6 v: y/ z) F# q4 [: F- static volatile int irqraised1 = 0;
, M# c+ H; M* s0 ]0 n - static volatile int irqraised2 = 0;
0 u. P6 |1 c3 t( ^/ P3 v* a/ Q
9 U! k; N, B- u; Y" E3 Z# s# I, U- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);. `$ ] ]! h; i m0 F& c' ]
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
0 g" O. W7 Y- j- X - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
- W6 P/ ~8 [+ P/ v - 2 D- ]4 V) x' r6 Y9 g1 n
- dma_addr_t dmaphyssrc1 = 0;
t( i! s% |1 v9 A: s/ \2 O - dma_addr_t dmaphyssrc2 = 0;% [( J! n) A' ?+ A$ S
- dma_addr_t dmaphysdest1 = 0;
, b) I6 N' N/ v% `& H3 l& R - dma_addr_t dmaphysdest2 = 0;3 }( G8 c& [# }2 e' _! P9 w. D$ i
9 O! g& |2 o) Q- h& k2 T7 }- char *dmabufsrc1 = NULL;: k5 D- F' c- J, U2 P
- char *dmabufsrc2 = NULL;
+ P3 Y( w1 k8 ?" W6 _* X( V- h) ^ - char *dmabufdest1 = NULL;
6 W$ k* K6 W+ r; Z. T, m - char *dmabufdest2 = NULL;
2 z- m6 m1 S2 s/ n
: p2 D$ H, T: c/ P% q$ i- static int acnt = 512;1 i- W; [( E. Q: t. P' e
- static int bcnt = 8;: c' Z# t6 x8 g6 i3 ~2 O
- static int ccnt = 8;- F4 n" G4 g, ^& E1 n
4 E( {. d/ V! [- module_param(acnt, int, S_IRUGO);" g2 v# E% z! x$ M& J) Y
- module_param(bcnt, int, S_IRUGO);. T @- O# Q+ Y7 E4 a) a( m3 j
- module_param(ccnt, int, S_IRUGO);
复制代码
; j# ^9 b$ U9 w" ^+ X) k0 @3 W5 G4 Q" T7 Y' e. d& s
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用9 V2 H2 m: u+ G+ O
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 i& u4 v8 p+ {, K. t 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
; d) q: y4 ~: N1 ]( c# a, y! O- t& e9 Z- ?# \. U$ Q. [& l3 N! Q
C1 T s1 \+ W. G3 A a; q |
|