|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
' F4 I3 b# i' J. ^+ K- [code]EDMA sample test application% s2 h1 D0 O, t
- /*
! t2 P4 m. F+ y9 s+ c- k - * edma_test.c B1 Q0 J) h' {
- *; S1 R3 [' H! A7 c/ |% p2 _
- * brief EDMA3 Test Application" f+ r) O' F s+ k8 v: p% q& g
- *
! r( \' j! ^8 X - * This file contains EDMA3 Test code.
; |% p- y3 f0 n3 t+ O - *
- S! c( d( q6 z: m" L) B - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE5 s: J& `, E* a8 M$ V
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT+ u+ F" D7 A$ f2 g; g/ S
- * TO CHANGE.9 J5 [& C, W1 ?
- *
6 [* I- k. k& [2 S& y - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/4 P& D& w" Q% n0 Q
- *4 ?. k0 V6 x3 \! K) U! v4 A
- * This program is free software; you can redistribute it and/or+ e; M( M' w, m2 N( _. t2 s" U, x8 Q- z
- * modify it under the terms of the GNU General Public License as
8 \; i A( ~+ u9 @3 U+ g) h; | - * published by the Free Software Foundation version 2.+ z _; R" t- c% m6 [* b$ w3 X
- *
, {" n5 ^9 M( v# M( g( H8 I - * This program is distributed "as is" WITHOUT ANY WARRANTY of any$ F$ U* R9 Q8 r: } R7 e' T, y! X
- * kind, whether express or implied; without even the implied warranty
4 f4 U6 W6 ^9 o9 I - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
p% h; G2 T$ p* Q3 X4 U- q o - * GNU General Public License for more details.( n" T1 V5 j, L, V+ E" O
- */
% `8 l( a! Y$ u% S# r
& r; i$ E( x5 @/ R- #include <linux/module.h>2 V% V( O1 d! s3 S2 ^4 e
- #include <linux/init.h>$ Q e$ Z5 o" W5 f+ v( A- C( [% s; |
- #include <linux/errno.h>
# n8 D {6 b0 u' J2 S - #include <linux/types.h>
" D1 X; K; M* S! u8 f: F, @ - #include <linux/interrupt.h>
$ a. E2 y _$ B - #include <asm/io.h>. I, v7 w+ B- s
- #include <linux/moduleparam.h>
$ x7 y; r: z, }: x6 s3 D, M - #include <linux/sysctl.h>
# E5 ]3 z V# r% I7 }8 v - #include <linux/mm.h>$ a* q. T1 w4 L$ x- o9 s5 ?# x( r
- #include <linux/dma-mapping.h>% l9 d# N; X2 H) R8 M
- + B' j$ e) `0 Z4 S' d1 O
- #include <mach/memory.h>
4 I; \' g6 D/ k' ~) g9 I4 ~ - #include <mach/hardware.h>6 `# b _5 f ^1 l6 i
- #include <mach/irqs.h>4 E0 G. g/ |+ I8 S
- #include <asm/hardware/edma.h>
2 C+ n% n E8 x1 Y
% w/ ?3 \1 e$ c- #undef EDMA3_DEBUG( j- K5 Z; f4 ~+ r; m. n
- /*#define EDMA3_DEBUG*/7 E+ C) l7 R5 k7 f3 ?% {. r6 l8 o
1 |. E y; b, Y# u( Q4 F- #ifdef EDMA3_DEBUG B) d* v- h0 N
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS): Y4 }9 V4 S) Q
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)" ?' V) l: _* d, t/ e
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)8 v4 L# P1 W% \1 |& V
- #else& S; D( T2 @( q& \2 a: I
- #define DMA_PRINTK( x... )
0 T E& @3 f8 s6 A- G, I - #define DMA_FN_IN
R* S2 L. ` @ - #define DMA_FN_OUT: k4 m/ s* C4 H( B `5 ^) J
- #endif' m/ Q/ e1 y9 l' N. ^
- * l8 q- F1 j# `! r2 p5 D! t
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
( f+ n" G. t. L - #define STATIC_SHIFT 3
) D7 U% T. B: V+ N5 j0 Y - #define TCINTEN_SHIFT 204 t- { Y1 q% l7 q) b# _- |: P
- #define ITCINTEN_SHIFT 21) X3 r) o+ F2 ]& ?! u) b) F% g, z4 n
- #define TCCHEN_SHIFT 22( U. P6 b8 j/ b1 z
- #define ITCCHEN_SHIFT 23! t1 y* L3 b6 B! e' p/ u
- 3 {0 x) J* D& W" B5 n$ A
- static volatile int irqraised1 = 0;
E; k Y8 o7 m+ Q+ b( b* w - static volatile int irqraised2 = 0;. g) a0 q* e7 b9 a
) L9 d& w! g. M0 ]2 d6 M: K$ v; M- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
2 ]; u) Y$ P+ \ - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);+ G( [3 a: v$ M% X
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
3 q6 E- B9 i* w8 H& l - . h" l2 G- M s
- dma_addr_t dmaphyssrc1 = 0;
5 _( r$ v7 Q" i9 o5 W: o5 G0 U - dma_addr_t dmaphyssrc2 = 0;
# [) I! ?" J/ L m( A9 A - dma_addr_t dmaphysdest1 = 0;4 N$ q2 }. Z' m) L- c
- dma_addr_t dmaphysdest2 = 0;
+ L% v Y0 l, k6 f7 c- ^* K
& X( |3 `$ v0 M z. ^- char *dmabufsrc1 = NULL;( S5 `: p/ B# m- Z% V% I
- char *dmabufsrc2 = NULL;
- z k# E. b0 o - char *dmabufdest1 = NULL;# ?- \/ h' W y2 S" ^
- char *dmabufdest2 = NULL;
, H g1 q4 r( e: d3 F% N0 H( T" K
, S, H$ L! x! ]5 B" n- static int acnt = 512;
% U$ a9 c- \* N( k0 x. h# d# W - static int bcnt = 8;
1 J0 {, a% N; N+ `3 m - static int ccnt = 8;
( e' V$ Q' |, u
8 A1 T- o! V7 N) P, y6 b7 z4 B- module_param(acnt, int, S_IRUGO);
/ E2 p, h+ [) l, A! V - module_param(bcnt, int, S_IRUGO);
8 t& H1 t+ [: Q O - module_param(ccnt, int, S_IRUGO);
复制代码 7 N1 m, X* g# ~8 C; ?9 | y
' W# F( m# ~! u' Q A3 h" m
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用" \& k1 W( C6 @! V0 |( k
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。6 l1 V' z! f0 _; a- x6 o; v& T
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。( M. u. M) |& Q6 L k+ s
+ n# T) {4 e6 e! e
6 K' l/ Z$ w: l, c) L |
|