|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
Z- |0 V W. U- [code]EDMA sample test application
+ ~* I! _; P% C3 f8 d - /*! P$ ~ V6 g* S+ H" X
- * edma_test.c
/ |/ u) x7 `- T3 l) c7 ?# G - ** v9 \( S: ^6 f9 i- X+ O
- * brief EDMA3 Test Application: N1 Y4 R/ G7 [7 }% W. @. c7 P
- *5 u! `" o& X( k3 L$ p) {* N- h' `
- * This file contains EDMA3 Test code.2 ?3 u, Z3 g! O9 b2 W% f* I2 s4 I
- *$ v+ y8 w& z" }+ i
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE, M* Q& z. y' @4 P) e8 t
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
, H7 J# H5 m/ g# A) o - * TO CHANGE.
- `9 \9 g. q% E, U* Z' Y" l - *2 {9 K5 `1 [6 j' V
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/" T( K# i3 U8 @4 D
- *% A8 `& W; n7 c6 ~0 E
- * This program is free software; you can redistribute it and/or0 ^( m" [- Z: Z
- * modify it under the terms of the GNU General Public License as
( |. `# y% P8 u, Q3 V - * published by the Free Software Foundation version 2.; E+ h4 J: X8 G- ]8 a1 N, n
- *
7 M' T2 f B1 I N - * This program is distributed "as is" WITHOUT ANY WARRANTY of any
; W* N8 R- L9 G& L+ s& m - * kind, whether express or implied; without even the implied warranty% \0 s- D1 x, F- S
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the$ S( x+ e* C% x" Q ~/ e# k
- * GNU General Public License for more details.
- b( `7 {- L4 q/ [. n. ] - */
5 X' h& l, Q9 A" z' b - 5 K) ?; U8 G4 _( C
- #include <linux/module.h>
! P3 F& o9 ]) u7 \( v% Z" ~# S$ n - #include <linux/init.h>* U5 l7 Y" L5 H6 K5 f! k
- #include <linux/errno.h>4 Y; g) o/ K/ }- E2 Z% ~
- #include <linux/types.h>/ q% }: Q; U4 h; ? x4 b% H
- #include <linux/interrupt.h>9 n! W. E$ i$ ^, u4 O
- #include <asm/io.h>
! t; _+ D: A4 p* X" F - #include <linux/moduleparam.h>
8 x+ j' L9 C, R5 V' y - #include <linux/sysctl.h>
+ C, v0 x* D% ?! _2 Y3 d: i3 Q - #include <linux/mm.h>
a. ]- _5 r) U" W - #include <linux/dma-mapping.h>
$ {( T5 j# P6 y' ~2 ]- ]0 x
2 T+ C6 [) B; ~) \7 d9 F' u: ^- #include <mach/memory.h>
: Z$ t2 u3 X# ?1 U - #include <mach/hardware.h>
3 h" A q# I1 V5 Q1 }! N0 R - #include <mach/irqs.h>
3 r$ ?: [9 o3 u8 g+ v) I) ^ - #include <asm/hardware/edma.h>0 ], u% F2 C2 a
4 F U2 U: K/ D3 R/ U7 E+ i- #undef EDMA3_DEBUG
/ L7 Q6 q. E6 ?- h( ] - /*#define EDMA3_DEBUG*/
1 P# w! W. E. v" b - # ~) m r& v- c7 F
- #ifdef EDMA3_DEBUG k6 w4 x2 w; b" e1 x4 Z4 j/ Q/ ?( h
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
, ^. Q( d u9 I0 ? - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
, v3 w7 e, ?. [ `8 L9 W - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)9 N2 ]+ z/ K: ]8 p! ~) ~ i
- #else
6 m# u' ~ P w( i ]" Y- a! B/ { - #define DMA_PRINTK( x... )# }6 U. c1 W" ~- w2 W5 b
- #define DMA_FN_IN2 k, ?* G! B, b
- #define DMA_FN_OUT
8 f8 ]3 ~! G+ e! e - #endif- X4 t& F1 Y8 Y x: S4 s5 b
- : K3 C& U- i' i+ c3 D' B+ S
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
8 k9 \. T. @# l5 P# H+ J - #define STATIC_SHIFT 3
( Y Z, i- k2 a+ v - #define TCINTEN_SHIFT 20
/ l! O3 Z6 k5 b- G1 U - #define ITCINTEN_SHIFT 21
' p& u) C/ }- A4 A - #define TCCHEN_SHIFT 224 L7 ]& [- _) _! y6 K3 s4 Y( b
- #define ITCCHEN_SHIFT 23" }/ [% P5 S9 ~4 y
) W* p- Z. ~/ J. A- V1 X$ R+ \0 a- u- static volatile int irqraised1 = 0;) R0 s: e6 g% m
- static volatile int irqraised2 = 0;. }8 w) Z2 O6 w1 v
: h4 y0 R% m. h* h5 Y- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);# Z! P: ]% _! j& b. i6 V; a. q _
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);8 ], k7 s: j7 w, l. x
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
8 X$ ]' v- _! a0 y( O) |, \( N - ' q7 ]7 _; l! e( g- q. D5 }
- dma_addr_t dmaphyssrc1 = 0;. @2 M& b+ M$ F6 ^( ~
- dma_addr_t dmaphyssrc2 = 0;
5 X! O, C7 r: B+ W - dma_addr_t dmaphysdest1 = 0;
. F x& v. D6 L - dma_addr_t dmaphysdest2 = 0;2 e" ?4 n/ |. y! F
- ( e! h7 w; T0 W. e+ m5 q
- char *dmabufsrc1 = NULL;
i( q; V V5 q5 q, Z - char *dmabufsrc2 = NULL;
, I8 } m# \$ L/ Z - char *dmabufdest1 = NULL;
4 Z; V1 T# F' c1 Y, I r - char *dmabufdest2 = NULL;
& T9 }/ }) f0 A/ w - : D1 {. R) h' O9 [5 o! l4 x/ \
- static int acnt = 512;3 t* W) O8 v- f- n- I
- static int bcnt = 8;
) ]9 ?' C; w, o: k7 H - static int ccnt = 8;' i3 Y4 l9 T! I- Z
- 9 }& ? ?. m4 Y
- module_param(acnt, int, S_IRUGO);: M8 r: k5 K1 ]2 p6 m3 I0 F
- module_param(bcnt, int, S_IRUGO);! ]6 y4 U6 U7 @
- module_param(ccnt, int, S_IRUGO);
复制代码 M( k+ ]6 j8 L$ k- f% [! s% ~
. G: \5 A) y4 \* m 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
" }3 W4 ~* V( ]" j% parm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。* f1 D' P. _$ V
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。. t) z0 G; v! ?3 j7 e0 I
! p' X9 s7 f. c/ H4 b2 m# u9 [
8 h1 G0 n/ t. {; R# A; Y |
|