|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 3 m/ W5 x) Y1 ~/ N6 L. j2 y
- [code]EDMA sample test application
, M. a l) F. E* d. P' K/ G, `2 S - /*- e4 i; N& v; U, ]
- * edma_test.c4 m1 X: n. r0 r. i' `
- *
. k5 u, C# B. s; |8 W+ G - * brief EDMA3 Test Application& N2 `, I4 }, L A0 c9 H3 b$ K
- *
! Z% A5 y& R) y$ m3 w% _: ? - * This file contains EDMA3 Test code.
! q$ ?/ C9 k* o7 p- M1 `" `/ _ - *
8 z5 x$ U9 k9 R- h) e# w - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
" d. Z0 i3 i2 m! I- l1 a - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
8 W' r" ]0 R& q: [ - * TO CHANGE.; `5 u; _- J3 M& v
- *. X6 m. t7 F; y: i4 I
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
" W7 ?; N8 m( H - *
1 L3 B* v$ X4 l' M5 A" t2 W5 g - * This program is free software; you can redistribute it and/or2 S5 A: b; U, J9 l: k" t6 s/ {' t9 U
- * modify it under the terms of the GNU General Public License as9 t! {+ T, P/ G. s" n2 r2 L9 F
- * published by the Free Software Foundation version 2.
# e0 z4 r7 R" ^2 w - *
& V \) ]8 @/ V: ?( x+ U$ c+ i: r - * This program is distributed "as is" WITHOUT ANY WARRANTY of any8 Q9 D3 M* c$ ~7 \# [8 g6 p7 q
- * kind, whether express or implied; without even the implied warranty
0 j$ k* j, P+ m/ A - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the: i' p# G+ \# |2 s9 `$ G9 p( F* Y
- * GNU General Public License for more details.
9 S( H/ a1 f9 b4 w - */5 N- `. ?1 G" M. ~
. Z8 S( ^: l. `( ?, Q4 O/ Q- #include <linux/module.h>" J; s+ X' P& f$ |; s4 \( i
- #include <linux/init.h>
4 w& s8 A) E* o9 Q" @# ^ - #include <linux/errno.h>/ e8 G2 _( l% C. o# V8 i$ i+ o/ `
- #include <linux/types.h>
0 q+ d; q1 A8 [1 l8 c - #include <linux/interrupt.h>
( I% Q' X+ G" m+ C - #include <asm/io.h>
: k0 k8 u6 S: [; {( c - #include <linux/moduleparam.h>
4 z" Q6 e" G( m: a; u- B' m - #include <linux/sysctl.h>3 `" J, n, R3 M( D
- #include <linux/mm.h>* Q, `8 z& C& n! r; x8 M
- #include <linux/dma-mapping.h>- p2 c4 Q' y+ ]3 @9 c/ J8 n
& n- X0 R7 f2 g0 \' `2 s+ H- #include <mach/memory.h>
" H9 {# t" m; t$ j$ h* m - #include <mach/hardware.h>3 O0 y- [8 ?7 U# B* Y
- #include <mach/irqs.h>( N$ I, ]( y4 N% }
- #include <asm/hardware/edma.h>
6 a x6 \, |' K# o _
7 T2 u" A; n& M$ T& d- #undef EDMA3_DEBUG
9 f, _ M" u+ W0 F7 \# G - /*#define EDMA3_DEBUG*/" N/ ]( N8 `1 `: x4 {
- 9 D) K1 f% Z _: h, e/ Y+ B3 W
- #ifdef EDMA3_DEBUG
* g8 n) \+ Y* e% ]- i - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS); a; p& }; l9 l9 |
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
' b+ v2 H' {* c2 c% }$ J3 h - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)% H+ m* s( v! x% q( r" Y9 y
- #else
# H5 t) o8 b3 j. s" C - #define DMA_PRINTK( x... )9 y- A7 d: J9 O5 u
- #define DMA_FN_IN- t+ y+ K W7 N
- #define DMA_FN_OUT, n- C5 N' M: c3 W9 }
- #endif
% S" `' A7 x1 q/ Z4 i - 3 w: ^2 F- J" B+ f- _* {4 ?: I
- #define MAX_DMA_TRANSFER_IN_BYTES (32768): ^$ ?. C$ V- m6 Y" a, g
- #define STATIC_SHIFT 3
' |! b4 r! F! s1 u5 _ - #define TCINTEN_SHIFT 20
( o. l0 G8 v, O& d+ W/ d - #define ITCINTEN_SHIFT 21+ p$ W( }! g7 F/ P% n; ] m' O
- #define TCCHEN_SHIFT 225 l7 M- ~3 e: c; U
- #define ITCCHEN_SHIFT 23
, J4 S4 y# G& m1 `# f8 @/ ~; B
5 M5 ~% j: v2 h- static volatile int irqraised1 = 0;- `8 ]1 [6 { |& _/ k( M
- static volatile int irqraised2 = 0;
; x( h1 \6 g9 J$ G) O
0 R2 p( W# g+ y" D5 K4 Y( a- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);; r4 {3 e q3 {3 T
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
! H: C3 M5 x4 u* K* V7 [ - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
% `4 c) R, R, g0 [% E: O) Z - " z7 B* Y' p/ w9 X$ }
- dma_addr_t dmaphyssrc1 = 0;
& y3 P, `9 h% y; r - dma_addr_t dmaphyssrc2 = 0;
2 T* E) {7 i5 F* b2 e; P - dma_addr_t dmaphysdest1 = 0;
7 x3 u8 U1 K: g& u" h/ X - dma_addr_t dmaphysdest2 = 0;
. X0 R$ I' ~- ^) F) R2 v& P# b( U
9 M0 A$ y! c E- char *dmabufsrc1 = NULL;
" C+ j) |1 z9 q* n4 E - char *dmabufsrc2 = NULL;# P7 |0 W9 |. r
- char *dmabufdest1 = NULL;/ }" f# W8 L) o
- char *dmabufdest2 = NULL;
& ~9 y4 [: B: `1 }& \ - 6 {: t; n) D& n5 K5 c- C
- static int acnt = 512;6 X+ U+ _& X3 Q4 C( X
- static int bcnt = 8;# q/ Q& m! N% N3 ^( Q2 {
- static int ccnt = 8;
- d3 Z5 U+ g* R, F/ X1 y, c
8 C7 n# l$ i4 g/ a: H: Z7 b- module_param(acnt, int, S_IRUGO);$ u- {9 v/ L$ P9 d8 o6 ]7 ?
- module_param(bcnt, int, S_IRUGO);
/ s& W: J$ f+ c& [4 f( F - module_param(ccnt, int, S_IRUGO);
复制代码
5 O( J- O3 \5 r4 K3 y- ]& F7 a" O% I" b: j; \
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
7 t7 K% F; `0 D: J$ M$ iarm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。# J3 o& O* p1 U0 H7 s. o- W- S6 p1 U
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
& A4 v% v. E8 s& r8 V
6 l& o8 ~. R+ J2 p% u1 A2 `3 Z) ^& _& j! e
|
|