|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
\0 L1 b% L8 l5 x0 {- [code]EDMA sample test application
; e( P* O' {2 V* M2 r7 _ - /*; S; L' M# \/ u
- * edma_test.c
% e4 d8 y% x8 ~. P" o6 Z4 | - *
/ P8 @ Z4 L7 I! N0 o( i; Z) } - * brief EDMA3 Test Application
) Y2 |% l' u( \8 x5 y' f, X - *
4 u* ? ^+ Z: g& ^5 O2 @0 G! a - * This file contains EDMA3 Test code." {" G U) g) r9 i
- *
5 _+ T; S7 |: l6 K7 t& s - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
* A$ y \8 X8 c! ? - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
7 T$ g* L3 X1 u' x) ~1 [. d4 j7 v- |: ^ - * TO CHANGE.. d% X# l/ j6 y. D+ r
- *# ?0 i: [7 f. c
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/- Z( I7 I+ p2 b) D! j
- *4 D) l2 y6 i* O! ]0 j( \
- * This program is free software; you can redistribute it and/or
' W# C5 v7 [/ L8 l1 r8 K - * modify it under the terms of the GNU General Public License as
o6 S# ^( V* g - * published by the Free Software Foundation version 2.- u% i% q# ^4 i+ ?/ o( X
- *
. Z9 U( j8 D) d: {: q - * This program is distributed "as is" WITHOUT ANY WARRANTY of any! P" t; u1 {1 r) ~/ C/ k
- * kind, whether express or implied; without even the implied warranty. G( w+ x. e( Z5 R E, T: [3 \& u
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the. g7 h0 L: J; l* D- u1 C V
- * GNU General Public License for more details.; T1 g) e! d" S
- */9 O1 [% e7 b; u' G! [6 o* Q4 I; r
, r" i# l1 K- Z8 P3 ^, D) L" k! J- #include <linux/module.h>( A: H1 L$ E6 T( p, w* T Y
- #include <linux/init.h>
! j) \) r* Y) r K$ v( N! I. A9 @ - #include <linux/errno.h>/ v( ?% C* y7 K) i- o3 G
- #include <linux/types.h>
8 ~) e' k2 U8 d+ e5 ?/ u( r4 n# V - #include <linux/interrupt.h>
' H: A( }1 B2 {7 v - #include <asm/io.h>- Q6 t" K1 X# z( M+ T% z) L4 J
- #include <linux/moduleparam.h>
( Y3 a6 f4 K9 t. [ - #include <linux/sysctl.h>. F P( e( P! N
- #include <linux/mm.h>
4 \' C j1 s* U0 x) L8 ]) k8 G - #include <linux/dma-mapping.h>0 I- }& ]! Q3 V2 s+ S) Z" h' n
9 x2 l ]. ^! Q: p" U$ Q- #include <mach/memory.h>6 [- i3 t v$ \' Z& I1 ^2 f
- #include <mach/hardware.h>
5 Y* [3 i' P) Y3 [8 R' l+ X - #include <mach/irqs.h>
' A, r/ Y8 }/ q8 ^1 Q - #include <asm/hardware/edma.h>, S) t. x1 [5 a3 w) l3 p
: g! B6 U- h* [: X1 p6 a. M- #undef EDMA3_DEBUG
, }' S: t4 R. U) H, d! A& d - /*#define EDMA3_DEBUG*/9 N& _. t0 o" ^' u/ L
3 o; |/ G6 d1 t# z7 C4 {- #ifdef EDMA3_DEBUG( @5 K' `- b2 b
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
; I* V8 O+ o; k/ b6 T - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
8 m9 G9 Z3 c1 Z/ z. _" U" a+ M - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
0 a( V t, [7 I+ K; O) R - #else
9 W) w1 n. R* M- d7 b. s! [' J: _ - #define DMA_PRINTK( x... )
( `7 z! m+ u, D+ c - #define DMA_FN_IN$ b( v- `5 z$ \" Z
- #define DMA_FN_OUT
9 J7 J5 _0 j$ \% B3 J* k - #endif# O( N& j4 N, C+ }4 N1 p8 |6 m
- ( i8 _3 I( l3 J. S) D" R
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)9 h/ x2 g4 t* U: Y9 s$ D
- #define STATIC_SHIFT 3/ l& w n) c8 q9 M I* P7 _% ]
- #define TCINTEN_SHIFT 200 Q$ d( E' r A
- #define ITCINTEN_SHIFT 21
6 f, F- i4 s1 p5 |- `- h* r- Z - #define TCCHEN_SHIFT 22; q+ s0 N0 r! }( |( T
- #define ITCCHEN_SHIFT 23
" J- l2 N5 S! [7 a; E* e2 B9 O - ) E% B" u. z- d+ W$ f L: Q4 u
- static volatile int irqraised1 = 0;
7 i; z7 H( _, } - static volatile int irqraised2 = 0;
- @: D& `: a0 f2 s- p
; j8 r v" z* E: }. K2 Q4 ^3 x% k- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
9 v% l. v' t9 K8 ` - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);: ~- M* ?1 h- ?
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
+ q. L+ ~. ?: @' I. N W, G) W
u; `4 T0 y x8 Y& c- dma_addr_t dmaphyssrc1 = 0;
/ @/ n7 h9 k H - dma_addr_t dmaphyssrc2 = 0;6 T3 y5 M [) [. v$ n6 F2 s
- dma_addr_t dmaphysdest1 = 0;! w1 k: G- e( V& x
- dma_addr_t dmaphysdest2 = 0;
' ^+ _* g; N- n: {, \ - # n! X9 M8 P$ U7 T
- char *dmabufsrc1 = NULL;
# L4 h- [- d5 r4 o7 F, n4 I+ n6 { - char *dmabufsrc2 = NULL;
p: R3 g. g9 P; G( N/ r - char *dmabufdest1 = NULL;
& o: m' W" b$ o$ ^2 \ - char *dmabufdest2 = NULL;3 V/ \- x. b3 }4 E! N" {
/ \7 J+ @: W- m, a& N% [/ v7 ?- static int acnt = 512;! d" v" p& q& A9 E: ~0 {" i4 P
- static int bcnt = 8;
8 q @7 Y1 U% j s7 M6 D - static int ccnt = 8;2 u7 ?* v( j) J8 I* j4 A6 [) H) e3 A8 B
- 0 H: H0 q+ M$ ~$ B. b* L$ h
- module_param(acnt, int, S_IRUGO);# O& M D5 P% v# Y
- module_param(bcnt, int, S_IRUGO);; k7 h3 i0 G& @
- module_param(ccnt, int, S_IRUGO);
复制代码 ' [+ z1 F" Z- m! J3 D5 ]3 ?( `$ q
) e( R6 {$ D! S9 M
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
: Y r* @; g8 c) {6 X( F9 C: Larm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。3 @0 o. }/ L# i C: ~+ E5 F
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。) t) J4 D5 w6 T) Q
. Q6 w" j! ]2 R, r
1 a- m& C! \, w! r5 D$ a S) z
|
|