|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
8 F" g( k) e+ X- [code]EDMA sample test application
) h# O: Q4 ]" M" G3 s - /*
; N6 a' J# |* ?: O1 H3 G7 R - * edma_test.c( `# h$ S: I5 a4 Y
- *
$ [8 F( R6 }( \( i( c - * brief EDMA3 Test Application
# p7 X& N: G" n, X5 z3 ] F - *
U5 B- ^' x& h+ }, n2 k - * This file contains EDMA3 Test code.5 J" g4 B" @4 {# [8 ^) }
- *6 y; D5 Q! B& g5 r6 b( I
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
7 A* x$ W% v* V5 U2 g6 j - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
a) l' X8 o- \, v7 N6 I - * TO CHANGE.
3 ?1 Z8 y: D/ k6 v6 W9 K% r - *7 L: i6 ~0 {# ^
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/) w- ?1 O& ~1 Q" v; l1 a4 v
- *6 h. v. o" d/ N7 G
- * This program is free software; you can redistribute it and/or7 M( d; @: x$ m
- * modify it under the terms of the GNU General Public License as
) n& G1 m6 i& z - * published by the Free Software Foundation version 2.
3 T6 o: k6 `9 ^# e% X - *+ r' ^+ P7 J0 ?
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any
/ Q' f6 c# h% s. m6 H- f - * kind, whether express or implied; without even the implied warranty. g/ f( z4 u" h
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
/ Z) w0 r$ ], q0 Z4 Q& o - * GNU General Public License for more details.3 F% }9 ?$ E. i8 w o/ E8 G
- */$ i2 ~$ H* ]1 g# K$ }) d5 R) G
% a0 ^2 O. f; t4 y* k- #include <linux/module.h>9 A# h! s" F0 H, p2 @% e6 j) \
- #include <linux/init.h>
# s W: H) N4 e s; ^ - #include <linux/errno.h>& [0 p/ k7 D; g' ?7 H
- #include <linux/types.h>
# {: C! t4 l6 I0 |1 B/ w8 R - #include <linux/interrupt.h>% ~; J% J- B" ~% i m" K$ l6 M
- #include <asm/io.h>
- H7 e' t3 j$ t% ~ - #include <linux/moduleparam.h>
& M9 P# T# J, s( q2 x - #include <linux/sysctl.h>. Y$ O4 y1 D$ F: F, J: O% z- O
- #include <linux/mm.h>
, f) X* |: |. `6 Z6 |3 S' j7 E - #include <linux/dma-mapping.h>
. I/ V& `7 D; D( v X6 G
8 ?/ ~% E9 x6 y1 o: e) ^3 `; Z- #include <mach/memory.h>
- C; m! F5 Q! y - #include <mach/hardware.h>& C! M+ s+ I$ `6 L/ V
- #include <mach/irqs.h>
# m' V `% I" s; H+ | - #include <asm/hardware/edma.h>
1 Y" I+ y* f& w1 ^' Y# q1 A3 K - ; |! `1 v" s, I- g' q9 `( Q, h
- #undef EDMA3_DEBUG7 Z. Y5 k) ] ^% F% R4 C7 B( I
- /*#define EDMA3_DEBUG*/
0 l# R! C! I1 K+ K9 z9 Y - , C! J. O ^" E/ e! H, W
- #ifdef EDMA3_DEBUG
j0 @' N/ {0 W: z - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
, r. w2 P4 M6 Q - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)# e! V Q0 z, G! g3 N. ]7 q
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
" o0 Q! n+ g5 ~' f - #else% n7 q& x: p2 I! M
- #define DMA_PRINTK( x... )
6 h: ]1 m3 ~6 }2 z6 W$ l+ d* _ - #define DMA_FN_IN
, _. B( L: c$ t, z7 k _* r - #define DMA_FN_OUT: x5 e0 L: Z) z
- #endif
4 @/ n8 V2 g5 {% n- f, O. J/ [ - & |: M; n( U. @4 m8 n/ M% @ P9 z
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
9 a6 V' x O) H2 I6 b/ j - #define STATIC_SHIFT 3
- D8 s( W4 z0 m$ ^% g0 \ - #define TCINTEN_SHIFT 20
& v/ ]/ y" @0 f. _, h0 F - #define ITCINTEN_SHIFT 21
1 t4 w) L$ C( o8 @4 ~7 u) v m7 R - #define TCCHEN_SHIFT 226 Q# r4 z; z, q H/ t
- #define ITCCHEN_SHIFT 23. H x J$ k& h1 `7 c0 z; h
- ) t/ f! h, N9 S& Y
- static volatile int irqraised1 = 0;% f `& ~8 q8 L: }0 C8 p O
- static volatile int irqraised2 = 0;
( ~& }8 x# w. K. |) c
/ v7 q) q7 b0 Y( s2 m% m1 M( i) ~- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);/ a1 Z5 F( Y7 R
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);2 r6 a: `, d5 _: |
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);5 _# Y4 K# d5 ]% }* G
6 ?& y9 u i1 g- dma_addr_t dmaphyssrc1 = 0;
- P+ R9 N4 v0 F2 a+ [* `2 w8 Z - dma_addr_t dmaphyssrc2 = 0;
V( w0 I; ^" H6 F9 Z1 A6 P) } - dma_addr_t dmaphysdest1 = 0;, }1 K% r3 b3 d+ l% e, p K+ _
- dma_addr_t dmaphysdest2 = 0;* Z# q3 w/ C' [9 c0 @" _& b5 k
# j2 R9 K! [' G4 m- char *dmabufsrc1 = NULL;7 B3 Q L2 Q$ q1 G' ~! V' q/ s
- char *dmabufsrc2 = NULL;% G: T6 R$ x' [4 \
- char *dmabufdest1 = NULL;9 D: D' k2 d& v6 R) A# u
- char *dmabufdest2 = NULL;) \) d" d) X, c' ^1 z m
, p g2 b# G q% }- static int acnt = 512;
7 t; \6 w5 D5 K% q% a& @- y1 J - static int bcnt = 8;! j+ x2 J6 i9 a# \
- static int ccnt = 8;
6 Z6 ?/ \) n. q5 u& c" L
9 J% X i2 j; k, S9 }0 w0 P- module_param(acnt, int, S_IRUGO);
* J7 {0 T) D* c - module_param(bcnt, int, S_IRUGO);% B1 N. I2 e4 i4 @; d7 K/ E
- module_param(ccnt, int, S_IRUGO);
复制代码
1 M6 u4 m" x$ v3 p! S" ~9 G+ q& Y3 j( X) H$ a9 C# q1 Z
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
8 ~* v$ o) \2 w- }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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
9 u v& V8 @0 h, }: T" H: E% O 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。: C5 P7 U8 j+ _" B. o' K: J
. d5 H/ y9 d# t& B
* q4 n5 l: w7 m" R2 i) Q B) S |
|