|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 8 q, L3 T' Z; E4 M
- [code]EDMA sample test application3 H0 G4 R$ P6 `, y3 j
- /*
8 X' f% ~% D% | - * edma_test.c
' s4 E5 u+ g$ t6 J1 a: c0 M - *
$ R7 p8 U% @7 a3 h& M) B( l# m - * brief EDMA3 Test Application
2 c9 ?1 ]$ a# I9 j1 \/ p - *5 Q3 x: w4 a7 K& D2 Q& i! ]
- * This file contains EDMA3 Test code.+ r2 p! L5 I! W. S6 ^ c
- *$ E2 R, `) s. E* O+ d7 G
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
/ M, v/ Q5 k% H8 k# T - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
s4 B+ u4 I' j% `5 _# Q) Y- Y - * TO CHANGE.
5 q j* s3 ^/ Y; s4 G - *
% Z; @- ]+ L7 w+ T R6 K - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/8 Y9 A: U S2 R3 M5 H3 a1 y
- * S- |/ A. P4 X: ]! t
- * This program is free software; you can redistribute it and/or/ I) i$ E0 x& `* R
- * modify it under the terms of the GNU General Public License as( Q2 U( p# n: |9 Z3 Y
- * published by the Free Software Foundation version 2.
" G; r7 k2 m+ s' v( v8 q - *
0 A0 r9 K& L) Q8 t/ m0 }* L - * This program is distributed "as is" WITHOUT ANY WARRANTY of any0 _5 Q( _( S: H3 C4 h0 I
- * kind, whether express or implied; without even the implied warranty* W. q: n7 T6 X/ n; z4 I0 T
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+ p& S9 f: G* B/ z$ |$ ^
- * GNU General Public License for more details.' h( D% `' U: z& C: `
- */
6 u/ A I6 o% [3 Q5 b1 r
# }. d/ D1 k! `+ }' Y; q- #include <linux/module.h>" D |" m, H0 H4 D3 i4 D
- #include <linux/init.h>2 ~7 s( Q& T* k; Y
- #include <linux/errno.h>
" R$ p; [6 l+ r! {3 Y' h - #include <linux/types.h>
' o7 R. [/ E3 k$ v( P2 b0 ~5 x6 ^ - #include <linux/interrupt.h>
2 E1 I$ P" z. X% Q4 h - #include <asm/io.h>: K5 i1 d, g0 a/ b
- #include <linux/moduleparam.h>
4 z* N: b1 k5 Z* O; I1 U5 O3 ?1 I - #include <linux/sysctl.h>( h0 p' {- K9 a0 N, ?: e: E
- #include <linux/mm.h>
2 [: F" \1 V1 P2 p. F! X - #include <linux/dma-mapping.h>
. o9 c+ Y0 [4 H' a. c" z. X - , t M& a: {0 M6 J$ i o( P
- #include <mach/memory.h>
" g% p) W* s$ P! x+ `: E& R. q - #include <mach/hardware.h>8 m ^$ M+ S1 @9 Q! f N
- #include <mach/irqs.h>
2 L( u: r' k5 S" }9 O! H8 g) H - #include <asm/hardware/edma.h>
0 r: b: z+ U, w" W - ) b' R7 C. N: P
- #undef EDMA3_DEBUG+ K8 {) }, Z) j: s
- /*#define EDMA3_DEBUG*/
4 i* }8 U- ]" t( k; i/ r - " l9 l/ a& g$ |
- #ifdef EDMA3_DEBUG* |8 O: F! R: O/ T% |
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
+ B; Z4 w4 z) L( ^2 a5 P$ T - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
& V" E) Q, U6 s( H$ M0 L - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)( K% C* V; u4 e6 Y8 p
- #else. b8 G2 c. f: U& x: N- E
- #define DMA_PRINTK( x... )
1 d) H+ g/ L* e* ~ - #define DMA_FN_IN
/ @1 u; s% |! e2 c3 a) {$ J - #define DMA_FN_OUT
2 |0 z, y' j3 y- W. e, B7 [ - #endif2 M P, U9 ^ W
- + [: @$ Q) Y2 C* J Y$ S* L9 p" `
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)% L$ a9 o# l0 ^" V
- #define STATIC_SHIFT 37 P) ~8 R4 x w0 B9 ]! z7 J- A& N
- #define TCINTEN_SHIFT 20$ b- S& Z3 c5 Z8 \4 I
- #define ITCINTEN_SHIFT 21 Q# H2 c! \; L0 Z, J4 H
- #define TCCHEN_SHIFT 22
: I; I' ~- i" q1 K3 E0 R, r' E - #define ITCCHEN_SHIFT 235 j- f6 O0 h) M: ?& R' h7 r
5 a" s1 h6 U% x6 D- static volatile int irqraised1 = 0;. a, S/ X9 z; [( a: s+ I
- static volatile int irqraised2 = 0;6 R" v: t- _8 I: u7 \- c
1 p6 d: I J) }( P; D/ D7 z4 t- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);4 y1 ~" G( V8 e {( d6 F
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
# J. [2 i {, V9 b$ e - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
+ {5 g9 v3 o% v3 S8 p9 B - $ h$ A9 [6 H: E3 p. R, l
- dma_addr_t dmaphyssrc1 = 0;# f$ g3 ^+ b9 [+ |1 ^4 a! d% Q- o! i5 j
- dma_addr_t dmaphyssrc2 = 0;
) _; ]4 L$ W( ^! E) J$ U - dma_addr_t dmaphysdest1 = 0;& k6 k6 d6 [( ]0 q: V" @2 M; L
- dma_addr_t dmaphysdest2 = 0;
& ^1 l5 h1 C: S- k# ?: P# g - " f- Z* o4 m1 }; U5 o
- char *dmabufsrc1 = NULL;0 X* w* l. K4 U
- char *dmabufsrc2 = NULL;6 c7 o5 z) A2 Q4 a& ?; C# K
- char *dmabufdest1 = NULL;' ?! R! O: {) ]1 X* A! |
- char *dmabufdest2 = NULL;
, d+ f8 ]1 A0 q( S0 m - 9 H+ F7 I" H( V8 N0 d4 f) [
- static int acnt = 512;
3 d& K7 v0 d5 c- ^ U5 ?& D- Q - static int bcnt = 8;4 ]9 O; K, w& w# y% H
- static int ccnt = 8;
9 ?; U2 E' z+ x - ( I3 k: @& a0 e6 d0 w7 K5 X
- module_param(acnt, int, S_IRUGO);: A/ A& R. u% v a! T+ K
- module_param(bcnt, int, S_IRUGO);
7 a* [) V2 z9 l/ f7 K - module_param(ccnt, int, S_IRUGO);
复制代码
3 ?# a) m5 }/ W' `4 T6 _! \+ c" H) o U `
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
# Q4 S" H* L4 m4 |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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。. k! `# h U& h4 W
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。' W( ^. W' ]! k& N
9 n2 u2 j) X+ K- S. s+ R
3 j" O- g2 L% \+ P0 u
|
|