|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 1 r; ^' i" D, E: P( t; k
- [code]EDMA sample test application% ^& z, \ z/ I, B6 a: @
- /*
# I# D# k, z, ?! }* _; d" x - * edma_test.c" O8 K% `6 `6 y5 C
- *! @/ |; s+ s9 Y& [- E4 F# h& u
- * brief EDMA3 Test Application3 G! O6 O4 [, ?- q# g( s
- *7 v/ r6 U2 E) @+ G: [ ]
- * This file contains EDMA3 Test code." i3 \6 O# T. ]
- *- |- s$ F A3 ^! M0 I
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE! _% H, `7 H2 F' T0 q2 M9 c4 ?
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT8 G$ {) |8 e3 \9 p. O
- * TO CHANGE.
3 k4 |: I* G- e* u - *
( ^1 M5 ?# ~6 i+ D f - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/4 A: t7 l1 e" T" c, z# N+ h
- *
' _: v& N3 ~" p! N" H, ` - * This program is free software; you can redistribute it and/or; Q2 X) j4 X3 W2 h
- * modify it under the terms of the GNU General Public License as
' r1 d3 g$ _- A+ o. E - * published by the Free Software Foundation version 2.; c$ c, }5 U) }' {
- *
k5 z1 I4 q5 \' b) O - * This program is distributed "as is" WITHOUT ANY WARRANTY of any5 O" a! |+ x$ |7 n
- * kind, whether express or implied; without even the implied warranty z: U' p9 b( X1 }' k4 o& _5 h
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* i, v2 f+ [/ i2 g" t - * GNU General Public License for more details.9 {# ?- z8 J5 g+ u! N
- */8 y# e4 P, o& a
- 6 z- d7 a' j& O
- #include <linux/module.h>
; C# @% R$ i6 t4 [7 X# }" P - #include <linux/init.h>' I9 T. d* k% I2 s; A% |6 C
- #include <linux/errno.h>
. e# M2 a7 d+ C) |' V* Q9 s$ a! R - #include <linux/types.h>
( w% T- X, U$ B& a, K2 ? - #include <linux/interrupt.h>
2 Q0 Z1 }! i5 Q! `4 w - #include <asm/io.h>
0 p5 ?: @' c/ z) Y7 K9 E# Z - #include <linux/moduleparam.h>( l+ C; N8 I. c: Z5 V4 r. \
- #include <linux/sysctl.h>' p) |/ N5 {, d0 A- d4 C
- #include <linux/mm.h>/ G- M9 U' M3 `8 \5 F# F
- #include <linux/dma-mapping.h>" O1 C" a) Z: C5 f: `
; b' R' k) x* h# y) w w- #include <mach/memory.h>
7 M: A; h0 j8 M1 x - #include <mach/hardware.h>2 e+ S, ^& f$ H! S$ S5 A1 p2 H% `5 c$ @) ]
- #include <mach/irqs.h>
* M" \$ y- D: Q6 T( u% W( w. m - #include <asm/hardware/edma.h>* ^4 U" D R7 Y- k# p
+ t% \) B3 {8 T/ q2 w8 r, e7 t& ~- #undef EDMA3_DEBUG
& s% ~4 g% W* V, P - /*#define EDMA3_DEBUG*/
- b" Q" U7 _8 r1 H+ V( `: Q - ) G% E# Z4 |, j& `
- #ifdef EDMA3_DEBUG
$ s# N% E' w, e2 H- `. p6 k- Q& } - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
. B; Z4 E) K9 e# I2 E" _( s( G - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
/ ~# I: S- y8 ~% `5 d% ^. g3 D - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
! A0 D! R8 h* S" w9 J9 x - #else1 O1 @; G3 V& T" C) {
- #define DMA_PRINTK( x... )* }+ A3 |* |& R3 Y( b& B) @
- #define DMA_FN_IN0 B' c0 k4 [" Z" a$ \
- #define DMA_FN_OUT
* `- X; F( n! g; [; T - #endif
% g k! Y$ Z) R" Y" c
- z; P8 G) \5 X- h9 p- #define MAX_DMA_TRANSFER_IN_BYTES (32768)/ c8 x8 n' d9 b
- #define STATIC_SHIFT 3
5 b j! Q( N. A - #define TCINTEN_SHIFT 20* C$ [5 [; k6 ~5 t, t3 W( v5 S
- #define ITCINTEN_SHIFT 21' s7 W7 B- P% u* L! |% P
- #define TCCHEN_SHIFT 22 \" {8 `! j7 _1 g) x) c
- #define ITCCHEN_SHIFT 238 P4 g; A; W1 E; W$ q. [
* b; i) h2 g6 L% ~- p1 B. V- }- static volatile int irqraised1 = 0;5 }% _& Z* ]; ?. g, \& A) c
- static volatile int irqraised2 = 0;
9 L+ q3 e) ~& Y5 J( j
7 U7 L# T# J& X/ j. P( @1 c0 Q- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
/ W% D% j, P/ C1 o( ?: @ - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
: N) K6 ]8 o1 ?5 R, C5 J+ e+ C2 R - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
+ p- @) S3 h& h3 q0 N* {9 E
, T: }5 @) B# _3 J& Z, o2 m- dma_addr_t dmaphyssrc1 = 0;9 Z3 [: t A6 f( {; C. b6 Q
- dma_addr_t dmaphyssrc2 = 0;7 V3 e& }, ]. R% D3 L6 f$ ?
- dma_addr_t dmaphysdest1 = 0;( ~% N8 q5 K% t. ?
- dma_addr_t dmaphysdest2 = 0;
1 U8 D3 Q$ \+ f4 Q - 9 v* X" K Y; U& i- p1 ^
- char *dmabufsrc1 = NULL;
5 @* |# {2 u& f" F R - char *dmabufsrc2 = NULL;+ V8 \% |. Z* h, g0 B
- char *dmabufdest1 = NULL;
' w0 u1 P* R P# Z - char *dmabufdest2 = NULL;
4 h3 K0 f g( k
, m; c9 v( Q' a% k! x2 ]4 ]- static int acnt = 512;
5 E5 k& Y$ K# L2 P6 W' j - static int bcnt = 8;
/ A4 U4 d( \* Z- N) Z7 r# Y - static int ccnt = 8;
! K' V* X0 S7 C+ `$ ` - & g- i5 [6 T) a% a8 b2 k; I1 ~8 h$ g
- module_param(acnt, int, S_IRUGO);$ N3 g4 n2 K( i7 _4 r$ k
- module_param(bcnt, int, S_IRUGO);
- F: _. H! l# n/ k! K4 H! E q - module_param(ccnt, int, S_IRUGO);
复制代码
5 S3 ?7 C1 ?% B8 a v( F( o
! G7 `) K" ]% h 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
5 F( Q5 ~0 e# I+ N' Warm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。" ~) x9 t+ [, o& S+ V9 i
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。; h+ |7 P) |! W6 q: Z& B+ C" e
+ O) A& T! _0 L$ T) d2 I# L: ]; E) N# ~) d, q
|
|