|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
# L" R8 p0 e8 P5 ~: Y- [code]EDMA sample test application
7 d) Z. L6 k- L) U T0 s J - /*! M& Y9 I i }$ n U6 f
- * edma_test.c
5 Z$ V% ], c) T/ B - *
5 e- p1 e& q+ p% z, e - * brief EDMA3 Test Application) C2 y5 V; S3 E9 [2 x
- *
& J# ]7 b+ E0 }( m! V0 m - * This file contains EDMA3 Test code.# f) F, F4 d" T j) Y
- *% d" J4 k3 b2 K/ ^4 l5 Z
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
( d. D! M ^, A: q2 L - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT( l$ _+ \" V1 P1 S W; m
- * TO CHANGE.
# i5 I$ z' \+ Q) N( t3 y' Y3 O - *
* d, I& q" z/ q - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/ E5 Y- ^3 X- Y2 O, E- l
- *
( u/ L/ f) W- j0 w* v5 Z% | - * This program is free software; you can redistribute it and/or
0 l# Q7 l* V0 ^' e0 ~- n- u - * modify it under the terms of the GNU General Public License as) G Q9 d& Z0 Q+ k* A8 Y
- * published by the Free Software Foundation version 2.1 Z, E3 C" \2 y4 ?3 r% R
- *
0 i" [8 U0 N0 n& M6 @ - * This program is distributed "as is" WITHOUT ANY WARRANTY of any
- I, e J# }5 Y& \ - * kind, whether express or implied; without even the implied warranty7 }) {6 i/ ~* q, z P2 H
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
: B* @( V! ?4 I# ?, l& @4 ^8 a - * GNU General Public License for more details.
6 C: @. ^$ s' }; @ - */& b6 l+ a) D( s. W
- 3 r% s$ R: a- U, f+ R/ \2 c: B! j
- #include <linux/module.h>2 }/ D* Q) V# }+ m6 C, w' y
- #include <linux/init.h>* _$ P- R( g8 i7 Q/ D2 p3 v( b
- #include <linux/errno.h>( Z$ j# x, V( _
- #include <linux/types.h>- P0 Y \4 z( I+ s6 T0 y1 W
- #include <linux/interrupt.h>$ [8 p3 N t$ n$ _5 T. V6 e6 y
- #include <asm/io.h>
' e# y3 l( a) E# F - #include <linux/moduleparam.h>
; c7 [* n+ r$ R% \+ A! M. E' g% u - #include <linux/sysctl.h>
6 W* |' @) j9 |8 o$ ? - #include <linux/mm.h>
& d9 `- s6 j O& t* m! J! m - #include <linux/dma-mapping.h>
8 L0 l8 r! N: E6 B1 P1 r
, R- ~# U; y% I2 X+ Z# \1 `" a- #include <mach/memory.h>
2 j0 ^, _; G* F9 \& k0 @, s) I - #include <mach/hardware.h>
c0 w. ^# M+ g7 \ - #include <mach/irqs.h>
" u8 e Y( a7 V7 j$ m - #include <asm/hardware/edma.h>/ P( G3 d) m3 r7 s9 y/ a2 Y
- " Q7 V/ e$ n1 M" G% o
- #undef EDMA3_DEBUG
& W- o1 M) s q( m7 c% i$ l - /*#define EDMA3_DEBUG*/# q- z& N1 g* s6 C7 T$ O" t
: p$ W2 {; S& z- m0 D8 N8 M4 q" Q3 L- #ifdef EDMA3_DEBUG+ Y1 g; P* p* G8 E+ G
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS); [# P3 {+ @* `1 {# y/ Z9 [
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)5 a6 W9 z7 [: e7 R' {
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
, O" ?, B, ^( F% ` - #else
, d( r% g+ F! H; a - #define DMA_PRINTK( x... )
0 R, b% A% L3 i0 X8 t& _ - #define DMA_FN_IN
* C/ Z# ~1 X* _: Y - #define DMA_FN_OUT" P8 B) ]3 X3 F- Z
- #endif4 G; d. j' a- N
; u( u4 i! I7 t$ O0 _. S- #define MAX_DMA_TRANSFER_IN_BYTES (32768) Q1 j. b2 ^5 B$ p4 z: C1 J
- #define STATIC_SHIFT 3
! j, n5 J2 x8 g1 |; E' W - #define TCINTEN_SHIFT 20
6 U) U+ O+ C/ p: [( M5 Y - #define ITCINTEN_SHIFT 21
, p' E% w7 `2 }7 { - #define TCCHEN_SHIFT 22* f: l0 n8 @; k+ v3 Y0 l) @ v! ?1 l
- #define ITCCHEN_SHIFT 23- L8 y! n5 O: S- G$ t7 i/ y
; d6 n$ l( `6 B; b- static volatile int irqraised1 = 0;; X1 L' G1 Q& `" v& N+ L2 v8 q
- static volatile int irqraised2 = 0;. r# \" N% W) z6 H' I
* Z. ?" A- n) W, a7 z: \- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);% Q4 Z& g5 b3 @3 O, o
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);, [% R- i+ N" I0 D1 Q- K
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
( I6 H! U% P7 ^2 P1 f3 P6 Q1 t
2 ~4 e$ l h# X: N- dma_addr_t dmaphyssrc1 = 0;2 f% N1 |) H8 y7 j9 _: Q
- dma_addr_t dmaphyssrc2 = 0;9 s! O9 [3 C' w
- dma_addr_t dmaphysdest1 = 0;
- X) M( i+ c/ c+ C - dma_addr_t dmaphysdest2 = 0;8 }) |. l% v% m/ z" k" p% [- d' \
- 5 b% E% |- {. b2 f/ Y* |
- char *dmabufsrc1 = NULL;
8 o7 ]/ H b5 W, f. I) R: S - char *dmabufsrc2 = NULL;
5 t& |" B, q( q% _3 I - char *dmabufdest1 = NULL;. P6 V# x# a2 v! f$ v5 K( j
- char *dmabufdest2 = NULL;
3 I$ }! [& ~5 H& I0 s - : C; d( e/ v0 c w4 P
- static int acnt = 512;: t, `# I# d1 F" H; C, Y, V0 F
- static int bcnt = 8;7 l) ~" W4 v0 c3 ?/ r8 L
- static int ccnt = 8;: x+ t; w6 l* |3 @0 m, g( C
- 6 v3 c, n O* q M
- module_param(acnt, int, S_IRUGO); S* `) _+ q+ V- a% s' P' q' ~
- module_param(bcnt, int, S_IRUGO);
: o! R* s8 G$ I0 z - module_param(ccnt, int, S_IRUGO);
复制代码 0 K( C' p2 |* `& }' q; v
1 g u9 i8 ?2 f, _ 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用$ J/ a+ X: t; T+ h7 n5 C
arm-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+ B& ^+ V; ^% K0 C- ]8 Z* {7 p
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
# ?! g4 l5 Z, P1 g9 C, K3 z5 K$ J0 N: Z }' g
; T! w2 ~: q7 n4 ^( j |
|