|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
% M0 `! b( y4 D6 J- [code]EDMA sample test application
$ m( w0 g' {, J* v2 _- z - /*8 x' C( v0 E: ~1 s5 N7 D( r
- * edma_test.c
' p \% M0 p0 C2 k5 |& U2 [/ Z - *
! |9 d! ]* t" Q - * brief EDMA3 Test Application
& q, ?4 \8 C. q& W4 e; P% Q - *
* U6 }& J. i8 N O6 e - * This file contains EDMA3 Test code.
% V2 l! s/ c+ m) A- f4 f - *! ?$ z5 z" Z7 |2 {1 K
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
4 |2 \' K/ s2 g7 r - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT3 E7 R5 P/ G/ @( L I/ j/ ?# Y
- * TO CHANGE.
' @4 H. y: ~( h+ C - *" a3 ?% e+ ^" q. A0 |
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
( e! @6 Z' \. h5 E" r - *
6 G( t" r5 G; d* X2 b5 T* u3 s - * This program is free software; you can redistribute it and/or! u, i) |7 J2 }! h
- * modify it under the terms of the GNU General Public License as& ` W8 t2 S2 {; i( }, A
- * published by the Free Software Foundation version 2.
8 R* D& m% Q( S' c% K. M - *# n! R6 G% j8 }$ C6 I2 c- M
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any# Z7 f1 z$ D6 a# P, T. _, M1 W
- * kind, whether express or implied; without even the implied warranty
4 c+ y9 F# z3 _/ u. Y7 r" @ - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
7 L+ b/ [7 z& t* Q! S2 Y - * GNU General Public License for more details.
- q; @( k. p" @ - */ }/ v a, @+ s) ?
- , I% J+ w0 ?4 W, P. K, ?( E
- #include <linux/module.h>
( |' X% ~ K2 G: x. M# B - #include <linux/init.h>
8 Q+ n' n! r! P; i0 M - #include <linux/errno.h>
' t4 y5 S. ~9 @8 @/ C: B - #include <linux/types.h>
) j2 M3 h" V+ l - #include <linux/interrupt.h>5 ]3 G! z1 K. p4 L. }
- #include <asm/io.h>! O' Z; ~( N4 H w @
- #include <linux/moduleparam.h>6 t, ?1 U! v9 n- y
- #include <linux/sysctl.h>( i I3 J. X1 ]# O) [
- #include <linux/mm.h>
# `$ J0 s: O. f/ x# @ - #include <linux/dma-mapping.h>% V1 M9 [1 o8 `2 N" Q) U2 ~
0 ]* N \" k1 k `! @7 {1 _' ~# k- #include <mach/memory.h>
3 L5 M- t/ C1 E. F' T5 U8 N - #include <mach/hardware.h>
x; K* P7 x1 V; u9 y - #include <mach/irqs.h>
) Q4 N* I: G! p$ Y: |+ Q: { - #include <asm/hardware/edma.h>1 M5 v! V# Q( I) Z- T$ C5 k9 G
0 p8 Y4 X" m7 o! r- H- #undef EDMA3_DEBUG
8 O! Y6 Z \- W# m - /*#define EDMA3_DEBUG*/
6 m6 m7 W/ Y6 B+ G* t" h/ I0 V - 6 X. W7 y7 h. o9 i7 j) w$ x) }
- #ifdef EDMA3_DEBUG
" R0 @8 R9 y6 r H% Q - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)2 D2 i, e# R$ L0 y
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)( ~6 v8 E- w6 A4 F
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)6 l; c, |, O/ G: Z, z- F
- #else6 o4 L# u) u: ]* k
- #define DMA_PRINTK( x... )& D5 i" j6 [ b" Q
- #define DMA_FN_IN
6 n) A2 }+ l$ ?1 I. q0 t" @) T% r - #define DMA_FN_OUT8 s) j8 V6 [1 i9 q7 _5 g, k$ U! S5 J: s
- #endif
\! c* v4 o% K
$ p( i3 b6 O I# }! j- D. u; m- #define MAX_DMA_TRANSFER_IN_BYTES (32768)2 [5 T& i. m) N$ f6 S% c
- #define STATIC_SHIFT 3
6 a4 P0 J) F2 c( g# O9 g - #define TCINTEN_SHIFT 20
$ @+ T4 e* u2 Y - #define ITCINTEN_SHIFT 21
- J8 R( [$ Q @- E! ? ~; C - #define TCCHEN_SHIFT 22
$ r; O" @: F! T6 k( |- N - #define ITCCHEN_SHIFT 23
) {1 P+ Z; p. T1 S7 s - + G' k5 T- v( |8 p! Z, H
- static volatile int irqraised1 = 0;
. B- _3 x% D* Q8 Q* e - static volatile int irqraised2 = 0;. c; j4 r; P" e+ Y( ^; l/ G. x, |6 m8 @' [
$ {2 X# D" d+ V' r- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
, R. ]4 R5 W2 H6 P0 s, Z. Y5 J - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
2 h2 v9 i& O8 \/ |2 q l. g. v - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);+ g+ P$ b' ]7 x: F
- & c3 D1 u1 {' L' f
- dma_addr_t dmaphyssrc1 = 0;
1 l* w' S; P6 i! R# |- i# U - dma_addr_t dmaphyssrc2 = 0;! e8 \8 P( g0 C a+ [6 R9 \6 O' s
- dma_addr_t dmaphysdest1 = 0;
/ T: [+ O' \1 A - dma_addr_t dmaphysdest2 = 0;
$ ?: W; _: G, U. r* H1 P, _ - $ y% @2 Z P' ^) B" q
- char *dmabufsrc1 = NULL;
- j3 U7 z9 K; [. ^5 s - char *dmabufsrc2 = NULL;0 L& e" A+ u% f1 `* p# B
- char *dmabufdest1 = NULL;% B( t# Y$ C* P+ p
- char *dmabufdest2 = NULL;: W( @ c$ @ s2 a5 [# b
- $ o9 a9 B& Y9 q) L: M3 ]
- static int acnt = 512;4 J4 T; K5 |4 W
- static int bcnt = 8;7 G" c$ y3 [# j4 \' O
- static int ccnt = 8;
4 v6 s& J, a* \( m) z
8 e5 i' r( r4 @9 g) T- r: L# [- module_param(acnt, int, S_IRUGO);
- V( J. k5 Y. z- ?5 J3 B$ C - module_param(bcnt, int, S_IRUGO);
. r$ l6 _7 `/ ?* ? n1 y" B8 E - module_param(ccnt, int, S_IRUGO);
复制代码 W5 e' V- Z3 L
' h( t& z3 {5 k0 ^5 ?' f% D
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用6 f, Y: ^3 A8 p$ J2 \8 i
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。, w0 a7 T( l5 u2 c
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
( K* e& @9 G& x7 P# _2 Z4 q" U9 L5 ?" \. h! w/ _) w' ~% F
+ n3 A9 _2 |& r |
|