|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
& ~+ w# b# [ C/ K3 s6 k- ]+ t. G/ r- [code]EDMA sample test application* e9 Z3 t- u8 ~1 j2 y: K) m
- /*
" R" ~3 @' _& d( H# Y) M7 x - * edma_test.c
' W1 W3 [( m+ v6 K4 z/ q6 V0 Z7 k( } - *
. }+ }2 N3 }# B- t- O - * brief EDMA3 Test Application
3 T. w0 M, f8 ]$ R2 c - *
! C/ ^3 _+ O8 _! q+ T5 ~ - * This file contains EDMA3 Test code.( D$ E' t- X- A3 l' K; ?7 D h
- */ U4 @0 W: C8 |: A
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
- n+ Z7 @, x2 d9 A. Z* A9 A - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT% c3 ^6 _' W* N, U n4 P" C2 H6 C
- * TO CHANGE.
+ j! g" u0 |0 K6 a, y - *
7 b* f1 Y+ w; y& w5 H. _ Q9 k) _ z - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
2 x* h7 P. [" e! E; W6 V - *+ p2 q" G5 n& l- U" w8 v. j# k
- * This program is free software; you can redistribute it and/or; @9 U% P) P- K, z& ?
- * modify it under the terms of the GNU General Public License as; X9 E- }, n3 R" S% o, h) j
- * published by the Free Software Foundation version 2.6 v1 f `# d; h6 X
- *" o" K3 v' t* p6 N% O2 X3 N
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any- H; j/ \6 L6 G0 f
- * kind, whether express or implied; without even the implied warranty! I; x2 d2 X6 y2 q( {7 C) f w
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- o) w! S+ W- y% |2 U1 B - * GNU General Public License for more details.
0 S/ G2 |4 V3 P% E- m5 O7 t. ] - */2 a5 U' c1 L3 b$ a/ Z
+ o$ D I5 q9 k5 s/ s- #include <linux/module.h>
, k4 ~& C- b" L) r% G% q* ] - #include <linux/init.h># i% c$ z* z3 E9 i
- #include <linux/errno.h>& ]# W& J2 n1 H S" p! g# f
- #include <linux/types.h>
5 `8 G3 A4 @8 I- }0 S( l: N3 \$ E - #include <linux/interrupt.h>
2 R% R, F3 n% ?& w+ k! w9 U& J - #include <asm/io.h>- y t0 P: E$ R1 ?7 X* a
- #include <linux/moduleparam.h> X2 j/ d1 m* i4 W; }
- #include <linux/sysctl.h>
+ v. d0 ]" v) K0 r; ~8 r' p8 Y - #include <linux/mm.h>% w) W" C1 t5 {1 r2 r4 d; }
- #include <linux/dma-mapping.h>
7 Z$ K+ {6 Y8 d/ _ P% c
1 W7 Z9 e" R6 j# J% A- #include <mach/memory.h>! j7 y1 {& @( z* B5 c
- #include <mach/hardware.h>
( P K/ u. W8 y; u% A3 [* L - #include <mach/irqs.h>: R# t& U6 y- P$ p0 U8 `$ D- u$ _
- #include <asm/hardware/edma.h>, M6 p3 i( Q$ b# ]% i* k; j
- 7 b! R9 {+ D1 V9 h% I) K/ s' r
- #undef EDMA3_DEBUG
7 k, f2 @+ k4 ]& A% i8 X - /*#define EDMA3_DEBUG*/
, K6 c r1 q0 O4 C2 C; v, ?4 N+ ?
' ^* W- ~+ u2 M; t# C- _- #ifdef EDMA3_DEBUG
0 b( M H: H# p1 U U) ` d - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)# ]: R* o' Y+ c# G
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
7 M# `. N9 L! a - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
$ T* N" {2 W9 H - #else
3 j- ^6 g' J/ `% i6 [6 ~: G+ F - #define DMA_PRINTK( x... ); w! [- n6 J2 c! d2 J. R& q
- #define DMA_FN_IN
+ t+ L* b) r; U) G( A - #define DMA_FN_OUT
1 ^; i2 e' o' q+ K4 [: ]# D; O - #endif) D( @2 d8 `9 T1 @
- 5 {0 f% C! l" B5 Z' [ z+ k2 ?, P
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
' K: t& ]0 R. \ - #define STATIC_SHIFT 33 r d2 r6 S3 f/ N% N h
- #define TCINTEN_SHIFT 206 z" K6 Q9 m: s
- #define ITCINTEN_SHIFT 213 m G2 d! v0 r1 ~* S( ~" i1 T
- #define TCCHEN_SHIFT 22
: ]) N" T3 v( b; d% m6 h2 d - #define ITCCHEN_SHIFT 234 D& w% Z7 H9 _
- 1 `# n4 s4 t2 ]+ z
- static volatile int irqraised1 = 0;
E, \# t: y8 n, J. k! D - static volatile int irqraised2 = 0;4 X) \8 R9 q, U5 _ }
- , X' T6 h5 B/ y. M7 T3 H6 l0 h' S
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);8 f9 X5 _ D; k3 e
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
6 P# A8 W" x( R2 k - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);' r& F5 [( q' d1 J# M: N! |6 Q
( C6 u' K* B9 S8 x9 u* s- dma_addr_t dmaphyssrc1 = 0;
- T) Z2 M' p* M5 L- H0 N6 O" V' ^ - dma_addr_t dmaphyssrc2 = 0;# ?! z; X- b& r% d. v7 @
- dma_addr_t dmaphysdest1 = 0;! W; `5 T1 v; |# f5 S
- dma_addr_t dmaphysdest2 = 0;
( Q6 R; G7 ^; r4 c0 P - 8 S7 u) j. h1 {. ]
- char *dmabufsrc1 = NULL;3 `. @! K! o! i0 f
- char *dmabufsrc2 = NULL;
. z; p. {4 Y- K - char *dmabufdest1 = NULL;
/ j* J5 p/ n3 x' ~ - char *dmabufdest2 = NULL;! e X" L# I- K) a) O+ V
; e! \ A/ r* n2 P- static int acnt = 512;
2 T' B6 N! O3 U: t# g - static int bcnt = 8;
% t% X4 U1 G3 W - static int ccnt = 8;8 S4 D+ |7 N2 m5 [+ H# X+ d. x% n
- 9 B; @9 o# e. r: r
- module_param(acnt, int, S_IRUGO);
9 ]2 W8 d) T/ `4 W5 t% Y i - module_param(bcnt, int, S_IRUGO);2 g' T5 c! @) k5 p
- module_param(ccnt, int, S_IRUGO);
复制代码
8 O+ ?2 {+ d. N V( e" e, ~
2 V5 t& P3 ~( x) O" F7 L1 ^ 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
: Y8 Z" o: Q$ U& Aarm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
r$ h! T5 _! e& W$ U. @' E8 _5 E 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
$ h! G' S3 D L+ c3 z- W# Y0 e; U( Q! f$ n
, T- B4 j9 X& ]( Y7 [ T3 {. E |
|