|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
$ n: L; o! ]4 ?- [code]EDMA sample test application
' S7 u% a4 [$ ]! _0 D1 D& X - /*- S9 N1 u# g4 u- u/ J2 K9 r
- * edma_test.c
5 S# l; l0 R* w3 l - *+ v! |$ Z2 g( P8 w$ \9 {- }; w
- * brief EDMA3 Test Application% M% q' H+ x J; q8 o
- *
6 D% S! M; l1 ?8 [/ o - * This file contains EDMA3 Test code.0 e0 b' x& k: T: Z& G
- *# o. E0 `9 U2 p2 H% H/ [9 y/ h
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE; `' @0 `! y8 }, m) _3 V6 R0 U# a
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT5 I/ ]5 o9 H( ]
- * TO CHANGE.
% [& `( | m' }! S2 ?- x/ e - *; \! _( V5 G5 D& W/ `# ]
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
! i1 u! v' y8 ~8 u4 M, Q - *
. t# b7 H7 C$ G; c+ q) d# L0 @ - * This program is free software; you can redistribute it and/or
( e; K k6 h6 k4 T - * modify it under the terms of the GNU General Public License as' _& G! ?" u: R; m1 k
- * published by the Free Software Foundation version 2.
* t/ m; d5 o, V; I2 j - *2 ^5 b6 h0 A3 U
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any
3 H# G& {* c- ~$ v, Y$ Y* b# x - * kind, whether express or implied; without even the implied warranty/ m8 Z# q" `! S; v
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
( t; d" U2 w, o- e1 d" I9 ~ - * GNU General Public License for more details.
& R" k9 v! y3 A5 K - */
$ ]& Y, v, @7 l+ F; P% i; l - * O: P# W" ?( e+ G$ r0 U3 a$ P f, I3 H
- #include <linux/module.h>
( m& i" G; R3 Z/ w- @: h: ^. x - #include <linux/init.h>
, ?: V Q, H- q/ v4 z - #include <linux/errno.h>
: I c# D# S$ ]6 c, r, A' ? - #include <linux/types.h>
- f7 d7 ]9 j3 P - #include <linux/interrupt.h>
3 D' z# a* a" u' ?0 g( Y - #include <asm/io.h>
. ?4 L; V) Q/ U1 r0 M/ H - #include <linux/moduleparam.h>
% q4 G& _8 s2 |7 n5 G' j - #include <linux/sysctl.h>3 L- ^* G& c' {. r x% ^/ i
- #include <linux/mm.h>: f' b+ h, }' u5 Q( q
- #include <linux/dma-mapping.h>
5 ]8 v2 a6 M5 I! |3 ~) K
8 I" M3 ?. G6 s2 @3 x- #include <mach/memory.h>
) Y, M( F! n3 [ E+ w - #include <mach/hardware.h>! n+ W6 f. ^3 k. k+ S! w% y- n
- #include <mach/irqs.h>
3 Y' @2 ?& }) i! N) i+ D - #include <asm/hardware/edma.h>3 E* R% @) r5 ]3 x: m( d
- ' \/ {! c5 h% a* g7 }
- #undef EDMA3_DEBUG
- y/ g+ K' ^2 J$ e T - /*#define EDMA3_DEBUG*/, Z, C1 g. p$ b4 K8 N$ d
, ?3 i6 n+ h7 I- #ifdef EDMA3_DEBUG
: S# ~; m& `! F2 x! r, O. J+ o - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)! Y( C: H+ U5 ?0 @) D% b Y
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__). a, _+ a5 k( u6 g1 Q, L; L
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)( y& \- u2 `4 Q7 g
- #else3 Z! n& B! X: @8 _% l ~6 F/ G
- #define DMA_PRINTK( x... )
$ `0 V" Z9 J4 ?* H3 m9 a. l) i - #define DMA_FN_IN# i: `% i2 Q, L
- #define DMA_FN_OUT
4 o! O$ R; r9 _( N" v2 ]& T( c$ b - #endif
9 u9 M; d8 E# L5 R
. K9 a! U4 \1 J; R4 g2 V& w. `; B- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
0 W- G; g+ {# T - #define STATIC_SHIFT 3
$ @- W* U% R& T! i! \6 B - #define TCINTEN_SHIFT 20& \. N- W+ }' N( [. Y- u ]( E" u: F: U
- #define ITCINTEN_SHIFT 21
9 W ^8 h/ g/ P - #define TCCHEN_SHIFT 22
( I0 l+ s! T: w; ^/ ]: V - #define ITCCHEN_SHIFT 233 X, @- ]# i5 ~. K& u9 L+ O
- ' p% `# d; D7 w7 K
- static volatile int irqraised1 = 0;
4 t& F( @ X6 V - static volatile int irqraised2 = 0;
?6 N/ F1 b/ m0 m' m8 f, | - H+ ^4 [, T+ k9 E1 j
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);, O- W/ j S \" q' R g
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
3 T+ p; A9 _1 o - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
$ z& t# }$ @5 c5 P G2 Y - / _" J# |4 X9 ^2 G* b
- dma_addr_t dmaphyssrc1 = 0;# m3 G8 `1 h) K9 ?0 ~
- dma_addr_t dmaphyssrc2 = 0;/ _3 ^* ` \, L8 U
- dma_addr_t dmaphysdest1 = 0;
% h/ t& q4 g4 r$ Q - dma_addr_t dmaphysdest2 = 0;: B) U5 W0 G1 z# X8 S
% y4 n$ U' w1 T% r+ A: r7 y z1 Y- char *dmabufsrc1 = NULL;
8 c6 g& d6 L \/ L - char *dmabufsrc2 = NULL;, d" [' U: U% m; | {
- char *dmabufdest1 = NULL;
1 F; l7 i5 [5 u0 R6 R - char *dmabufdest2 = NULL;
u8 }6 L, N# s7 g+ l. v; V - , ?5 u! X" Q! `( v, a: J, i4 ?
- static int acnt = 512;4 a% z7 B5 @- r: n+ s
- static int bcnt = 8;
+ q8 O# x& H1 \ ? - static int ccnt = 8;
0 U7 K2 x3 Y+ k3 H5 T% O( [" s2 A
& u& S2 R* I# X; q' E- module_param(acnt, int, S_IRUGO);" P9 `6 R7 e. A9 c" X
- module_param(bcnt, int, S_IRUGO);0 g/ D& y+ n4 ?8 J- m7 m9 b
- module_param(ccnt, int, S_IRUGO);
复制代码
( h S) o. J4 @0 X9 a
9 g& A0 |2 H* B3 w/ P4 `7 V$ |6 G3 M 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
3 G7 I8 U t. Q# f! c- ?* yarm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
# e0 Z- G7 o8 @+ ~" J; _# @7 Z- P 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。: k) i: W: a2 s9 l6 a
8 _. e# `8 e7 R& y v' w1 E+ b3 T$ f3 M
|
|