|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
8 {. G/ [. l: K& [- [code]EDMA sample test application
! e, a* I; L' U! A - /*
2 ^4 o" J) }/ _% N5 \; V - * edma_test.c2 h1 F3 w; \; s2 e- C" w0 d
- *' O8 O: [+ c% Q8 j( `* O4 M
- * brief EDMA3 Test Application+ [7 u: V/ X3 o* W1 \
- *
7 V) w, ~$ f' ]6 D - * This file contains EDMA3 Test code.
0 o& f7 g+ K; u- z/ a: Q - *0 l( c) n& e! q. t" a
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
$ i# b0 |. ~. x& ?4 p - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
4 [, {) d# h; r, v. E0 \& n0 j - * TO CHANGE.
- b2 o8 ]( L% [5 F- x$ }/ @ - *
/ W" j/ K: ~; U - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/7 e. }( ^; ^8 W' C$ O6 k4 H$ H$ [. S; e
- *4 R* l. c3 b* T/ _& \! g/ Y `! f
- * This program is free software; you can redistribute it and/or6 b: Z3 @. v1 c1 A% ~' D# P
- * modify it under the terms of the GNU General Public License as
$ i, W+ {7 @" a - * published by the Free Software Foundation version 2.
1 p; Q5 I& J( ~& W - *
( A6 f4 e. C7 z - * This program is distributed "as is" WITHOUT ANY WARRANTY of any
) `% x% p5 b) D. a* q8 O+ I4 S+ S - * kind, whether express or implied; without even the implied warranty; L4 Y5 c( k5 @% {* Q2 J. b ~9 D3 Q
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
7 [. n6 O" O% {7 O# b% H. a - * GNU General Public License for more details./ g9 r+ I. k/ n% l
- */
U( F9 t) w6 ?; _3 ]4 y - , K; R. L; v) Y) O; f3 ]( Y6 L$ x
- #include <linux/module.h>
0 ~; c( x# |4 f0 U0 i5 w7 A# k - #include <linux/init.h>
' ^& n6 P1 Y, p# d& N R6 y$ c - #include <linux/errno.h>: b( H2 h$ L: t; ]" e
- #include <linux/types.h>
, k6 n( n% n( ?. ? @ - #include <linux/interrupt.h>
% @1 [/ ~0 |. [1 \, m - #include <asm/io.h>
' t) g7 C, @* @- _3 v& l9 c. n - #include <linux/moduleparam.h>" g2 o1 G! z& A& T
- #include <linux/sysctl.h>2 y z2 o+ D+ M6 L. M
- #include <linux/mm.h>
2 j4 u' w- y! X2 i - #include <linux/dma-mapping.h>
: R# A3 W9 Q8 T2 a- V" h- C - 1 u* N7 }' W: v. {
- #include <mach/memory.h># Z! a- n9 [1 j# x; r5 Q# I
- #include <mach/hardware.h>) S+ Y) f6 V0 J S2 m
- #include <mach/irqs.h>" l% N5 ^3 F! I& N; R* @
- #include <asm/hardware/edma.h>& w7 n3 I7 l6 v5 w1 _) l
6 c- g; @& K! W* | w- #undef EDMA3_DEBUG
" }3 t5 `3 J2 M - /*#define EDMA3_DEBUG*/4 n: |- J+ ]; b
- # d* D, U2 u3 Q
- #ifdef EDMA3_DEBUG
6 l( Z# E: a& s1 e `9 `+ [& O - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
+ C* p( L7 g, P5 b: S/ |$ C, s0 P - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)& M: J% K" c3 P
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
q: R# L- ]* r! K8 V- F- b - #else: N$ i$ D2 q! r; |+ C/ A
- #define DMA_PRINTK( x... )
7 m4 d$ \+ p% q+ j9 `/ N" P - #define DMA_FN_IN
: f1 d* K% c; P& V - #define DMA_FN_OUT1 Y' {$ y* F( U1 q' Y9 H, b; r
- #endif- Q1 X9 G9 H' u6 m( f% P
- " X5 e" Z! {9 h. r- ^
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)' T) P4 {; n/ R, d5 A) _. g
- #define STATIC_SHIFT 3
/ R) z5 H" i3 R1 ` - #define TCINTEN_SHIFT 203 ~# a# |; E. y' q
- #define ITCINTEN_SHIFT 21
0 y6 G/ G( S* T1 F# F5 F - #define TCCHEN_SHIFT 228 l6 }3 W9 v4 A: ]- H3 k: r& W. u2 w( n
- #define ITCCHEN_SHIFT 23
( V. g* b2 h' K" P* Q0 G; h
" q4 A1 n0 R: M, u; o0 a! L+ [- static volatile int irqraised1 = 0;
5 N$ t$ U; u4 \% m7 E - static volatile int irqraised2 = 0;
' p& v; T1 E0 o: p
! @$ B6 }% X- _+ j3 x+ {, N* f- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
) C' S( t1 n! }# F6 Y! e' h, H - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);9 b. a2 M9 Z$ A! @
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);$ q; }( p$ @) r8 C2 _" o6 H
- 9 D3 e+ N: B7 g% e5 Y* W
- dma_addr_t dmaphyssrc1 = 0;" x6 @* |3 G$ d1 X. s. g
- dma_addr_t dmaphyssrc2 = 0;# ]1 f& \; k5 Q
- dma_addr_t dmaphysdest1 = 0;3 J- U: a* K( o" p
- dma_addr_t dmaphysdest2 = 0;
' v: V; I5 }9 `, ^ Y; |4 f - 6 C/ H+ J9 [% p# \& A7 ]9 w
- char *dmabufsrc1 = NULL;. k+ g, A1 o7 @. c- ~
- char *dmabufsrc2 = NULL;
3 n8 j7 |! l1 Y: f. | - char *dmabufdest1 = NULL;
* ?% m: }5 U* ^2 p/ Q - char *dmabufdest2 = NULL;
8 h# u9 ?: B6 j+ d - 3 T* _, H- L* D* G8 c: ^9 B- e
- static int acnt = 512;. o" Y4 _; V$ o2 K6 }5 Q5 k" _
- static int bcnt = 8;" S" p! J R7 F( `1 B) u! P% p. a% x
- static int ccnt = 8;
C7 Z, L" b0 B- [' Y! }6 \. [1 n - 3 k: m" Z3 ]2 T) ?5 x
- module_param(acnt, int, S_IRUGO);
5 T& o* e/ B3 ?5 ]: } W# l+ D - module_param(bcnt, int, S_IRUGO);
4 U' T% I. e) Q5 t# f4 o: J6 N - module_param(ccnt, int, S_IRUGO);
复制代码 2 s* S1 O5 f$ Y4 Y: s1 B h5 @
& p' F9 {8 L9 S7 B; r6 P
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
% n4 R0 g S! ~( [5 a" c/ E: Harm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。: I! d/ C8 _! c1 m* E
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
, O$ a* H- P4 e2 ?& Q9 p& S! ?$ } l9 S: t4 t
8 V$ |( q. H0 C, x6 S
|
|