|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 $ p- z# n$ u8 |0 K5 T* k
- [code]EDMA sample test application* R8 L: e0 T( j+ b6 ?
- /*
) J8 k' r, i, T - * edma_test.c
2 X9 V1 l+ ?. ^( G" P! ` - *% {9 R7 K9 x: S6 i& Q
- * brief EDMA3 Test Application
( ?% t6 ^( z5 X& y2 e - *
# p7 @! n" h) O" {' s. n! L1 A8 ?$ p. q% Q* g - * This file contains EDMA3 Test code.6 J% K) x5 ~0 t; ?% P
- *5 f% N: f) V/ g
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE7 Q6 ]! f6 X( T/ E0 N8 b8 t
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT; I) M& c* \4 |: N3 I
- * TO CHANGE.
+ ?$ h( h( d4 a - *
& P5 z$ R6 j' O0 w0 p& e3 U$ ]6 s& z - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/! }0 H( K* h$ c; M8 U3 N
- *
9 S0 J: y# D% N - * This program is free software; you can redistribute it and/or
! v4 k( C% \* z+ n5 c+ o - * modify it under the terms of the GNU General Public License as
& H1 y+ D6 s! f2 {: y+ c% t - * published by the Free Software Foundation version 2.9 [8 Y. R/ v/ L" Z0 f5 T: b" F) x
- *
7 I9 Y7 W( ~% p - * This program is distributed "as is" WITHOUT ANY WARRANTY of any
n/ @8 C& u% b3 I8 _( a2 ?1 k& O - * kind, whether express or implied; without even the implied warranty: y6 B3 g& ~# Y! c0 W: \; W- ^- a* |
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
$ M; G' j+ r1 L - * GNU General Public License for more details.2 L" J- ?2 a! n
- */) M0 q1 h" z- `+ n( {( I8 t
- k: ?7 [5 w2 i' ?( P6 l5 E3 G0 [; D
- #include <linux/module.h>' h8 @' z1 C/ [5 }) d
- #include <linux/init.h>
, x6 L2 m* B4 g - #include <linux/errno.h>
, r0 @5 L( i% o - #include <linux/types.h>( F% d5 g+ s8 s9 I# K" w" R9 d5 U: ]
- #include <linux/interrupt.h>& x u8 F% N5 g& ?# |' m8 [' s
- #include <asm/io.h>; C: A, N4 s F/ S/ {
- #include <linux/moduleparam.h>* U# t; L" N1 ]7 U- N
- #include <linux/sysctl.h>
' e! s/ r+ H; n) m9 B4 k - #include <linux/mm.h>% e6 V! V; s1 D' q. [ n5 k! ^
- #include <linux/dma-mapping.h>5 B+ H9 f3 j3 z- R" G, ]
8 _2 b! Z$ H4 g9 N- #include <mach/memory.h>
0 o7 I* [7 u' m4 F - #include <mach/hardware.h>
) B8 A( t0 V p- T7 u - #include <mach/irqs.h>, K! ?3 F# J8 H2 f
- #include <asm/hardware/edma.h>
- j# K7 \# b; E2 K% q& O - " V1 t7 ~$ C1 d& C: H2 L
- #undef EDMA3_DEBUG
8 R. O+ m- g% ]& O+ U6 v# ] - /*#define EDMA3_DEBUG*/1 f) Y* a1 _9 V; \" c( O7 Q& [3 q
V X8 @" B3 ~9 [# K- #ifdef EDMA3_DEBUG/ T1 k" ~+ V, S. {- t! }
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)/ e8 Y* S) Z M# z0 ~0 _/ {
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
: [6 M0 @1 W& |5 E6 T9 x2 W5 e - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
; t9 G/ ? b, j! ` - #else
9 y3 X' M3 `0 s% m6 O# p/ q - #define DMA_PRINTK( x... )
: U' Y8 g# c8 A* |# Y; w* I - #define DMA_FN_IN/ s& n% ]3 Y9 G
- #define DMA_FN_OUT& }( ^4 l" j9 O' j: i
- #endif0 |$ r- a" i* Z2 f7 B1 a0 l0 c
- + w8 G8 _* @2 y& G& r0 U5 |4 y1 w+ [
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
, D; O! n. y) \' T! L# c - #define STATIC_SHIFT 38 T& u* U- A) e. Q' T# O
- #define TCINTEN_SHIFT 20* F9 I2 z0 s. z' s p
- #define ITCINTEN_SHIFT 21- k4 V7 o& |. [
- #define TCCHEN_SHIFT 22 I) e5 q+ F7 j
- #define ITCCHEN_SHIFT 237 T# }# B: [" c. ?' C0 e
/ S$ F( E: m: ~3 T% o$ P' N- static volatile int irqraised1 = 0;( R2 g, Y! f% P0 B6 }
- static volatile int irqraised2 = 0;
4 p4 j4 M. Q$ z' m3 m/ h - : l0 D. P& H& ?- Y. _- ?( s8 p2 A; t
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);# x8 }' h8 { f+ k
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);# X& X& ^/ {. j
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue); S2 R# D3 N, B6 l
; w$ n8 Q2 O1 J+ I- s8 Q* {- dma_addr_t dmaphyssrc1 = 0;
* C: S+ k* ~/ C2 n! G - dma_addr_t dmaphyssrc2 = 0;5 f9 B9 M% j0 v/ ]. d
- dma_addr_t dmaphysdest1 = 0;7 i% B$ u! c7 i; h+ s, X# c
- dma_addr_t dmaphysdest2 = 0; A5 l8 ?9 J5 d) s8 S0 A' L
$ v5 s5 x6 U; J# o8 @- char *dmabufsrc1 = NULL;
& C( x* M& m" H& G - char *dmabufsrc2 = NULL;: t# V, J0 u: M S1 @& p
- char *dmabufdest1 = NULL;
, c9 b L7 T1 Z# k+ H+ ] - char *dmabufdest2 = NULL;& |9 z7 I3 t4 z) X9 ]) C" N/ b% F( o( j
- 3 K0 A! S2 k* M
- static int acnt = 512;
6 f* `* {( C: k' w6 O - static int bcnt = 8;
) w$ ~. e" S% @4 K - static int ccnt = 8;
1 }7 u$ r( p" t6 |+ k6 i - ! N& }$ ]* _; ^ R! t* A% x
- module_param(acnt, int, S_IRUGO);
_# p) \7 |- V: S- ? - module_param(bcnt, int, S_IRUGO);! b, f ?2 R N! W: d
- module_param(ccnt, int, S_IRUGO);
复制代码 * J% [6 E5 w4 V1 l2 W5 s
% L J+ q, U! m/ a2 L 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
$ N2 U" J# H- J3 m/ Jarm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。" @/ i, i4 W4 F6 i. t9 g; [
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。/ w( b" g4 y3 z6 u8 P/ y, K( D
$ }9 _7 o3 w V' R6 ]: _: v+ y
E* k9 \4 N& z. b( m+ `7 v* F
|
|