|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 9 [ X* v& y2 x7 Y O( c
- [code]EDMA sample test application W) a7 a# s1 j% g
- /*
3 t2 m( _' ~! n2 C) V - * edma_test.c. y1 _$ @: E2 @
- *
3 _" }8 p% [3 K8 z+ a% M: |# o - * brief EDMA3 Test Application& ]6 L8 s2 e8 d# _
- *" s, Z3 Y+ i2 _% C
- * This file contains EDMA3 Test code.
* v6 Y- _* _0 _1 m& j6 q9 Z, A - *7 U9 C( E3 m8 @ h7 B
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE9 Y) \8 ?. @: U4 f
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT5 q8 n: m8 j, z- q% o8 D
- * TO CHANGE.2 D* c* Q1 M9 ?$ s; o {8 b
- *
3 }. b+ q% Q- F7 U - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/7 B9 q7 P/ p! F$ r7 |- m
- *& M% Q1 C4 {" t8 @& f
- * This program is free software; you can redistribute it and/or
: y6 R! ]( M2 v4 W! R - * modify it under the terms of the GNU General Public License as+ ~2 @8 s, H* v/ p' R& C. q
- * published by the Free Software Foundation version 2.# ~9 ]' k1 g, ^9 r# E
- *9 \7 z+ g1 a7 v0 G
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any
$ h y$ B3 X* D; L - * kind, whether express or implied; without even the implied warranty
: P, v3 i& z1 o! e - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the) d( s8 V& V0 S0 X( i( q/ N4 A7 y0 Q
- * GNU General Public License for more details.+ R3 k9 c+ b' ]# y& M) I- Y. S0 V
- */
( I0 v% H( K. M1 v% A. b7 ?& p
; }2 E4 B, L5 j9 x3 [- #include <linux/module.h>* p. b6 ]# w" V: \0 R( S* W7 ^% A4 a
- #include <linux/init.h>
3 n8 \( i) I% B2 Z/ f" G2 ?* m - #include <linux/errno.h>
# b7 Z- U2 \! j" O1 p6 p& k5 Y - #include <linux/types.h>: l' I" g: w8 K
- #include <linux/interrupt.h>; ?/ \ n& i" ?8 L( c. o
- #include <asm/io.h>5 N# ?: V. V6 e7 P# I" C
- #include <linux/moduleparam.h>
' X* ?. ^ p9 |! Z9 C$ P/ V - #include <linux/sysctl.h>5 F0 y7 F5 r% `( S4 @
- #include <linux/mm.h>- w) G$ d' a8 ?" K* K' H) O
- #include <linux/dma-mapping.h>
' _- c$ @/ G& Y, k% s9 K1 Z2 V. _
6 i* e$ t6 q& c5 N8 U" R" e- #include <mach/memory.h>
" _9 G* D6 d- i) C, m - #include <mach/hardware.h>. B6 D) X. C/ P" G+ y0 ?
- #include <mach/irqs.h>
9 v6 u! P# Z/ p, R - #include <asm/hardware/edma.h>
P3 Q% ]8 H# ~8 U* P - - p- `+ N0 z7 |+ P
- #undef EDMA3_DEBUG
: s q0 _: [( C( o' o, y - /*#define EDMA3_DEBUG*/
" o- k+ U' k' f0 n' P - c- e/ P/ y( f. @( E
- #ifdef EDMA3_DEBUG
8 }3 J5 `' ?' n. p - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)3 q" T1 j+ j1 _6 A0 z
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)' G6 `! ~* f7 I" e* y) u" n& K1 P
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)0 M: g/ n- t0 h- }* ?" _! T0 R
- #else
) ^" s5 C) s- P9 K$ A- r' \ - #define DMA_PRINTK( x... )5 Y. r. c1 ~. y* W
- #define DMA_FN_IN' X, r* G) ?& E6 `
- #define DMA_FN_OUT. W: U7 R' S. G9 ~* k* B
- #endif
) @* T7 |4 j/ ]& C$ [6 t2 O
; H2 \6 h& t) z3 Z! P& C* A% q- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
: v$ ^8 q* W" Q. p1 O - #define STATIC_SHIFT 32 O$ z6 u, H% w2 ~9 h' Q$ i
- #define TCINTEN_SHIFT 20
4 q+ V5 L) W; C# v: Q - #define ITCINTEN_SHIFT 21
U9 O4 j' O6 V9 U+ F1 @ - #define TCCHEN_SHIFT 22
4 K. e) j) B& \' K& X( B& ~ - #define ITCCHEN_SHIFT 23
% E8 I7 a# ]+ N; m* F' i - & T8 M' e3 ^ ? Y4 P
- static volatile int irqraised1 = 0;6 o2 O: z; q, ^+ z- R, o$ l( D ?6 j
- static volatile int irqraised2 = 0;, S* M8 C# C& P( P4 W9 i0 @' u
- % L8 @/ n6 R! t% I S
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
* s F: K) G' U2 o! ^3 [ - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
+ F& J: H" \4 w - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);7 _2 S% F" K3 y9 c5 P
: p2 w `- ?/ u- dma_addr_t dmaphyssrc1 = 0; [+ B4 i( k+ K# [
- dma_addr_t dmaphyssrc2 = 0;$ T! O9 \: R) N. X* Z. M
- dma_addr_t dmaphysdest1 = 0;
, B3 |* i* @: c2 X2 _4 B( W - dma_addr_t dmaphysdest2 = 0; Z7 K5 K) }% _, T
- * ~% C7 M2 e5 ^- l" B, U1 |* ]
- char *dmabufsrc1 = NULL;
5 n; `9 b: f- E. ^8 K, q0 V - char *dmabufsrc2 = NULL;7 K: S* Q. N# _1 m! ?5 ]" f0 E4 `
- char *dmabufdest1 = NULL;# Q9 p, |% o! z6 [1 W7 M9 J8 |
- char *dmabufdest2 = NULL;
0 |& m5 F4 N$ a5 r6 \/ Z8 ~ X5 N/ x
; J" z0 K i0 j. Q! G9 m- static int acnt = 512;
) y3 L! Z/ i: ^9 v. u2 E7 C1 O6 V - static int bcnt = 8;! q! M8 I+ N/ X: X
- static int ccnt = 8;
+ w( g2 @; [9 ?- ~0 b# K/ T
' S) n" e4 |& }; x- module_param(acnt, int, S_IRUGO);
4 R' \- w, d0 M, ^& V) A - module_param(bcnt, int, S_IRUGO);
3 n- U4 L3 U7 d5 K - module_param(ccnt, int, S_IRUGO);
复制代码 / m$ S3 A$ [% ~& s! q, ^* T
0 i: @$ M4 v5 o' |. x3 i: A
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用9 a/ \' v5 R9 U& ~
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。3 F6 p# H! n( _6 v! ^. Y' _ Y
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。# S4 o/ T9 d& b: T- s9 C
& U9 f. w# K" m% O% I& @% x
& n9 k9 q' v, D K* o: w/ i |
|