|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 6 l0 @# M0 n' a" }& N
- [code]EDMA sample test application
6 p: C4 E2 S* w+ c3 f! Z& Z- u - /*
6 P. P" r6 W4 |: M6 @& T - * edma_test.c, A( n9 V, ~( c8 g( C' ^" W' W+ E9 \
- ** ?- O6 M; q7 j$ ` t+ U( \4 V
- * brief EDMA3 Test Application
9 H1 ]4 [+ o" g" ^0 R4 `! Y% y - *0 W0 m0 ]+ ^. @7 R# U: V
- * This file contains EDMA3 Test code.3 n- u$ s" }9 Z# F8 X
- *
) `7 _! L5 _7 Y5 W0 x& ? - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
$ f7 C* J: O$ l, J0 h x2 ~ - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
9 |3 f' w5 V% H! f - * TO CHANGE.
$ F' z0 W" z2 p- f - */ M: I; k! Q+ t- r7 v
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
% }* T( J/ e6 n5 w& S- i5 T3 t& o% N - *
$ j2 J8 J3 k" T/ y6 f$ v1 ` |9 ] - * This program is free software; you can redistribute it and/or( z6 X9 Z* ^1 x8 O5 e
- * modify it under the terms of the GNU General Public License as# }; _0 i2 t' v; h d9 ~. t! Q) }
- * published by the Free Software Foundation version 2." W, c6 Q& e/ q
- *
7 F4 |. j+ C0 a- W# ` - * This program is distributed "as is" WITHOUT ANY WARRANTY of any: f1 K% t; e0 G+ }" z' H
- * kind, whether express or implied; without even the implied warranty8 O; \' \* p4 h ^. s- S) W+ ?1 T. t
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+ C% S+ Y5 l& i F0 I* S' |' t0 l
- * GNU General Public License for more details.) P- Q; f) {9 J
- */0 k5 T" }" P6 m5 @% r
( r2 G( A3 |& r# ~% |- #include <linux/module.h>0 H+ A* d/ v2 q5 j. t
- #include <linux/init.h>
$ {+ K: t0 ?3 O8 E: a$ o - #include <linux/errno.h>0 g) f7 F# c$ u' I' @4 R8 j6 t
- #include <linux/types.h>
3 b d4 ^& i- Y! T8 X - #include <linux/interrupt.h>' I! F9 R- u+ W4 y& Q% J% g
- #include <asm/io.h>
! [6 G3 ]* ~" C3 K - #include <linux/moduleparam.h>
. C: k; b# }0 m8 O, C7 n B - #include <linux/sysctl.h>0 N) T' `6 h9 U1 f! t$ k6 C: S
- #include <linux/mm.h>
& T; K* X/ Q7 N: G5 ]- p - #include <linux/dma-mapping.h>; P+ m7 i H! m0 T, j: [
- 6 u" n" p/ j/ B) E$ r
- #include <mach/memory.h>6 M6 R' r9 ^$ U+ I B* D
- #include <mach/hardware.h>& _0 h+ L, ^' r9 l1 [
- #include <mach/irqs.h>4 u9 f+ s" F% [7 `! n" e
- #include <asm/hardware/edma.h>
0 _+ P, Z- M6 b( l K) y - ' ?) f; _! G1 @3 P
- #undef EDMA3_DEBUG
+ Q9 u. I" X1 e- A% N8 ~" D6 n - /*#define EDMA3_DEBUG*/
- p5 w" A2 C/ L2 [ - " `/ @- R" I2 a# p
- #ifdef EDMA3_DEBUG" ?2 s6 w7 m# A5 K, g4 i! b
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS) A- Y& \: ^6 u$ `+ r" F- X
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)$ k8 \4 I: O9 V! ^! n
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
5 `# _" r7 K0 K! U - #else: F6 g/ ?+ V' _, k$ B* J$ Y! [
- #define DMA_PRINTK( x... )! z8 U0 L; W* ^
- #define DMA_FN_IN) f7 X# {8 K) w3 z; t1 i6 W
- #define DMA_FN_OUT
3 j. u* l- o- V# e/ }% _1 z - #endif; K2 R3 L I/ W; }9 L
$ T& o3 d6 @$ |1 z- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
- T& j a3 B; {0 \- t - #define STATIC_SHIFT 3
/ ^9 V9 s7 w1 T! [& L# Y - #define TCINTEN_SHIFT 200 |6 d; U8 R# z) S
- #define ITCINTEN_SHIFT 21
6 ?% N6 j: n2 g( o9 F - #define TCCHEN_SHIFT 222 {% c8 T% k9 J4 l
- #define ITCCHEN_SHIFT 23
) K5 O7 C5 N" _8 l: y5 q
( r- N. _3 y0 F) L3 \$ W- static volatile int irqraised1 = 0;
8 @1 H3 a) d, A - static volatile int irqraised2 = 0;
8 P( |, d8 g( T; g0 x# @
4 i- i0 c7 s: _3 b2 M+ v* q- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);# o# T* |5 p3 v6 q
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
( c5 ]0 J+ g% m6 E% ~# }5 t - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);: I5 N- y1 ~% c
1 f h' \# x* E0 n$ k# ^- W- dma_addr_t dmaphyssrc1 = 0;
/ M4 ~% l$ D- N2 z! I - dma_addr_t dmaphyssrc2 = 0;% w2 ?! B- \$ G; g0 X! X
- dma_addr_t dmaphysdest1 = 0;
# V# y1 ?" _/ i! W9 L - dma_addr_t dmaphysdest2 = 0;
+ L2 O' K% T& V3 ]
/ L/ s+ g# \7 w: [- char *dmabufsrc1 = NULL;
. `' U; H' Y3 }1 X - char *dmabufsrc2 = NULL;8 _0 D' B/ z& q: f! j7 X' m* j# E0 x
- char *dmabufdest1 = NULL;
' h1 j" k4 L, I. y( Z - char *dmabufdest2 = NULL;! {( r; G# y5 m. s F3 t
2 r% q9 }& x+ x! N3 t2 n( X6 E! y- static int acnt = 512;, W' u: b$ {2 @1 {, S2 v* A" {+ B
- static int bcnt = 8;9 g9 Q, R! u; t9 M
- static int ccnt = 8;
$ s( ^, I2 r& I- n! w - " J9 N* e* ]% c3 |
- module_param(acnt, int, S_IRUGO);/ [) r* w! S# S3 t. X, P
- module_param(bcnt, int, S_IRUGO);
( F% y R0 [9 n) i& d7 ]- p. Y! n - module_param(ccnt, int, S_IRUGO);
复制代码
4 a T% w3 O+ G* _
! _* q# C4 v$ h+ p$ Z; ^ 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用. L: d2 y, V7 L- r* W
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。2 z* r1 D. Q' a Y" a* [
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。8 w) A! ~. Y! `! m
4 u% a% n! M2 z$ v3 Y
3 N' ]( g3 @7 f' H5 v9 v+ \ |
|