|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 # D9 v9 n- u2 ]5 Z! E& Z8 z! S
- [code]EDMA sample test application
# l' F; g. z0 J* z+ w- r - /*+ i& g% p* `7 A u- x
- * edma_test.c
. c+ @5 r( y3 p1 _. K6 I - *8 t8 M( F. U- I; a9 y
- * brief EDMA3 Test Application
. ~& e3 {1 q2 X& i - *: X6 g+ b/ B' e% g4 E$ C5 U+ U! z
- * This file contains EDMA3 Test code.8 H! V! ]: t0 y5 {: H% L
- *
, U; f, j' Q- W% m* T1 ~ ? - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE9 B6 U, K% g3 w' v5 F5 V
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT1 S. A# m0 H6 k$ Z8 H R1 Y4 m7 _
- * TO CHANGE.) J( v' ]$ Y* s5 E7 J
- ** V' z6 j; r) j2 i; _4 Q
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/4 G3 T c7 }* J: L" Z
- *
}. a0 N% Z* D4 M0 m - * This program is free software; you can redistribute it and/or! @# g$ Y9 f2 m
- * modify it under the terms of the GNU General Public License as* y. }( f) I9 {* H T! w
- * published by the Free Software Foundation version 2.
: @9 @( i" B" R. g* S- y1 l - *
1 m- @ h9 k. Q. U* b- p - * This program is distributed "as is" WITHOUT ANY WARRANTY of any: W- R" k; a( K% q) ^
- * kind, whether express or implied; without even the implied warranty% [2 v6 U0 L) A# S
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the8 ]2 P: B9 n) k( H* p$ D
- * GNU General Public License for more details.
* |) E5 o, r* _) A' v8 o, F - */
! S' e' y4 j+ |3 b' a% U, D$ Q - 5 z" G+ }/ \, A! V9 [ V2 ?
- #include <linux/module.h> k2 c* C& c: D9 v! |& m
- #include <linux/init.h>
' o' e% _4 P( P4 ^7 e" ~ - #include <linux/errno.h>
% Y3 k! c$ {* z5 q5 n, |( J4 | - #include <linux/types.h>" ~3 f% R. j- |3 s. z2 U+ C3 c8 L
- #include <linux/interrupt.h>
; s: [7 K& ?6 n4 I - #include <asm/io.h>
7 K6 T. ?) m( Y% ^3 M- b, j - #include <linux/moduleparam.h>
) r; x- a* R; ?/ Y9 ?( ? - #include <linux/sysctl.h>- n" i% ^0 Z$ m( g
- #include <linux/mm.h>
; s) M( ]9 ]6 I/ P- C0 z2 V0 r7 ] - #include <linux/dma-mapping.h>2 h# A4 g0 X9 t
& U" P' ~$ T: c6 z8 v- n- #include <mach/memory.h>
/ Z; ?4 \+ m: q5 s. z; L3 D - #include <mach/hardware.h>' b& G' M! Z; h$ J3 F. e
- #include <mach/irqs.h>
8 `; S3 e# H$ |8 Q - #include <asm/hardware/edma.h>
$ n9 l8 i/ K6 ~3 s( t2 E: i - 5 E$ r. A" z& o8 ~
- #undef EDMA3_DEBUG% r! L' v9 S; Q/ Q
- /*#define EDMA3_DEBUG*/
/ I5 @, P0 h0 H. K
; l: R" I6 F4 P6 s4 z5 Q0 l- #ifdef EDMA3_DEBUG8 o7 U* O4 q. \! O9 C
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
& T. V6 p0 R# i) p - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
; I3 R. Z* i& \7 L - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)$ |- h' P! x: p
- #else
+ y7 X* x9 S: I3 c5 G - #define DMA_PRINTK( x... )0 d8 l1 E/ c4 l; Y
- #define DMA_FN_IN6 |, T5 T% [' A
- #define DMA_FN_OUT
, c. ^4 p8 s1 f& |# M, t - #endif* |) G+ E+ N/ O- n3 A5 ^( z
- k6 P6 d4 ?' H
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
4 |0 I. k- V5 M: Z/ y; }% G+ n: i - #define STATIC_SHIFT 33 ]4 @. J8 c3 `6 V, w( k; s! F
- #define TCINTEN_SHIFT 20
8 [ U9 W! N* J3 n9 U1 ?" g' O - #define ITCINTEN_SHIFT 21
L8 z9 M6 d1 r$ z- M! F0 O - #define TCCHEN_SHIFT 22: J7 h9 ]5 d2 H. _8 t1 |
- #define ITCCHEN_SHIFT 23
" S& L. j: i2 j$ Z$ P3 n, Z& u - 7 W$ f: N) {3 U, m9 w2 p
- static volatile int irqraised1 = 0;
: Q W3 { ~. S8 ?: [ - static volatile int irqraised2 = 0;
$ `+ P1 @1 O7 r" V- Q$ X$ D - 7 A4 Y4 b# k7 L" c4 F
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);; Q: N, p, }8 J! K
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
2 q- `2 @% ^' U1 E; v3 s5 m - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
, N6 R/ Q3 {* B# G6 k+ w$ Q% r" J
5 U* |7 M. L" K* R0 L/ `9 R& T- dma_addr_t dmaphyssrc1 = 0;
9 M5 T- c& Q+ Y: o1 a - dma_addr_t dmaphyssrc2 = 0;5 x7 W O# S, X8 L# Q4 ]( @. n8 W
- dma_addr_t dmaphysdest1 = 0;! ~5 E u+ i! T
- dma_addr_t dmaphysdest2 = 0;
0 Q& E! c% x; x7 z3 d3 e6 a7 ~2 P - % Y, V" k \4 m5 \ ?3 ?+ P) y
- char *dmabufsrc1 = NULL;" I5 k. M Y7 i4 p8 q1 p0 C
- char *dmabufsrc2 = NULL;
) n% a8 l0 Q" N8 e' H! O - char *dmabufdest1 = NULL;
- Z5 \3 f) s( b- H& k- ] - char *dmabufdest2 = NULL;
$ d9 c0 P* T% K - : D, G4 p% {4 h" e; f3 r
- static int acnt = 512;- N7 f ~; G$ q, }% C# T
- static int bcnt = 8;. o6 P T) E7 u3 Z
- static int ccnt = 8;
) c2 G ]5 R( _ {6 C, O% \
2 ^$ `8 F+ M0 s' {0 v- \- module_param(acnt, int, S_IRUGO);, Z* m/ J, r4 N' L
- module_param(bcnt, int, S_IRUGO);: x" Z$ F- s) z# U0 U
- module_param(ccnt, int, S_IRUGO);
复制代码
4 }- z7 Q/ x W
3 x# z+ k" J3 A u* X 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用" N. d2 X8 b+ H7 v0 n* f6 ^6 d
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 K, l; I/ u9 k+ Q1 H
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。( S0 G5 R$ {* F! K1 z+ I
# R! A; b8 H$ O
. O6 H5 [' Y1 e9 m2 F6 W
|
|