|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 # c/ L* t" r' K
- [code]EDMA sample test application
8 X; \5 J o9 m - /*9 v2 A4 l( s& Q! u
- * edma_test.c
- L3 [$ E# P; [: \ - */ P4 n. `; _" X
- * brief EDMA3 Test Application
7 ~; Y O. M1 t; B0 @1 L - *
# C% N. U; h# Y6 t! M" }" _ - * This file contains EDMA3 Test code.
- l7 X% W) N0 z* h - *' J5 L9 i- ]2 e8 l' L( M# y
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE y c# R- W4 h6 L: Z
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT3 q1 d+ I# e j
- * TO CHANGE.
7 w% J. i' e) a - *1 K/ K" K$ w, a7 D8 r1 U: l
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/% ?! B1 Z* n) R1 B T3 X! K
- *
6 C. L4 b5 } m! g. N& T9 G! x6 R- A - * This program is free software; you can redistribute it and/or& i3 W3 \* V( J$ ?( M
- * modify it under the terms of the GNU General Public License as9 z( l" M! F- U1 w" I% ?: X
- * published by the Free Software Foundation version 2.
: N& y# o" I* b; g4 C0 b7 k+ A - *
# a; v" ] [4 v& m0 J - * This program is distributed "as is" WITHOUT ANY WARRANTY of any
& k# w6 U9 J, t' l' K - * kind, whether express or implied; without even the implied warranty
9 u, K1 M- e5 D6 ?8 c: `" L - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the. E2 y3 P- u. N& |
- * GNU General Public License for more details.
6 i1 N( a' r- v$ w% q - */
! S- P7 l& b+ s, \, I" m - / b; U. a" s+ O0 c7 k) l* ^" a3 a
- #include <linux/module.h>' c0 L1 v" w% v) c& w
- #include <linux/init.h>
2 [/ X+ Q. ^, r% I# p$ K$ f4 F$ B - #include <linux/errno.h>, r, }$ z3 [$ B
- #include <linux/types.h># U0 M* R0 x$ _! @
- #include <linux/interrupt.h>9 d* ~1 F$ I T: y
- #include <asm/io.h>; w4 h3 q1 {) w" w q/ N- \+ ]
- #include <linux/moduleparam.h>' I& k' B; K% n5 ?
- #include <linux/sysctl.h>
/ y7 ^& s+ {1 S1 W; X - #include <linux/mm.h>
: f+ _/ ^9 _& V, _/ S8 R l - #include <linux/dma-mapping.h>
# K' m$ S6 s7 q; r - 4 ~9 p* \3 H$ P/ x3 @5 ?
- #include <mach/memory.h>
+ m6 k I$ Y* m8 V5 L3 V - #include <mach/hardware.h>/ s1 v4 L, K n1 ? x% C
- #include <mach/irqs.h>
' h' |) U2 ?, L' R, I; M' b - #include <asm/hardware/edma.h>/ E8 c3 Q4 y3 T% F6 i
- 7 Z1 Z y, x+ T+ T
- #undef EDMA3_DEBUG
; m W1 k$ a% H9 |8 w! _ ]$ C2 L | - /*#define EDMA3_DEBUG*/
) j/ ?3 Z; F B$ k - 0 S) y# o( `1 ]
- #ifdef EDMA3_DEBUG) P& h( P& [$ {+ J. G/ Q
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
4 }: h- N E" S' @0 M$ n" t - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)- D: ]. C# O: ^& N: j/ i& S# Q, R$ ~! O
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
7 i& o6 b* D& Y; J U - #else0 F9 ]; s5 ^( G; T! \! f; D# c( g
- #define DMA_PRINTK( x... )0 j) }) D# p7 i& t$ Q8 |
- #define DMA_FN_IN5 I6 Y/ _; ^- k5 c/ s" V6 S* U
- #define DMA_FN_OUT; x4 Z9 _' ~6 M& G5 H- l
- #endif
! d: Y( d6 X! I# _1 P, ~" l
* ?* r0 j, |# `9 | J! l; ?2 V- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
7 W6 W- \; O2 H1 ]) O: K - #define STATIC_SHIFT 3
4 i; O' V: g, o# G6 A - #define TCINTEN_SHIFT 20/ O0 f' V* J, \! \/ b- J/ X
- #define ITCINTEN_SHIFT 21 p! d! ^# s- Y- n6 }/ J( T4 z
- #define TCCHEN_SHIFT 22: s9 {- {0 f9 X3 ]# o) E
- #define ITCCHEN_SHIFT 23$ a: Q+ x$ W4 j; f
- , ~9 g9 j+ H; W3 H6 S0 J3 r
- static volatile int irqraised1 = 0;- o# c6 W- p: y: v
- static volatile int irqraised2 = 0;
* @% Z6 O1 { ~! l) _* S
; j7 g7 c3 d' c; D- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
6 J- _6 H& v2 ?: o4 f R1 q" k - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);8 s0 C/ E Z$ {; |* R' w
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
% q. W, y: M h+ ]8 H/ p* R& z - : h7 Y6 L" g1 c. t
- dma_addr_t dmaphyssrc1 = 0;+ j) _- `5 G* Q. r( L* K3 b
- dma_addr_t dmaphyssrc2 = 0;
9 g" `. d4 E) {; T+ R: L5 Q. ` - dma_addr_t dmaphysdest1 = 0;- O0 ?- b: k' n0 a# u; Y
- dma_addr_t dmaphysdest2 = 0;
; _3 {: {. M; L/ q - 5 T# x) t: G+ P
- char *dmabufsrc1 = NULL;+ J3 p6 G$ r0 m- q+ t# P- _0 h
- char *dmabufsrc2 = NULL;
: E; f/ h" F% {1 Y - char *dmabufdest1 = NULL;- _) [: Y; l6 M
- char *dmabufdest2 = NULL;8 y( u1 O: Z! T- w# E
3 U% S6 _, }$ g }- I$ f% J2 J- static int acnt = 512;
( ~, s/ Q) K9 g) j, i - static int bcnt = 8;: Q) \( G9 M9 ]' W; |3 I. {
- static int ccnt = 8;
5 e( X$ C6 {, _" L
0 v/ o/ ~- @/ Q$ N! d4 j- module_param(acnt, int, S_IRUGO);$ n2 _' R) w7 P. P, |! B
- module_param(bcnt, int, S_IRUGO);
/ F' L. a0 J1 \% {# j - module_param(ccnt, int, S_IRUGO);
复制代码 0 W/ B9 e' r( u$ |3 B) d& r+ _3 G
* B0 [: @- u) Y5 V, G' N- }
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
% y, b2 v9 k* i- o2 Narm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
. J) w: U0 y; E W0 ] 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。. K5 J/ W( T9 f- N# i5 h
) ?9 @2 v4 |- r. q0 \
$ B) T6 ]. x( Y f2 j |
|