|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
/ t& f6 y6 p0 k$ r/ }+ u: W- [code]EDMA sample test application! r$ g- r7 B- R5 k6 g# R# q
- /*
# s5 _/ {0 A7 f6 \ - * edma_test.c" Q. F x/ v' y( [: ^
- *
/ {; M$ j5 C$ i/ ~ - * brief EDMA3 Test Application
1 L, q% O2 V* U; y$ P* X - *
) L. K0 @7 h: j# a% V, I3 [. H - * This file contains EDMA3 Test code.2 o7 P2 C4 G( K" b9 N
- *
6 W0 u" }, K7 a+ }* T# {5 d - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
! i! f" E) p- d* m - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
9 b- O" a+ ?8 T+ M$ f. J - * TO CHANGE.
0 Q$ P% ]3 F' p; P, `* t" i$ ?9 ^6 A - *: x- T! X8 n% F' G8 u6 M
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/) X) |" S2 j; P2 _4 W% d' p2 d% Z
- *& Y, C; }7 k. D! p! y8 a
- * This program is free software; you can redistribute it and/or/ Q& L$ A. ?1 u
- * modify it under the terms of the GNU General Public License as
* r& c& R( x; c3 \ - * published by the Free Software Foundation version 2.& O; E& f) O# _, l2 T" z& z' J
- *# X6 Q. D+ R8 v% f1 k8 @# s$ Z
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any
$ G: c8 [* j- d+ `- a' | - * kind, whether express or implied; without even the implied warranty/ o! s: l8 {+ I% V' p, a6 o d
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3 L3 h! R- ?0 d4 F$ z( o - * GNU General Public License for more details." j( O9 q$ l0 _+ w9 ]0 r( j& H7 ]
- */8 A8 u2 Y! z8 ~9 M3 {& d- c
- ; ?+ C4 x- C' ]( O; D. h/ V7 c, c8 p
- #include <linux/module.h>: O# B: C6 @" k: h) }/ [+ W
- #include <linux/init.h>
! L* }+ Z+ R. k7 ? - #include <linux/errno.h>" Q# W8 q8 W9 `, y
- #include <linux/types.h>2 b$ A y! T7 U1 h' P
- #include <linux/interrupt.h>/ \' q) v- e6 U% Q/ Y8 x* }% ~
- #include <asm/io.h>* ]4 a* O7 h6 t6 R7 v
- #include <linux/moduleparam.h>% P) f+ u* R; F& m( P3 i2 y
- #include <linux/sysctl.h># [0 U; Y. u' R
- #include <linux/mm.h>( r% {; X8 o8 x4 k
- #include <linux/dma-mapping.h>7 q4 D5 m# _- k, T
- " ~2 F3 R: X/ ^* W0 d9 z
- #include <mach/memory.h>6 I$ p( u; e4 P7 w4 j# U; r! s" x
- #include <mach/hardware.h>" }# [ y T$ C5 U9 s
- #include <mach/irqs.h>
( ]2 g, M( l% f; @ - #include <asm/hardware/edma.h>% r: h" I. g2 K$ _2 Y4 i8 x
- # t4 T, M- s7 R4 e! j; b- E! i
- #undef EDMA3_DEBUG, `6 {- t2 s6 W2 X
- /*#define EDMA3_DEBUG*/
! E+ Z9 B F _+ w - 2 a+ ?1 O: b% ]8 e
- #ifdef EDMA3_DEBUG3 V1 n. z" r( w/ t6 e
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)) S. j" Y2 G+ E( M3 o
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
, ?5 a5 ?# E) ]# r% B( i - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
1 l4 m& n1 \7 H5 d6 z - #else, p. ~( G4 v# C+ N
- #define DMA_PRINTK( x... )6 Q+ k h, @# m. c2 j9 D1 m- O, o
- #define DMA_FN_IN
|# l a0 O# f- {+ G+ U1 e; b - #define DMA_FN_OUT
- s: ]! ^8 ]0 a; v* G) e - #endif" T7 {& O8 Y4 e6 m
- ; q) t" ~) [$ h2 z3 l% M' H& y( s( }
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
' d2 k2 k# s6 {" G k4 s1 K - #define STATIC_SHIFT 3
, ^) u6 m `! E2 X0 m" x1 H - #define TCINTEN_SHIFT 20, w9 {9 P, l+ v. m* U
- #define ITCINTEN_SHIFT 21
$ y3 ^- l7 Q3 I# H% n; v9 F - #define TCCHEN_SHIFT 22
6 h( B0 u; E9 _5 n5 k+ ?. L$ | - #define ITCCHEN_SHIFT 23
# e2 X1 s% W8 @" Z7 p, ~, K
. |1 F/ E5 [- _! r7 H- static volatile int irqraised1 = 0;( m! v4 D5 t, \" g4 X/ k1 C7 p
- static volatile int irqraised2 = 0;
, a; d5 W% N* ?9 ^% k
+ P( k# ?- _6 c: R3 c& J- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);/ g+ O* B l) `+ u
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);9 Z6 ^" C0 e, b) \4 d+ m0 e) J
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue); Q0 Y |% K# d# b
- / z# [% v' d+ w
- dma_addr_t dmaphyssrc1 = 0;* d, O* u' g8 P% u$ I
- dma_addr_t dmaphyssrc2 = 0;
: H0 e6 l! \) z) I& O - dma_addr_t dmaphysdest1 = 0;& ] }+ N5 u0 U: N1 W3 P2 Q
- dma_addr_t dmaphysdest2 = 0;
& W0 Z6 V8 l8 k1 L. b3 O1 C L - ( K0 L1 s6 V5 B- S4 v% z' y
- char *dmabufsrc1 = NULL;/ s& u( W: K& ], [+ `/ \
- char *dmabufsrc2 = NULL;' Q9 B8 k3 X0 Q2 j9 \3 y9 Q
- char *dmabufdest1 = NULL;
2 d7 t( u; X! k# @ - char *dmabufdest2 = NULL;
8 R r: B1 l! J2 S) t3 \
1 e# m) J( K9 H1 C, q/ l- static int acnt = 512;' g) [) l- ]3 u! X$ N: y p
- static int bcnt = 8;9 R; {: f+ g9 L2 U9 a3 H8 w
- static int ccnt = 8;6 f' k" h% |$ u5 A% a# n
1 _; C0 {: C' e7 |1 X; C) w- module_param(acnt, int, S_IRUGO);
8 x1 R7 z4 K7 w4 `0 I" U" u - module_param(bcnt, int, S_IRUGO);* x1 a) B) ]' ~# x; R
- module_param(ccnt, int, S_IRUGO);
复制代码
% c2 ]/ u$ D9 F, e! ^
9 x" j7 i3 C6 f( z" S3 B 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用& B5 x( c$ v4 N3 A+ m8 _
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。" k: R/ O# d1 w& }: o4 f4 a
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。9 N. P9 L9 R! B) a8 w/ @/ `4 ?
6 \( O/ k$ f, H- A5 W9 I8 V3 [" r
3 O5 H7 v: w9 R; V( J8 [$ x0 I |
|