|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
) n5 h* p' x" O9 L& n- [code]EDMA sample test application
# z0 S6 ?3 w; c C5 U - /*
1 j/ r, i2 _' U) ^ - * edma_test.c
5 `- j C0 o+ O b$ M: I - *
( ^9 u( N7 k7 E% v9 d" A: r/ y$ r - * brief EDMA3 Test Application: k" C# F$ Y; I$ v" {. O% o
- *
7 B4 b0 |$ _' ?1 y' G1 A: G0 O - * This file contains EDMA3 Test code.
8 Q# s7 M, S0 ?. E s4 h - *
3 L+ Y# ] a: b - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE) t, @ [! M8 |" _) @6 D/ l
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT+ M8 A/ Z. S. ~, f4 S' j& i
- * TO CHANGE.9 [% s: T! o; P' f$ I
- *8 M4 L# T$ V; S/ L8 q
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
$ ?/ g4 @: o, p9 s# z, W' X/ l - *
6 C# ?. }; X+ v" G. E - * This program is free software; you can redistribute it and/or
# w6 H" d) |+ {1 w9 K - * modify it under the terms of the GNU General Public License as
% ^! @! t8 d" h9 q, o: _( [ - * published by the Free Software Foundation version 2.
- [- \" ^/ H7 n - *2 z+ d6 N" H w K+ _0 H* P+ G" r
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any
; }( ~% f5 _" J; L( t% A+ k: V @ - * kind, whether express or implied; without even the implied warranty
l- j3 `# @/ ]; B! G& G9 [9 U - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
: e4 Z: D# `- S3 I! D - * GNU General Public License for more details.1 n9 d. B- I5 ~& N' w
- */
; {0 s. m2 z( X8 I
: [/ ?+ I' p0 ?( i6 t- #include <linux/module.h>
; s' k# O# ^* Y9 Y0 ]- t$ a - #include <linux/init.h>
# d7 f4 g! h" b- V. y - #include <linux/errno.h>7 @$ A3 P* d/ B: }
- #include <linux/types.h>
" C7 d( n" U2 k - #include <linux/interrupt.h>
4 ?1 [/ r' f7 p/ K. c - #include <asm/io.h>
5 U' k, f* Q, h% k" b: F9 h) J( B- \0 i9 O - #include <linux/moduleparam.h>1 b& e U2 t+ G* D! g* D! N
- #include <linux/sysctl.h>1 z. I v+ M' \+ u* b; e
- #include <linux/mm.h>$ ?7 @1 h8 W) C3 S
- #include <linux/dma-mapping.h>
' p) v- G" F5 g" j
5 m6 d7 V& F) W- Y1 ] u8 M! F- #include <mach/memory.h>
" }! T! Z- F; V& g9 } - #include <mach/hardware.h>
9 d% r$ q( f) H2 C: j9 @, B0 f - #include <mach/irqs.h>
4 _' ~. G3 U% I% a. | - #include <asm/hardware/edma.h>
) ^) z4 a% {. {. P
: P3 r; N1 H" Z- #undef EDMA3_DEBUG% H" E( h; `0 z3 O: X% p q
- /*#define EDMA3_DEBUG*/5 `5 F6 G( R0 O3 h: ~/ _" X( j' G
- 0 ?! u1 }$ \; Z5 G% | O
- #ifdef EDMA3_DEBUG
) R8 ]6 M% o7 O+ U6 J& ] - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
5 G. t$ Q8 l" ?0 A" Z - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__). C3 q. V5 N( @+ [5 w2 m X( z S
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)- r0 s; r% _/ d" t# u( D7 s* y, c
- #else
/ N! C+ Q6 S3 u - #define DMA_PRINTK( x... )
! s* [ o4 S) G* S4 H - #define DMA_FN_IN- d9 @! r# p' ^8 I8 ~
- #define DMA_FN_OUT
3 X6 H8 g2 Q2 S* I9 v* G - #endif
3 K/ s$ f: ?9 v( E4 ?) G! M - ! _& O$ B. o# w, R$ ~( Q# s
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
$ W- `; C0 B/ N4 G# r' B' X/ l/ k - #define STATIC_SHIFT 3# v1 ^# @( k8 t. t
- #define TCINTEN_SHIFT 20
5 c. n- ]/ z, u6 T$ J- E3 n - #define ITCINTEN_SHIFT 21' h4 K! a4 O. m4 J0 j/ q' Z
- #define TCCHEN_SHIFT 22" z, p0 k# Y6 r! I* g5 ]
- #define ITCCHEN_SHIFT 230 d6 z! o5 k; g
# ~4 e2 X6 Y/ }* D& u* R- static volatile int irqraised1 = 0;: u5 j; L* q2 ?! L# F, l' H D
- static volatile int irqraised2 = 0;" o2 [6 t# T& Z2 Z
4 b/ \+ ~$ x6 j2 Q; J. k- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
5 t( p1 F3 H# a9 P& Q - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);7 o- h' i% M' \* V
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);, A; V0 S, ^( G( l2 N- }
- 2 F4 Z; }8 L) V1 B6 H' X5 _0 z
- dma_addr_t dmaphyssrc1 = 0;9 x" T+ ?" U1 R3 c
- dma_addr_t dmaphyssrc2 = 0;
4 ?# g ]- f2 j3 M& a - dma_addr_t dmaphysdest1 = 0; U* P5 ~, x9 n6 L3 \3 S7 n
- dma_addr_t dmaphysdest2 = 0;
+ E$ w9 m' n# f4 w N) A' d
* K/ R0 j$ l/ Z( }6 E$ e; R- char *dmabufsrc1 = NULL;! q- f5 O* r- o, S- X1 B l$ i- Y
- char *dmabufsrc2 = NULL;
' h# _% V9 h# d) y) ^7 _) g - char *dmabufdest1 = NULL;
+ f! q* E2 N6 o u# H - char *dmabufdest2 = NULL;
0 Y8 J- P% u) i" n( W) ]' S) R
: Y$ ^2 B: a" G- U5 N- static int acnt = 512;
1 k) [: u( `4 e* m9 g - static int bcnt = 8;
2 T9 K5 g0 e; r- E8 q7 V8 a - static int ccnt = 8;! Q, _% e6 T4 j g5 @% [" I6 S
- , |* O! K2 s Z/ \7 `
- module_param(acnt, int, S_IRUGO);
2 B. {9 f$ u+ P" f9 L8 ^, f - module_param(bcnt, int, S_IRUGO);0 l8 R- o2 J$ i$ O+ W
- module_param(ccnt, int, S_IRUGO);
复制代码 6 ^4 N* y# R4 i" y. M
9 p! k7 k8 ~ u$ v" i* a" F& I+ n
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
4 c8 e9 X( e) d% 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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
* O% l0 `, k$ r/ C+ j1 f X 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
2 o$ S8 l: ]( u5 O6 P
: l! {6 d. [$ h# r1 d1 p+ c% j( t: r9 R+ Q' g/ V2 P
|
|