|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
5 x n% a3 D- g* N) l" x6 W- [code]EDMA sample test application
; E2 ^6 Q- m/ g5 r! V, B2 T/ O0 ] - /*
. ]6 u0 B1 A% I. M6 `4 Y - * edma_test.c
! p% s1 _$ d9 r8 G9 p1 C - *
7 |' _% A4 V2 N% c) v# r8 `7 p - * brief EDMA3 Test Application0 r: h3 _8 A4 m
- *- I) q1 E! p4 e; Y; {
- * This file contains EDMA3 Test code.
/ E+ R; U8 R1 D( ?; S5 Z! e - *1 U0 \ {8 |7 `0 v- o5 \1 _' i
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
3 a4 \* v7 f" z4 k4 E - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT3 y( [: y8 c- B0 p
- * TO CHANGE.$ @7 o+ } y. T* [. r2 I. \; z
- *
\- m7 L! G9 e+ w7 T& Q+ U - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/2 v- M# l3 f2 z/ a$ B; L
- *
& Q, z- I8 C1 S5 ^) b( d5 K - * This program is free software; you can redistribute it and/or
/ u( c2 P' o4 g5 H% b - * modify it under the terms of the GNU General Public License as0 F5 F" S3 A! T2 E7 [3 ~
- * published by the Free Software Foundation version 2.
% B+ m& L4 h8 m! r2 Y$ t( b - *
7 ~' q) }. b0 D5 Y5 B# H% b/ N5 K' @ - * This program is distributed "as is" WITHOUT ANY WARRANTY of any J# o3 }8 Y/ E7 L2 ]; j% B
- * kind, whether express or implied; without even the implied warranty
6 C+ Y7 _, n% z! E& O - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
6 S C+ g- o3 d2 Q2 e! n/ d - * GNU General Public License for more details.
5 I/ X) A( e4 b: Q. u - */
( T$ D/ k- |" X' D6 B9 v - , |$ \* ]" [0 t
- #include <linux/module.h>
3 R& u/ V, N0 t4 V0 m$ X - #include <linux/init.h>
8 q' [7 X' V' u& u - #include <linux/errno.h>
- z [3 k+ {3 J& z - #include <linux/types.h>
+ V i$ [: F# b/ P- L0 J' b% |6 Z - #include <linux/interrupt.h>$ k1 t( v- S4 v; x% ?
- #include <asm/io.h>
, m: A0 M* \4 g0 A0 q+ g6 M& P - #include <linux/moduleparam.h>
; i; l2 `: ^8 r8 n0 l: P2 D9 k - #include <linux/sysctl.h>
* H7 P/ K) O2 C/ E5 P - #include <linux/mm.h>
) _- F. J# _' d# K - #include <linux/dma-mapping.h>% p* K/ A8 t& @# B( h4 e
# S4 m( |( {) D# J0 t0 k- #include <mach/memory.h>
5 t9 `9 O* Z/ b: Z. T/ s" v; I - #include <mach/hardware.h>
, V8 l9 C1 D2 U$ d. U4 n7 y - #include <mach/irqs.h>( ^( i! ]$ f- n" T
- #include <asm/hardware/edma.h>
8 ^8 k1 i' B/ O0 |* z
! H. W+ ^7 F9 x9 Y( ?6 g% n- #undef EDMA3_DEBUG
7 @* x1 d5 n7 B7 C) y5 [, p - /*#define EDMA3_DEBUG*/
1 ^/ t# k P( V
/ j6 \0 B+ Q% c6 M' q4 B- #ifdef EDMA3_DEBUG
" X6 f5 e8 Z! j" `, o - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
0 @6 c! ?" B6 G) c. D* N/ s - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
* h' _: M+ Z7 o0 ]) p/ O - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
# E4 N# Z4 [, d8 [4 v - #else5 a6 u, f2 l0 G2 W
- #define DMA_PRINTK( x... )& o6 R1 i b1 d
- #define DMA_FN_IN
, { Y1 a2 I/ Q' G4 Q - #define DMA_FN_OUT4 O8 X( P9 n' e/ {" q b7 R
- #endif
1 R; x$ q W. a* w0 N% X! _ - {# z a% i! H" B @0 Z
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
. f: K. d, F$ ]! z2 A; m$ w% c - #define STATIC_SHIFT 38 Q7 ~$ s4 o [6 P& C8 ^+ }: u
- #define TCINTEN_SHIFT 209 U B& A1 R1 N [6 z
- #define ITCINTEN_SHIFT 21 K9 H0 M! \5 P" @9 z7 R& p# O& p
- #define TCCHEN_SHIFT 22
7 `- b% `' _ Y! w - #define ITCCHEN_SHIFT 23
7 l5 t1 c# ^0 U5 U5 D- A. Q% ?
8 K; V8 f7 ]7 r1 O0 P- static volatile int irqraised1 = 0;+ B) h7 P! W/ n% I
- static volatile int irqraised2 = 0;
7 k) i! C8 @+ E1 t% l! h. P - 1 E6 V$ S5 m7 @* x. c
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
5 X+ Y1 I) b; c$ l! c8 V: X! V9 K - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);) q$ a/ O, o D. U
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);0 K9 r# W6 l/ q K0 g- q) m% I
, e' x, y: Q, F2 n) U& A- dma_addr_t dmaphyssrc1 = 0;0 n J9 S, J: T4 Q5 A
- dma_addr_t dmaphyssrc2 = 0;
3 y" Q" @0 f, b0 `, x - dma_addr_t dmaphysdest1 = 0;
! `6 c2 ~. E3 J! Y; A) \ - dma_addr_t dmaphysdest2 = 0;
b( l. @! m# e& w% @* G - / { A% N! S# s
- char *dmabufsrc1 = NULL;
6 \7 O/ _$ b. N( S( f3 @; o- J4 L - char *dmabufsrc2 = NULL;$ @9 d- v% j5 j: X0 R+ l" L; d
- char *dmabufdest1 = NULL;
, P6 {# Z1 r3 K - char *dmabufdest2 = NULL;
3 ~8 r6 d/ }& {0 T - ) _, y& d( O2 g9 n% r3 O
- static int acnt = 512;
1 O, Q' [+ ]$ ?+ m0 M9 D - static int bcnt = 8;* G+ y$ X# _& w3 J' L! V
- static int ccnt = 8;- ~) ]; V$ e4 E* F
- 2 q' X6 O$ o: g, K) v
- module_param(acnt, int, S_IRUGO);
; \# V9 H4 {# `+ @3 P - module_param(bcnt, int, S_IRUGO);, p6 w# L0 B2 e0 |0 g0 Q' p# j
- module_param(ccnt, int, S_IRUGO);
复制代码 + H1 w/ C$ Q5 x: {
1 k2 A, W) e0 _+ y0 D( N
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
+ @1 A! y1 A9 t' m- rarm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。( r9 q- @: C5 Q& r2 ?) o$ x" `
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。# r3 k# X$ B* `6 |1 y
/ K8 _/ L; p2 U
5 E, L# Y" H# u |
|