|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 8 _1 t! G7 B3 W# N
- [code]EDMA sample test application
( I# Q/ i* _4 E0 G' Z7 Z" h - /*5 r& H0 [: G" J5 p5 Z: J
- * edma_test.c
0 ~/ D, k# p! G" Z - *8 I+ C7 X3 N5 k5 D4 X# t" [5 u
- * brief EDMA3 Test Application4 p8 v+ b" n `, c: a
- *
/ y+ E9 ^% ^6 H6 P0 ?5 P$ p* u - * This file contains EDMA3 Test code.8 H( T9 R" t+ V4 n+ E# J
- *# U6 i* W% t& {( r, ?( x% F# E
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
) U9 y' A( s! d! G# {8 s5 b5 z - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
4 k1 N/ k! H- l3 O6 G4 I% [4 j - * TO CHANGE.* t \) X3 ]4 J& S. {1 B
- *8 \. C) x6 W9 L
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/3 Z* {7 `0 d& g" a5 F. r' y t
- *
: H& p) K2 z, P0 f( C2 T - * This program is free software; you can redistribute it and/or) K8 x1 K2 \: G" `8 a
- * modify it under the terms of the GNU General Public License as
0 {+ T8 N% `. y! d; h6 M4 y - * published by the Free Software Foundation version 2.
) V/ r4 ]8 c; O; q, c - *
+ P1 ~+ v: _& c) V5 O2 }! a% R - * This program is distributed "as is" WITHOUT ANY WARRANTY of any
# N& |; M8 |% R - * kind, whether express or implied; without even the implied warranty# x% \1 p4 c' B$ z, i
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the7 |( y5 w2 l% Y6 L
- * GNU General Public License for more details.+ S( T7 Z9 _* f
- */& q# `. U% s1 O+ D/ E& [# p
1 w" X( x; {: }; u) i( K& ]6 K- #include <linux/module.h>
/ r; T, P; j2 p: C3 d- H" \ - #include <linux/init.h>' b7 N$ N/ e" U
- #include <linux/errno.h>
k" c0 B) ?- x2 I$ j/ S - #include <linux/types.h>
, l" _$ }; i! `* u - #include <linux/interrupt.h>
- L% u$ n0 n- M3 j) a0 A - #include <asm/io.h>
t9 p4 r4 {! o3 @% ?* o2 e" O - #include <linux/moduleparam.h>
8 o- m1 U f. T% `2 o - #include <linux/sysctl.h>5 p" t9 |; Z3 }; V& |
- #include <linux/mm.h>) |4 L6 `1 |8 D0 C( w) ~$ p
- #include <linux/dma-mapping.h>
3 Q6 O; ^% I/ y7 Y. B
3 y6 W, V# b: j- ~3 y; M, U1 T- #include <mach/memory.h>
. J& |- D B2 ^+ [% l! B - #include <mach/hardware.h>. l+ S) {: ?, F+ p' R
- #include <mach/irqs.h>( C1 E7 M& W- a5 {+ m7 ~0 t6 J
- #include <asm/hardware/edma.h>7 G9 y0 ~ ^+ v+ L# m3 _
- 0 L8 ?9 \6 P/ y' r( G. m. C: J
- #undef EDMA3_DEBUG* `, r* O# k( {- d4 f/ l4 c
- /*#define EDMA3_DEBUG*/
, f7 l5 \$ s; F/ M3 h+ b* G3 g* t
1 q6 i% o8 c: Q( m; A8 A% v. y) _3 Z- #ifdef EDMA3_DEBUG6 G- g, y k+ R& r
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS). q: j) y. n5 |# I- P
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
7 t5 Y0 U5 r: q - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__). L4 N K: f9 B. e
- #else1 r! Y& H. T a* V
- #define DMA_PRINTK( x... )+ U; _2 @. ?$ q: M* E! ~
- #define DMA_FN_IN+ d2 I3 Z5 x8 f+ l+ s
- #define DMA_FN_OUT$ Y; h0 b' y, u: u$ y6 |. t
- #endif
8 G4 |) @" G4 {9 F: i
; [4 V" K; F" B: _+ h( z3 {- #define MAX_DMA_TRANSFER_IN_BYTES (32768): r4 R" w5 q x3 O7 y) v
- #define STATIC_SHIFT 3
0 h% _9 x m4 x - #define TCINTEN_SHIFT 20" r4 k, e' e$ M. ^ s, l
- #define ITCINTEN_SHIFT 212 w; C* j" l! v& L- u0 d) a* P
- #define TCCHEN_SHIFT 22
3 v6 n; L D& F2 c$ y9 ~ - #define ITCCHEN_SHIFT 23
/ i# [, {" g2 L
' Q4 q# ^, P3 j- \. ^/ O# n; a5 s- static volatile int irqraised1 = 0;
8 E% U$ e9 \1 N) f7 K2 n& q - static volatile int irqraised2 = 0;6 L; p6 @, X7 B' g7 ?
- + R- q9 P& Z" M! c/ K1 a* C0 p
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);. Q, S! x, d' I3 U. d# U/ X
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);" c6 m3 l! @: O* ]0 \1 H
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);' v2 E2 b% m- E3 I& m6 y2 R
- 0 b; ~# W- }$ F- P9 I( d& @3 d7 l
- dma_addr_t dmaphyssrc1 = 0;
' g) n! ?$ ]$ {" t - dma_addr_t dmaphyssrc2 = 0;, O) Y/ r3 _/ x! S: L! }
- dma_addr_t dmaphysdest1 = 0;) a+ o8 c8 I4 g% H+ N H( [
- dma_addr_t dmaphysdest2 = 0;
, U! l) o" h0 g8 z% K8 H) c& N
$ l, k0 x, u! z1 ~5 Y6 [6 z- char *dmabufsrc1 = NULL;
3 H ~! B8 O1 d - char *dmabufsrc2 = NULL;
/ Z$ p7 ]$ W( f - char *dmabufdest1 = NULL;) ?' l2 O3 Z1 O, j1 K" v! |
- char *dmabufdest2 = NULL;/ q8 G) z1 r6 R5 H v
$ a2 `) o( p/ S, I( C- static int acnt = 512;3 G* r! x- c) K$ }+ M& Q
- static int bcnt = 8;
5 }. M ^1 i! V% ?& T3 G - static int ccnt = 8;
. i: A0 ?/ N2 A6 t; D
$ H/ {6 n- ?+ \' Y3 t2 F* h- module_param(acnt, int, S_IRUGO);( I* Y3 P( h* Z( f0 M) A
- module_param(bcnt, int, S_IRUGO);/ o2 p* L1 B$ W& T9 s. O
- module_param(ccnt, int, S_IRUGO);
复制代码
2 G7 Z- i* j2 r' q+ V! d+ c$ _0 z, }
% k7 X" p' |" i 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用& ]$ D$ p8 w) X4 i6 E7 C D2 C* ~7 H
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
( B3 x7 |# t) ~2 G3 n0 w1 d- I 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
2 k6 Q4 |1 d% y' C- n# y0 t
. G4 w8 W: D2 C5 d }
, s1 ?% j- Y, l3 c |
|