|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 , b( p8 ^! E( k) E8 F4 @: u
- [code]EDMA sample test application
9 s. q: d g' @* m' D - /*6 ?5 M6 O- P! i% j
- * edma_test.c
1 P. f8 m+ S9 I% Z* g9 y9 w' f - *- f7 ]$ ^. [& \% _$ Z! N
- * brief EDMA3 Test Application: ?1 T' C9 O2 G2 e# F$ W
- *
/ p$ `4 M. Z8 B, A; r. H$ L, ? - * This file contains EDMA3 Test code.
& m% E% J) ]3 `& K6 v( e2 Z - *
- }. w4 H/ P" ^, @% x7 i - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
0 b. T/ x; ~( W% m2 m$ g' V - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT2 g3 I9 j2 J9 A# R5 V/ ^
- * TO CHANGE.
& z7 _% C7 A- d( } W - *2 J/ ]+ P9 Z8 e5 `' M z
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/8 P) b3 O9 r% t; h/ a2 v/ D
- *
8 K/ s2 H7 A/ v2 O2 } - * This program is free software; you can redistribute it and/or7 i& t; M9 {0 q- k1 `
- * modify it under the terms of the GNU General Public License as
) y* G3 u) M3 g: w - * published by the Free Software Foundation version 2.
) r4 W4 T) @" U2 M2 D K - *2 m: j5 r& V5 T' ?
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any
8 u' ]9 l% m- N! e - * kind, whether express or implied; without even the implied warranty
7 | R% U/ d t( u: y$ ` - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the) }$ a# w0 r. {3 z+ F
- * GNU General Public License for more details.$ @0 b8 D* o( Z2 ~5 U2 r
- */' r' w2 @# y1 L2 E' ~9 K: V
" b: Q" C4 N, e# ~4 w- #include <linux/module.h>
- R- R5 } {5 G' A+ Z - #include <linux/init.h>
0 L3 c0 K, Z$ i2 v3 U7 y' R" b; | a - #include <linux/errno.h>
+ P' G+ o$ c ~1 Q2 t: ~: P+ ?& n0 o# N - #include <linux/types.h>0 _! \# Q, Q! D# p
- #include <linux/interrupt.h>; ~$ @* q2 w' k; u. e9 X4 b
- #include <asm/io.h>+ s/ |) R# y' i& J2 a7 O F- [
- #include <linux/moduleparam.h>4 }" i5 I" Q4 U3 V5 c; J% i/ U7 Y
- #include <linux/sysctl.h>
3 M2 p) Y8 r* N9 i: B - #include <linux/mm.h># A* f' [' Y4 x: l
- #include <linux/dma-mapping.h>
2 O8 W3 b, U0 ^* f% N# l$ j - : c+ t% r J$ }5 i/ x. `+ b' ~
- #include <mach/memory.h>. P" t6 \/ o( U3 d/ X
- #include <mach/hardware.h>7 |& c7 B) [& A) l2 Z$ O4 k
- #include <mach/irqs.h>/ P2 h: @9 ~, e7 U4 b6 D. t) q
- #include <asm/hardware/edma.h>$ d) [/ v0 }: F. U' ^/ _+ \) ^
- , D* K( z* U" S" N% b
- #undef EDMA3_DEBUG
0 d! \9 {) c. {$ n' N$ E6 Z/ I8 ^ - /*#define EDMA3_DEBUG*/
( e; I2 Q+ ^ N; S - `% A5 Z+ }: K) b: i
- #ifdef EDMA3_DEBUG
: T8 q% q+ S% e, V - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)& ^1 e; q: N8 {3 m& B! t. B I
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)) J9 L* O; n3 r7 K: E/ U
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
3 L+ h: f/ {. E3 A* r0 R# F - #else- X* Z8 {6 m6 R% b
- #define DMA_PRINTK( x... )
: C; D. V6 n6 X1 l% x# t - #define DMA_FN_IN1 Z* X# [. i( [$ N9 G5 L
- #define DMA_FN_OUT
6 M& H1 u$ v5 x1 z% E; J" p - #endif" t' x' s) X n' c5 A" b3 y
, G4 I& T; }8 O- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
* V+ Q% J# I1 X0 Z& r& p/ b - #define STATIC_SHIFT 3( I, `6 U: K2 X% ]7 i
- #define TCINTEN_SHIFT 20
' ` w5 d3 F9 `/ I6 v - #define ITCINTEN_SHIFT 21( s% j4 F- Q( X6 P
- #define TCCHEN_SHIFT 22% ?) D1 `# H0 w$ L# n
- #define ITCCHEN_SHIFT 232 D0 n6 A/ A2 R5 d/ W
1 j) l: `, f, e) W! F3 X- static volatile int irqraised1 = 0;( [* {" I& Z6 ~ a+ A
- static volatile int irqraised2 = 0;
2 b& q9 I; ^+ A; k
7 Z3 Y/ G! ^" O, ~' l! X- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);# t+ {; Q# L( o8 A, L
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);' ^* J. E2 _( }
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);1 I. \9 ]( b& z8 H+ J
0 B$ z) T- H6 _9 A: M* o- dma_addr_t dmaphyssrc1 = 0;* u( n' j! E. o. p4 u0 F
- dma_addr_t dmaphyssrc2 = 0;
2 h0 W6 H6 b9 w/ _3 `: Q* }* H - dma_addr_t dmaphysdest1 = 0;
$ q7 u: W7 x; {9 }: B" ^ - dma_addr_t dmaphysdest2 = 0;
2 g, n( w( J& i( H6 Q! D - $ i0 |* H3 x( E9 u
- char *dmabufsrc1 = NULL;
7 n6 P; i5 h* z9 C4 m - char *dmabufsrc2 = NULL;
3 y: w# N( T1 S* [5 ] - char *dmabufdest1 = NULL;
! |2 Y$ [, o" B0 ]( O - char *dmabufdest2 = NULL;1 {" G* x# u& y& G
- % E& o: C9 e% ~/ \
- static int acnt = 512;
0 j3 S7 N, g2 G" M( d5 T; z - static int bcnt = 8; w0 F! o: p% [; _
- static int ccnt = 8;0 ]5 ]3 O. h* o4 h1 y2 C
4 W- A4 U! p; g- module_param(acnt, int, S_IRUGO);+ r! T8 b. u3 n% z
- module_param(bcnt, int, S_IRUGO); D4 I- f% A# r
- module_param(ccnt, int, S_IRUGO);
复制代码
3 j8 G, O: g% R* k2 Q" G2 B7 y6 q' ?( k4 f
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
7 i0 k( K3 G* z0 }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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。/ Q. ~$ W" ^+ N5 w( L, r
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。! ]& `$ Z2 f$ R4 X; ~+ t. D3 G2 n
8 }- d2 v" Z* |3 s8 b+ Q* v
9 P4 z& o7 N5 ]0 ?' k! K0 M( U |
|