|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 3 l0 ^* O5 U" T9 l5 G2 ^7 O* j
- [code]EDMA sample test application
! m* P6 u! t9 D0 m6 ^6 B - /*
) d$ e+ t! ~ P5 H8 t- Y - * edma_test.c2 |) x% N! E$ T2 s6 E7 Q* F4 Y% j! {
- *
# ?. U2 a# C7 T7 x, j+ I; \ - * brief EDMA3 Test Application
& u" g% u( g, E- }' V" ?4 _/ J- ^# K - */ D: h. w+ H) ~" J# ] Z+ W
- * This file contains EDMA3 Test code.1 p* A/ x7 I, t/ Q, ?' P
- *
: H7 K* W$ `& K0 k" A/ |9 U - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE3 L. G/ z b7 b
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
$ T! T# e7 B; a& { - * TO CHANGE.% R; k( U( s" M \& |; d7 N
- *
+ Q0 X: p, `# L: m6 a - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/; c9 w# c3 B$ u/ a' Q
- *
8 K* w, T! S' G9 y1 z - * This program is free software; you can redistribute it and/or
4 p, w9 F- e( K9 J - * modify it under the terms of the GNU General Public License as
4 v$ u0 u6 m* H9 H9 T+ c - * published by the Free Software Foundation version 2.3 w A1 i: r1 ~. J
- *5 U# f G' r; z5 k
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any
) X$ `5 }; k) T$ X* T/ \; ]! J - * kind, whether express or implied; without even the implied warranty
( i4 X( h" K! S& Z# u% z; @9 v& K - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the" q) p' ]; t& B# n( K
- * GNU General Public License for more details.
) A4 Q$ j: T& e - */# f4 i# k' K% i u5 g2 \# Q
, G: v4 k, b- a( i- #include <linux/module.h>
+ ]% a9 B: ?* }7 D( q+ G3 V5 ] - #include <linux/init.h> A9 X) c. W% K$ x4 k, O! B
- #include <linux/errno.h>
! f7 n) j7 ]3 D! I/ h# X1 e& X) p - #include <linux/types.h>
: P( g7 z( R, ]8 e - #include <linux/interrupt.h>7 G1 w$ ~4 P8 n+ _+ |, I3 }
- #include <asm/io.h>: { h Z9 Z6 G( K. |
- #include <linux/moduleparam.h>( B2 D( y. g8 J5 q
- #include <linux/sysctl.h>3 z6 ^# P+ j* ?2 K' z$ W3 ]* G7 r+ B
- #include <linux/mm.h>+ d/ a$ s/ k7 W% Y" r6 V) ~' c
- #include <linux/dma-mapping.h>: @& i* s( e7 h5 Z4 ~1 I* U8 R
- , L' k7 ~* o3 {: c" w4 c; ]; ^
- #include <mach/memory.h>
: v* k- P/ C- S: X, _ m/ {% r - #include <mach/hardware.h>, \, I/ N; I, \3 p! B
- #include <mach/irqs.h>
3 m, q3 c9 M4 x# m$ C - #include <asm/hardware/edma.h>5 D# E# [* E T+ b2 n& g7 T
4 d& {$ A t+ Z+ [3 ]- #undef EDMA3_DEBUG: w" C. v5 n. V3 {$ Y6 j
- /*#define EDMA3_DEBUG*/
" A% y- p, I% s$ F. `. M - 2 I! L. R0 l4 c1 p8 i* G1 ?7 ~
- #ifdef EDMA3_DEBUG! I' R8 c- _, L3 @5 t: b8 x1 k
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
( U7 I8 K) G+ u! S - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
# F* n/ p3 [3 k$ J8 G$ I* C - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)8 V# N! `. V5 X, ^2 E- a8 ?
- #else) @$ g* V# W& J9 ]
- #define DMA_PRINTK( x... )
3 B$ ?: ~( K5 A1 M - #define DMA_FN_IN
- C6 n0 O8 n' L( G7 ~* h - #define DMA_FN_OUT
$ R- ?, |# n+ g) Q' L) [/ `4 o - #endif
5 [* O: i8 E- p; u/ _
, h* K: S( C& z& G2 ^7 S/ o: |3 V- #define MAX_DMA_TRANSFER_IN_BYTES (32768)2 ^2 i; N9 p6 T" P1 @
- #define STATIC_SHIFT 39 ]2 k4 O4 z& m8 B! i0 ^, v
- #define TCINTEN_SHIFT 20- j" z3 P; B9 q; _
- #define ITCINTEN_SHIFT 215 p6 o g7 Y a W# o, Y s, U
- #define TCCHEN_SHIFT 22
4 m( V& k8 |6 E+ J# n. w* {5 M' B - #define ITCCHEN_SHIFT 23$ K( K K W+ _- V: h9 {- L( H* R
0 Z9 s; O# b. |4 ?$ N* i1 _- static volatile int irqraised1 = 0;
: |2 |, V) o( I& V7 x) r9 { W - static volatile int irqraised2 = 0;, k/ n8 O6 [+ P. X
- $ ~ d* _: ]+ J) i; E( _; l6 h
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
. ^" `! h% x3 ]+ O* X - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);* J$ Y% q5 C) U; c# @/ l e- A
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
w: M% z7 F* ^4 R# N - % Y8 \: ^4 S- H: Q( L7 ?, \
- dma_addr_t dmaphyssrc1 = 0;/ b, g A$ _# H+ j/ S Y
- dma_addr_t dmaphyssrc2 = 0;5 M7 d+ z: C$ \' }' {$ h
- dma_addr_t dmaphysdest1 = 0;
3 J2 H( `" i* @ - dma_addr_t dmaphysdest2 = 0;0 q# d1 T; V2 W, {8 v' u3 [) o _
1 }/ k0 |( s: A$ \' v- char *dmabufsrc1 = NULL;
. y. N" `9 h! F$ t k - char *dmabufsrc2 = NULL;
+ {" i* ]$ y C+ m5 p' o# a& }. M) |, c - char *dmabufdest1 = NULL;
, p/ \& Y |: C2 F9 s, } - char *dmabufdest2 = NULL;
( `' o$ W0 J6 e) n9 U3 \* e
; Q+ Y7 H* o8 Z) K- static int acnt = 512;1 `7 X) Y! O4 Q4 a) e
- static int bcnt = 8;# U h" N+ P; x8 b% n% n
- static int ccnt = 8; B- B# t: h/ y' k: w( z6 l
- " Y# d2 i+ a" O% f8 T6 z
- module_param(acnt, int, S_IRUGO);3 z' ^/ A' Y' b& x& q5 G& L
- module_param(bcnt, int, S_IRUGO);
/ [" I* p! x; _$ p- P - module_param(ccnt, int, S_IRUGO);
复制代码 7 D. \% m8 P! i) z- c# e6 N
2 F, z# b O- y0 P1 E
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
! \1 I9 w% U" \! B1 Larm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。1 \$ l& }* [ M+ t2 g6 r0 N( |
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
# v/ |+ E! ]' o! [, x/ T
. m5 _- @ @7 a" h- g f# L3 @% p7 Q, g8 f. g
|
|