|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
7 j/ q( J+ z! f( t- [code]EDMA sample test application
: Y9 a! P4 ~+ S; C& ^2 d - /*" d! C5 ~$ o8 q# d9 R8 B
- * edma_test.c- a+ C7 v% B: V
- *
8 s' k) v$ G" i& I& y2 `9 [ - * brief EDMA3 Test Application( \+ x4 F# s- |- y
- *" l# a1 z: S, X8 r7 U) @; J
- * This file contains EDMA3 Test code.' g" i6 F C4 t8 m
- *. Z0 K: T5 e& ~
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
8 }% J. e4 \# ~' J& n1 D - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
" Q* V( X/ Z/ x1 r9 H) @ - * TO CHANGE.5 s% X0 D6 w# U/ T# ?
- *
3 Y, [+ j6 ]+ }8 C' j& i1 _ - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
) B+ L! t9 Z* \) s1 v8 E - *
4 q- u4 f. w3 y& Q: P - * This program is free software; you can redistribute it and/or n- \5 v7 ^" U; |
- * modify it under the terms of the GNU General Public License as }( o) q% d; h I
- * published by the Free Software Foundation version 2.% V6 G9 p" g! l! C% @$ _# e
- *7 P' R; Q6 X4 d; U+ M/ D+ Q+ q( h- `
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any, L# p$ ~) u$ v
- * kind, whether express or implied; without even the implied warranty
9 n5 r; T) J* S3 \8 h - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
$ y$ ]& k2 [ K8 I9 l! r* H3 A4 W - * GNU General Public License for more details.
& A* U+ f) ?6 }. Q" d - */& l% Q9 D* P# R6 x' Z; c
- ! a R/ H$ {: i! h" @
- #include <linux/module.h>2 U |' R" [) S' L: H
- #include <linux/init.h>6 I- j: }: A; j. r
- #include <linux/errno.h>
, P; h4 T) S$ H) D h - #include <linux/types.h>
v* F$ l7 \: M" W. N - #include <linux/interrupt.h>
/ B- t* F# w/ B3 C - #include <asm/io.h>
8 k# t' ?6 p4 u& F' t - #include <linux/moduleparam.h>: `0 _$ d: U4 K- J5 V* d/ _
- #include <linux/sysctl.h> u- U$ H$ h; m$ [
- #include <linux/mm.h>
# B3 @ C. P9 b) l! W, W5 h5 h6 o - #include <linux/dma-mapping.h>
( ~( ]3 M1 ]; d - 5 ?/ W' {" G& n
- #include <mach/memory.h>
: m+ v" R- a% I% c2 \8 l* K4 v8 u - #include <mach/hardware.h>9 a" J( J( y8 k' {+ ]. y
- #include <mach/irqs.h>! ^% L) m9 ^8 o7 g/ {
- #include <asm/hardware/edma.h>
/ \4 n& y. t2 S/ L6 Q6 p: n
$ g; u* M3 y1 |8 _- #undef EDMA3_DEBUG
# u/ X* p- G. N0 i9 B - /*#define EDMA3_DEBUG*/* D: d+ M$ Y0 @ M
5 A# v( D5 I3 G8 X" I8 g& B% t- #ifdef EDMA3_DEBUG
7 H1 G0 Z5 ?- e- ` - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS). e0 m7 l8 M4 Z# ^, z% i9 p
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)2 d2 V/ q8 L' E; f$ H
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
7 E! c/ u% Q" u2 h - #else+ P/ L0 H. Y0 ~( m$ W) i+ v
- #define DMA_PRINTK( x... )
' @% ]' n) A7 M6 p% @9 V - #define DMA_FN_IN
" b, M3 d' v' i* V$ Y0 a+ { - #define DMA_FN_OUT4 }+ D. D+ M+ J" g4 D
- #endif
) Z% c+ z! \5 Q% B% e+ |
: n: M9 Y* h* Y3 [9 f7 N( k+ `7 H- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
' q% j% H" S: N4 a# u0 s - #define STATIC_SHIFT 3" K; E& j7 t8 {" [7 N% e2 O9 X
- #define TCINTEN_SHIFT 205 t# p9 k3 f/ m* L
- #define ITCINTEN_SHIFT 21
! ]5 Y2 O8 r$ g' ^! | - #define TCCHEN_SHIFT 22
% A/ M( U$ u5 L, F7 { - #define ITCCHEN_SHIFT 23' d( V" x6 J, q1 r+ }4 c. [) m- n
- 2 j9 s9 `: y0 {+ v3 k
- static volatile int irqraised1 = 0;" s0 ]' K& g& p: |6 e
- static volatile int irqraised2 = 0;- ~# u5 i. ^! k ?% T% O
% _1 m3 C+ G% Z: x( g. ~) R- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
! [& Q3 X: _! m/ m4 A+ O - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);9 Y8 i8 F8 e" d- P
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);2 S7 l! v Z, F. [; I. x
- $ S2 Q2 z3 [: C' H6 {9 k
- dma_addr_t dmaphyssrc1 = 0;. ~( L1 N, ^3 d
- dma_addr_t dmaphyssrc2 = 0;
9 _% t: D' B0 v! ^" e6 q+ R7 I - dma_addr_t dmaphysdest1 = 0;
" k) {- |7 D y% ` - dma_addr_t dmaphysdest2 = 0;
! v8 a1 N: A6 [* R% d# j$ @ - ( [( I, S; N: u. p+ J/ j2 ^% L
- char *dmabufsrc1 = NULL;
8 C8 d% W* Y$ ]( c - char *dmabufsrc2 = NULL;
9 I4 ^2 O+ {' L) _: U - char *dmabufdest1 = NULL;
2 N# E/ ]! q' `# ]: I - char *dmabufdest2 = NULL;2 a7 z( w! r- P' i; s
; L3 B6 d8 u$ C+ k4 r, C- static int acnt = 512;' J! o7 e) r( V$ E6 G
- static int bcnt = 8;
+ i; d1 U+ s+ }1 j3 a# V - static int ccnt = 8;* R0 V6 [/ t4 M9 X
- : R- B! P$ ?9 _
- module_param(acnt, int, S_IRUGO);
r7 z( K" B4 h* j; H - module_param(bcnt, int, S_IRUGO);
* G' Y0 m0 P9 {0 G. f. _* p% J8 a) n - module_param(ccnt, int, S_IRUGO);
复制代码 4 R+ q0 W0 I' R* F$ I [
0 O5 J; P1 d' @" ^2 Z" m+ I
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
! L/ f9 S% r- _6 X& D9 `5 darm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
( ~- \' M# r8 s* @* d 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。& B# W8 M5 _+ |
- u& R! Y$ U1 ^$ F
& \7 A& m# |) A6 M
|
|