|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 0 \$ s' h; I5 U8 o0 H
- [code]EDMA sample test application
( f: Q* L; U8 o' F5 N - /*6 S8 i i* G% _9 F# Q3 k" w7 J/ [) L
- * edma_test.c
5 N" z1 V: P8 W* ^, x - *7 q- {) ], ?" s# u E! _' F5 C
- * brief EDMA3 Test Application$ m, a7 `3 V0 O; E$ z0 B7 b
- *6 F C6 f. ^9 q
- * This file contains EDMA3 Test code.! q1 P. o; Z" A, N7 c" P
- *0 X, c6 o; J. F$ @4 G/ v! T$ d+ x3 J* D
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
$ m: d7 T6 P. a# I, g& \2 m5 K' A4 g6 V - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
/ @' S9 p' f* ? - * TO CHANGE.4 `. J$ S3 d" J' D* O0 p& q$ |+ {
- *4 _. P4 Q& d, G7 N8 z5 b% u
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/, R8 d4 S, ^2 d0 u4 N' I; b6 v
- *7 S% j6 y6 i( } _) C; D
- * This program is free software; you can redistribute it and/or" D6 m s" c9 q% X
- * modify it under the terms of the GNU General Public License as
/ j6 y: a) M0 b0 j - * published by the Free Software Foundation version 2.
. @9 z" \9 l: [2 A* [ - *0 a# }6 W" V0 w5 R2 {
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any
9 D9 z6 T3 c& V* H - * kind, whether express or implied; without even the implied warranty& \! ?0 i$ B5 _& b+ r# _* z+ k
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3 r8 `2 {! c& X% E' J" d: t/ z - * GNU General Public License for more details.
( n, A, W4 ~" q7 v/ m% r6 i- L - */
( _8 M: b; M2 M" _% g
?/ V0 H7 a2 c' W: ?- #include <linux/module.h>
& F$ H8 l/ H$ ?% R' b - #include <linux/init.h>
' V+ |2 z1 L( c - #include <linux/errno.h>9 h# t' x8 s$ E6 p# e
- #include <linux/types.h>
6 c) o% o% g: k- s6 F8 x - #include <linux/interrupt.h>
8 z- {6 Z. n# Q/ V+ p" m - #include <asm/io.h>
; t- e. ]& B z1 x - #include <linux/moduleparam.h>9 W/ C2 J/ V6 o) l& V/ k
- #include <linux/sysctl.h>0 J, U" o! ^8 q) I
- #include <linux/mm.h>6 q8 l# M' u4 s
- #include <linux/dma-mapping.h>$ y1 R: m9 H" [
0 I2 H. n& p I% k2 s- #include <mach/memory.h>
5 ?: D- f: @+ |1 i$ r3 R; ?( ^ - #include <mach/hardware.h>9 n, G, z9 P2 I, P& G
- #include <mach/irqs.h>
3 ?& [* ]% k/ n: q! C5 ~3 s' h7 d: j1 n - #include <asm/hardware/edma.h>
q' { I& [& m' B& B; l5 v
, p# o a# q- w' F3 j4 j- #undef EDMA3_DEBUG% S G: S7 \$ C/ e3 I( v& Y6 R7 |5 @
- /*#define EDMA3_DEBUG*/
" r2 T% M4 T' x" h
# C7 q! D* Z/ M# [0 F; U6 ~$ {- #ifdef EDMA3_DEBUG. t0 C8 \: N1 S% Y$ G" O- F
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
- T$ C- n8 ^" p - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
8 ]( @/ Y( U2 t& f ~1 z - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)/ ~4 J( M! p7 l4 `8 @5 A
- #else
4 O# o( ?9 O( s7 ^3 \2 p: Q - #define DMA_PRINTK( x... )* Z) `) C! _- }: ?, ]1 t
- #define DMA_FN_IN) }! O: ~0 J8 w2 a' ?3 g1 X
- #define DMA_FN_OUT& M1 ~: H9 E) a7 ~, s5 s
- #endif
' f/ A4 N1 I, [- q N
$ y6 c. u6 Z' n1 @- z7 w$ I9 R" i- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
* U! ?5 L- _) }& T - #define STATIC_SHIFT 3
3 \: }6 t- ]$ n6 H - #define TCINTEN_SHIFT 20: i$ h- \/ m! D% G
- #define ITCINTEN_SHIFT 217 Z* G) J& E) j
- #define TCCHEN_SHIFT 22
/ }# m5 ?: E6 E K6 e: U - #define ITCCHEN_SHIFT 236 H) }$ s: ] o) P0 K
" G. G; J* N' ]8 L% m8 i% s- static volatile int irqraised1 = 0;: i$ _ z( x1 ^/ D9 \! b D3 Q$ r
- static volatile int irqraised2 = 0;
. ~, V9 o- e; {
: D2 v0 m! `% Q! {. C( [4 O0 F- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
: S5 q% N! Z9 ?* ] - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);- N4 d+ _! J5 [+ S/ m0 S
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
8 Y6 b$ ?9 }7 P$ u+ j; Q
) y/ l3 d# i( E' K: C3 u- dma_addr_t dmaphyssrc1 = 0;
# n( r7 V8 I) q8 B: _ H& k0 H1 s - dma_addr_t dmaphyssrc2 = 0;
, n- f8 ^& k% g* ^ - dma_addr_t dmaphysdest1 = 0;
- e2 U. q& }4 s9 B& y - dma_addr_t dmaphysdest2 = 0;
6 d( K3 N% @9 Z7 \
. X# q+ F5 y/ o0 }% [2 Q- char *dmabufsrc1 = NULL;! f1 `# I6 y3 z% j: J; F
- char *dmabufsrc2 = NULL;, ] P1 x7 f4 A$ x. c8 }
- char *dmabufdest1 = NULL;
. w3 b; H, y7 v+ i8 N - char *dmabufdest2 = NULL;
! J3 u/ I2 q$ v/ ]! `& W! B
8 _0 z" h3 x1 J: m. P( \0 n1 {- static int acnt = 512;& ~0 W- k) q2 ]6 y' g+ x. I" V6 ^
- static int bcnt = 8;& a/ O5 I' ?& Q' g' ?
- static int ccnt = 8;
8 F+ ]; D) Z' c% i - % U: E: l% D& Z+ Z. x4 T$ W
- module_param(acnt, int, S_IRUGO);7 s Z/ ]; S) {' D) B
- module_param(bcnt, int, S_IRUGO);* j. t6 B& J6 }" I/ ?6 g: g
- module_param(ccnt, int, S_IRUGO);
复制代码
6 g9 t# s: s Z1 H
1 s' W5 ~2 \! F3 p3 D 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用1 Q) B, }" l0 z+ p% ^
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。+ U2 p& z! T: Z7 f
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。, l+ v2 F) ^4 |
, r% s+ ` L b8 n) G o2 v0 L2 Q8 ~
4 H" x2 N# c: m) J% R- B |
|