|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 + m8 L& N2 Y& }
- [code]EDMA sample test application
+ D$ Y4 Q9 _# _. x8 r! _ - /*9 k8 s; |1 B; `# S
- * edma_test.c" ^! J+ f" i* `: e/ V1 Z. t" v/ V
- *0 b: W9 A' X- R
- * brief EDMA3 Test Application8 |3 q6 O# s& a) n
- *
4 Z% N" B f. Z. h7 X - * This file contains EDMA3 Test code.0 P W& g& n8 [! y1 d b M
- *
6 O! ?: f% N9 x2 c4 x - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
4 R+ e" {- R! Z( n! x" F - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT4 I1 _. |, L! }/ x- z) v# W- L. l5 @
- * TO CHANGE. y; X0 I: @# E6 {8 b
- *
5 @% ?9 R# D9 N- y8 w - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/4 d; o% ^' T) I& B
- *' L4 ?9 x( W( p2 d0 I8 b+ i
- * This program is free software; you can redistribute it and/or
) Z; i" C+ v E% Q: ]. Q - * modify it under the terms of the GNU General Public License as9 q4 K% |3 V S+ J7 @
- * published by the Free Software Foundation version 2., X! \6 W4 p( p1 I/ n; F
- *; w8 @0 ?0 t0 \% F% k# o$ K |) \
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any, S5 ?$ D) g+ W8 C" d
- * kind, whether express or implied; without even the implied warranty
% W4 A1 z# |% `" B* ? - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- v9 u2 @- D: \& ~5 T" K8 }4 E - * GNU General Public License for more details.
& U2 l; C" A- K# K5 c - */, U, M( ~. k: v, \# `/ }$ M$ E9 X. _( j
- & H/ `1 N% |$ N! f6 _
- #include <linux/module.h>% J: t8 w R4 `0 s$ Q0 O
- #include <linux/init.h>7 x6 L: x3 L+ `0 j
- #include <linux/errno.h>
' r! T& B5 Q4 T0 q4 X - #include <linux/types.h>
" X: @! W: I6 z& T; X e( h - #include <linux/interrupt.h>
; h" |/ N5 M& g! l7 a - #include <asm/io.h>) V) e- C1 I+ S1 Z+ @2 |
- #include <linux/moduleparam.h>; h. J, J2 x( K+ u
- #include <linux/sysctl.h>. ^8 b+ p4 H; P: o0 X
- #include <linux/mm.h>( ]/ x. c0 W, ~9 g. s
- #include <linux/dma-mapping.h>
; u! E/ u; d6 M: @2 y' _ - ( o6 R' j$ P8 ]8 a7 h
- #include <mach/memory.h>
/ U) D: g y( P* |. \ - #include <mach/hardware.h>
* X* H* D. q$ j - #include <mach/irqs.h>
" i0 j9 k& S/ `, e5 i - #include <asm/hardware/edma.h>- R' B) P. c( b r: b+ u& [
, G$ M, X3 d( V- #undef EDMA3_DEBUG
5 M2 b5 R+ B$ S: N - /*#define EDMA3_DEBUG*/4 K* \3 i1 o6 U( A$ P
- " r! ?9 e( c9 H+ H6 @% D; q
- #ifdef EDMA3_DEBUG
: z8 R# U3 ]1 s% D* i - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
* h$ C9 V! p2 L4 J% I/ P2 N- E. U4 U - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)7 C! Y Y+ @. c5 a
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
4 u( o, y, h2 Y - #else
3 l: b" ^8 k3 a& B* O - #define DMA_PRINTK( x... )4 j. t" V) N3 S6 ^
- #define DMA_FN_IN* D) O4 M3 \( w, n7 `: c% e
- #define DMA_FN_OUT' X3 Y+ Y) f6 [# X. L# F8 y
- #endif
. s1 f9 D" m y- D4 g
X2 _! E ^3 a, X8 F# B5 h- #define MAX_DMA_TRANSFER_IN_BYTES (32768)6 F) W* [$ S9 s5 k1 U: f
- #define STATIC_SHIFT 3
0 Q W; N! |8 B8 F* w7 E, r. S& a E - #define TCINTEN_SHIFT 20- G$ T" {( L) P" @7 o% ]6 x
- #define ITCINTEN_SHIFT 21* m7 T3 |/ Y/ {& E# F0 Z; X
- #define TCCHEN_SHIFT 224 Q! t. d: J/ v# [9 g% X
- #define ITCCHEN_SHIFT 23
9 U% U) x. w) e$ P) B - 3 G( f3 _4 \' {! i; U) Q' b7 k
- static volatile int irqraised1 = 0;
4 A+ k/ x/ M- F L4 U, ?/ y - static volatile int irqraised2 = 0;
4 ]( z' C( Q" u2 X, z - $ s9 a; G: n) z( ^! T% c: q
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);1 r/ l) f) ` t9 s) c
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);' d U/ k' U7 G0 Z2 x! C3 m p
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);$ Y+ {/ }! t& F$ W
% v s5 Y+ t; q( J, s7 ]" h- dma_addr_t dmaphyssrc1 = 0;
! |1 |' E; d& ?+ c( i - dma_addr_t dmaphyssrc2 = 0;
8 P$ y2 D2 @3 M - dma_addr_t dmaphysdest1 = 0;
2 i8 P' g) i( Y - dma_addr_t dmaphysdest2 = 0;
8 l5 F# [/ B1 s0 s# S - ; N7 C0 J+ {) F4 K( ~2 T/ U* E& j7 k
- char *dmabufsrc1 = NULL;0 g5 z& N8 c( Z3 `
- char *dmabufsrc2 = NULL;
2 t" g, B3 Y0 D! I6 i6 f - char *dmabufdest1 = NULL;9 E; y& Z2 D3 Q( l4 [( m0 P: z" N
- char *dmabufdest2 = NULL;2 t; G" y( v; T, z% V
- & \9 N9 r; \5 f) g" X" u
- static int acnt = 512;
, I3 m2 A+ N# t4 x; U8 B! m2 _/ c - static int bcnt = 8;0 Z) }" i' u9 y! ^% }. P2 g
- static int ccnt = 8;
! |5 K( ]6 z( _6 V& Y6 [ - $ C# V; @+ I9 f
- module_param(acnt, int, S_IRUGO);) B4 v0 x/ F# z$ X# ]
- module_param(bcnt, int, S_IRUGO);
2 O g# i1 R2 p3 B& R5 Q( ] - module_param(ccnt, int, S_IRUGO);
复制代码 ! G I" q4 X9 X* k5 b
( |8 c+ K5 \4 F( p! I X6 [5 K 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
9 L ^6 ~- n8 L' W+ n. n+ Narm-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 U- w% b; L0 ]9 s4 e+ v1 R$ n
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
- n, A6 u% x$ ~& ?: @' Q7 B+ `+ N# \+ h" X
6 k! L! R" K6 b' b |
|