|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
, A( C& W* e3 n- [code]EDMA sample test application
- n; D1 ~" H8 ]$ ?# `9 w/ d - /*- E& Y0 L8 y) f+ d3 k8 E
- * edma_test.c) `& j% ?- _; m. A8 l, X' P
- *
# D* I0 u" I: h8 O; u0 R - * brief EDMA3 Test Application
7 ]2 E4 x/ j7 y* w0 J+ B' n - *5 o+ N0 Z+ P- Z
- * This file contains EDMA3 Test code.
$ c z( O' ]$ ?% `$ E0 s - *
# d3 l: w0 Y) H5 ]: f) Y5 x - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE' m d! e" D3 c' B5 c% P6 C
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
9 e$ k, e5 `$ }! e, n% [ - * TO CHANGE.' t! _0 a5 R) n" T4 R+ Q
- *
% w3 A @; L' A- J: m - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/: `# O4 k: l, P; v4 w; m
- *
7 x! t, f* _) ?" r: X; p, B& A - * This program is free software; you can redistribute it and/or
' C% I0 T2 d' L8 B; Q! X! I - * modify it under the terms of the GNU General Public License as6 H0 m: \6 w$ e [
- * published by the Free Software Foundation version 2.
! M9 K. F/ C, h( g c/ Q - *% N% E. O" x& z6 @
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any
$ h" M6 I8 ?, q8 } S5 Q7 M- ` - * kind, whether express or implied; without even the implied warranty
% N5 @/ F" ?3 E8 m% [7 j; K - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the0 O* r# M' }3 P8 Y3 B' P
- * GNU General Public License for more details.
7 r8 P* r) g6 U0 e# s: v; O* J/ E0 H - */
1 w; h# ~ I0 V- {+ \% q3 ^; }# K. c
1 E4 {! x3 O5 P% o/ z9 _- #include <linux/module.h>5 \' l4 i8 W' {: h) i5 D0 y
- #include <linux/init.h>
; T, D6 L0 K* Y+ P. ~7 I - #include <linux/errno.h>4 X9 o% f" X6 r0 s$ E* h
- #include <linux/types.h>" \6 {; B0 R+ o
- #include <linux/interrupt.h>* F7 ]* k. q9 D. {/ w! g" ?
- #include <asm/io.h>6 B9 n7 Q' V; p7 u
- #include <linux/moduleparam.h>
$ \5 p5 G! G& M- m' l9 y - #include <linux/sysctl.h>+ c ^- @# D" C9 [" Z
- #include <linux/mm.h>
9 \9 k! K- R) Z! v, x4 {/ H0 K! T" Q - #include <linux/dma-mapping.h>
; _/ f, D. m. J. h. M! j
$ m: E- N, M5 O+ Y$ U7 g5 X- #include <mach/memory.h>
2 M6 s: B% I2 c: h, k! P5 f/ B1 r - #include <mach/hardware.h>
9 } M5 K, o- j+ q( _9 ]1 t - #include <mach/irqs.h>( }- _+ f- P, S2 N6 ?
- #include <asm/hardware/edma.h>
3 s" ~5 ^! M6 w - 8 ?" w" G% ?! p" T, }; w
- #undef EDMA3_DEBUG
1 B" u9 L& i4 j/ O1 z. ? - /*#define EDMA3_DEBUG*/
( g2 r+ L: v8 b: p
% D( R" A; W, v$ A" C5 }9 Q- #ifdef EDMA3_DEBUG
. q6 B, k R( _% Y - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)2 p+ c3 ?4 Y1 J* N) ^; [2 E( s$ v6 E
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)" q- x3 e: w% G* X0 K' m
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
7 _* Q" X+ }9 L0 w6 ] - #else8 b' L- c$ l T r
- #define DMA_PRINTK( x... )
. S& f9 @0 s! y1 R0 A - #define DMA_FN_IN
. a& V7 \( f( S' i - #define DMA_FN_OUT% X% l1 T; w- y2 X" ~
- #endif1 {; |$ M6 w4 K% f/ n( R% y4 a
- T& b" a" ^. H% W- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
' p+ ?- q; Y- y8 L4 I, M- h - #define STATIC_SHIFT 3# p/ A' e( Y/ }- q+ ?; m, f O$ r
- #define TCINTEN_SHIFT 20* J! m& P e1 j4 ?: d2 _$ n
- #define ITCINTEN_SHIFT 21
! U& ~% D* S+ l( f' A4 r - #define TCCHEN_SHIFT 22
6 ?' h% O4 a. W* a5 b' ^" b - #define ITCCHEN_SHIFT 23
8 f) J/ ?- g/ g8 y - u) e) b- N! V7 r' q
- static volatile int irqraised1 = 0;, A' F" N3 O7 L" r3 j# L" {
- static volatile int irqraised2 = 0;
6 v$ n: E: ^1 H3 t - / b! z+ x% g" H7 L6 {. ~) C
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);$ p" s, f0 K, U# r
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);7 w0 R/ ?& [" x. m, i4 m
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
2 D Y7 M, o$ _
5 u9 I. d: B+ A ^0 S. c- dma_addr_t dmaphyssrc1 = 0;9 J+ R: R H. a7 x+ k
- dma_addr_t dmaphyssrc2 = 0;
9 U8 c$ P) D& k5 q# s/ N7 ] - dma_addr_t dmaphysdest1 = 0;
. b J# e1 O9 W' w- ]4 H - dma_addr_t dmaphysdest2 = 0;3 g# I, w" ~3 ]1 }
( Y l9 V ?$ X# L+ ^. }" J( F" ^- char *dmabufsrc1 = NULL;
2 T4 X+ x7 _/ {4 } - char *dmabufsrc2 = NULL;
H, @4 \. | |7 w, I7 c0 _6 e; _8 v - char *dmabufdest1 = NULL;
: f+ G+ L0 ], Z - char *dmabufdest2 = NULL; ]2 U# u! {% o# N+ z6 \1 T) r
, f- l3 W0 u/ }- static int acnt = 512;) o3 t% f2 v0 g
- static int bcnt = 8;
$ [& I$ z$ r8 n5 [ - static int ccnt = 8;
, T( B5 m6 m9 V5 S0 J# h - ) \& m# p8 m/ ~% o0 i+ z/ A
- module_param(acnt, int, S_IRUGO);0 x5 V. E; J$ n# k
- module_param(bcnt, int, S_IRUGO);
0 O4 W. R8 R0 v ~, B - module_param(ccnt, int, S_IRUGO);
复制代码 . A" u6 Q G2 z t1 C9 l8 P2 z$ u; L
( x _" u4 ^- J9 Y- f, |4 ^ 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
6 K: \/ r8 H' @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 A' b& Y* [, x" \2 N2 ^ 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
/ I: ~6 y5 t0 G' G; b7 N0 |5 s
9 G$ a+ |" E5 [; y
- l' O6 R5 Y/ u, K1 h/ U |
|