|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
. A5 i. U7 A' j- l9 Y) n$ B- [code]EDMA sample test application9 v* E% g- ^: E7 x D4 C' j
- /*
( n& `; Z! g" c6 \6 `5 q5 o7 I - * edma_test.c
6 u" y; W$ U7 Q& R) O* ] - *
! L/ _) S1 M) g$ z- ~% L+ {4 M1 g* d - * brief EDMA3 Test Application2 w' }% I" X3 W5 [! v4 n7 J& l! Z
- *
. B. {/ V, o) h6 A1 Q$ @ - * This file contains EDMA3 Test code.
' t6 k% ]3 h: S; Y - *
8 b; x* L* u* y5 _9 ~1 [ - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
) M! R* ^0 R# V9 H* h - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT3 j$ l3 \: p8 d) S s0 N: s
- * TO CHANGE., f" w" R/ `) t* s+ i( B
- *
. D4 ^: @$ b9 U/ E - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
2 g: \( _- M" g - *
, k0 B1 c; k& F) {& H/ ?2 d( q - * This program is free software; you can redistribute it and/or
4 F! U& v. \2 t* b - * modify it under the terms of the GNU General Public License as1 ]+ ?; \" p( t2 s9 s. @' J0 D0 I) ~
- * published by the Free Software Foundation version 2.
, Z0 S/ Y/ V5 e$ u - *
2 ^5 }$ W/ r2 H3 o! o" S: B - * This program is distributed "as is" WITHOUT ANY WARRANTY of any
4 f; ^4 ], l8 [, z2 G - * kind, whether express or implied; without even the implied warranty
* ^2 s6 W1 \* Z3 E - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
) j! G% z; b9 ^% L9 p3 H* b) ] - * GNU General Public License for more details.) C5 k- q$ H' ~/ S7 s6 j
- */
: ?4 I2 g7 i8 k2 ?' O1 J4 j
w( i. M' d Z) A# A- #include <linux/module.h>
& l9 ]6 H( j5 o g2 w - #include <linux/init.h>: j. b# E7 c/ G4 Y9 X
- #include <linux/errno.h>
1 K% G: X8 \/ N: `. s* K& e - #include <linux/types.h>
5 l6 P: d/ d( z4 K6 N \) |; A - #include <linux/interrupt.h>7 W! P! w5 e! V" J$ o) A3 w
- #include <asm/io.h>
5 A- L& y8 q6 S* O2 N% V - #include <linux/moduleparam.h>
! q6 m; f" h, x" k8 H% p9 `5 h - #include <linux/sysctl.h>0 X* E I V* w X& R
- #include <linux/mm.h>
) B/ X$ r4 T3 Y/ z4 L) }3 l - #include <linux/dma-mapping.h>/ p9 q$ Q% X( b
1 J1 h, g C. `) s4 O5 |! q- #include <mach/memory.h>+ i3 w* e& o! o) J$ B5 l0 |
- #include <mach/hardware.h>
% p% C) ]( L @9 P5 M& p$ z - #include <mach/irqs.h>
6 R3 Y5 ^7 D- O$ N/ g - #include <asm/hardware/edma.h>
" c- f) E& [4 G - 4 n" M# ?: R2 @: v
- #undef EDMA3_DEBUG' s9 [. n) U7 k" X$ V; f! R- ~& X. L
- /*#define EDMA3_DEBUG*/
' g6 j( K( h5 f5 Y
( f3 m, K$ d$ m' w' h- #ifdef EDMA3_DEBUG1 f+ H& u6 _) @, V
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
) Q; W4 k. `6 Q: y8 A - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
; \0 o B1 {# Y! _0 f! m1 y - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
# x, Y- }2 b% {6 H6 ? - #else
) @, \( u" C$ j& N - #define DMA_PRINTK( x... )
3 j; |; Z6 y3 _" [. T - #define DMA_FN_IN
5 w( \$ f) y4 E6 a3 Y - #define DMA_FN_OUT
8 g2 O& F6 o9 B1 F - #endif% `1 ^5 }' R3 A! d8 c: l7 H
- C1 W% e* Q: X! ^1 s6 B: |2 b5 U
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)$ V- {' Y4 [7 y9 Z+ r$ ^
- #define STATIC_SHIFT 3- |0 h' t# Q& N8 M& D! b/ A, T
- #define TCINTEN_SHIFT 20
- V% k7 m7 t! M& @# b - #define ITCINTEN_SHIFT 21
# t5 s. ]* I# W, N - #define TCCHEN_SHIFT 22& i' T, t G7 X/ e! ]; M& ?0 Q
- #define ITCCHEN_SHIFT 23
# g% ~! p1 E% p B5 @ - ! ]5 T- d5 X- G& |* i4 g8 Y& y! ?
- static volatile int irqraised1 = 0;
9 u1 r) d# m7 C( _0 v3 N" M - static volatile int irqraised2 = 0;
; m1 O% o2 Q& d+ \# K. [
9 K5 }( H6 E) |7 ?# C& e" g) M- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
- c" J7 @# v" S$ N' \ - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
# l5 k* w9 Q" e( x7 N1 O - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);8 Q L0 ^9 `6 I
- 0 F: _& I5 Q4 g# A/ l
- dma_addr_t dmaphyssrc1 = 0;4 Y, d6 t7 p( k, r
- dma_addr_t dmaphyssrc2 = 0;
1 G1 _' u8 B* Z& x# U; }0 | - dma_addr_t dmaphysdest1 = 0;7 t- Z6 N/ |) \: H Q" L6 U
- dma_addr_t dmaphysdest2 = 0;
& s( D/ i1 i1 I [! Y: ^3 H, u
G& J" D; [+ I0 a# g- char *dmabufsrc1 = NULL;3 r6 v2 j3 _3 f6 V
- char *dmabufsrc2 = NULL;; s, P) j6 q* z; A9 l, r
- char *dmabufdest1 = NULL;
& X9 K6 i. H0 m) \- i - char *dmabufdest2 = NULL;
8 k- }% w3 b$ o; K( C1 V - 4 c6 T' [) @* }* U/ h/ k
- static int acnt = 512;
' b6 S( L: K: \& ?3 V* e$ } - static int bcnt = 8;0 n' z6 ^" D" S+ @3 p7 z. f
- static int ccnt = 8;& @5 C) u9 b4 h" |( l* k
8 Y5 d9 L5 p1 F/ [ T: N! U- module_param(acnt, int, S_IRUGO);
, Y1 O# m4 R9 y {6 `4 _ - module_param(bcnt, int, S_IRUGO);
}# t2 e' S7 e1 { - module_param(ccnt, int, S_IRUGO);
复制代码
- a! o3 D5 v) w/ V8 |4 x
* f1 t" d+ a; Z! w5 f; O" e! [ 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
p( V: K, K- Farm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。5 \7 f2 M1 E0 f
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。& C9 y. t3 n9 D$ E
4 S3 B9 U$ V6 S. v! x4 [
6 M! G4 l0 b9 B) j" M) \
|
|