|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
3 B- y* z! K. l% X- [code]EDMA sample test application
4 H+ q$ f/ c) L% A! P9 q - /*
7 W. F* v' D' _ - * edma_test.c; ?8 S" s- w" V& R" P3 M. i
- *
# C$ @/ J! T% }( y( N5 w - * brief EDMA3 Test Application! T* I: i3 w t: t Z, p
- *
# x/ a& z% V& ` L - * This file contains EDMA3 Test code.
8 F3 o0 p' F4 A - *
9 r V% l1 k5 l( v. Q% k, T0 j - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
8 |. J! i, y* h: z3 \ - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT5 |+ A! R1 V0 M" l% @. M6 ~, x
- * TO CHANGE.$ X3 E; B& [: b: M$ e) m2 a
- *
3 ` I. o# G6 B! W+ u2 Q - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/! r! y {0 k0 z8 x# [& x; _; \
- *
4 W+ w& o7 L, N, ]/ \* p - * This program is free software; you can redistribute it and/or
; l% Z5 m- x6 p! `8 k1 Q/ B - * modify it under the terms of the GNU General Public License as
w7 b" k$ j5 q- n - * published by the Free Software Foundation version 2.
B) k$ {3 {9 u0 L# O' Q - *
6 }% _% T& X! w7 { - * This program is distributed "as is" WITHOUT ANY WARRANTY of any- M; D* U, g/ n6 [7 g$ I
- * kind, whether express or implied; without even the implied warranty0 e. }( O9 Q5 Q, S
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
6 y; M( Z1 Q3 |# Z$ Y" _; _ - * GNU General Public License for more details.
3 ]- L8 g' C$ r8 V# F - */
% ^6 w" Y% g" l) t" Q! t - - D' ]9 i. S1 m/ u
- #include <linux/module.h>4 v7 q( U. M$ `: n, W
- #include <linux/init.h>
+ u' |1 g9 f+ @9 W) V - #include <linux/errno.h>
g& Q, c F$ {7 Q - #include <linux/types.h>
n ] N; r/ ]( h- w - #include <linux/interrupt.h>) x9 t5 M) M8 p0 [6 @. x' D) N3 W
- #include <asm/io.h>6 U D& b) j, S. v9 X$ \& m
- #include <linux/moduleparam.h>5 T+ f: Y" y7 R6 |: N
- #include <linux/sysctl.h>" e: Z: s3 \' M
- #include <linux/mm.h>7 ~- }, }8 q, V3 L; q1 n9 }
- #include <linux/dma-mapping.h>$ g0 d# t# P# z8 e, t" L( Q
- 3 v- h% D5 w* J8 }
- #include <mach/memory.h>
0 }& A6 g, {; f# ~. k - #include <mach/hardware.h>/ A x$ j# E' \7 f; _( t) |2 d% X6 c
- #include <mach/irqs.h>
" z4 N" p, X: t) M' U! f - #include <asm/hardware/edma.h>
% n9 V. q- w& m4 H5 W# s
9 O$ @4 A' @- O* G- #undef EDMA3_DEBUG# Q3 L) Z9 d( |% |$ F' Z; U+ P
- /*#define EDMA3_DEBUG*/
% L2 G, Z* t- {4 s" r {, v5 E
( m: r5 t4 H2 F$ d' E- #ifdef EDMA3_DEBUG4 J' _- G& W/ j* D
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
1 j0 n7 }' Z$ p9 X) j' |8 F - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)- ?1 p+ w- F- n; c
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)* B' l( ]8 [9 a) t" I3 k P
- #else
+ w& L2 Q4 W) h1 n& X - #define DMA_PRINTK( x... )( Y, I4 x. }1 O; T# O) W. \6 P
- #define DMA_FN_IN
, s9 W9 K' I6 `& f - #define DMA_FN_OUT
+ z | l& N. E. ]; x. H% W - #endif
) x" F0 f, a* k n
/ Q0 Z& G, N( L& i5 r4 g7 t- #define MAX_DMA_TRANSFER_IN_BYTES (32768)9 z4 R; k/ h) C
- #define STATIC_SHIFT 3$ i2 n" y8 J `+ R9 k
- #define TCINTEN_SHIFT 20
- B. S8 J& H( D2 v5 m - #define ITCINTEN_SHIFT 21
* _( f- B6 r2 v# V1 M - #define TCCHEN_SHIFT 22
1 `( ]; d: U9 q. y% |) t3 } - #define ITCCHEN_SHIFT 23
3 N Q2 X `$ F3 X. W( j - % o5 H \; W% L6 E4 h) M9 ^/ y: |
- static volatile int irqraised1 = 0;, X O, ~6 r) o0 o4 d
- static volatile int irqraised2 = 0;
2 h" M6 e2 @2 C6 X - + n* k4 \( K. n
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);! o L% |. F& I
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
7 y# p: o. [9 p2 X9 k" b - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
( |$ f0 x8 J3 ?# Y4 C6 m9 l+ | - 5 r! K+ l" ~% N
- dma_addr_t dmaphyssrc1 = 0;+ ~* N. _6 j$ T+ }! ?
- dma_addr_t dmaphyssrc2 = 0;: j# p& ^. j+ ?$ a
- dma_addr_t dmaphysdest1 = 0;
) j# _0 E+ ^' {5 o+ i* [ - dma_addr_t dmaphysdest2 = 0;
) T* \5 p- [0 l* z! ^ - 5 ^) f1 v4 L" y
- char *dmabufsrc1 = NULL;8 R$ R" v5 y+ b+ y7 h
- char *dmabufsrc2 = NULL;
# w7 v0 \( y3 S& K: {, X6 ] - char *dmabufdest1 = NULL;, c+ |! Z# z/ j' N @8 t
- char *dmabufdest2 = NULL;
m; u- d8 i, u6 \. Q - 6 n6 r: V% s; G, G% z5 P" [7 l; f
- static int acnt = 512;
7 |4 m0 W5 `5 h& O( S! d - static int bcnt = 8;9 L* u1 l2 F) v) @- y
- static int ccnt = 8;
) u! D2 s: a/ P; h5 V" O
3 C8 m5 D4 A8 u: a; k" B- module_param(acnt, int, S_IRUGO);9 l$ k' ^' F, _2 |: W9 f) E
- module_param(bcnt, int, S_IRUGO);4 B5 Z& C+ m( E; W+ X( q" @* x
- module_param(ccnt, int, S_IRUGO);
复制代码
7 A& Z# P- z5 r( ]
! `8 c6 A% \+ V' m% n) B 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用( L; {& g) b; E) E$ Y/ h, w% H
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
% z2 P8 K4 D+ l# k& Y4 z2 \' ~ 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
: n& T2 I5 |# X/ R9 _
0 b! I3 _( T& M7 f0 A' c; @! I8 G+ }9 J; q8 ]
|
|