|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
/ z1 b" f' Q& O% o9 n1 b' T- [code]EDMA sample test application
g2 I+ C9 G# l' s- A9 o - /*; f$ v' Q8 m0 G
- * edma_test.c9 q* U+ ]9 h# b( h. ?! N
- *
4 ]- j+ p! \! d. x& C3 z' x4 C - * brief EDMA3 Test Application3 Y+ X6 K' P" }8 c/ e1 a
- * l# W, E# I! s
- * This file contains EDMA3 Test code.* {) P+ Y$ g4 f; T; ]5 {
- *
5 r8 m w! X3 l- ~4 J, ~) j - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE O: E& t- o- [( g7 _) L4 Q' b* t
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT) N6 U1 E* u# O% V% w
- * TO CHANGE.6 N" G9 H, P" \% E- b
- *
$ u: U. y" ]2 c* p1 H+ q0 s - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
# K- K, `; Z- H/ {4 M6 j - *
. X# A) z: I3 f( b$ D, ]1 S - * This program is free software; you can redistribute it and/or! t8 } c' ?& N/ a. ~2 ]& N
- * modify it under the terms of the GNU General Public License as
) t: E' n4 n( x5 G$ c8 s- d - * published by the Free Software Foundation version 2.
/ ~) W% b6 w, G; z: k4 O. M - *
/ V. K3 J* D# Q. K. `% R - * This program is distributed "as is" WITHOUT ANY WARRANTY of any6 n- U. S& w# y5 C/ @" E
- * kind, whether express or implied; without even the implied warranty
% ^/ {4 X4 e: f; P" F - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the: `1 {- ?3 ~2 T+ i' u- f& \
- * GNU General Public License for more details.
9 ^2 y% G, v) H! y - *// r0 b, j' n* F( C
/ @( n: |7 y2 S6 l* m: k- #include <linux/module.h>0 I: n% v" N8 s$ _1 j8 |0 |% _+ L
- #include <linux/init.h>0 \# L: U( X( i
- #include <linux/errno.h>. H! V" s7 D- l$ c9 R" V: r
- #include <linux/types.h>5 \8 Q0 P8 _' O& f
- #include <linux/interrupt.h>9 Z7 R- J$ l0 u' ?
- #include <asm/io.h>
: A3 F, ?& O) F2 }/ o/ K3 l - #include <linux/moduleparam.h>$ D0 `( q- X; ~
- #include <linux/sysctl.h>
5 [. }9 q3 f5 G5 w, Q9 c - #include <linux/mm.h>
7 s7 l# |6 Q1 `) g$ S - #include <linux/dma-mapping.h>) q( o- t0 p& O- v5 ~
+ M' r& u7 [ o- #include <mach/memory.h>" N( C+ z/ }1 g( Z" t
- #include <mach/hardware.h>
, w& D7 Q9 W$ U3 a8 p4 ]0 g - #include <mach/irqs.h>- K; g+ T8 E0 \6 `0 x* n. l
- #include <asm/hardware/edma.h>
9 ]' Y! l- L$ D/ ^/ L% Z1 Y
- a- y, ^# n1 J; R. v; w7 j Q" f2 g- #undef EDMA3_DEBUG- N: T% s( x2 n0 _* _' L
- /*#define EDMA3_DEBUG*/
8 ]5 d p" y5 \( E: ~3 X
( G" F2 j4 I$ Z" w- #ifdef EDMA3_DEBUG' t6 \! g9 M$ ~5 \9 ^5 I* [
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)- e/ K$ B' h, X0 H1 e5 O
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
2 A" z& N: m1 _' ~: g7 F+ @ - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
/ V: v t" h @2 i8 h9 w6 \ - #else: n, z# x' @# A! c% G* p0 ^( g
- #define DMA_PRINTK( x... ): j( r3 g$ f. O, b
- #define DMA_FN_IN
8 o) w ~* [8 E! k - #define DMA_FN_OUT
& e0 @, V. m0 E' B& O/ Z - #endif
W. l. H6 g: F0 h6 K6 w - - Z; R4 ?6 w, d) m3 C
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)# {1 o c1 G- ]* F
- #define STATIC_SHIFT 3+ E; o' {1 [5 ] q0 A
- #define TCINTEN_SHIFT 205 l% U, Q$ c8 r$ I1 U. t; o
- #define ITCINTEN_SHIFT 215 c- h; q) G, G3 b) G1 q( c
- #define TCCHEN_SHIFT 22
: b2 ]3 L0 ~7 }8 Z4 a( ? - #define ITCCHEN_SHIFT 23! r+ b X7 T4 h, e! {
* N+ K% S* o, \9 p) c5 {- static volatile int irqraised1 = 0;0 l. L. U+ x. r$ Q$ K
- static volatile int irqraised2 = 0;. V" `6 q/ c0 z: W
" Y9 V, F* \5 X, S) Q# t- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);3 k. ?3 |/ [1 U1 B9 l6 C) o0 q
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
6 O* d5 a; }/ H$ Y& z/ ?9 y$ } - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
% P# I/ K3 y" Z7 t: s0 T* ?4 ~4 y
0 [# z( X" V+ [: |6 M- dma_addr_t dmaphyssrc1 = 0;
: v$ ?6 k7 K. w, h, l/ {+ Z- j - dma_addr_t dmaphyssrc2 = 0;
! j9 x) a4 Y/ A - dma_addr_t dmaphysdest1 = 0;& w+ N0 B* s; W i8 t$ _
- dma_addr_t dmaphysdest2 = 0;: |2 { c; O# B4 j! k1 v4 l
% F0 b) `+ e H1 Z! B+ M( N7 G3 q- char *dmabufsrc1 = NULL;* F Z8 C7 c6 v: U1 B' p
- char *dmabufsrc2 = NULL;" P. |2 D, R$ ^; c
- char *dmabufdest1 = NULL;8 N7 P# a: W9 ^
- char *dmabufdest2 = NULL;7 n' w# a6 d5 a t, b! y; ^
" V. x4 _! f; d7 h0 e4 j; E! ?- static int acnt = 512;! B# l% l. f/ ]- w- [: W
- static int bcnt = 8;
- k; H B* K1 c - static int ccnt = 8;
- ~: w v- \" T) r) ^$ W2 E' }/ \
2 o3 J/ T1 m$ @7 S- module_param(acnt, int, S_IRUGO);: Y1 n+ p; X+ Y h# ~: Q( c; }
- module_param(bcnt, int, S_IRUGO);
; J3 P3 Z" E/ P, g - module_param(ccnt, int, S_IRUGO);
复制代码
. W% F0 F8 w- [# o, ~% @* o" M+ a/ x+ R; ]8 l/ W
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用, Z/ `1 n9 i: h U$ A& L: w' B0 U
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。# h( M5 d( |3 h. `; z: A
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
0 b6 v# ]- F$ y: M1 v8 i. p$ G5 f3 ~) U: l. c4 X7 ?0 s1 b; c
2 W4 _/ V% V) I: h" d6 v; B1 F
|
|