|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
. p6 r3 {% E2 E; [9 a8 u$ ^- [code]EDMA sample test application5 x0 h4 G4 g4 _5 z- k: W) ^
- /*( s% v7 K5 M% a, C! m8 h4 P: @$ N
- * edma_test.c
& D: E9 d0 i% m - *
5 h$ q" M/ Y: ^1 B1 d }& W - * brief EDMA3 Test Application& z g, b( d- [( v, _( X
- *
) b. H/ Q# Y8 n L7 P/ P' X- u - * This file contains EDMA3 Test code.5 I/ s* J$ r0 X' I: C* x6 O
- *
$ ~/ y; _- v0 C7 c9 s - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
2 `) l( X* }6 ^+ L. e" U: B# L - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
d% k4 B# h5 ~/ c! s5 f - * TO CHANGE.3 u) w! k0 d$ j+ E! R
- *5 B; W8 t% c1 G( c1 b; p9 {
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/( [1 R- ]( D! D* v2 Y& b) f
- *
7 F) f( o8 Z& w$ q5 G6 Z \ - * This program is free software; you can redistribute it and/or
/ S9 K. ~" l) D% z - * modify it under the terms of the GNU General Public License as/ Q; x& _$ w7 ]" p5 {3 I' H% C
- * published by the Free Software Foundation version 2.
+ q4 \& J4 ?4 { - *
( u$ Q9 H, Y" Q5 X- g - * This program is distributed "as is" WITHOUT ANY WARRANTY of any
' x; j) w5 f1 d, M6 a5 t- f - * kind, whether express or implied; without even the implied warranty
& c. }; @3 ^, r$ B - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2 ~8 I% ~( U: Y; |/ E - * GNU General Public License for more details.
& ~) X5 y6 A# ~$ M3 u - */
$ }& ^% A7 i& M3 ]; H( F. w0 E - * K3 F( V& z' o3 s" ] j. w+ h
- #include <linux/module.h>! ?5 F1 H, C" x
- #include <linux/init.h>
# p: @+ K' ^: I5 v - #include <linux/errno.h>. q# m7 i% P$ [0 j
- #include <linux/types.h>
/ E3 e' w' Z3 I - #include <linux/interrupt.h>1 J# A- G G3 E0 K/ M# q
- #include <asm/io.h>" g- V# r. M$ E; @
- #include <linux/moduleparam.h>
! |7 m0 d" J# z) P; J" |8 X1 M" b - #include <linux/sysctl.h>' u5 \ J2 W2 m8 ^) l) q0 C- p3 f
- #include <linux/mm.h>
- `* Z3 t- |% L - #include <linux/dma-mapping.h>
: y6 C& k& p# B5 @ j* `& R W
- j% a* ?# n1 @7 p5 W5 a- #include <mach/memory.h>4 W( v' H& g' d2 ~" I% C4 }/ Z) i
- #include <mach/hardware.h>6 Y' p R# I. U: w/ _2 `
- #include <mach/irqs.h>* c6 ~% S7 w: \
- #include <asm/hardware/edma.h>0 R4 }# ~% a/ k# L
/ o* |+ @" M+ D' h+ o- #undef EDMA3_DEBUG
/ c* r6 Q) V1 O' k7 u - /*#define EDMA3_DEBUG*/
7 n4 S8 [2 T7 b. f! S+ K5 ]2 ^
" b" e5 |5 G9 p( R c# p: s- #ifdef EDMA3_DEBUG5 i# K( j8 ~6 |
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
0 v$ q. M1 r8 c1 V - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
0 D) n! @6 }( s- } - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
! W, ]) W4 r3 E. V, @7 R/ @; E4 ^ - #else
' n& P- P, `# \. j9 \ - #define DMA_PRINTK( x... )2 F/ p! q- `* T" Q" w) q& R, O; o
- #define DMA_FN_IN! h# R* b+ O8 Q6 o J, i
- #define DMA_FN_OUT# M8 D# S: C/ t" L5 B% r
- #endif
6 \- P6 _/ u% ^2 V' w
0 x; Y0 B& A8 _1 x. \" P- #define MAX_DMA_TRANSFER_IN_BYTES (32768)6 L1 K( q! R. m
- #define STATIC_SHIFT 3
3 t' ~% U- P3 }, x6 S/ L7 E( ] - #define TCINTEN_SHIFT 20
O) K( P. Y2 P8 O& R7 S - #define ITCINTEN_SHIFT 212 e b% C* s0 p+ `
- #define TCCHEN_SHIFT 22
! S# T; m% q/ h - #define ITCCHEN_SHIFT 23
4 g9 \9 B+ I- O
& R$ F. f/ \0 o) P) j) j" ?- static volatile int irqraised1 = 0;
, c4 b7 j5 Z9 M( T2 |* R U - static volatile int irqraised2 = 0;
, b9 Z5 R- t: r. [
* _7 H! a6 _8 ~- u+ u5 j4 X& P- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);8 ] [- ~: t9 ^ }
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);' T z6 l- H& g0 \3 ?
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);7 a7 }" V/ J& G' Y; d
- v9 a) {, V1 m6 [
- dma_addr_t dmaphyssrc1 = 0;! X8 k$ i9 S6 Z) f( L! Q3 g5 O, P4 {
- dma_addr_t dmaphyssrc2 = 0;
( S5 \8 y- B- T, j7 x! e/ O( ^ - dma_addr_t dmaphysdest1 = 0;7 N* G( C8 w# q: I; ~
- dma_addr_t dmaphysdest2 = 0;, k; k1 C+ I4 L% k# g' a
- 7 ?1 Y1 i% j0 o$ ^- @, B: w6 S2 O
- char *dmabufsrc1 = NULL;
3 ]+ J8 M2 f2 \8 J* j- x5 y - char *dmabufsrc2 = NULL;8 O9 \- L0 p; h3 s" a
- char *dmabufdest1 = NULL;
8 J1 D8 O6 ?; G/ y9 h+ O - char *dmabufdest2 = NULL;
) y5 l7 m' C. [) m% ~: F7 u3 r& L - 4 s4 X: z" ]; S2 A; R# o
- static int acnt = 512;
5 ^) p. l8 J( _1 ^ - static int bcnt = 8;' M* T- ~3 i+ k; ]; Q9 x
- static int ccnt = 8;& b# {9 c0 T% t; Z1 X
! G* k N, z$ b- module_param(acnt, int, S_IRUGO);) ~* q+ E6 `* K; h, i
- module_param(bcnt, int, S_IRUGO);7 c9 J/ z2 |2 t6 m
- module_param(ccnt, int, S_IRUGO);
复制代码
' D/ r. R9 `6 {) S
- r" v- d" i% s 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
' ^! A" _2 V5 T. y( {) Barm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
* O, }: A. i% U# |: D) g 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。- W1 h% n+ B* ~" {; i" a
/ i: S0 @' z4 I7 G$ ]) ~3 s* k. l5 F/ N2 I9 \
|
|