|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
: ]3 L" d7 U+ F, N; }; |, R- [code]EDMA sample test application
9 T; [ l' `# `/ K1 i8 S - /*
" q O9 G; X, Q" ~) s9 a9 }- ^ - * edma_test.c
5 m) S$ K2 g+ \+ L0 l% j0 O - * l7 P1 M5 {& @
- * brief EDMA3 Test Application
1 ~: z! S( S2 t6 i - *
4 c! p$ W5 P: l- H" b - * This file contains EDMA3 Test code.0 B4 T: n& Z3 [0 P8 |
- *
. z) M a3 Z4 U! q* w& D, i6 i - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
U, X! m% v" U, ?. }( t% p - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
/ A$ K! \& M- q" w3 D - * TO CHANGE.
- D2 T( T) s, x: w - *
7 q) e- N. ~/ @( [4 B3 L! t - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/9 c6 `' \- |! @3 Q6 C0 q! A( y
- *
6 B+ i, }+ x5 |) C - * This program is free software; you can redistribute it and/or7 ?6 G9 _- o; e) v& c8 M
- * modify it under the terms of the GNU General Public License as
3 a+ A2 s, F: r! ` - * published by the Free Software Foundation version 2.$ O) E/ ?( I+ H
- *6 d$ f/ b' n& T4 Q+ h. E( e; L
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any* p4 a3 A, N) v
- * kind, whether express or implied; without even the implied warranty
7 f- J1 }# \" I& T* P' e; J - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the4 O1 B6 V4 j; J9 s- X) F7 }+ F9 b# |
- * GNU General Public License for more details.& q3 t' R: v5 d+ W* S0 j6 E
- */% M3 c: q1 H, T! K* W$ r. p( i/ o0 D) E
2 O. l9 s# T3 X1 n" q- #include <linux/module.h>0 Z/ t' E$ ]7 [: l. B
- #include <linux/init.h>
+ L$ z, w7 q$ y - #include <linux/errno.h>
% n8 x" }6 T3 A, E3 C - #include <linux/types.h>: l( P1 a* n5 O
- #include <linux/interrupt.h>
. N4 t8 S4 G |8 `+ N5 P - #include <asm/io.h>
: [8 L( f' I8 T/ I; ]* m - #include <linux/moduleparam.h> q3 q2 e2 O9 j
- #include <linux/sysctl.h>
2 S* T6 v n# b' f+ O G: C- {; ? - #include <linux/mm.h>8 D. ^8 \6 F: s" ]* h& n! @
- #include <linux/dma-mapping.h>- d/ D U1 C! B: y' ^' H* E
- + |, l" x& F- W. N
- #include <mach/memory.h>
$ p9 o) U% s6 d! r( ~ - #include <mach/hardware.h>$ Z- y8 z0 o7 Y5 \# Q4 | A# g
- #include <mach/irqs.h>- @2 [- \* h4 r1 ~0 _
- #include <asm/hardware/edma.h>) a ~) [4 m- b0 Y. V/ D4 l5 D5 Z
- 9 @: M( X) m% k: X6 G: Z8 v( c. z
- #undef EDMA3_DEBUG. E2 j+ [& M, \" k/ M' h) F" V
- /*#define EDMA3_DEBUG*/
2 J1 P$ S! L5 I) ]1 ` - 5 k3 s6 G/ L' I0 \3 i
- #ifdef EDMA3_DEBUG3 }! o( a3 y* z
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)6 H; M F8 j; {$ J6 r
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
5 T5 K# r2 c, m) _0 w - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
9 e ^% D$ n: F4 {% w6 S. y+ e - #else. W5 l6 i. J3 L. l2 T+ R! E* l
- #define DMA_PRINTK( x... )+ O n; O4 n6 P! p. a4 p
- #define DMA_FN_IN: K; M$ { f5 A" J8 s5 t: X3 K3 N
- #define DMA_FN_OUT
1 @$ w# V1 N2 ] - #endif: J# K" l% U7 e5 M5 M
- d& \4 r+ l% v+ P5 Y" P- #define MAX_DMA_TRANSFER_IN_BYTES (32768)8 a: N/ }, a( H) J6 U3 Y* r7 c( {
- #define STATIC_SHIFT 3
7 K& X4 ?0 D# T- e% }5 p - #define TCINTEN_SHIFT 202 X8 W; h3 Q, J7 n# p5 Z
- #define ITCINTEN_SHIFT 21
3 q# L' s \1 m* l - #define TCCHEN_SHIFT 22* a) v' ~* X- [5 p9 m$ A, X
- #define ITCCHEN_SHIFT 239 ?( G+ ~1 l# d: M7 G& d3 Z
- + N5 u3 D2 R; Z8 A8 o3 v
- static volatile int irqraised1 = 0;; \+ D+ G: @1 Q5 X
- static volatile int irqraised2 = 0;6 {5 X2 z, z3 K
- 7 `/ d( ?$ Q: u: T$ i
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);$ O: f6 H% `9 ` v- S3 ~7 f6 s3 h
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
. S8 V$ q; B1 s9 E- C8 j( L9 o- U - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);2 n" u6 _) D3 X4 N( I2 G: O7 u
4 I) E' g3 I9 Y6 z. ^7 y* i, q/ [- dma_addr_t dmaphyssrc1 = 0;
4 H$ b8 r$ k. f4 ?6 P, m' \ - dma_addr_t dmaphyssrc2 = 0;
/ c3 _" i5 W% U( C - dma_addr_t dmaphysdest1 = 0;
4 V! s2 B% W# E - dma_addr_t dmaphysdest2 = 0;
) z# K( B) @+ t$ _4 d: X+ F7 F% f5 m7 { - ' x$ W2 b3 P2 y; N2 \$ e
- char *dmabufsrc1 = NULL;
! }% X1 b3 ]% ]0 u4 r - char *dmabufsrc2 = NULL;( J# q' G7 h% I4 c+ u' Z7 f/ v# h" F1 n
- char *dmabufdest1 = NULL;2 _% S4 K* x7 r% r
- char *dmabufdest2 = NULL;
/ S2 E' X3 A! L) d) K - 2 B5 e" V5 m9 g" b0 i
- static int acnt = 512;
/ p A8 w: }& l6 ?2 Y - static int bcnt = 8;
$ R7 |) G0 j& o3 X% |/ @& S - static int ccnt = 8;
8 n; y4 B1 x3 k6 @
9 `7 I, S% q4 m9 x, P2 r& V7 R- module_param(acnt, int, S_IRUGO);/ h$ j( A9 Z0 ~5 \% V- h
- module_param(bcnt, int, S_IRUGO);/ g# `5 @* x7 O, g
- module_param(ccnt, int, S_IRUGO);
复制代码 6 a% q) t* h' v. y" t' ^ k7 u# x$ p
6 v! S% V: X; U$ i6 ` 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
+ @( G5 V$ Q: darm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。 M c% ]1 C" G; o) P R1 I
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
, L/ s& `* v* X! u0 v' P
+ g6 ^1 a0 b f5 r/ |
' K3 P# n u- w- ] |
|