|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
8 v% C. X" E% K3 Y- [code]EDMA sample test application
2 {% X2 m. J6 [3 H" i9 G8 q - /*: H- C# f4 e v( B$ r
- * edma_test.c
- g# }+ ^; g( v! V4 X9 q - *
% F5 W5 ?* x# u3 [6 S) E( g% p - * brief EDMA3 Test Application
4 m3 b. n9 c$ L, g( R3 b3 L - *, {/ r2 u/ Z, z
- * This file contains EDMA3 Test code.' |+ U. {8 E4 o7 \
- *
) w8 u' x* g) |6 B; J" t! n* L - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE& ^+ G- u7 u4 h2 K/ V: `* \
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT" l( P, C+ g! i0 Y% R
- * TO CHANGE.
' }& ]/ c1 k m8 P( E1 ~ - *
. a* Z( z6 j! W+ A( k( H$ ?7 T# ~ - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com// X# i' i- m; @4 J( ]' q# ^
- *; v7 }) \6 a5 V, F# P8 _; u: A9 F
- * This program is free software; you can redistribute it and/or
+ H1 V9 ^7 t5 K" Y0 W - * modify it under the terms of the GNU General Public License as
# s5 S V( e6 N9 _" l1 E% h" Q - * published by the Free Software Foundation version 2., d6 U, t( V1 I. `: L& G) L" f
- *0 p* ^4 L7 G2 ]5 I1 V
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any
5 W/ |6 i) U% A/ V [+ l - * kind, whether express or implied; without even the implied warranty
% } @# c7 m/ B- Z& ?8 k - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the" ]- I4 _( {+ o
- * GNU General Public License for more details.9 A0 i" i& S5 g. Y# T
- */% \: Q# W) a. o7 g, a
- 0 G7 a @% h- a2 I
- #include <linux/module.h>3 u5 [: m: {# P
- #include <linux/init.h>
( p4 P2 N% ~7 a- X: U- M - #include <linux/errno.h>
/ B- K& C$ P# Q+ a; y - #include <linux/types.h>3 ]7 r3 f6 L0 S$ ~" c$ Z7 W$ h' h1 T
- #include <linux/interrupt.h>
; Q% t9 P5 t9 T' x - #include <asm/io.h>8 R; m( b% E; Z; j) w! J. E, F
- #include <linux/moduleparam.h>2 C! {7 d! z5 U- ^+ ]# O2 ~" t4 t0 K
- #include <linux/sysctl.h>
8 P; n U/ K) A0 P - #include <linux/mm.h>
4 ~ u( ?7 o3 R: Y L - #include <linux/dma-mapping.h>
; g, n, ^' C5 N7 w8 O" r
# v5 B/ N2 i- t* `- #include <mach/memory.h>! K, i6 }9 T, L, @* t6 I
- #include <mach/hardware.h>
K& X" y7 F) c" R) p9 k/ q! o - #include <mach/irqs.h>
! ]: v# C2 I+ z z* B - #include <asm/hardware/edma.h>! x, {6 i! A/ v
0 A% X5 {% J" y+ Y6 X/ A k3 N- #undef EDMA3_DEBUG7 [' j7 f! b# ]" E: z p l% v
- /*#define EDMA3_DEBUG*/
Y- f" A+ {/ Q) f+ }9 D/ C
7 l# L0 d6 q- z+ m" n) C- #ifdef EDMA3_DEBUG
3 s/ P6 j7 c& H* i( d) s: R - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)" d: o" S- F A( q0 R8 `. {# |2 Q
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
( e8 f# y7 t9 {0 V* O6 R6 y - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__) E! d7 M" I3 z& |; H! f
- #else2 k% Y$ k# P# O V
- #define DMA_PRINTK( x... )
/ B1 S7 j4 k/ M. K- v* e' W ?2 | - #define DMA_FN_IN! H" D9 |6 D v6 Z+ J9 f4 S$ U
- #define DMA_FN_OUT0 |1 X0 |3 c( E3 m$ U0 u& ?
- #endif& b4 b8 d# W" r9 N# V
8 {$ u- K: E7 J- #define MAX_DMA_TRANSFER_IN_BYTES (32768). i. c" @2 U; y6 [
- #define STATIC_SHIFT 3
, i R( X; x8 s, `4 E8 ] z - #define TCINTEN_SHIFT 201 Z+ r- i* @! ?5 ^
- #define ITCINTEN_SHIFT 21% z% U ?. |' r B+ ~
- #define TCCHEN_SHIFT 22
7 x$ h- ^9 ~0 c& M$ `/ X/ o/ z8 @ - #define ITCCHEN_SHIFT 231 O1 }6 F' i& z( A
7 @' I, m" o8 v) K' l- ]+ E- B- static volatile int irqraised1 = 0;9 P1 a9 V! v: P! t: H5 t
- static volatile int irqraised2 = 0;
0 Q5 L N4 t c% P! x - 1 c6 p3 y) J/ I. v0 @+ S
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
; F3 I& p; {& |/ B& p$ c/ _ - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);! |( \2 G) u1 u
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);9 j2 ~% G: j2 A( ]
- 8 x; e# U7 L- s+ t) r# C/ V& V
- dma_addr_t dmaphyssrc1 = 0;1 K* D4 `2 [6 \' @/ l: R. g# x
- dma_addr_t dmaphyssrc2 = 0; |4 G; M; k6 e$ ~
- dma_addr_t dmaphysdest1 = 0;
. _ E: g: ~9 b7 g/ a7 S! b - dma_addr_t dmaphysdest2 = 0;
( D! g/ f* N% ^" ]1 ?- k
4 t2 A+ L% k$ d: r2 E; A3 Z' ~, \9 H# n- char *dmabufsrc1 = NULL;+ N- k2 X5 o/ x+ b3 r% F2 l
- char *dmabufsrc2 = NULL;
- y6 m- s6 B: W6 y - char *dmabufdest1 = NULL;; I/ `; T' I! j" r4 B- |
- char *dmabufdest2 = NULL;( Y$ ?' o; N4 V
8 f9 c6 g6 r4 `8 h% B- static int acnt = 512;
% d5 }9 N* I& C4 y - static int bcnt = 8;
9 }6 i& ?1 x& g - static int ccnt = 8;" U! @" n6 g* T0 D5 s% _
- 3 m2 R& _% g- u: ?: U- f
- module_param(acnt, int, S_IRUGO);$ l3 Q& N8 G3 A4 \ L( C
- module_param(bcnt, int, S_IRUGO);
f4 H* ]4 X- A3 h' J8 K3 l, R, t - module_param(ccnt, int, S_IRUGO);
复制代码
. q" [+ L% F0 N5 E3 ]0 ]3 T3 V+ }1 m( j, n* q7 M/ e' ~
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
0 U6 Z/ n- o8 Marm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
( d& { r+ g1 e/ _ t ?/ D 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。$ ?2 v$ o7 ^: A Y
% B, W* }( T1 {$ f- c5 ^' C* J. X' L0 W9 @. i X( p5 m6 P* y
|
|