|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 6 t* s5 W/ Z x% J( r* l$ g2 I$ f
- [code]EDMA sample test application
( P S7 a5 N+ r6 u - /*
+ U) H4 ]7 }) G8 m/ u - * edma_test.c
2 `) m, t6 f/ S L! N9 I! |& o - *1 U% M+ W; Q, z) P) c
- * brief EDMA3 Test Application
" w8 p L1 R7 a( Q( ]2 U) D$ p - *1 N! T; N- ~0 P7 r
- * This file contains EDMA3 Test code.
- j3 L' w' F q8 U# L z - *# d- i: ~+ E9 O% F6 f, ~
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
9 k3 M& U% @$ B) f! t/ ~' P - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
$ K1 J+ \$ E1 c8 L, f" Y - * TO CHANGE.
% j+ b. j# `) |* @: z$ a& S - ** w. O! J0 I( t" f! b- t
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/9 {, f- }/ v8 \7 _6 m
- *
?) J/ s; \3 ~ g7 X3 I/ ~ - * This program is free software; you can redistribute it and/or
# K9 ?# k. Y8 h& D% A0 b6 k - * modify it under the terms of the GNU General Public License as$ T7 N T( _: m m! P* {
- * published by the Free Software Foundation version 2.
# n. e6 p7 W) k - *7 T, P/ R) v: A' s
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any
) I- L1 I" W3 s. P - * kind, whether express or implied; without even the implied warranty" S' b- T) v/ |! }
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
& P# K8 @. a) }9 m, R - * GNU General Public License for more details.
' a" X" b) F: ?' Z; [8 Z - */
1 B* m6 g8 y& v( ^7 V - _( l- d/ p N
- #include <linux/module.h> a, V5 K8 T& y" V- x
- #include <linux/init.h>
7 c7 t! `6 P; t0 X9 J# g9 l - #include <linux/errno.h>
8 n0 R4 E6 H1 |6 `* D - #include <linux/types.h>
2 v. \( u) |: r3 a0 A# Q - #include <linux/interrupt.h>1 e4 x, d6 V8 B3 `- q
- #include <asm/io.h>
& ^, {1 I7 r- u; j* |0 c0 L8 Z# y - #include <linux/moduleparam.h>
- y4 I2 n6 M- w+ O - #include <linux/sysctl.h>
! m! X1 ?/ ~8 i+ ^, Z' w - #include <linux/mm.h>* u6 |7 }* f9 X
- #include <linux/dma-mapping.h>
- _9 X& j/ ~3 @ - ; P+ Y* z" [: s2 D. B* L
- #include <mach/memory.h>% M5 `5 X# J3 r/ ]; o1 v
- #include <mach/hardware.h>8 Y" d2 b8 S, e; y! m3 z
- #include <mach/irqs.h>
! Q3 }8 K# Z' x! p( R - #include <asm/hardware/edma.h>* i$ j' O) s- [9 x/ G
5 I( I& a$ J0 V' @7 l& j- #undef EDMA3_DEBUG
6 M! c7 X0 z6 m5 M8 m0 j" { - /*#define EDMA3_DEBUG*/: n3 R: I6 w6 J2 B+ W; g
R' U3 g0 o7 k+ w" R1 d: T- #ifdef EDMA3_DEBUG
/ m* I0 D( [3 Y - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
3 }- k6 I6 h) K$ _ - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)7 o2 ~) a1 T( l7 d+ r" r
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
% T# W( M1 w% i2 y1 }6 F - #else, {; q. @) D0 g' u
- #define DMA_PRINTK( x... )
0 n% ?4 |5 C: J - #define DMA_FN_IN
( Q& O: M' T; [% K2 ^! C - #define DMA_FN_OUT
5 \$ O8 ]8 A X- h! v4 P - #endif: g/ E9 l' M/ b# l+ T2 `5 v0 R6 h9 \
7 N0 H9 j" t) ?1 B- #define MAX_DMA_TRANSFER_IN_BYTES (32768)1 C( d/ L, E, ~5 X3 k. [8 @
- #define STATIC_SHIFT 3
" I/ r: T& ^6 u6 S: s: `/ k0 j - #define TCINTEN_SHIFT 20
) J' p; a- W- R1 I2 w - #define ITCINTEN_SHIFT 21
- w( ]1 l/ N2 C: Q8 C% r - #define TCCHEN_SHIFT 22& |; A* h; I$ _+ a8 p* P
- #define ITCCHEN_SHIFT 23
; C% Q8 x* M: C4 \
7 {; B5 l/ q/ i. e. u- static volatile int irqraised1 = 0;
# _6 ?* e5 J8 u - static volatile int irqraised2 = 0;
$ {' y; Q$ K( P9 A2 O. U6 B+ g: [
4 B9 ]$ \2 `) n5 k2 Q- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
% D8 m* z) E# j" M7 L2 O - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);+ d7 U1 | ^" }
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);6 G. \( T! N+ d8 q2 l; T3 O
- 4 t f) a' a4 l/ t# R
- dma_addr_t dmaphyssrc1 = 0;# g$ Z4 b C1 ~( B
- dma_addr_t dmaphyssrc2 = 0;% I2 p! t4 k" P4 {
- dma_addr_t dmaphysdest1 = 0;$ C" _% d: b6 U8 X
- dma_addr_t dmaphysdest2 = 0;
0 q' e; o+ L- Q* W
' u( M2 s5 x2 F% ^- char *dmabufsrc1 = NULL;
9 q" h3 P8 S5 o! ~) u - char *dmabufsrc2 = NULL;
6 E6 N9 I9 E: ]% J9 W+ @ - char *dmabufdest1 = NULL;+ q8 }6 h4 E0 X, F$ t- Z
- char *dmabufdest2 = NULL;
8 J4 e. |' p5 w4 T+ @7 }
: v' W% n1 }3 g; z- static int acnt = 512;- @1 E; i: \5 V0 _- x! Y/ D. O- a7 S
- static int bcnt = 8;+ D: |' A+ A, D, ?
- static int ccnt = 8;
0 d( W" B# d' V9 _
3 I( j3 J. A0 Q- module_param(acnt, int, S_IRUGO);+ Z0 m, U" y7 s9 }' B$ o
- module_param(bcnt, int, S_IRUGO);
% M& z8 \7 c. l# B# d+ R - module_param(ccnt, int, S_IRUGO);
复制代码
* j+ c$ P. F( {4 n* [+ B7 z
$ d e0 W- r& h9 c# z 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
& Y r6 |' [& I. w M1 larm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。9 m% I0 ?" `) b
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。6 ~/ q: l: v6 R, p
?* v$ v5 |# t% j- _" H8 g
8 Z% n' I! e0 I" B
|
|