|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 1 o3 P7 V9 l. \
- [code]EDMA sample test application
9 _! x. ^9 N- n, G - /*9 A$ B6 [1 q5 t- g' c* H& c0 E/ {
- * edma_test.c
2 k0 J4 {! w v e& C( F - *# b& f5 H( e: |$ ^
- * brief EDMA3 Test Application- ~* V9 j0 @0 o% \
- *
8 u) `) O( [/ M, p9 h. | - * This file contains EDMA3 Test code.
5 Z; {: T% j4 r1 l8 L - *
# o) c' p1 T$ }4 I- {1 ~ - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
+ f# `. m. D& s6 A5 ~ - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
9 E$ s" Q' M/ K/ N - * TO CHANGE.
# S4 L( K' T- ^ - *
9 I" C# f! U" N- x - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
0 F; _$ s e1 Q) o9 i- f: r - *
; z( N/ |% J2 `3 b: q2 j - * This program is free software; you can redistribute it and/or
' B% e4 v( i) D8 W - * modify it under the terms of the GNU General Public License as
2 z- d) j \9 |. I; n! ] - * published by the Free Software Foundation version 2.4 j. U; O+ }% D+ G1 |0 K
- *
5 }" A& F1 {5 I z - * This program is distributed "as is" WITHOUT ANY WARRANTY of any( I& Y1 f' \* i% E% R
- * kind, whether express or implied; without even the implied warranty
1 i6 B" B5 Q1 {9 X; D. T - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
% ^1 W1 E; \: u3 D - * GNU General Public License for more details.
# m2 w. U3 m5 V2 e( [ - */
* L2 e/ J7 j8 D' }, i
& q! Y8 t& k& n) J& s4 C3 q0 `- #include <linux/module.h>6 v# p. d7 g$ A/ o, T$ u+ B
- #include <linux/init.h>
8 [% ^2 d* X' F4 j" _7 \ - #include <linux/errno.h>
/ y$ `/ h' R8 J: S) H - #include <linux/types.h>
/ Y2 D* X* K/ _" T) s - #include <linux/interrupt.h>
& q; P: g: Z+ t2 a; ~" Z - #include <asm/io.h>8 t* e" h% S. Z, Q" \ E# \
- #include <linux/moduleparam.h>
1 V5 ]+ s" Z& Q6 ~7 a5 y - #include <linux/sysctl.h>
) f. f6 E0 N; Q: ?2 V - #include <linux/mm.h>" ^3 @) ]/ F6 Y, p6 W
- #include <linux/dma-mapping.h>
5 M; C2 ? K- j' g, @
5 @' o) @2 D" g$ @5 ~+ Q! |- Y- #include <mach/memory.h>
( |6 [$ Y% H2 j - #include <mach/hardware.h>
5 ^2 X" U* M- Q - #include <mach/irqs.h>
2 h+ T& n" i- i7 Q. b - #include <asm/hardware/edma.h>
: T2 d) t! o' B - 0 i- L8 v4 l' k4 O j
- #undef EDMA3_DEBUG
; o$ T& \$ ]( A - /*#define EDMA3_DEBUG*/
8 ^( |9 h; w$ s& ?! y - 2 q9 J" E6 Q, q! G
- #ifdef EDMA3_DEBUG
! A0 Z* q0 D0 `9 w( [! o - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
; E! S4 q; B! ` y# V7 T - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
t6 Q$ J N) N* [ - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)1 F" y1 C" {+ u
- #else
9 x5 C7 q/ d& T- _2 G. \) m/ Z - #define DMA_PRINTK( x... )
+ d0 {# V. D9 K9 K - #define DMA_FN_IN
6 b) f* z6 A! r8 u9 V2 |# S - #define DMA_FN_OUT/ y# A, D# G$ R$ R7 C8 s$ H
- #endif
. m) J: i* {' { - " q9 Q* N; O, P) O
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
1 S$ b9 _" Z: a - #define STATIC_SHIFT 3/ k8 R8 w" I+ H. f. Z
- #define TCINTEN_SHIFT 207 G3 @, W& x0 x, W4 P3 J7 V N
- #define ITCINTEN_SHIFT 21
! O- n5 d+ H6 N' ^, S3 g. q7 Y - #define TCCHEN_SHIFT 223 o0 _; y: }- y! @' R8 z
- #define ITCCHEN_SHIFT 23
/ o. N& O( I, c( d/ n+ P' }, s+ Q% s8 ] - $ }- r+ G4 Q% h9 e$ W# p1 D
- static volatile int irqraised1 = 0;
% M3 z$ Z' p! V, j - static volatile int irqraised2 = 0;
" L. g, y3 Z; P( T+ n! X" L
! e F) A% k- T6 V- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);; |1 d3 Z1 G3 X2 l# J
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);* f9 b" F0 E+ c5 i+ n
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
! D, v- C$ f+ V6 L0 J. ]: v( p
5 l4 f# t6 F3 ~% P- dma_addr_t dmaphyssrc1 = 0;* G/ h. f# o6 n( N6 _
- dma_addr_t dmaphyssrc2 = 0;# p2 u0 }! j2 K5 B
- dma_addr_t dmaphysdest1 = 0;3 k J% G2 f6 L0 I0 |% W
- dma_addr_t dmaphysdest2 = 0;
' F7 X4 `6 m4 b% \8 N
" q6 D) j! ^# {" y3 r- char *dmabufsrc1 = NULL;' p0 E6 M5 R P. E' \2 k
- char *dmabufsrc2 = NULL;
8 Q8 k( D. K7 r9 T; E z& O - char *dmabufdest1 = NULL;
G8 p2 E( V: z/ o3 C5 a - char *dmabufdest2 = NULL;6 u" U4 s" _6 y9 K- n' Y6 B0 G
( i' U3 _6 K @( U- static int acnt = 512;
$ ^ U$ o- ~1 w& b* h) B, Y4 C8 } - static int bcnt = 8;; T* `, i: Z4 R7 s+ d
- static int ccnt = 8;
8 q0 k6 J, ]8 [9 O8 K3 R - 5 ~+ s; v$ h7 Q7 @4 d
- module_param(acnt, int, S_IRUGO);
" V. |; O% \; F+ b - module_param(bcnt, int, S_IRUGO);
/ P! N6 U- o6 e- v - module_param(ccnt, int, S_IRUGO);
复制代码 : Y6 A, C. v# c) `
* O: m# w' y, ?
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
4 [* T$ A' y, B; J7 R4 b w1 darm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。; ~. x4 W w8 Y8 M
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。5 L2 p( i/ ^2 k) k5 j8 d
3 p1 N9 U5 W* V4 t$ V- p
B8 w5 Z/ F4 m8 R. }* c |
|