|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 % u+ K) z/ G# }( i
- [code]EDMA sample test application k7 }" m" Z' v. B
- /*
& U y( g9 B# V1 }( X7 l- J - * edma_test.c. z: c+ B. ^7 e' F5 X8 i
- *- o8 t, t% }% {' b7 H4 H
- * brief EDMA3 Test Application" Z+ S/ T9 y" r4 H
- *
" K( h4 r/ h$ Q) I - * This file contains EDMA3 Test code.
$ O$ U5 h& p* F! H6 I - *
" E' k- S& P$ R- P - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
* M$ w" W' O) e( e+ h8 s - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT* a$ p, F8 _ a% e
- * TO CHANGE.
6 X( O* I: k3 p4 g1 ~7 ?0 F - *
' c, M8 y3 @4 W5 n2 a7 ^ f - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/1 \7 h" m. T! z# q7 W
- *
2 B e* D& z1 E, e! y - * This program is free software; you can redistribute it and/or
% }- f$ v, |) M1 N, Z - * modify it under the terms of the GNU General Public License as) e& _7 G( Z V; z, {# E
- * published by the Free Software Foundation version 2.$ N1 u: q) l% j% y5 q
- *
; L J8 q; w7 D$ @; I - * This program is distributed "as is" WITHOUT ANY WARRANTY of any
S( M+ C& X% D- A2 r! f - * kind, whether express or implied; without even the implied warranty2 Z% W: i W- R
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
. A4 Q v/ Y4 Z1 L) m5 a - * GNU General Public License for more details.1 b" D+ m& A" ~! c$ G" w) C
- */
; { P( ~, h. @. P0 l5 ] - + N. l' K. m) p p$ W
- #include <linux/module.h>6 Q% N- B" Y$ i) B
- #include <linux/init.h>
, v7 h3 t9 j* j0 G# o - #include <linux/errno.h>
, @* ]2 l& ]$ y5 l O# q/ E- I - #include <linux/types.h>( e& o/ _: Y& i5 K t2 E8 Q
- #include <linux/interrupt.h>
" z% z& f( f" Q. m4 o - #include <asm/io.h> Z. ] f5 w, G1 h5 \
- #include <linux/moduleparam.h>
. D2 H0 @7 {' H; Z& E9 y - #include <linux/sysctl.h>
3 ?$ D8 f6 d$ z' d - #include <linux/mm.h>
% O0 H% L, a0 b0 g7 ^ - #include <linux/dma-mapping.h>
4 c- c6 t3 P8 s - . U8 B/ ~ \5 X# I6 A6 ^& n
- #include <mach/memory.h>% [5 V. |, T: G r
- #include <mach/hardware.h>$ O' F( G" y3 p4 U) p: y* ?4 {1 T7 h
- #include <mach/irqs.h>
! d+ f9 [& a" L: \( @8 y - #include <asm/hardware/edma.h>! r' b! s$ w; T# W% G
/ p( M! t D2 k" b1 h x- #undef EDMA3_DEBUG- u% I, ^ a( F2 l
- /*#define EDMA3_DEBUG*/( c" ?: q8 h7 n6 ~. [9 R
" {9 l1 x7 g; k9 `1 {, J, q- #ifdef EDMA3_DEBUG
, p: c1 v" f, w: p2 S - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)1 M6 U. [2 p; ?# z2 i. I# u
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
. u2 Q: z% J" h) R. Q! R - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
* e$ @ t# i. a* e" s - #else1 {2 z |$ s( E5 c# ?/ E+ d; T/ z
- #define DMA_PRINTK( x... )+ ~ C: p; l3 S% q- i3 \& [
- #define DMA_FN_IN
# X/ l' p4 y/ Q6 o# y1 W - #define DMA_FN_OUT
. v* B# k! l& `' C/ V. h! o - #endif
3 F2 a9 e+ n: V6 V* O V7 l7 U - 7 K0 E" R7 `6 C5 I" \+ |
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
7 ^8 l# q3 ?4 ^2 L+ u - #define STATIC_SHIFT 3
8 g7 O0 |. ` W7 v. j, q' M - #define TCINTEN_SHIFT 20& L2 u( A( x" n+ ^3 a6 q
- #define ITCINTEN_SHIFT 21
9 O4 g- P, ~' I- l% e4 u - #define TCCHEN_SHIFT 22, c/ V1 X5 q, a: E
- #define ITCCHEN_SHIFT 23
" x8 d& e8 F- H+ K D - 7 h2 `+ k% Z0 ^ [$ e
- static volatile int irqraised1 = 0;- R! U, Y# }) q' A. x
- static volatile int irqraised2 = 0;
5 J+ Z g8 K4 R6 A$ k
5 j3 @* b1 f; Y; X- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);8 Y$ z" ?2 d/ e6 s
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);; F3 G8 S# B4 V) e
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
3 X* P; m2 r- F, o$ k1 E - 8 \4 j$ h- z Y& w2 V8 j7 e4 F% U
- dma_addr_t dmaphyssrc1 = 0;
3 g5 T7 k7 l" x# C8 n, a - dma_addr_t dmaphyssrc2 = 0;( j3 u# p7 C. P, ]/ y& s
- dma_addr_t dmaphysdest1 = 0;7 j* [/ Y0 g. v# U' k* B/ l
- dma_addr_t dmaphysdest2 = 0;
1 r. S! j! i: V' P
9 h! A1 n5 E, {) @4 {- char *dmabufsrc1 = NULL;: A: G" g2 p6 ]1 _* b& a
- char *dmabufsrc2 = NULL;% b: r+ u& U6 ~, J- C0 R
- char *dmabufdest1 = NULL;) @* x' ~. X; @) w* T9 C$ T
- char *dmabufdest2 = NULL;
% ]7 `; x5 [7 Z0 s0 l# y! h - / t! I1 ]# Q6 e: W, m
- static int acnt = 512;1 F# J/ V# m [5 K1 |3 j3 [) |% V
- static int bcnt = 8;
7 \+ \7 n; P0 c' o% f, l+ _4 c - static int ccnt = 8;, g. k& X, u3 p# H! \, p! e! M) e
- 7 `( O7 y1 H* @( Y
- module_param(acnt, int, S_IRUGO);, s- K5 Z1 ~- |: Z
- module_param(bcnt, int, S_IRUGO);! ~/ _+ h% @* i. v
- module_param(ccnt, int, S_IRUGO);
复制代码 ( f n, Z- k+ W7 N) G
# x8 f: o& Q/ P1 v# l5 C9 ]
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用" v& |+ k7 Z# c
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。. C$ r6 u. g) R0 ^5 |
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。9 C# u- e" G" O! o/ T: x3 H
# v! D& _6 K& M* |' |6 S, t
* t% y( t( w n, E- c2 Z |
|