|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
4 p& q Y; f4 `, p2 H- [code]EDMA sample test application. J6 f! |; g" g) ^6 \- h6 N( y1 `
- /*5 p8 f: g1 I; |7 ^
- * edma_test.c3 K6 w A5 ~ @0 {4 G6 }
- *. x" j2 x* Y/ P" ^& S" f% |
- * brief EDMA3 Test Application
4 A4 a S) T: X8 O+ ~ - *! d7 q7 B" l& L k! }' p) J
- * This file contains EDMA3 Test code.
3 u1 P, @0 x) S9 M+ h - *
; d* z' X4 a$ {* D9 T3 x% e$ [ - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
2 v) Q$ h5 B* R) B+ j8 P - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
, d' c$ B' z5 O7 D/ s* z - * TO CHANGE.. B; G. Y0 X& t2 e( P; C2 @. u
- *+ S) F2 L7 D* G- n& n4 w# q
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
. e" p. L1 f) g) j: R - *
/ n0 u4 J7 }$ W B4 h - * This program is free software; you can redistribute it and/or* @0 J, l2 q. ~ H. b* Q( Q
- * modify it under the terms of the GNU General Public License as6 D, ~! r- L% o; ^
- * published by the Free Software Foundation version 2.
' W8 L( y" C. d+ R! c& _: ~0 E. R - *
3 j; ?7 p9 p6 M, C3 W - * This program is distributed "as is" WITHOUT ANY WARRANTY of any; o/ k! B6 V- [4 q( U! X- n! u& g: J
- * kind, whether express or implied; without even the implied warranty/ b) J$ k3 V' Y' O) P5 ], x
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
, Y7 D1 S! ~$ L/ L8 u& W1 x - * GNU General Public License for more details.8 V! D$ ~9 g' @" Q% I# h/ @$ t `
- */! _3 C5 u2 k" ^# L# U3 H k
- - {9 P: l- j; n5 }% S D$ F4 h
- #include <linux/module.h>: I! A4 h2 K6 G- y4 a" p
- #include <linux/init.h>
/ {) A* s4 [: D# z* E9 \6 r - #include <linux/errno.h> j% ?6 v! }8 f- h4 p
- #include <linux/types.h>
! t" @8 k; s7 w0 q1 C3 C - #include <linux/interrupt.h>8 v; s1 K) Q5 ~; t9 y
- #include <asm/io.h>! |+ T1 M+ i6 A6 e1 q! f+ \
- #include <linux/moduleparam.h>
) r v8 u6 B; b% }1 y - #include <linux/sysctl.h>
. H' U! O$ i( T - #include <linux/mm.h>
: K: l2 q( i+ G0 M - #include <linux/dma-mapping.h>/ f! k3 Q& p5 ^; g: [* I m
: C# l% j J" u ?- #include <mach/memory.h>
- |0 W6 A9 ?& F& a; i/ L; C( X# c" m - #include <mach/hardware.h>
4 E9 m% I! Y6 m - #include <mach/irqs.h>
6 m# A5 s' _* P0 P# N! P, t* s. ^ - #include <asm/hardware/edma.h>
6 N4 J+ r$ O' u; w% E8 a$ s
$ N* |2 A' n3 u1 y: K5 I, b) m- #undef EDMA3_DEBUG
4 A! X" X7 j+ X' d - /*#define EDMA3_DEBUG*/
) E0 Z) v. A5 H+ W. N$ \ - . [0 k5 c) _/ V) [4 \
- #ifdef EDMA3_DEBUG
; ~# D6 g0 B$ j4 s* w" ~! a - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)+ c# { W( H; n& g
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
1 q; M- D4 H: o! ?$ V |2 y - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)% j( L0 o9 V& s9 ~+ K
- #else/ u% j9 g& q$ E
- #define DMA_PRINTK( x... )
# F& A( D: O3 t z - #define DMA_FN_IN$ O6 o! X% d; t1 ?
- #define DMA_FN_OUT
. w9 |5 b0 [# Q4 [" o/ v - #endif% @7 X6 Z* e3 u
3 j' I6 H! ?7 U3 l- #define MAX_DMA_TRANSFER_IN_BYTES (32768)" A! B3 v% A% ^3 Y
- #define STATIC_SHIFT 35 D5 P K: H: T8 I9 a8 x
- #define TCINTEN_SHIFT 20
' M& i* t% H: [ - #define ITCINTEN_SHIFT 21
6 C+ t C1 G* Q/ h3 ` - #define TCCHEN_SHIFT 22* _- L1 w! z- o, E; F" q% U5 R
- #define ITCCHEN_SHIFT 23. h& W9 T9 u3 k! }
) P, x% X/ d( Q+ `. z" G* F; p/ U- static volatile int irqraised1 = 0;
4 k8 H; P+ g& A) s X8 y' y# q( ?% w - static volatile int irqraised2 = 0;
' O" B9 R5 h3 a# ^" v
5 ~- ~; {: f+ w0 c- w$ y5 X- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
N: D3 n! G. _. @" u: Y7 C - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
0 |: h6 D4 ]2 A8 U - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);; }* n. |2 V$ N0 s
- - f3 W. M ]3 m: D
- dma_addr_t dmaphyssrc1 = 0;2 Q* k+ U. ^% W8 `8 J: e P
- dma_addr_t dmaphyssrc2 = 0;
% E7 ^# C. N# } - dma_addr_t dmaphysdest1 = 0;( [- u5 s' c' L8 i; c
- dma_addr_t dmaphysdest2 = 0;
- D) Y" z# X& F; y4 I
0 h) J- v" x+ F- char *dmabufsrc1 = NULL;$ ]$ ^* C/ i6 J4 F3 g+ b7 d) k6 c5 I
- char *dmabufsrc2 = NULL;- l- r" e7 {1 r4 V7 a
- char *dmabufdest1 = NULL;
* B% l9 ?/ u4 M1 v7 N4 x' r - char *dmabufdest2 = NULL;* b/ ]4 ` T: n1 J$ X5 D4 ]
5 j. b) W& M' X& x, t$ E- static int acnt = 512;% V6 h- G' L& g2 C
- static int bcnt = 8;* j Z2 O' `& h
- static int ccnt = 8;; d9 V- t' e& A; `* ~. D$ Z
- 5 f+ L9 X# v/ w T
- module_param(acnt, int, S_IRUGO);& v9 w( Q* n8 e, j0 T3 ~
- module_param(bcnt, int, S_IRUGO);% m4 l# u$ T4 M" r. W
- module_param(ccnt, int, S_IRUGO);
复制代码
3 E0 P0 L' t6 G _$ A$ q+ C# G; B% y* |; @ ^! B& `# l3 g4 L3 ^
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
$ E" p0 R9 {) c) i% Tarm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。, G/ q5 ~+ [' v" H+ W
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
0 B3 r/ o( N$ \1 t' C! R9 K
* U% j; K; y+ A( i
5 R, H7 ~+ r5 [& u- @! s" d: r |
|