|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 ; U7 g( M$ l4 M" I# l5 f; \
- [code]EDMA sample test application
; S6 ^, J0 N' l5 q9 l - /*
. E9 H( Z, C4 q9 J - * edma_test.c
! }" x+ R& M$ j3 \ - */ U. V; l1 B) G+ n, [, b) L7 J
- * brief EDMA3 Test Application6 Q, G+ s7 B' c/ [- c. H7 S: B2 F/ c
- *
; k! e* ~& X7 i- h+ R- b - * This file contains EDMA3 Test code.
/ r% Q) L/ S" L6 T - *" }# |0 \" T9 U/ _: [! ~
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
* u7 ?/ j+ J7 s* S/ X2 e X - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT3 _) q8 G/ d+ O
- * TO CHANGE.
( |' i" ^* @/ d% F - *
4 G3 i9 }& Y6 [+ D! K# }/ i+ O - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
3 P* g" l' Y" A, _ - *' F- b) m' i4 K2 l" g/ {+ b4 H
- * This program is free software; you can redistribute it and/or
4 L/ d0 m+ s9 C( \- k$ b4 t - * modify it under the terms of the GNU General Public License as; r2 }4 N/ P+ h4 l1 x. K) r2 F
- * published by the Free Software Foundation version 2.
' e z! j) y7 B4 [. [" m- A - *
3 [) ?) ~/ x6 B! `- U - * This program is distributed "as is" WITHOUT ANY WARRANTY of any
3 C9 S. m( \7 y' x% P. [ - * kind, whether express or implied; without even the implied warranty& `; b/ U* t, {! E
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
% H: x" h$ u5 V3 V1 ]6 N - * GNU General Public License for more details.4 r0 G5 v' M9 D: a3 F
- */
2 x# |. T& t* o" ?3 n! [) M - 4 ]1 R# U+ Q5 u" S
- #include <linux/module.h>4 K( h) d* s* O! A, W6 q: [- Q
- #include <linux/init.h>
0 T$ {0 f& w1 ~3 v2 V - #include <linux/errno.h>; V0 @' t- N n* @) X9 i
- #include <linux/types.h>
: v9 m# D+ d/ S( h2 ]: i# i - #include <linux/interrupt.h>
/ X0 I" |7 n& t# y6 y0 c. l V: B - #include <asm/io.h>; C% _. n9 V: @' u" x' n$ ~5 A
- #include <linux/moduleparam.h>! L2 w" e$ r6 Z7 ]) a2 E
- #include <linux/sysctl.h>: G- Q7 b |' I- H I U7 p: S
- #include <linux/mm.h>5 J8 V& S" Q @# d, \7 Y7 Y+ V
- #include <linux/dma-mapping.h>
( L0 K6 p8 T( m+ f, d4 S1 J2 ~ - - I! c$ _7 c- {( C. o
- #include <mach/memory.h>: _6 K0 u( S; ~4 d5 L1 k+ F
- #include <mach/hardware.h># O4 @4 V& j$ P4 R% A# g1 e* ^3 T; h
- #include <mach/irqs.h>1 f) O1 k) @" v3 L2 z, a
- #include <asm/hardware/edma.h>" W7 x+ M5 Z' p% {
9 M8 i$ I. G) I) ?) R- #undef EDMA3_DEBUG
( a* \) S5 W0 s - /*#define EDMA3_DEBUG*/8 `, [0 C6 E6 W8 J K4 F4 H4 b
+ S3 R( B: `* P7 h, e4 j8 L- #ifdef EDMA3_DEBUG
, H9 Z) N$ n2 I1 i3 D' Z+ y - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
- M. q. h# k2 O3 i3 [; G! g - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)$ V8 l7 O/ N! d; G1 D' G4 i( i
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
/ ]; V8 [; V U! s0 O - #else6 S0 Y; ^6 `. [, O
- #define DMA_PRINTK( x... )/ v8 v8 h3 T S1 f) m) K
- #define DMA_FN_IN' ]9 G+ N' c' r* ^2 m
- #define DMA_FN_OUT6 f* o+ B: _+ ~- S
- #endif
/ L6 o6 I' A! _& r# c
2 W: |" H8 ]1 ?- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
" z) b: P5 l3 H/ g: g1 P+ S8 I& R# B - #define STATIC_SHIFT 3
! q/ ?! c: i; w- _: m8 s: K. q - #define TCINTEN_SHIFT 201 U& k$ k- Y* m' W( Y' u6 {; o
- #define ITCINTEN_SHIFT 21
`8 L) @# @+ x% y/ h% D# Z2 _ - #define TCCHEN_SHIFT 221 T0 R+ l! n, u
- #define ITCCHEN_SHIFT 23
$ b" l0 c2 H% M5 u1 I2 T - 2 T6 n+ ]( o% P* G- ]! p' A1 l, h3 i J
- static volatile int irqraised1 = 0;' g+ y) _4 J4 t0 [- R
- static volatile int irqraised2 = 0;
& X }5 J7 J: A$ @4 c2 i% `
8 \0 T3 Q# Q; a5 i8 b- ]8 }- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
. }. R% H V8 n' d7 @, r. |/ K - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);, |8 r& K @1 I; l6 d* Z, H/ N
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);" Q& [% s6 I- p" [4 [0 {
) ]. d2 E. `0 C+ x* ?4 ^- dma_addr_t dmaphyssrc1 = 0;3 p/ l+ [7 M+ F/ T
- dma_addr_t dmaphyssrc2 = 0;
. Y' X8 `5 |/ j0 H" g. v - dma_addr_t dmaphysdest1 = 0;
3 X$ A) d2 v5 t2 U8 H8 }* ]9 l - dma_addr_t dmaphysdest2 = 0;+ l& t9 q4 A! ^8 c
- 8 z3 ]$ [6 g2 X4 ]6 D: k
- char *dmabufsrc1 = NULL;) [; w a: n( t: W* C
- char *dmabufsrc2 = NULL;, @- s! I& i2 ]7 a* t/ I- d
- char *dmabufdest1 = NULL;) ^1 ?* t/ a9 ~' Y# j! H' Q# E
- char *dmabufdest2 = NULL;
- l. [% g9 T( P6 X. l) {, `! M - & r7 E0 O" T. s
- static int acnt = 512;2 d! M% S& L! l j w
- static int bcnt = 8;& ^ l) e1 v- B1 X0 o# i+ k
- static int ccnt = 8;$ h4 p9 O8 N$ i7 N) g, f7 ?
3 w5 w7 _; z% V/ F7 y# e. h- module_param(acnt, int, S_IRUGO);9 |. s; B' V" L9 M0 i n
- module_param(bcnt, int, S_IRUGO);: c$ q) n7 k* a* G5 B! }+ u6 I
- module_param(ccnt, int, S_IRUGO);
复制代码 0 E/ y) Q$ A* {9 s
1 k: B6 n" T2 t 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
7 r4 H; z! B$ f0 s0 _# ^) d3 `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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。& q9 t9 c B1 `
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。! I2 H& d2 Y1 |0 _/ ~8 O+ P
4 ?/ X' z( \# N, Y/ r- S+ G
. |) a& p- @. S7 `; r7 p; ?( M |
|