|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
1 H1 L4 q, c2 w! k; U/ M3 Y- [code]EDMA sample test application
- M9 n4 t7 Q& ?! c' ]6 M+ n. Y - /*
" j7 j* I, A2 ]9 [- w - * edma_test.c+ D; b; M U; z0 o/ k, \
- *
+ g9 w5 N1 z5 [" ^ - * brief EDMA3 Test Application0 K( e' a2 W6 Q0 s; P
- *
- m5 X) G7 V0 d - * This file contains EDMA3 Test code.6 N k5 g; W& S& G
- *! Q& B: m5 \8 L9 i' X$ B" k: S3 e/ n3 L, J
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
5 U( I8 u! K, ~' t( z - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
6 I$ I3 \; u: c+ y3 S - * TO CHANGE.2 N5 d$ b d$ ]* L' O4 I
- *
9 K1 X' d: ^. v - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/6 t! X: B7 Y* t9 }
- *
- U/ J& h) q5 J, H' c' M- Q, j. w - * This program is free software; you can redistribute it and/or
$ f% c1 H) v0 n - * modify it under the terms of the GNU General Public License as m( O: X6 j# r, D) I- @
- * published by the Free Software Foundation version 2.: t2 n, J+ J$ P& f
- *
. x3 |: S. o0 n, E4 N - * This program is distributed "as is" WITHOUT ANY WARRANTY of any
9 G) J. I( l G1 V# e( X - * kind, whether express or implied; without even the implied warranty
: J: W& @8 U$ b& v( o; H - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the/ o& [# I" C1 u; I4 o) W9 e
- * GNU General Public License for more details.
( F, A6 w7 B; K; _+ a& L8 B - */
1 [& D8 d* |0 w
' `, ]# X9 b1 ~1 v" N3 D- #include <linux/module.h>' d! U/ @9 K s- c* a K& D' i
- #include <linux/init.h>
0 V- c1 a+ _8 ~4 z - #include <linux/errno.h>
* n% g3 G4 Y5 y: ^" l - #include <linux/types.h>
* q* e3 Q* L9 d- ?& F, j - #include <linux/interrupt.h>0 P/ t; w; l \+ b' E6 M
- #include <asm/io.h>
7 \( H; Z) B& }# h - #include <linux/moduleparam.h>
! }/ q5 A7 Z1 ?; ]$ P - #include <linux/sysctl.h>7 c+ @$ e4 e5 i: d
- #include <linux/mm.h>
+ q+ q2 [. {5 f# s+ W: g/ m: ? - #include <linux/dma-mapping.h>
: U; n& K2 M4 {: _/ _9 m5 t5 q1 L - % [. \# w3 z$ k7 L& b* D! w J
- #include <mach/memory.h>" W' P( Z3 n5 u5 E
- #include <mach/hardware.h>! {" y+ b4 j; _
- #include <mach/irqs.h>: s+ w2 o' O% t
- #include <asm/hardware/edma.h>
- e" l# k# e5 J% w
' o/ ]2 X8 \1 X) ]- #undef EDMA3_DEBUG
) d# {9 h3 K2 Q: `6 T - /*#define EDMA3_DEBUG*/
) O! ]. ^* n \3 F/ ` - * |: u+ R( z. H+ e1 F. ~
- #ifdef EDMA3_DEBUG2 j+ x, M3 Z" Q* |& S l$ s
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
1 d4 U" D- C$ y+ S+ K - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
! C* M2 Q1 \ Y1 b* U# g - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__): P# Q0 P# l: i0 t# X' A7 E6 ^
- #else
/ v& A4 B c- Z5 P* y6 d - #define DMA_PRINTK( x... )
8 z8 g5 K5 g3 e+ u9 B- X" r% B - #define DMA_FN_IN8 G1 B4 W) t5 ?8 t
- #define DMA_FN_OUT
& v. \7 l3 ^2 \6 ?& n( |3 l& Z) b - #endif7 Y- o% X1 X1 j% d+ q0 c, L
- ( f/ p P3 D7 h5 e
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
( G6 ^4 Q3 F8 b/ d8 s& y- Z0 w: ` - #define STATIC_SHIFT 3# A" c. d) @4 `! t+ s7 M. `
- #define TCINTEN_SHIFT 20
( |7 T9 E8 M: g9 A% o, ~& | - #define ITCINTEN_SHIFT 212 E3 r' s& U8 h. o4 v& ]
- #define TCCHEN_SHIFT 22/ B% ^: o5 `$ U4 Y2 D
- #define ITCCHEN_SHIFT 23+ w$ {! o1 J4 N" j
- 4 k5 S9 h' s+ [/ y e9 q
- static volatile int irqraised1 = 0;( o4 U: f6 ~: b) s4 E, ] p
- static volatile int irqraised2 = 0;; L% [: W; j; @7 x& \
% h- e* K* L" j. ~* U- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
" f9 S5 Q: |& f l% n% V Z - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);8 _# N v, f7 g, [* ~; q i
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);+ p1 z( G* e. p
- - Q8 w; M) D) [6 n
- dma_addr_t dmaphyssrc1 = 0;
' W; \$ _, j/ w- m0 F' y. u - dma_addr_t dmaphyssrc2 = 0;
/ p! ?8 L L4 [+ i6 e: m0 U - dma_addr_t dmaphysdest1 = 0;
! h3 S" d. l) @ X. Y, k2 }# y) Q - dma_addr_t dmaphysdest2 = 0;
: {% i. ?* E- j, V* |1 @8 r - 4 t' d* F8 j+ z/ @- _* [
- char *dmabufsrc1 = NULL;
% Q1 f |$ e1 T: k - char *dmabufsrc2 = NULL;7 X: x7 l; q5 H) ^) M
- char *dmabufdest1 = NULL;
: B- V3 [ ?: h; j! d4 Z - char *dmabufdest2 = NULL;
* @) u( S& {8 u$ U" E
0 H# J5 _+ Y0 F5 s- static int acnt = 512;
3 @& o) ?2 k. _* ^+ V# E' m2 ? - static int bcnt = 8;
2 {5 [) \4 `; D/ O - static int ccnt = 8;
2 M. @7 N7 {6 ^8 H2 }! H7 ~
# J9 x% h4 P- |: |7 o3 [- module_param(acnt, int, S_IRUGO);
5 y( Q& x! j- s6 u9 a- O6 ^ - module_param(bcnt, int, S_IRUGO);
* g& L! Y3 o- X4 C+ H: } - module_param(ccnt, int, S_IRUGO);
复制代码
$ l/ h7 e( Z- f" L9 f# N& j- t' H/ m; C6 [: y: W7 m
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
$ J- A0 z) s9 X# u7 l; Q4 earm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。$ Y7 a/ Z- y2 S7 B) X4 E! Q
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。7 \. [8 a! V/ \& h
8 b% r3 l+ _4 P/ w5 D2 k1 e
m1 t' D$ a! f) e# J, ^$ t& c9 ^2 H |
|