|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 : _5 |: y2 P# Q& I% U
- [code]EDMA sample test application
9 f: X) {% X3 F9 U0 _# M - /*( d( k) c" s( U6 E+ t
- * edma_test.c
' Y8 R" I# u1 y E - *" x9 q, G$ j; ^5 | l
- * brief EDMA3 Test Application3 v/ Q* a( h3 }9 r
- *
, W3 U3 v% O m( J! U - * This file contains EDMA3 Test code., \- A0 T9 ?1 F& m; X" T
- *
0 a8 a2 O& ^! Y5 l" X - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
" Y' ]: {: F6 c( \2 U& t' B - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT2 d' A7 y1 R% R$ g8 O9 x. O
- * TO CHANGE.
. j- J5 p. A% m! g! Q - *8 O' l2 h4 T) e% u, v" R
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/ t2 ?2 C/ ]3 x; o5 {* t2 `
- *
2 {8 D/ p) x5 D: J0 | - * This program is free software; you can redistribute it and/or
0 f1 }& \; x/ F7 w' [ - * modify it under the terms of the GNU General Public License as" }% H9 c- Q6 y3 ]6 A, Q0 }, Y* p
- * published by the Free Software Foundation version 2.
* S8 Z6 j. P! y E9 P! z, F - *
! R3 @/ N9 p9 D- s6 }2 m2 y - * This program is distributed "as is" WITHOUT ANY WARRANTY of any
+ d7 N, t, I( n( G - * kind, whether express or implied; without even the implied warranty
4 F' A5 l; t9 U( ^- L( z - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the9 J* \5 C' r [; W
- * GNU General Public License for more details." v+ I; v% X7 J
- */
; M" i/ g3 R A0 } - _. V8 r4 v2 \
- #include <linux/module.h>( |% t M0 W' T7 X6 N# }
- #include <linux/init.h>( }; z7 S% G: P/ C: E8 x. M h0 a' D
- #include <linux/errno.h>. I- ]9 P: w$ Y& P1 z
- #include <linux/types.h># W Q, g0 A- w& B5 E; J
- #include <linux/interrupt.h>0 \; [0 b( F/ W; m r% x1 {3 z
- #include <asm/io.h>' W g) r$ R! E" l6 V! h
- #include <linux/moduleparam.h>
5 T9 w0 L. E+ a( v - #include <linux/sysctl.h>
3 z: u) @. Y) q+ P# M) B - #include <linux/mm.h>
! O6 o0 z; v9 L: b! t - #include <linux/dma-mapping.h>
, L7 T0 H) |5 g2 {9 x1 Q - 7 O, l3 L U& \& p
- #include <mach/memory.h>
* a: A. h7 o) @6 } - #include <mach/hardware.h>, z+ w9 v5 ^: D- X% j3 ^6 D9 q- `
- #include <mach/irqs.h>$ K* J( G- f5 e" j4 `
- #include <asm/hardware/edma.h>
5 F$ z4 u m: N! ?+ Z: \5 r
3 F5 e2 O/ \9 x" y% N; k l8 J" `3 K- #undef EDMA3_DEBUG1 o F6 s$ h4 \
- /*#define EDMA3_DEBUG*/ r# u3 o' q4 W5 c: }( [1 S
* \; g) X) W; k$ E0 Q- #ifdef EDMA3_DEBUG
+ q* ?* C0 j$ N. X& J9 C - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
( |& p& H7 m# k- q5 h - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
* ]$ K# P Q) j# k: A/ a: U - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
4 f+ {8 E) F1 X& ?/ i% `4 Z% O5 q - #else
+ U9 Q6 {9 \ j - #define DMA_PRINTK( x... )
1 s4 u$ h1 `, r; D - #define DMA_FN_IN" x, |: r; i3 G/ `
- #define DMA_FN_OUT
% ^8 v/ u4 y6 D# t3 ] - #endif
# X6 y' ]( T. K8 B- }" @ ~( k
0 f9 ?4 \$ e$ M) Q' S- #define MAX_DMA_TRANSFER_IN_BYTES (32768)& W- [# K% u& N# s5 ?+ A
- #define STATIC_SHIFT 38 o0 _; o2 n7 [ {! o
- #define TCINTEN_SHIFT 20
7 `3 Z5 j$ |" ?3 h1 x B - #define ITCINTEN_SHIFT 21
: q. X) ?# Z" y5 I9 j - #define TCCHEN_SHIFT 22
, r4 s1 r- T3 ]) H - #define ITCCHEN_SHIFT 23
* |3 ]3 Y. Y" g - + b- `8 R$ j& y: O d, s' W
- static volatile int irqraised1 = 0;9 _. F$ u$ w4 Q" L) c K- Q
- static volatile int irqraised2 = 0;
) s# P+ J! ^/ E4 o6 ^3 I - 7 @/ t, C, Q6 K/ w& \0 p: H
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
/ e, U- _( e* F - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
6 K* ~3 o$ j/ N- I1 p - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
2 _$ T, \6 e% K" h& C- @- a
+ H3 ^5 ^/ Z& u4 s. W- dma_addr_t dmaphyssrc1 = 0;
: X! J+ x0 w- i# u U: m. O - dma_addr_t dmaphyssrc2 = 0;
7 k1 k4 f% y( ? M3 { - dma_addr_t dmaphysdest1 = 0;
9 b/ h1 f# E+ _4 a$ I - dma_addr_t dmaphysdest2 = 0;
$ e7 S) z: d7 o; |* h: A p) f - 4 ?; m+ ]0 z) C
- char *dmabufsrc1 = NULL;
% v# ^, b4 l+ q6 d - char *dmabufsrc2 = NULL;& G6 N" M1 K' a# L1 }! m( D
- char *dmabufdest1 = NULL;
! `7 W$ I$ p0 @; t8 r4 D& w - char *dmabufdest2 = NULL;
, {$ S6 c8 h: {9 {; U - . E6 q) d' S4 o2 s) a1 B
- static int acnt = 512;3 n) w8 ]( Q2 A$ Z ~ {5 ? w
- static int bcnt = 8;4 \; B. ^- T, E5 k% @1 Z
- static int ccnt = 8;: W1 b/ H1 R8 V! k' I* l
- / L, _/ O# j6 h3 t8 j6 l. D! i$ \
- module_param(acnt, int, S_IRUGO);4 ?& C% c' c0 f( r
- module_param(bcnt, int, S_IRUGO);
2 m5 U. M; |, v) U' Q- {; ]: h! A - module_param(ccnt, int, S_IRUGO);
复制代码 , ~- s: v4 r! t+ H
! [* a+ |( a1 b/ _" O- o
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用& {2 r, X0 u; t
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
$ f$ W; G- f( b5 I 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
/ T. A0 w* O- _6 e* u6 a
9 ~; O" Y/ h& [5 z, a1 T8 H- f7 |' B1 x# J2 y
|
|