|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
! U; p% R) z, k4 e; d- [code]EDMA sample test application- D; X% \7 Q) s2 \% u* c
- /*( ]) z6 u- ~' ?. o0 D! o2 h
- * edma_test.c7 t' U) O9 Y- U9 ~3 H2 L0 T
- *. r2 @' I' F7 R
- * brief EDMA3 Test Application0 Q5 X1 g' s% D( R' R+ D
- *7 V. H6 h5 }3 j
- * This file contains EDMA3 Test code.
0 @+ A5 X/ y6 }4 @& R - *3 v8 i, f& M* x2 C7 ?" M% M8 \
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
* {6 T+ y+ h0 w5 \- i - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT' e& J! ]7 F- a9 Q
- * TO CHANGE.
* f5 z; s/ m4 t8 Z( W. {5 W( t - *1 ^3 x5 ]: J1 m
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/8 ~3 ~3 `7 J1 Y' O, a
- *, n+ @+ L" k) |- z; b" D
- * This program is free software; you can redistribute it and/or8 Q4 }0 P2 x- B( v* ?5 T
- * modify it under the terms of the GNU General Public License as
; s- e# S- g! f5 n* D/ Y - * published by the Free Software Foundation version 2.
5 K$ G' K3 Z2 F% h - *
' X7 F3 G% f2 B, s9 k - * This program is distributed "as is" WITHOUT ANY WARRANTY of any' b; j% x4 [; ]8 o6 r( |
- * kind, whether express or implied; without even the implied warranty
T4 q( p: J0 O - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the' W7 v8 s, i o4 o
- * GNU General Public License for more details.$ q3 @( h; f2 I9 E
- */
6 \, j" f0 `; u. l1 }7 Z0 z* T( j( ] - 0 a: X7 ~. m$ S
- #include <linux/module.h>
( ^/ ]8 p3 o7 M. l9 f/ w! b - #include <linux/init.h>
2 U& z& f2 D+ d' E( @2 R. O - #include <linux/errno.h>
; ^/ i2 A' S4 u4 `7 e4 z - #include <linux/types.h>
% G! D1 _. |- l: F. V - #include <linux/interrupt.h>9 K: x+ X2 D( |: y5 z: x8 F
- #include <asm/io.h>
2 h6 D, a# |" a' @8 K# u - #include <linux/moduleparam.h>) m6 \; t, Z2 w# I2 L
- #include <linux/sysctl.h>: i4 G1 a: P& S- g4 [
- #include <linux/mm.h>9 T! B' h7 P* C
- #include <linux/dma-mapping.h>4 n0 T8 {% P: l! c# E" n& j
# b: |8 m+ c$ h9 _7 e w- #include <mach/memory.h>
* G0 ~+ ]7 |& _, f5 m, N - #include <mach/hardware.h>
4 O: `; R, l5 K) g/ r - #include <mach/irqs.h>
" d; H, ~: u# h8 H2 i - #include <asm/hardware/edma.h>: r9 q m; Q! N0 U* b
- ! a) N* y6 F6 u; }4 f4 i
- #undef EDMA3_DEBUG# K7 c6 y3 z: h/ T5 t
- /*#define EDMA3_DEBUG*/( O) V2 ?) A' b/ m# D
8 [3 T5 g6 r. Q0 m- #ifdef EDMA3_DEBUG
! X8 p5 _! k% T1 A) e+ t- Z5 B - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
+ S! w( W# C, H$ | - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
( a: K$ G; T3 f' D4 u1 z - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)% m+ E8 J# L/ `! x( u
- #else' x0 c' ]/ I. V" V+ h& |
- #define DMA_PRINTK( x... ). \9 s4 e/ t( i% E5 d
- #define DMA_FN_IN' o: @% K9 G( R1 c4 |/ p
- #define DMA_FN_OUT
1 u X* \) ? r; @7 J* A - #endif" g! f0 C( W' k2 r: g& ^" f
9 { H) g6 y1 ~- `. w. K$ V( B. `. r( ?- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
4 @, z+ E* n0 n - #define STATIC_SHIFT 33 c, j, O7 C2 M# w7 @+ w
- #define TCINTEN_SHIFT 20" E! n0 i! M, e, A7 d$ h3 F
- #define ITCINTEN_SHIFT 21- @0 L! G* _/ v( H
- #define TCCHEN_SHIFT 22 _6 v' n& \/ w& u
- #define ITCCHEN_SHIFT 239 ?0 O- t. u2 @' |: ?6 u, G
- $ u/ ^' S5 z. n2 S. A
- static volatile int irqraised1 = 0;- [) x$ X! o: f- ^& N% |
- static volatile int irqraised2 = 0;
8 O7 q' Y2 V4 R8 r( O8 c
9 G# n* E# a! F: u+ I: v$ _! j- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
2 h# h% D% N/ S' S# ~& M0 E( g - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);+ |* k, m! o8 [
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);0 m2 R& l2 u/ Z2 x5 @ f
) n* q1 w# Y' L0 ]- y8 ^- dma_addr_t dmaphyssrc1 = 0;, [8 \& [4 i, o3 `1 D T& B) r2 _
- dma_addr_t dmaphyssrc2 = 0;
/ P |/ f7 J, a! e - dma_addr_t dmaphysdest1 = 0;& w8 S* W& O! Q; o
- dma_addr_t dmaphysdest2 = 0;& t0 d; C3 I) f
, N# q9 H" O/ f- char *dmabufsrc1 = NULL;
' t3 g9 j. H: D* ?# r" c - char *dmabufsrc2 = NULL;" s- f& A; S" ?- T/ i/ _3 p
- char *dmabufdest1 = NULL;7 @ Y# q- E) A9 L
- char *dmabufdest2 = NULL;
0 V( m+ ^& m2 U
* @( v8 }6 O, E- static int acnt = 512;
7 s) ~$ k/ ~. S3 e0 l) C - static int bcnt = 8;" u" E9 U7 L( [: A. X8 K
- static int ccnt = 8;
0 |; |; K( }" b4 ^, W$ o- k- D
0 X4 y$ |. m5 J( r- module_param(acnt, int, S_IRUGO);
7 H0 p. U% ^8 ]1 r9 w8 P% a. F$ h$ y - module_param(bcnt, int, S_IRUGO);
6 Q# K; m) Q5 J- y - module_param(ccnt, int, S_IRUGO);
复制代码
9 G- z! u# Y4 ]
" Z0 v. M; l+ B* V& U7 D( G3 N6 E 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用) n! [0 e6 H& h5 \3 C7 _" M
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+ T. y& r& ?3 c; r
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。. _; V6 L- Z8 A1 w4 S/ |$ y' \
- ` @& z' {; Q
$ U" P+ J' H( ~! x% y- O |
|