|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 / F: g9 [% S7 U9 F0 H# c
- [code]EDMA sample test application
9 ~) y4 G8 L8 }7 V6 o - /*; g5 F7 f2 \$ o$ \
- * edma_test.c( i% Z V) s' t7 R) h6 [& r
- */ {8 Y- Q( r: ~( Y, {( h. `
- * brief EDMA3 Test Application
3 _, b" Z1 \7 y; p - *
# X3 d. S- l `! H - * This file contains EDMA3 Test code.
) p! O* `8 V5 w* V - *" l/ a+ ? T, w2 O- W" g! j! g
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
2 k+ D8 J, c/ j5 j) n - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT* B1 l# {/ X/ r% ^, {/ w
- * TO CHANGE.) q1 x9 O' \* s4 _/ ]: e0 Z1 o9 _
- *! {& L ^1 n, K% F5 d) e
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
* I+ W% N7 v! S, G! o - *5 O2 q3 h" w/ V O: ~
- * This program is free software; you can redistribute it and/or
- }; U5 k! ~* Y- P4 M$ m" z! n - * modify it under the terms of the GNU General Public License as
1 B' R# U7 _8 G - * published by the Free Software Foundation version 2.
& h8 Y: W4 {( a) ]4 k' F - *
0 q; i' ^% e: h/ r8 I. N - * This program is distributed "as is" WITHOUT ANY WARRANTY of any4 v6 L* Y+ Q: t1 P K- c0 l
- * kind, whether express or implied; without even the implied warranty
; b( p+ l0 L+ K' {& [3 q# z; q" o - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
$ D# Z5 y4 A9 @2 c5 K& m - * GNU General Public License for more details., S1 e. [- \- u) G% m
- */1 A; O' N6 J- X! W1 Y& p5 x* Q" b
/ N# L9 k, ]- }5 \ V1 L7 F( \+ W- #include <linux/module.h>
8 A+ W1 K: ^+ k0 m q. D2 \& D - #include <linux/init.h>
` A6 j9 `. c# I - #include <linux/errno.h>
0 W8 L, {5 m0 \; V( f7 z6 L# Y& G - #include <linux/types.h>+ r, U+ D* q! V/ n U! @
- #include <linux/interrupt.h>2 {0 O+ a, c) C3 |: i% O
- #include <asm/io.h>" @. W6 Q7 y0 Y# e1 V! U8 e
- #include <linux/moduleparam.h>
+ d9 b4 |! X/ j1 [ q" N! { - #include <linux/sysctl.h>0 U/ R4 a5 Y1 M+ f# B
- #include <linux/mm.h>
" h) @6 f0 l$ m5 s - #include <linux/dma-mapping.h>
p! g3 ]4 E1 q3 B% j
4 {- x5 g [/ {& D$ P( B$ g5 I! V- #include <mach/memory.h>
! Q* d4 u" J" N: }2 Q. A- i6 s& Q - #include <mach/hardware.h>
5 l5 B* u9 @4 X2 |/ P# ] - #include <mach/irqs.h>; [5 L9 R; @; t* ]9 n' E
- #include <asm/hardware/edma.h>
$ h; `! J; t- Z* X" ?( m
; Z) X. _- ~* Z+ K1 G# e0 ?- #undef EDMA3_DEBUG6 M! S' S% P0 b
- /*#define EDMA3_DEBUG*/4 z9 K) f( X7 c# }1 u- ~% b
- * d! Y' E4 f( h' k" m" H4 y: h
- #ifdef EDMA3_DEBUG/ ~8 ~7 ]+ } |! Z- d$ c1 y/ P$ B
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
$ m% l4 S2 e/ n2 r0 f, R - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
( {% `# I; N0 m* p0 _1 g% n - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)5 q' t8 ^( c6 P8 U0 k4 v
- #else7 `/ U" c: D# u" h+ W% m
- #define DMA_PRINTK( x... )
1 h% V. {, q/ K$ z! i - #define DMA_FN_IN, U- A2 ]9 G8 T& \9 f7 v8 a/ o
- #define DMA_FN_OUT
r% k( W' m' n- J. C; H - #endif
2 w8 z" W2 I9 Y4 }- M
+ x2 Y0 q2 {1 k3 }- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
* h3 E7 T ^% O, o3 p7 G4 s" } - #define STATIC_SHIFT 30 m6 y+ m& F* [" X* I& e
- #define TCINTEN_SHIFT 20
, q/ T8 X, V: d+ Q& }6 h8 _ - #define ITCINTEN_SHIFT 21
( K: z" h4 d0 l% R( b. j) X - #define TCCHEN_SHIFT 220 X D& v; @, o% K: f1 @2 o& a
- #define ITCCHEN_SHIFT 23
: |$ A2 Z: ]$ f3 W( ?& S: a7 Q5 W - - b# E* }4 P8 | I2 Y
- static volatile int irqraised1 = 0;( K3 ?# @' Y6 ~
- static volatile int irqraised2 = 0;
. ?+ C1 {9 u+ Z& Z- f
# R0 F/ e$ T$ Z- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
3 f% o' O$ @/ M6 r! {- b - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
8 |- J9 ^: k9 b2 V - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue); o/ V: r5 O) u, v0 s# G
- 7 ]0 i4 q; y4 A" y$ ]6 e2 y
- dma_addr_t dmaphyssrc1 = 0;
+ R+ ]- P1 L1 |! Y2 A( @ - dma_addr_t dmaphyssrc2 = 0;
# Z, T% r3 {3 `" w$ f& p* ]* w- C - dma_addr_t dmaphysdest1 = 0;
9 y9 |8 Y/ F$ f$ N4 r5 Z - dma_addr_t dmaphysdest2 = 0;
" t: z; h' x7 e& i# u0 P1 r - ' ^7 a3 T p+ A( k" U Z
- char *dmabufsrc1 = NULL;! H: b1 k' ]0 ^5 u/ F
- char *dmabufsrc2 = NULL;
" q; o+ d7 Q/ y0 J& K - char *dmabufdest1 = NULL;
3 a' ^; G" F; z - char *dmabufdest2 = NULL;
6 T2 v: r1 v8 L, G. X! W: r- X - ; E& D c4 C1 S' `, A
- static int acnt = 512;
) V8 \5 z. G/ A" ~/ o; }. j, J - static int bcnt = 8;
- X) w0 j% d1 s0 u, G5 L- f3 L - static int ccnt = 8;/ |0 k2 [. r$ }+ A4 Q- B
! o3 a! @- A0 _5 c5 q- module_param(acnt, int, S_IRUGO); A+ W0 P0 B. F0 n" q) f
- module_param(bcnt, int, S_IRUGO);
6 W ~! O9 U- o d - module_param(ccnt, int, S_IRUGO);
复制代码 ) p$ M4 V: f& J$ H
7 H; R; n; |/ U% L% }1 ^ 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用* L# C% Y( B. q5 l
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。" t: f1 p" r: b# U- F( M
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
% k" l7 c' X6 W8 ~ m r+ `; q; a4 l. C* Z0 [9 d( Q1 w* x
9 L" ~/ _) ~' t" u+ Z' R
|
|