|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 6 R H/ A& q( s* U1 ^. v/ ]0 @
- [code]EDMA sample test application
9 {; k |9 s* t4 k8 H - /*5 x" y f( Q: l' f( u
- * edma_test.c& G: c& I' a. L3 ~2 w' v, }$ k
- *1 |- X+ t' e9 d: i4 \
- * brief EDMA3 Test Application( ]1 D+ v0 n- E9 B
- *. L+ v2 Q) r6 \ y
- * This file contains EDMA3 Test code.
% C( `+ m; d4 [) r( S6 Q - *' a1 ~. v2 U+ h$ C2 p
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
! _' K' I. [% a - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT2 D- @, l; i9 A& T: H) ^7 G
- * TO CHANGE.
2 y4 ]8 `" ]% _5 S0 H, o C - * n. }$ ^+ j% g/ L
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/' H# P7 J5 ?3 G$ y) v# z
- *. A+ m! X) }6 ^4 L/ Z
- * This program is free software; you can redistribute it and/or u& L4 N) A" [8 Y: s- s0 Z, g# q
- * modify it under the terms of the GNU General Public License as
6 q4 S: k d7 N& Q# w$ R+ G" I - * published by the Free Software Foundation version 2.& F0 p* A | X' Y* d
- */ w# t# u* @1 w, K& h" e
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any# \* P, K; x7 E8 }
- * kind, whether express or implied; without even the implied warranty+ r/ K) [8 z/ p$ ^2 d, K
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the$ w- \" m- l4 H! s9 g0 M
- * GNU General Public License for more details.! B$ N* ^# {0 ^" v! j& ^
- */ V* p" c1 w. j& {
5 t7 m' r5 y k' z6 s1 X/ U- #include <linux/module.h>
5 G/ x' _2 a; A$ Y9 o v1 b- k% t - #include <linux/init.h>. F" x) P# @1 u& t1 K: l c
- #include <linux/errno.h>; Q: V4 g. J# s# P' t
- #include <linux/types.h>5 x1 G; Z' T8 Y! u( W% X; x
- #include <linux/interrupt.h>& y) i f3 ~( o* e
- #include <asm/io.h>8 |; Q4 m9 h3 k3 C) i% ^9 K9 d' U
- #include <linux/moduleparam.h>
" D }- K" W, l* N - #include <linux/sysctl.h>
* U+ H5 L" L, H' I i - #include <linux/mm.h>7 w3 S! X7 J' R) f5 S s
- #include <linux/dma-mapping.h>
. o2 \3 |7 s( @# b2 q3 q6 w - : g2 N0 w6 Q6 d9 {6 i3 l+ D1 N
- #include <mach/memory.h> Y0 h+ `; Q: e" Z! y( D2 K
- #include <mach/hardware.h>
# J1 m/ `' n% ^$ f3 o - #include <mach/irqs.h>
7 b, [* B; [% e: q( q' ?/ s - #include <asm/hardware/edma.h>
/ P$ E) O. C- h! B% _ - * \. \; _1 C" g: L# V4 @" w' u
- #undef EDMA3_DEBUG2 Z0 z; P, j u- k% w5 V2 {8 R( I: ?
- /*#define EDMA3_DEBUG*/& r% s' E6 w9 l
8 |1 b; J8 |2 m/ F3 V- #ifdef EDMA3_DEBUG
& w( x9 l' r3 D+ F+ Q - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)* v. x* C3 o* J% a
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
) H$ p- |1 M2 G2 M, i - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
7 c. N; B2 P" L; K8 T! c - #else
5 p) b2 |$ D( D4 H- Q- |0 g - #define DMA_PRINTK( x... )0 v( I8 }5 \9 Y6 k9 s! ~( ?1 r9 u+ W
- #define DMA_FN_IN
4 _$ C0 P- e9 G - #define DMA_FN_OUT# F. R9 i3 g0 v8 Q: _
- #endif+ w& z8 c* E' `8 T5 S u
1 N+ j0 I* A, F4 d' Y0 R" E' \3 f- #define MAX_DMA_TRANSFER_IN_BYTES (32768)# i {8 S- t) e1 t7 p' l
- #define STATIC_SHIFT 3+ x$ I0 P' ?0 O$ U! {' G( L
- #define TCINTEN_SHIFT 203 a/ g6 n7 ] c# u6 T3 a/ H
- #define ITCINTEN_SHIFT 21; @& y& q* y( X
- #define TCCHEN_SHIFT 22$ W, c* @; L( g
- #define ITCCHEN_SHIFT 23
' s9 a3 `7 [+ `3 g - " Z2 @9 v9 F P6 O, |0 `
- static volatile int irqraised1 = 0;% W( z9 P7 q3 f9 u& L' i# z
- static volatile int irqraised2 = 0;
: w0 o2 J! U5 C' Q6 U. `
* q7 A/ c6 W" z- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);. |# X; v- J& c" t7 q6 I/ {# n
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);3 {. m7 L' N& v% L* Y
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
" b4 K3 }! J$ J$ Y5 E4 n8 U
8 D- @7 r6 o" H4 {, \2 S- dma_addr_t dmaphyssrc1 = 0;& T, x5 t& `& r q7 g# S
- dma_addr_t dmaphyssrc2 = 0;$ s0 \2 S1 ?$ B
- dma_addr_t dmaphysdest1 = 0;
- C+ u1 |$ e7 s) V" B& O* U - dma_addr_t dmaphysdest2 = 0;# N, A, {. B$ [7 ~$ k3 K0 R& L/ p
% y4 L0 ^$ q- B2 Q; |- char *dmabufsrc1 = NULL;
! N% w( J; k6 Y2 A9 s' ?$ i$ k - char *dmabufsrc2 = NULL;
. p/ Z8 p- N) _& r - char *dmabufdest1 = NULL;
8 `7 p: o/ f( q Q" ] - char *dmabufdest2 = NULL;+ V1 r+ a( g+ l& _6 F4 r) S6 x
* S# y7 j7 J `: r- static int acnt = 512;
+ U( D R1 O) `8 a1 C1 q) J5 z - static int bcnt = 8;, f8 \9 Q! R( {% n1 J( p
- static int ccnt = 8; ?$ q s+ @1 |7 b) s2 q
, F9 a7 ?) C$ b0 C* x' t- module_param(acnt, int, S_IRUGO);
`- W% W# K; `+ U/ t9 x- X - module_param(bcnt, int, S_IRUGO);
) b9 m6 Y5 R, b/ i: g* c: X8 y* A% G - module_param(ccnt, int, S_IRUGO);
复制代码 9 i/ P9 |# _" [ S. N7 s
( c) c8 E/ Z9 A 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
* R8 @/ E- @( h' v; a% 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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
) G" Z/ |% e# j {( X4 s3 }/ K 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
, B& i7 h2 t0 [# D1 S- t0 ?5 ^; }1 t* J& ^6 }; R# W* c7 M W
* \" X* x8 O9 g* \% }& g5 q
|
|