|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
* U6 A( Z/ f% G2 a4 ]7 {- [code]EDMA sample test application
; {/ [6 p% `" V2 w, B - /*
, |! e- a* d3 ^+ q - * edma_test.c6 N6 [$ W# M6 @: G
- *
" r8 g# f E. i' N& h1 Y% ` - * brief EDMA3 Test Application, `% y7 ?. i* J" V! D2 l# A
- *
2 j& r/ a/ X. l9 f; e0 ^ - * This file contains EDMA3 Test code.
- f& U+ X. X- {0 P+ p - ** j1 a, B2 e9 M# C* E- Q$ ^
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE* D' I, }. [5 [8 D+ o c
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
$ f+ M3 r9 \9 `' G' Q3 O. y8 b' ~# z - * TO CHANGE.
, L9 P( X9 Z( }8 ^. H- S3 M - *
Q3 u7 ]8 k9 N- w2 Q - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
% K9 J; a6 l& D2 ^7 B. p+ s - *' i: Y! g4 O' P" ?
- * This program is free software; you can redistribute it and/or5 {! y# Z( p2 l; @7 e; Y( ^
- * modify it under the terms of the GNU General Public License as
1 n: {6 K4 g: u - * published by the Free Software Foundation version 2. X% A- F& b; C, a% j
- *! k$ T0 I9 F& D& V1 ^
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any
7 `' x6 q9 D- ]# o# e+ i - * kind, whether express or implied; without even the implied warranty% Y) Y! X2 F; s, B4 M" T
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the) @" M. G9 F% F O, ^+ w, R) F
- * GNU General Public License for more details.
1 m" G6 O' u ^1 E ^! B - */& K# B; j5 Q- P) q8 R0 A" v+ ]' l/ i* R
, Q# F4 c* U8 {9 Y( f" c- #include <linux/module.h>
/ m) ~' Y, @' N) B* r - #include <linux/init.h>
8 y. n( M4 Q% c% `$ P1 a - #include <linux/errno.h>3 x9 Y! }* o. I$ p9 y/ H7 [
- #include <linux/types.h>
; h9 B3 E- S- Y: U - #include <linux/interrupt.h>6 B/ q. `+ @% o; M8 \0 ^; `( P
- #include <asm/io.h>
( k3 }0 G- m" Z$ {& ]/ |( k - #include <linux/moduleparam.h>
4 ]* l. w7 m: i) J7 N R; E \8 w - #include <linux/sysctl.h>' x+ m1 k4 y$ S
- #include <linux/mm.h>8 k9 p, ?+ Q8 B7 U$ k% I/ N" Q
- #include <linux/dma-mapping.h>
- n5 o* P% ?# z/ B4 m6 {5 B1 q - 5 {. g6 D. j( }4 m! {" z8 z
- #include <mach/memory.h># A# n, h/ ]$ G8 D. i
- #include <mach/hardware.h>2 B8 H+ ~, [; {; B/ O! k6 \
- #include <mach/irqs.h> [* u5 t" b A7 A& A
- #include <asm/hardware/edma.h>& y. d6 B4 S7 U# J
- ) o& k* g+ X, g5 G+ M, c/ X$ P5 H3 r
- #undef EDMA3_DEBUG
9 e2 [6 z( g; g; G - /*#define EDMA3_DEBUG*/
) M% a+ h6 ?/ m( E% n
; a3 {9 _. k# U% [6 r6 D: a- #ifdef EDMA3_DEBUG
' r2 t9 p! _0 t+ F q - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)7 W8 y! o5 D; u
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
1 s5 s( J% Q, A- l' } - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)' n/ U$ y7 B& K4 C- ~
- #else
- D- @( G- W: ?: e( M4 | - #define DMA_PRINTK( x... )* e$ f1 K. @; n+ g2 T9 |( O
- #define DMA_FN_IN
2 J3 b# ~9 g% z' p0 B: S - #define DMA_FN_OUT
5 i0 v) o# G/ e1 H4 g6 j4 Y - #endif
$ I W/ H# \5 ^5 s" Y5 {" g
7 V# _1 z6 y' x E3 q% u- E7 A5 d9 k7 H& `- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
& |8 G1 G+ G, Z - #define STATIC_SHIFT 3, }6 {5 V2 H* I" R' M' v+ U
- #define TCINTEN_SHIFT 20
, n) Y8 s% H. B2 ?; { - #define ITCINTEN_SHIFT 21+ F& p* j3 g1 J# Y' W5 H4 S
- #define TCCHEN_SHIFT 22
+ G5 _- h! ~! P# J, [4 ~0 R - #define ITCCHEN_SHIFT 23/ X2 u% c {4 G
- 1 I8 }' `0 ^* D8 f" q9 T8 s% d+ A8 S
- static volatile int irqraised1 = 0;
! e' C+ m/ e% A {- v+ p - static volatile int irqraised2 = 0;
: z, K, c. r3 B - / y h" Y2 ^$ M7 r6 q7 r
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
7 k" n8 H: {& x1 F( v/ `* N; b, o7 { - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
) G; e7 Y% s* p, |, V - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
" I( X' a [8 T5 P* Q - ( A. Z O9 R2 T8 h9 H, t, A
- dma_addr_t dmaphyssrc1 = 0;
# D4 J e1 L, Z5 T% B - dma_addr_t dmaphyssrc2 = 0;
" q9 _. `' K& t( z8 c$ e3 | - dma_addr_t dmaphysdest1 = 0;+ ^+ R8 `9 a. ]* N& `! R
- dma_addr_t dmaphysdest2 = 0;% S3 I7 {+ p% H7 [
- , c+ W( M0 y; n( s* _" b% p. L
- char *dmabufsrc1 = NULL;
% \ j2 m. y2 V1 D3 G9 @ - char *dmabufsrc2 = NULL;. _7 l. U& I. w7 x3 a$ X
- char *dmabufdest1 = NULL;) Y3 @0 x/ d- C
- char *dmabufdest2 = NULL;
4 W: a9 j5 I& Y7 z) H
# m7 _! G* i* r4 A- static int acnt = 512;
, r$ g0 E! I( K0 k/ t" u; I+ u - static int bcnt = 8;$ ]+ g8 ^& }& Y
- static int ccnt = 8;( u; @) l% L/ `. p2 P. |" F
9 x4 @! f' @8 [, F8 K* k- module_param(acnt, int, S_IRUGO);
( Z9 f1 t$ Y( A* G/ P( x; m; F - module_param(bcnt, int, S_IRUGO);, u! E* i) x* `* q1 C7 e
- module_param(ccnt, int, S_IRUGO);
复制代码 , R# x% O6 ~ s/ [; d* X* }
( a2 Q/ \$ C. V- {/ { 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
* {6 f& [/ C$ H, b5 xarm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
% F. j& l' M' ^2 o1 Y 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。: V o* m0 i. |" E' E
+ b, K: y# K$ A: o4 ^
- p5 N9 Y- i: Z |
|