|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 + y6 t& w4 n$ L3 Y) h
- [code]EDMA sample test application
3 b9 w7 x; j2 t! @. \ - /*
+ N" z7 T9 w% l9 p, c - * edma_test.c+ X! x; W H0 o" X
- *7 _2 m0 n+ U- Y) w6 [6 T' L: y
- * brief EDMA3 Test Application" g2 m6 i$ w& ~
- *
4 ^5 x( b7 l/ W$ ?2 D- g1 q* O - * This file contains EDMA3 Test code.6 k4 L5 J5 Q, u( T( \
- *( e- g. c% y9 {% W9 w4 Q( j/ _
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE" R* z, a/ e* U$ ^4 W
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT. I; X' {1 G( ^
- * TO CHANGE.
5 ^' r' B+ P! g" o+ g( D: k" i. I - *
$ n7 } s3 T; W3 V3 _5 g! ? - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/ k4 q3 L1 A2 ]) Y
- *
% X# D( E1 h8 m% a6 N - * This program is free software; you can redistribute it and/or
) v! J! p" M8 W8 d+ r - * modify it under the terms of the GNU General Public License as1 n \$ k+ n3 c w. a3 r
- * published by the Free Software Foundation version 2.& X4 z; L( k# I* J' Z
- *
+ i" H( D/ r4 T |+ x! W; U, `" I - * This program is distributed "as is" WITHOUT ANY WARRANTY of any; H# Y7 g3 ^- e! G
- * kind, whether express or implied; without even the implied warranty
& C7 T% J7 @+ g! }( p E - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the8 Y* ^9 W1 T. s- Z. B
- * GNU General Public License for more details.
6 l% I; }' N1 Z0 [) z; W, L$ o* L - */
/ P% W" j ]/ ^5 S
7 s I& z! M& y2 [& K$ C- #include <linux/module.h>. o. s6 F! p9 H6 |5 F
- #include <linux/init.h>7 F' Q! w- D* s: C
- #include <linux/errno.h>
4 G! `8 J$ ~* S: Y1 P; F - #include <linux/types.h>
9 ]2 }! M/ t: S8 ^ - #include <linux/interrupt.h>
3 D, B6 T7 _3 o - #include <asm/io.h>
2 r! ]2 @: W8 I! j0 g) t - #include <linux/moduleparam.h>
$ }9 z, I2 R- J# d; p( d - #include <linux/sysctl.h>: i& L" v2 d. B/ d/ e
- #include <linux/mm.h>
3 U; a1 a; U+ }! ~9 ] - #include <linux/dma-mapping.h>
$ H/ F0 Q8 i. q& T4 }# x - . U6 r, h) C! u- P
- #include <mach/memory.h> w" b; D5 L! J) L* J: W: u' e
- #include <mach/hardware.h>
6 ]+ j: y. {3 }+ { - #include <mach/irqs.h>
7 E; B# Q6 f. n' [! s3 C& l4 J; c& d - #include <asm/hardware/edma.h>9 n7 r, D) ]0 p( s. w! e) ~
" d9 o; M& Y% N1 s7 v& B1 d- #undef EDMA3_DEBUG6 `: s! Z0 x- Q% s
- /*#define EDMA3_DEBUG*/: j' R6 o# n$ a1 R
- + O+ ^# `! E# B, C6 P
- #ifdef EDMA3_DEBUG
/ l, m, \& O3 Y) ^" U - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
; L( `1 w1 E% s" E - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)6 K( O/ O- x ~- e/ U
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
. m: N7 W$ W( u) N& _* \% w" i3 b% ]/ Q - #else; p4 A8 X; p0 k* B8 o
- #define DMA_PRINTK( x... )
- I& B$ C8 \5 X$ l5 T9 S4 u - #define DMA_FN_IN- J) K' @# I' @ [1 Q. v, ?3 u- {
- #define DMA_FN_OUT
- i2 o& y9 z8 M/ O# `: }4 d7 I! @$ n - #endif6 L7 c. s/ \: B. P0 E; V+ m8 S
6 b* m0 o/ J& }+ Q/ T$ c4 e- #define MAX_DMA_TRANSFER_IN_BYTES (32768)1 W5 h' z# }' n7 U- H
- #define STATIC_SHIFT 3$ Z0 F S& g, {( ~) m$ |; }" Y
- #define TCINTEN_SHIFT 20; i; e# [+ O8 z; a8 g; w
- #define ITCINTEN_SHIFT 21
7 R4 p% s+ G/ m7 m - #define TCCHEN_SHIFT 22
7 T2 Y; P+ U0 p) _ - #define ITCCHEN_SHIFT 234 u# F) H' I1 o. o+ B
- % R) L5 n4 E+ N+ T- L" Y
- static volatile int irqraised1 = 0;# l8 t* O" \ V2 J2 |" @
- static volatile int irqraised2 = 0;
* N L0 K+ y7 o' @! E% c: y+ g3 B3 m - , I7 A* O, B, k# m$ v5 R
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
+ R3 R+ w" A) w' f - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);: e4 D% P8 ] O- Q0 U: l( ^5 R
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
2 L' p3 G1 E* ]8 e8 t! H& U: } - - z* H5 L: P) H
- dma_addr_t dmaphyssrc1 = 0; [5 S) |: b, U4 I
- dma_addr_t dmaphyssrc2 = 0;+ V% H* Q2 I' I' X$ J- ~! A
- dma_addr_t dmaphysdest1 = 0;" Q7 ~, u D; L5 C% T
- dma_addr_t dmaphysdest2 = 0;% |% C. o8 l2 O6 L; h( Q6 ?8 K
$ w# I9 K0 w9 J) I" }& a8 K- char *dmabufsrc1 = NULL;$ A) z* c! T! N, I% N, s
- char *dmabufsrc2 = NULL; L" w f; [/ m, x/ a% Y
- char *dmabufdest1 = NULL;
8 F# \' C3 m1 p - char *dmabufdest2 = NULL;) T! Q3 Y: |7 {, b
- # R+ Y) P. g2 S6 K2 h1 u; t8 U
- static int acnt = 512;- x' v5 I9 ^' i6 P% N3 Q8 k( _
- static int bcnt = 8;4 l, O9 ?/ E$ f' h: q+ U
- static int ccnt = 8;
, T' P4 X, N5 W, n# J
. N" @' o, ?! Q( b- module_param(acnt, int, S_IRUGO);
3 h& n4 C0 J. R+ O5 R - module_param(bcnt, int, S_IRUGO);2 I1 V0 j7 C7 C' m6 R7 ]0 ?( b9 c
- module_param(ccnt, int, S_IRUGO);
复制代码
. D m$ K" c1 t# p- B+ C
9 o. D: w8 d) V% Q( x 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用1 M3 N( m0 e' a9 U: q
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
/ o. k' S/ t8 l D( r V6 Z 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
4 J/ Y7 O! k5 _ p: q' T
% b9 c3 R3 _& r0 Q+ m7 i, P/ r1 S4 c7 H. g
0 ?5 M/ C+ h4 q- P |
|