|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 & s9 P& k. q6 h9 B Q2 M- {
- [code]EDMA sample test application4 q8 h0 f; S+ P( o3 L2 t# m
- /*7 Q' L1 ~* |% f) E' [/ u
- * edma_test.c
# g. E2 L7 J* L$ o' K# |; J - *
! p c4 a2 U- N! v) G) a - * brief EDMA3 Test Application* V( a0 D; ] I: q) B) y: G# j
- *
7 [( E8 E" B- J4 R2 B. N o+ `" W& p - * This file contains EDMA3 Test code.
- W" C' B2 V" `5 i - *
( c3 o h. f u* ~. C. U* R - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
2 |: y& P5 h- ] - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT0 p: L1 M: T5 _4 w6 W; ]9 T
- * TO CHANGE.
/ ?& j( Q. @* C7 |+ v+ R - *7 Q9 p3 ~1 \/ z/ n2 x# L: D
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
+ C0 k: [/ {0 ~$ o& r% v - *
2 o9 ?* L6 S8 ~$ g6 l - * This program is free software; you can redistribute it and/or
$ Z& v" |* H2 C; u9 a - * modify it under the terms of the GNU General Public License as1 T, W4 o' s o, k
- * published by the Free Software Foundation version 2.# g% ?" E( m& b U
- *3 z/ X! f# P# P( Y' Z
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any3 d4 d. D* _" W5 l J
- * kind, whether express or implied; without even the implied warranty
: m! m- H4 A8 V. f& M! B. [ - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the) l/ `- I* B3 J
- * GNU General Public License for more details.% K9 t" f1 _& v' M: \! @) E
- */
, s" `. Y. M! O5 I& @- C4 P - # T( v& C) y. Y. }% g2 i
- #include <linux/module.h>" d6 J" E+ z2 q; {; m- i0 d7 p
- #include <linux/init.h>( C+ b. Z" {# i$ _3 s& M6 }- @
- #include <linux/errno.h>$ y; L- I; G4 I! ^
- #include <linux/types.h>; a$ I, }8 @. J; N. [7 c
- #include <linux/interrupt.h># b7 b& i2 ]5 J/ D' ]) V% H- P
- #include <asm/io.h>
8 P6 c4 n- Z R; [ - #include <linux/moduleparam.h>0 Z: v, g6 T6 o( m
- #include <linux/sysctl.h>
: v P) `* D& P! {% _ - #include <linux/mm.h>
/ e9 Q1 p/ f0 {9 M) `& v& v - #include <linux/dma-mapping.h>. U2 ~' G3 J! U9 ~" e- |6 e: x5 I
- ( I4 f" z2 }. ~
- #include <mach/memory.h>" T6 q5 s/ [% J9 M
- #include <mach/hardware.h>. D1 r9 }; L5 T. e
- #include <mach/irqs.h>( q' f, M' I* ` l5 N9 c+ ?
- #include <asm/hardware/edma.h>
3 a& \' ~5 I# {5 s
' w" [+ ]: x1 z4 f* w- #undef EDMA3_DEBUG+ D! F2 h* G0 |5 u) o- g* E: L
- /*#define EDMA3_DEBUG*/4 E" A. L3 W. Z* ?# _, L% _- x0 g
5 o) k$ ? K6 X7 r- #ifdef EDMA3_DEBUG
0 c: J; x9 P& m ^* Z - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
, K8 B# b* j' f% b: U) ~6 u - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)$ x7 i8 O7 U; `% S
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)% {" ~$ E: P6 l7 ?4 l( V& }# X
- #else
( V3 m' G9 P; J2 p, `( W - #define DMA_PRINTK( x... )
* L8 B# x1 D: m1 |0 M - #define DMA_FN_IN
$ U5 @% Y, h/ K: T- J0 Z+ s5 X - #define DMA_FN_OUT2 Y( I6 a9 i7 o' N, B! V
- #endif& r6 Z$ ^4 V$ f& {
- 1 K/ e8 p2 J6 D. I: a! q
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)5 b4 _) |4 c. p# ?. w3 D
- #define STATIC_SHIFT 3. C% K( D3 b. s {
- #define TCINTEN_SHIFT 20$ y1 Q8 x8 A. E, Y' ?3 b p
- #define ITCINTEN_SHIFT 21% u# C8 B( d1 D- h, w0 u" h
- #define TCCHEN_SHIFT 22
/ z; y9 F. y( U" | - #define ITCCHEN_SHIFT 23
* _* Q$ V+ T* y) e) o7 G0 G+ { - 5 y/ e! S {) T) c* s5 R. b0 d
- static volatile int irqraised1 = 0;8 t# y5 q, ?' W; \( R
- static volatile int irqraised2 = 0;
1 }. l; n7 }2 t; v( y2 n
' a% _. j$ f5 W3 U- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue); v- d, Z" l" W, i
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);; i0 n i m5 E! K
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
/ R- B7 a6 e1 T1 m8 O! o - ( R. L' @+ `* d9 ^. S# d
- dma_addr_t dmaphyssrc1 = 0;
2 T' W: x9 Y/ _: i. o& {0 ~; b$ y$ K - dma_addr_t dmaphyssrc2 = 0;
/ [+ i- C1 x2 I3 _- m- A, C - dma_addr_t dmaphysdest1 = 0;
+ [2 V J/ Z' o - dma_addr_t dmaphysdest2 = 0;
8 l6 c- E+ f9 G - : e2 b* |5 K6 U( {) Z% p9 U
- char *dmabufsrc1 = NULL;
2 `& j8 l ^1 p( X7 \& N g - char *dmabufsrc2 = NULL;4 t" R g/ ?0 X! e' K, \$ m
- char *dmabufdest1 = NULL;
$ \; V$ Z: E: _4 ~, E - char *dmabufdest2 = NULL;5 o1 }& j" X. d- N
7 \5 L& F/ S7 K. G% Y2 U0 A- static int acnt = 512;
$ v1 G# K' l. C, | - static int bcnt = 8;# c& Y. y8 o5 c
- static int ccnt = 8;
9 q- N: Z' N$ `' W - 8 `5 l9 E% ~+ e% B3 `& {
- module_param(acnt, int, S_IRUGO);
% p1 N" x3 V% A3 g4 l - module_param(bcnt, int, S_IRUGO);! `! {3 `5 A- m& m7 R3 F
- module_param(ccnt, int, S_IRUGO);
复制代码 9 o, |+ D: z3 E, u
* t( p! _. ~3 v5 Y: u5 U. O+ T. _ 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
& [% k* n2 j3 o; \2 E8 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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。: A w6 c% I1 O- q- B) S8 C" h
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
( |$ t0 {4 ^' Y- _! W; e( v0 D0 G+ O1 v; m
4 U, z/ J* r$ g! ]$ v- I |
|