|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
) p0 _0 C3 d; n" K5 v1 Q. i" c- [code]EDMA sample test application( |. Z6 }, E. _. _8 |9 s
- /*
: r2 }# p6 S. s5 t - * edma_test.c
6 I7 C, l4 {2 b+ a - *
# ~" i2 t1 f- t( G" m3 M; s - * brief EDMA3 Test Application. I' M6 p8 N3 z7 m- Q$ A2 c
- *
3 V; j3 M& @) ]. @& v) X F - * This file contains EDMA3 Test code.$ y& C4 e2 U4 X# w) g8 \
- *9 M( {' u/ A& Q% ` H/ h
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE/ e$ H6 ?, e$ y# W) q* x9 L
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
0 R( ~1 e6 ~6 } - * TO CHANGE.
1 {: c0 P2 F( J - *7 y4 X2 P9 b1 @, Z! L, [* n* |5 k! u
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
) D, `4 Y& {: h& C& }/ r* L$ G - *
" t- Y' u! y- Y* P6 l1 S1 ] - * This program is free software; you can redistribute it and/or
: q/ x5 h4 J1 ~5 a - * modify it under the terms of the GNU General Public License as
3 Z; B( W1 k \8 l - * published by the Free Software Foundation version 2.
9 }. N* C' _; \7 A - *3 a @( k, T2 w' d6 o1 c: C' }) h
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any
2 `" }" y( D3 ^# S - * kind, whether express or implied; without even the implied warranty
1 ?9 y5 K* A' l - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
6 v/ z9 s9 j1 r6 c1 J' R - * GNU General Public License for more details.
# s0 t1 g: z! K, @ - */
( W/ [0 a6 x! l" L - 4 p$ e* |4 ~8 k8 n+ o) w, t
- #include <linux/module.h>1 V. K* Y( T c. Q7 j5 ~7 l2 \/ H+ V& u
- #include <linux/init.h>! J' _ [4 k+ B" M: b* K; y
- #include <linux/errno.h>& ]' d7 p7 U4 d3 h
- #include <linux/types.h>
7 K; t" {/ z6 ]& R0 ?! v) ~4 ] - #include <linux/interrupt.h>, a/ z( w6 ?5 y7 I% T
- #include <asm/io.h>: f" I, O7 S+ q$ E
- #include <linux/moduleparam.h>
: Q2 y9 R7 M+ _ - #include <linux/sysctl.h>
' x" L. |8 e3 C9 p - #include <linux/mm.h>
+ k- E7 e7 Q* R' d - #include <linux/dma-mapping.h>
. I6 `4 O0 k; ?$ F9 } f: O6 F
; V/ C! i" o) U/ v: `- #include <mach/memory.h>! Y- f9 s1 s- U7 {" }- X5 B$ x8 X' h
- #include <mach/hardware.h>
6 I& f2 p' m& w) C% A9 j3 M8 B) n - #include <mach/irqs.h>
7 q7 ~. \: p/ q# v/ F! K - #include <asm/hardware/edma.h>; @0 c( E7 d' g7 h1 P% P
- 4 p* w- j, `) @* c6 c
- #undef EDMA3_DEBUG: t! w N4 \6 Y7 ]. @8 n+ T
- /*#define EDMA3_DEBUG*/3 v) ?+ I( g7 q
@0 S) [+ @% `# ~* I- #ifdef EDMA3_DEBUG* \9 H- g ^# u5 L1 N: T0 ?
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
7 x$ T) _) W( L* G4 @, R - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
W, \6 c# D# U* L) n - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
$ s; A6 k# H, N8 W2 m& Y* t - #else
S$ f1 B8 `/ _/ _1 K( b - #define DMA_PRINTK( x... )7 D" n) ^' d2 e( r; ?2 v; J, V
- #define DMA_FN_IN( x0 c; \1 i* f- C
- #define DMA_FN_OUT
! \7 S1 z3 X9 A) T% i - #endif
5 l0 h/ T! C6 X }
! E% D, p- H& j8 F- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
9 K6 Y4 M a; P$ t$ n- p" b - #define STATIC_SHIFT 33 k7 ^: z8 I$ V; g
- #define TCINTEN_SHIFT 20 T2 v$ p {/ N
- #define ITCINTEN_SHIFT 21+ H4 _) M, s9 G& O8 j# V
- #define TCCHEN_SHIFT 229 @7 Y7 L* Z+ _; k4 ?
- #define ITCCHEN_SHIFT 23
2 z% z' {( X0 S0 d& k1 | m
! A" M* P$ o5 L7 X- static volatile int irqraised1 = 0;
1 {" n- w/ R5 ?& y0 d - static volatile int irqraised2 = 0;
4 o7 G6 N Z5 l7 t! l# U' H5 O
3 Z% c( t3 Y9 u8 f- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);7 F4 u$ B+ `( v Y1 L1 `9 r' r; Q
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);0 o% _3 Q0 O5 h8 L
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);+ G1 {$ c, E7 [
- 6 d. M) ~; s) H
- dma_addr_t dmaphyssrc1 = 0;
! e2 b; a+ b( x0 q H# j7 e - dma_addr_t dmaphyssrc2 = 0;
$ J+ ]: V# M- g" s! z: M - dma_addr_t dmaphysdest1 = 0;
; o3 i3 c2 e' i w y7 T( z - dma_addr_t dmaphysdest2 = 0;$ r0 @3 B( W: i; `
- * H2 b% H1 X9 z* |
- char *dmabufsrc1 = NULL;
* ?, f& Q' I5 r* ?- D5 v - char *dmabufsrc2 = NULL;% @( @8 c# x* B% ~# H4 f9 G$ M
- char *dmabufdest1 = NULL;
" D ^3 k( f4 a# H) \* L - char *dmabufdest2 = NULL;; k/ \! g+ m4 c0 ^- ]- e
0 n; z& Y1 c( _, v- static int acnt = 512;
) L; n: ~% `9 n$ E- \3 p - static int bcnt = 8;
" y" z# _2 z0 b8 K- K2 O - static int ccnt = 8;4 V# H" \$ g" L' v9 D& s) R& F& ^ L7 x* {
$ ~4 S. U9 O# Y: u1 ]1 ?- module_param(acnt, int, S_IRUGO);
. }) [& N, B! @ - module_param(bcnt, int, S_IRUGO);/ N# @/ j& w0 w) E3 o' ?9 d: G
- module_param(ccnt, int, S_IRUGO);
复制代码 . n+ J& G5 J/ G0 M: h
' |" n; Y/ F6 t 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
5 j w3 H$ a! T" v6 _: ?2 h* Varm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。* Q: ^+ x& ]) O9 ~2 p
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
4 @# ~0 m& ~2 c" t- G1 R
% m$ G$ Q0 \: K
0 ]" j% k3 c) T8 Y5 h. V3 A! S) b |
|