|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 : M5 W( T' C# m1 l2 H
- [code]EDMA sample test application5 }" }# q3 \$ O$ _ m6 w5 v
- /*8 ~' ]) Y" |1 j! p1 _
- * edma_test.c
; w7 L( H) G' N+ j: P5 s& V$ E7 o - *
* q* C! \- d0 r8 Z& V+ L) i - * brief EDMA3 Test Application
V6 O' Z# e. T# ?2 }0 V - *' o9 C: J: D7 Q H+ _ R
- * This file contains EDMA3 Test code.& `3 U7 @9 I, Q+ J: T9 T
- *9 }) v2 {& {! O
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
5 g7 ~* x/ Z( K+ n - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT1 v: ]0 }. w% z" Z3 P, ~: ?. D& Q
- * TO CHANGE.2 K) q2 |9 x: F6 H ?! D+ `
- *) G. Y" L2 w% C' B6 i: w" @; |
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
+ o+ A' |- [+ W! H - *
. u$ _; M+ l! j; \, f0 L! ?/ U/ A0 n3 D/ b - * This program is free software; you can redistribute it and/or
! M- g8 Y% W) M% v8 ?4 A - * modify it under the terms of the GNU General Public License as4 b/ B4 ?, P+ k: S9 j: {
- * published by the Free Software Foundation version 2.
) ^7 z6 }8 z; y' Q$ l - */ |/ i7 b7 {, B1 U6 O
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any
3 D9 a# W8 L* z7 a4 N% u9 ?- g4 a$ s - * kind, whether express or implied; without even the implied warranty
, y8 X) Z& s4 l. p4 W* h$ [ - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the- B" c' K5 K+ J5 [9 y: G# }
- * GNU General Public License for more details.
) k0 G' ~2 i" J4 F$ N9 D - */( X# R6 U) t! J, g7 k; u4 i
. Y0 y; ~& r3 ~9 w" G+ A' e* B- #include <linux/module.h>! k4 ^" f& @3 C* H( ?0 p7 T# H- z: [
- #include <linux/init.h>
6 M: g# E- l0 _ - #include <linux/errno.h>
- G% |# l+ H2 k, F2 d - #include <linux/types.h>
$ w/ |8 _: ~ x z' Q$ L - #include <linux/interrupt.h>- W) o5 M# o5 d) ~3 k
- #include <asm/io.h>) F) ?( s# s0 E& Q6 Z+ V1 q
- #include <linux/moduleparam.h>
/ y! x3 [* T! p# j- n - #include <linux/sysctl.h>
; h7 F; f4 x6 j' @1 S( t - #include <linux/mm.h># ^+ Q* F5 |" K1 o( P
- #include <linux/dma-mapping.h>
3 h+ f( b) h# u( n1 g1 n
3 {5 z- Y. J) M5 |5 b7 v- #include <mach/memory.h>4 b/ g5 H( S. g0 N; a
- #include <mach/hardware.h>
- t) s3 I3 ~- d# O6 e. D* Z - #include <mach/irqs.h>
: ?+ ^4 A/ {( Y6 r1 P7 ~ - #include <asm/hardware/edma.h>+ N0 b- i7 \% V
2 n: ]: S2 A/ a. C. p: k- #undef EDMA3_DEBUG4 {, D# L( y6 g: }9 d6 R( y
- /*#define EDMA3_DEBUG*/% c! g) d$ C/ z, ` v, l
- 8 l7 l' p. Y! g3 S
- #ifdef EDMA3_DEBUG* ~0 s) t8 z, T
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)8 j, i5 L6 D9 ?/ C" }1 X' A0 j
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
0 \( D5 l7 z0 E6 v" | - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
& i( J& g" b6 `) J - #else
' J9 }* R3 W* Z" e c: M - #define DMA_PRINTK( x... )3 N7 m9 ?3 G0 ]& q7 c( Z+ X+ ]
- #define DMA_FN_IN5 V( l+ h& _& ^ a$ b3 d$ j3 {
- #define DMA_FN_OUT
+ a0 F+ a" F+ s; l) f0 V - #endif( B2 i% L! [# E1 H
- 2 B5 Y- o3 N# c
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)5 I- [; t# V' ?2 {. c9 l
- #define STATIC_SHIFT 3
- ^- Y% U% r2 z0 e. e) b - #define TCINTEN_SHIFT 20$ k- o0 N8 R( X) k
- #define ITCINTEN_SHIFT 21
) {( M! L9 Y5 h3 B% Z1 F, ` - #define TCCHEN_SHIFT 225 p$ ^, G2 A/ x5 }
- #define ITCCHEN_SHIFT 23
" B" `# B) \+ M( p+ q# v - 3 z, V; K5 E5 m" ~$ F( d$ M: u2 ~
- static volatile int irqraised1 = 0;
1 O3 F0 f" F! _; S9 { - static volatile int irqraised2 = 0;
! V' @5 n& c$ F# J) U8 p
6 v" k9 m7 Z% _& T) B" C- ?) M1 C- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
x# r' E- ~( p, Y" P2 _2 X - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);+ {+ k" P6 h4 |# x3 k
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);; H# V& }7 h; e. s0 b4 L# H
" S/ R7 E3 H8 v2 ?1 s; W- dma_addr_t dmaphyssrc1 = 0;
! G8 K- e" A- z" s1 U( |7 K. i - dma_addr_t dmaphyssrc2 = 0;
! K7 a4 j2 e5 O5 M$ y - dma_addr_t dmaphysdest1 = 0;* e4 t H6 w. O" P1 X& u0 Y
- dma_addr_t dmaphysdest2 = 0;
. ?' b+ x2 q' v( u6 y! a9 t - - k. n" U) [1 P* L
- char *dmabufsrc1 = NULL;' W5 P/ {/ F6 A9 V
- char *dmabufsrc2 = NULL;
) j$ D1 C6 {! b3 H# A. t4 J7 m - char *dmabufdest1 = NULL;- b& A( J( O m. I c# m$ `/ v
- char *dmabufdest2 = NULL;. y# S" i* f8 S' a4 c# @) d9 V
3 R! t$ L H' t7 Z9 o: @* D- static int acnt = 512;
+ u% ~3 R. B' H9 K* S - static int bcnt = 8;- @' Q4 C) `! u/ K
- static int ccnt = 8;( \8 q! J. ^4 n5 b7 @$ X& w# P
- " {% y) W4 x2 r* n4 p- E9 b# {1 f
- module_param(acnt, int, S_IRUGO);* o8 G% g: z" V2 c) T o& h$ f
- module_param(bcnt, int, S_IRUGO);
. F& b# Z% C/ Y- G( B- q8 U0 W - module_param(ccnt, int, S_IRUGO);
复制代码 ) h' e8 v/ s+ E" f% c! @0 o
" K0 Q! f/ r) v 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
. d L. P/ P6 L& @" Parm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
m: w) d2 z0 q2 L: y! }, _3 p2 K2 i3 ] 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
Q0 M" L8 k! I& b0 e; d& h% o; N) \. J, J1 J/ Y7 n+ |0 a$ B
& W+ X- S& l7 k |
|