|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 & }1 O4 }( o, X% l7 m
- [code]EDMA sample test application8 {: o4 Y4 O. X: `/ l
- /*: d' O, y" J" o6 ]' f' S
- * edma_test.c* x# ~0 p% E, `% I/ ]
- *
% J( l; B4 p4 [; v - * brief EDMA3 Test Application& w u; L$ t, p3 A: q# p
- *1 e1 u1 c3 ~4 x1 s0 u
- * This file contains EDMA3 Test code.
2 T! A5 a) W( w* Z \- D - *5 n1 R. S. Y; ^; ?& v# I1 p. N
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
- H2 |1 m3 x6 a1 m& C! E - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
% {. j! |3 h6 F. [9 J - * TO CHANGE.
/ E: l: ?% ^) r, L9 g R+ y - *! G7 i3 | O* U; x$ d: ~; l
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/9 h4 {/ O9 A- [+ s/ l1 m
- *9 n1 g# x3 k% \+ w
- * This program is free software; you can redistribute it and/or
9 W! C, k* f9 p# b2 r5 p - * modify it under the terms of the GNU General Public License as- L6 i" b# e% i( \. F h
- * published by the Free Software Foundation version 2.
$ t* k/ B: x3 S3 Z - *. m' _# v7 C* @; \( d
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any
: i/ C3 w' X' w' K; Q5 B2 E - * kind, whether express or implied; without even the implied warranty n) b# `9 [& [8 d: ~. U2 z
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
/ i# x$ Y7 e2 r4 b - * GNU General Public License for more details.
- k0 c- J' X' H- C) e - */" h& f7 t( }- b" ?' X) ~ w( d4 Z
& o- d6 [6 @/ E) i0 o9 o- #include <linux/module.h>1 f' p1 X: R$ c; j. w8 U
- #include <linux/init.h>. n6 Y# N, A' w, r0 T& n
- #include <linux/errno.h>
' F3 v7 s2 v: L0 O6 d' w - #include <linux/types.h>7 S1 S: L! u5 g1 L& v
- #include <linux/interrupt.h>
) j; o$ T/ l6 V- m - #include <asm/io.h>, ]6 K8 v% V3 j8 e
- #include <linux/moduleparam.h>7 c4 |& W1 ]3 `* U: g& C
- #include <linux/sysctl.h>
$ E5 u' `/ S5 W3 V5 n - #include <linux/mm.h>7 i: X. O. w! j6 c! e
- #include <linux/dma-mapping.h>1 g" t* p3 ] Z. F9 j9 I t X. H
- ( `7 c$ \" s5 x' d0 W- t: g' N
- #include <mach/memory.h>
1 S$ P# g8 p, Q7 J' | - #include <mach/hardware.h>
" n! l- x! l8 V5 A: G7 p/ Q% | - #include <mach/irqs.h>4 [9 r0 A% i' c4 s8 r7 @) [2 ^9 u
- #include <asm/hardware/edma.h>
( x, Y4 k5 H* C/ [
/ v' O7 Y* }7 L- S- #undef EDMA3_DEBUG
9 o+ Q- b5 O) I8 v8 A/ Y- X - /*#define EDMA3_DEBUG*/' u6 z/ Q) d4 P% p0 D
, M" u- L. u9 J6 s% F- #ifdef EDMA3_DEBUG3 _3 W/ |: d0 E7 n/ e
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS), j/ ]+ B5 S) Z( O/ q2 d' v6 ^/ I' E
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
2 t) [! Z. R! c6 Y* W - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)) f0 L" W K. e% c+ Y% s
- #else4 V- a+ g) a- I+ Y% k9 O. D
- #define DMA_PRINTK( x... )
& O& C! Y3 C" ] - #define DMA_FN_IN
5 k+ J9 \0 d, g6 W: t - #define DMA_FN_OUT
4 u( @1 W% t% @% a1 J, {. [ - #endif5 C: h! S! S0 ]4 w4 s5 ^
4 Z n4 x4 k& M/ r+ e" I. p- #define MAX_DMA_TRANSFER_IN_BYTES (32768)! n3 t1 i n# A( y2 w7 d0 T" O# ]
- #define STATIC_SHIFT 3
j. w2 h: L, W u# }0 x - #define TCINTEN_SHIFT 20
0 q5 X0 s# `' b4 | - #define ITCINTEN_SHIFT 21- x0 H- g7 u' K j7 Y l" a
- #define TCCHEN_SHIFT 22
7 P I* z5 f2 {3 ^6 t: B - #define ITCCHEN_SHIFT 23" v% C; N" r9 Z" K$ Q3 D' d: y$ u
. V B1 D s5 z, G$ }4 A- static volatile int irqraised1 = 0;
" g+ o' {) k n6 n# C: R% t - static volatile int irqraised2 = 0;) Y; E7 G! Y" a2 `# ^; n4 E0 i
- 5 X) W6 u, j) u! F; u2 e
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
# O; g4 ]# ? G5 D4 U - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);+ z1 T; J& D, E B" ]- q( s' Z5 X
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);# ^* ^. D8 y3 M. }* D# K. m
- + }( h J6 S7 r/ ?
- dma_addr_t dmaphyssrc1 = 0;
1 z u% v- ~9 x/ s. O0 y' C - dma_addr_t dmaphyssrc2 = 0;
; ^# H% |( b" q2 {8 E - dma_addr_t dmaphysdest1 = 0;7 }$ M: B, H8 A) S" h0 r
- dma_addr_t dmaphysdest2 = 0;
5 r7 i* O2 s: x/ ^8 }6 [
! {3 [5 \1 d- J$ Y" Z% c+ O- char *dmabufsrc1 = NULL;
7 h% W( Q7 u/ `3 v5 r7 @, k - char *dmabufsrc2 = NULL;+ S& f% l, t8 Y7 y, `
- char *dmabufdest1 = NULL;# w" z& a: w8 b) o2 h
- char *dmabufdest2 = NULL;
4 o8 Z% r" w$ V9 `" @( O; t - K" w0 n" C- ?: j$ k, Y
- static int acnt = 512;
; P0 ]. i) N; l* B - static int bcnt = 8;3 F1 |. R9 S: `; X* K
- static int ccnt = 8;# {* s: r' O8 J4 Y1 }
- " F2 K7 l4 ` f9 d: J2 O: A
- module_param(acnt, int, S_IRUGO);; d5 ^6 Y: z, C, a9 M& l/ n. t
- module_param(bcnt, int, S_IRUGO);
8 h J/ ^; A/ ? - module_param(ccnt, int, S_IRUGO);
复制代码 6 [6 j9 P) Z0 I, Y, k; C
' i3 U& @$ T' ~9 B$ n$ o) J" t 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用( T# e7 F+ p& C- m- p% E6 y
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。5 p2 w* n r* G/ ?. h t
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
! F5 \1 b5 ^* f5 j* r
5 M( h. b4 L8 F" `
$ y/ x0 E4 f6 i4 f) D) m: @ |
|