|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
6 p5 d4 w" a' ?& A u! Q+ X1 ]- ?$ ], e- [code]EDMA sample test application
# h k' Y. M. j - /*
" h8 K- h/ q: k% [8 k - * edma_test.c4 q: N9 k/ A2 T F
- *
! g( \ Y& q* o- W5 }6 y - * brief EDMA3 Test Application4 \+ m$ A# j, N- `
- *
|5 @% v8 B1 l2 d: `1 m - * This file contains EDMA3 Test code.
& r% m8 g! J; A3 K; t0 q - *% k0 k$ g+ j* X
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE2 x2 s/ U* z. C9 T; m0 P' k
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT' w/ J+ s5 \! ^" }
- * TO CHANGE.) x* \# i! }$ Z: b \9 V! }
- *
" f) E+ i! P& g5 n6 S2 w" x, s - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/ u1 V6 `7 T/ h6 y0 j/ v
- *
8 J" \& [7 U3 |) U$ | - * This program is free software; you can redistribute it and/or
Q8 `6 S! \2 I" i - * modify it under the terms of the GNU General Public License as
1 ^' J) ^) e* j' l6 e# T - * published by the Free Software Foundation version 2.
! U. E8 x1 k4 u% E" F - *
! {5 y: I% m" S( h- t* Q3 I - * This program is distributed "as is" WITHOUT ANY WARRANTY of any
4 E: |% L3 o% t" r' i - * kind, whether express or implied; without even the implied warranty
1 i% I# T& r- n - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
% k# Z( h5 [: \; Z - * GNU General Public License for more details.5 Q" @- I8 H0 A/ J. S# k! \! N
- */6 {3 i) r( V8 `( h4 f
- . M$ Z# p7 m' [- F" A5 X2 G( e
- #include <linux/module.h>
& s' w/ {6 `% x3 D. @ - #include <linux/init.h>
4 f7 l, D0 i9 g7 W$ G6 [: P - #include <linux/errno.h>
/ t$ M; e. u: H s \/ [ - #include <linux/types.h>
8 {9 Q# X9 X# o- g+ B: t: t# {2 U5 l - #include <linux/interrupt.h>( A+ ~% B( N4 \! l7 p1 V. y4 H' ]
- #include <asm/io.h>; A6 G9 G9 ~% o1 U. S& `
- #include <linux/moduleparam.h> o) s" |* U% B, G" u. e* m7 B. Z& ?
- #include <linux/sysctl.h>: p) N5 D; {) T' _* N) ?) M
- #include <linux/mm.h>
( t% s8 t3 _, W# r3 B1 K4 B - #include <linux/dma-mapping.h>. K k5 K X0 p% S
. R/ s6 m. t7 t+ F0 I3 T- #include <mach/memory.h>$ k: j- ?/ y% u* X+ u3 Y
- #include <mach/hardware.h>
" W" s. M/ G+ J: p' i - #include <mach/irqs.h>/ |( }! o1 v) B P
- #include <asm/hardware/edma.h>! L2 e& |8 U+ B! E3 x, m V
9 k1 Q3 ~0 H+ B/ d% y L! r5 E- #undef EDMA3_DEBUG5 @( ?4 F" p. f4 s1 T9 [$ y8 Y
- /*#define EDMA3_DEBUG*/
' O. @- Z' y2 M
/ R6 Q/ f$ g7 v2 F- #ifdef EDMA3_DEBUG
5 Q/ z4 ]+ U0 r9 K6 V- s - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
3 k" \1 o+ ?* m% w8 V# s9 \ - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)+ s$ I: M' h v3 s
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
3 p' G3 ?3 K% q* l* W) O - #else- \* G$ |5 b9 X& L2 c- o6 v, {
- #define DMA_PRINTK( x... )
- }! G1 j% a3 j& C+ S' ?6 g - #define DMA_FN_IN
8 l" D l" | e. d - #define DMA_FN_OUT
6 b' R) A* S0 M' L+ B - #endif
1 ~. e4 ^, u- ~9 J - 4 ] T8 s/ \% U7 l* V
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
5 `/ v' n l0 ]6 f - #define STATIC_SHIFT 3/ K3 l3 A/ I7 K
- #define TCINTEN_SHIFT 20
. t4 k" d, h& Y" h/ n9 D- m, x - #define ITCINTEN_SHIFT 21% G1 q d& X% X( Y8 o& Q9 |
- #define TCCHEN_SHIFT 22
* q* l/ @/ n+ a/ Q4 g - #define ITCCHEN_SHIFT 238 G3 b9 _& f W& V0 a8 ~
; g% ~3 D' R4 Z2 I s# D+ |8 X- static volatile int irqraised1 = 0;
2 A1 o& g0 g4 x) V3 p - static volatile int irqraised2 = 0;
7 t/ E! E: h$ [, A, P- m" A. U2 f
' z6 T+ z, |) P9 y: H4 b( M# }$ V8 W! P- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);' M) s" {& }2 I
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
; ]4 ~* V; |+ n% @ - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
% d- v' H! d# V9 z( A5 ] - ) ^! X& s3 n9 k
- dma_addr_t dmaphyssrc1 = 0;
8 Y8 E6 ~4 D! M2 q5 m - dma_addr_t dmaphyssrc2 = 0;( }6 k/ k+ @4 p* |. d, w
- dma_addr_t dmaphysdest1 = 0;
% W$ X0 S0 ]( u& s0 C5 d - dma_addr_t dmaphysdest2 = 0;! c! y0 T+ s7 x4 I& Q6 o. X% @
- . B* s D0 S; z7 s a+ W& m8 t0 e
- char *dmabufsrc1 = NULL;3 |* Y# B- @. L9 b. q! ]
- char *dmabufsrc2 = NULL;
# O% L$ K# H7 v9 F4 _6 ] - char *dmabufdest1 = NULL;+ b0 E- a3 e \; m7 v
- char *dmabufdest2 = NULL;' Y9 i4 M: c" C' H: `9 ~) M
$ n5 ]& p/ ~1 E& `- static int acnt = 512; Z! \9 E$ e. v* l3 \" I
- static int bcnt = 8;
; F; p# d, g; a9 d6 W1 e - static int ccnt = 8;
! |( ^; u; ]. M) E2 F - ' r. b1 [6 p# h, F: e5 w
- module_param(acnt, int, S_IRUGO);
' G9 d* A3 @2 L4 A. R - module_param(bcnt, int, S_IRUGO);/ \1 Y! |& N- Q
- module_param(ccnt, int, S_IRUGO);
复制代码 ' j. {/ t' l$ }0 V4 P/ N
% m9 F1 a2 c$ U# A 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用 X" v; m& k! N: p: U. h4 ~
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
' Y% r- E, R! e, X, N 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
8 ]( V# Y/ {2 D
: H# ^: n) Q4 m' Y6 x' M2 U' m% |! E; u8 G8 {& z
|
|