|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 ) D0 F6 c+ x0 Q/ _
- [code]EDMA sample test application
/ q0 G0 C' I& o' ~ - /** ~& e; \7 ^6 D! |
- * edma_test.c
O) ~# ~. w& q; e, f0 \ - *
! e- S: {; B( v& u% q) r2 Q- U - * brief EDMA3 Test Application/ j; ] Q) _+ w* F% R. z6 H6 `) A3 {, P
- *
. { o ^8 R- _! L) W - * This file contains EDMA3 Test code.9 V9 k# c: i; `9 ^
- *
0 o. ~: e. j+ Q - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE2 @- Q! ?) [. I+ @& O" g! q
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT% W1 s0 V/ a: C4 |$ w
- * TO CHANGE.: q; \; W1 Y' T! O
- *: P! b5 b% I4 t ]; x
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
& u& H% w4 \1 P$ k - *
/ T# S4 q6 m' T' F - * This program is free software; you can redistribute it and/or5 ^) R3 f& E' p f8 f3 M# Q
- * modify it under the terms of the GNU General Public License as
# i. q: u# G1 |! }2 p, ?! l, l; h - * published by the Free Software Foundation version 2." i1 G- f, j( E9 D$ W" t! X7 m
- *6 j! F# ]" M9 t. j
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any* Y6 Y- L$ M) W
- * kind, whether express or implied; without even the implied warranty
( ]9 G) J2 k; |/ t& ?* Q/ ^6 b - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the; x. E* x! X2 Z; S9 l% A! z2 u/ w
- * GNU General Public License for more details.
. i- l T' s$ T1 D- J- I - */
" |* _' t9 X8 d) A [ - , v3 B% e( Y1 ]1 o+ ?. w
- #include <linux/module.h>+ p" a4 \3 G+ O& h& u {$ ]
- #include <linux/init.h>: m. [' ^) R! ^6 @6 c, }# v
- #include <linux/errno.h>
+ x3 E6 f/ [+ t7 }0 B! H - #include <linux/types.h>) L. G |, {0 I$ v7 L2 v+ u
- #include <linux/interrupt.h># g4 E3 O! J4 q
- #include <asm/io.h>( }2 f/ _1 F$ K. C6 J% s& E
- #include <linux/moduleparam.h>' [3 {( D2 Q5 Y# c( j# d8 ~
- #include <linux/sysctl.h>
$ X! b4 @$ f' E1 `: H+ ?7 u9 t! [( B - #include <linux/mm.h>- |( |6 a$ G: ]8 k1 X/ n
- #include <linux/dma-mapping.h>
! Z. O* w& Y$ n6 L' i# J) `
7 @ m* M5 ?& T& C ?. Q2 f- #include <mach/memory.h>" K8 r Q5 _& Y7 ?! g1 V+ _! m$ n2 P
- #include <mach/hardware.h>( ]9 n( U7 [% a/ z8 D; p+ s+ a
- #include <mach/irqs.h>3 C1 Y1 ~6 e8 @: v7 I' |* a
- #include <asm/hardware/edma.h>
% S/ J# j4 @6 d. ~ - ( ?: T8 T2 B+ {2 c) k
- #undef EDMA3_DEBUG0 }5 O8 B8 f8 T, q; E+ H. u" V. Y
- /*#define EDMA3_DEBUG*/
) d7 S( Q* g' \0 @* p% U1 a - 2 l4 J- d+ b7 n+ W% C
- #ifdef EDMA3_DEBUG1 H0 r0 ]! A! C6 I
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS): ^! q6 S7 I# L; q z) Z
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)+ f7 G0 m; X1 ^, s1 a# [, {( w
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
g' j1 J. `. k* F7 H - #else
2 T! n0 z0 s" |) }6 w/ o - #define DMA_PRINTK( x... )" [' I! n' z' A; H! S
- #define DMA_FN_IN
4 i+ d1 |* _; I - #define DMA_FN_OUT1 b4 ?: _0 h7 z" j" _5 ^! P
- #endif( H2 ?" c, z$ {2 @4 v+ }
7 F1 s$ [# L7 @* m4 C3 I- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
9 ^" P B. L4 I2 @ - #define STATIC_SHIFT 3
+ P* }5 z2 t7 L* [) c9 R# ? - #define TCINTEN_SHIFT 20
9 G% ~% Z1 ?9 L1 Q* j - #define ITCINTEN_SHIFT 21; C, z, _6 \9 Y ?$ e- _
- #define TCCHEN_SHIFT 22. B# G; t9 F9 j/ S/ I
- #define ITCCHEN_SHIFT 23+ `( d2 F/ f2 c X
- # E4 P7 L/ ~ J+ U! M" U
- static volatile int irqraised1 = 0;
+ w) T' _, I1 ~+ _& I1 T) Z - static volatile int irqraised2 = 0;) ^8 w* H% h6 j7 t3 L7 n, P
- $ e8 @# Z) [* ^8 f7 _. K; D: ^) d
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
7 |0 i/ k, g) q/ k. A - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
0 X) `5 X; j% H4 Z5 d" k' H - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);% R; o& p- U7 x. e! s( o( c, {' \
- 4 r' T; R) U* Z0 ^2 [
- dma_addr_t dmaphyssrc1 = 0;
) e3 R% u4 ^. d- O8 s, Q, b6 K - dma_addr_t dmaphyssrc2 = 0;
! h$ Z# P# ~3 }& S6 d - dma_addr_t dmaphysdest1 = 0;$ h$ z% @% h2 G' G1 e
- dma_addr_t dmaphysdest2 = 0;
4 ]! }- e% Y8 z
+ K9 L0 \+ ^$ P8 I& ?9 v1 j, q: k4 ^- char *dmabufsrc1 = NULL;2 v: T. e, M* Y
- char *dmabufsrc2 = NULL;* @' X% x7 v+ w( I, Q
- char *dmabufdest1 = NULL;5 v# ^" s: j% @
- char *dmabufdest2 = NULL;
4 y. E2 P8 i5 o2 [, F
* n" x { K" I1 t% } k. e- static int acnt = 512;% F5 P5 S* j* h8 \" x0 R& Z* w
- static int bcnt = 8;
2 M& O* W) ~, W3 P9 g3 f$ P - static int ccnt = 8;' {6 L4 p: z5 a6 l. h
& t! u& y8 I; e8 ?5 }- module_param(acnt, int, S_IRUGO);) w7 C% h) G. ~# k
- module_param(bcnt, int, S_IRUGO);
! S, s/ e. ?; U) k( O3 a- `& M - module_param(ccnt, int, S_IRUGO);
复制代码
# ~7 U1 b& t% _8 ^. p
' O! Q- V3 G; I, |* S8 d, ` 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用& G1 F5 {; N3 q1 H7 K6 z6 q, t
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。" W. Q) r5 n7 I. [* i3 }
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。) R0 S- j- t K* ^6 D* j
& V% c2 l1 K7 }+ I
! E: }5 C0 f( _' d3 z$ N- J |
|