|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 & z, v5 W, K8 x+ _ v5 i7 Y
- [code]EDMA sample test application
# {) |. r* ?& k2 [/ i1 V - /*
. R# l% E/ G$ x" O: k - * edma_test.c1 I, ]/ j) s% ~. W. a; f ]
- *
^ {4 C: \* y6 K) X - * brief EDMA3 Test Application
. q6 N! r0 D6 {* o - *. f8 e* Q) I! v r7 l
- * This file contains EDMA3 Test code.5 N+ A0 n5 n" e( U" S. ~
- *
. f' E! a* j4 O- a - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
! o2 b* x! [ X" b1 m$ M8 x: O - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT5 Y2 O' L3 b% R. o0 @( g/ c' m
- * TO CHANGE.
& k' J* Y Y7 g+ m* i - *0 L) u3 C) x; k8 X" \
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/( y8 h: r; i: ~1 k: l, y
- *& U% g3 }9 `' D6 B8 g1 _# \: e
- * This program is free software; you can redistribute it and/or: k+ E3 Z' e; ~( m: v' G/ h1 Q
- * modify it under the terms of the GNU General Public License as
7 R; a0 f: B: l4 r) } - * published by the Free Software Foundation version 2.$ D N. o Q" H6 r; u- {& b
- *0 x1 T+ b5 _0 l2 {) ^2 X t! E
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any
. e& i6 z1 }" q/ ^8 `$ L+ N6 f$ Q - * kind, whether express or implied; without even the implied warranty
9 L& {# F# s0 l. Z, z* y - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the( L) R$ {, d+ L- u2 i
- * GNU General Public License for more details.- Y$ A. e; W1 e" R' S0 R) l3 x
- */- i+ V4 E" ]* D: d7 Y! {! @1 B+ R
- 3 @9 L$ K6 f8 c; I& o
- #include <linux/module.h>) H# u+ [8 H! H% S4 l, z6 e1 P
- #include <linux/init.h>" Q% w% t& ~( t
- #include <linux/errno.h>9 b- O5 K8 a+ \. e
- #include <linux/types.h>) v: z1 }$ c1 {& P( r/ u
- #include <linux/interrupt.h>
: ?( }$ t" M& ^3 G9 \ c9 x - #include <asm/io.h>
" u3 X/ z! `5 E - #include <linux/moduleparam.h>) R' j7 a# Q; t+ M; c
- #include <linux/sysctl.h>
y& X& v4 r& H4 f - #include <linux/mm.h>9 O E& `: B! q
- #include <linux/dma-mapping.h>
- `& m( c, @* m$ d3 X: k4 a - ; [$ t* a1 H0 f8 V9 B
- #include <mach/memory.h>
; Z+ e5 Z7 d* ~1 ^3 j/ b - #include <mach/hardware.h>! e( j) h* O" L
- #include <mach/irqs.h>) w) \5 W( G6 s$ a- Y
- #include <asm/hardware/edma.h>" Y, ~( D3 y0 o* ]& e
- 2 \" `+ X' n8 e L {5 W
- #undef EDMA3_DEBUG
" R& Y( k0 q+ ]5 J/ e) \ - /*#define EDMA3_DEBUG*/
! t4 C* g d3 g: i! D: ] - 0 b$ T6 z. X+ x4 ?- b3 c6 [
- #ifdef EDMA3_DEBUG
& k% B' ^" Q. O, a7 L - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
, \8 R4 E2 V4 w1 U* j) ^ - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
: a& R9 @# ^/ D0 E9 b* C - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)" N, ?5 ^+ Q$ ]8 J' u5 A% L5 y
- #else
/ c5 p# x" v1 N# o6 h1 T1 c - #define DMA_PRINTK( x... )
( B. C7 R& y0 ]# g - #define DMA_FN_IN
9 S: ~4 F) {4 f- I2 t m: d - #define DMA_FN_OUT* e" T# K! e4 \& n
- #endif1 b) X( B, Y4 W; O
- 6 l5 C# b+ ~' |. X U2 p
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
3 V: o' A/ P# j8 Y% q- Q - #define STATIC_SHIFT 3
9 v) n8 Q( [3 u& P: F T* d - #define TCINTEN_SHIFT 20) `3 L% V" r8 `4 \4 } {
- #define ITCINTEN_SHIFT 21
: @$ v, I: M5 w& A3 k& [+ o - #define TCCHEN_SHIFT 22
! H: j' k$ p. T! |5 _3 n - #define ITCCHEN_SHIFT 23
: d; o* E9 _+ \* _; ]
1 g7 ?7 s( J4 q( E9 U* V- static volatile int irqraised1 = 0;
% X7 L1 H+ [! M! A0 k2 O; @ - static volatile int irqraised2 = 0;
$ M5 G) T" d) h9 ?6 k
* y! W. G: p% o/ \0 F/ k* [- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
4 J: S8 A4 t4 R" u6 d' [5 O - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);5 T3 q" g" P. m% G' i% J2 p
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
! e6 g# W: e% K; |% N; Y5 P - : w1 K, C* B r. A
- dma_addr_t dmaphyssrc1 = 0;. ^2 x) Z" l" L/ j7 f
- dma_addr_t dmaphyssrc2 = 0;2 d" ~- u3 [; G' e6 [
- dma_addr_t dmaphysdest1 = 0;7 ~8 |$ B, B. ~1 H) ^$ K" S
- dma_addr_t dmaphysdest2 = 0;4 f# z; P* \' E) p. q" x% q( Y
- : R/ C1 Q, {6 |+ \5 w/ `. \% p
- char *dmabufsrc1 = NULL;& t# t- p. S/ S8 \
- char *dmabufsrc2 = NULL;
J" o# U1 d5 I- @ - char *dmabufdest1 = NULL;8 K" o3 A0 F3 L0 R
- char *dmabufdest2 = NULL;
! [+ r8 P" R6 U* n) Z - 2 j1 \1 x0 F! Y/ j2 u
- static int acnt = 512;
2 O7 N6 _/ V' K - static int bcnt = 8;" S, ^. i+ u6 H$ j. U4 i$ H3 c, J
- static int ccnt = 8;
1 z; D4 l, b3 E" s - # s0 U* o# j' t h# d
- module_param(acnt, int, S_IRUGO);: a6 Z5 J4 x5 {) p% [9 C
- module_param(bcnt, int, S_IRUGO);
( _. }$ W" V9 D0 H W" ^6 N/ [4 n - module_param(ccnt, int, S_IRUGO);
复制代码
- h1 s, C* d8 h6 J
5 s+ @7 [* m. N5 d1 c 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用( w$ o) q7 d0 `6 r' P2 l
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
- k, G$ k; y, ~) _4 t$ q. _ 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
' Q b* z: u7 V9 y7 d! m1 w7 }3 f% N/ h' c" D- X1 R6 M- C
! |9 K/ E" R* c6 @/ Y/ Z7 N0 t3 n |
|