|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 % x, `& |3 S6 X7 L/ l( y; w, G) N
- [code]EDMA sample test application; B4 Z7 V; S: P I" L) A; U8 ?# O
- /*3 [8 k9 h9 J' y1 g* J8 M* r
- * edma_test.c
' ]% F9 w M8 c9 p8 G. d, @, x - *
& c% C! D' ~$ v9 c - * brief EDMA3 Test Application* M2 U o6 \ g# Y# t( Q/ m* F. u
- *
* Q! {5 S7 n' I2 k - * This file contains EDMA3 Test code.8 S! d! G* b( M' C; M2 A/ L
- *, y; o5 b* K( r& T* w1 i$ {# I
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
; K; q7 i. {" z6 p - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT! a$ r* Q0 I$ { K* _' y; E5 a5 m8 G: {
- * TO CHANGE.8 C9 C, m( }7 U- N1 g: Y
- *
& O7 T/ L y7 Q) N - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
- D; C' V3 W/ m9 H8 B - *
- t! R5 \" I8 A - * This program is free software; you can redistribute it and/or
7 U1 E$ S: w+ C& ~& a$ g9 W7 v6 d - * modify it under the terms of the GNU General Public License as
, p' `. \: f1 N7 b8 m6 D" c - * published by the Free Software Foundation version 2.
/ e, T' \4 f$ w2 o& I0 ?9 H4 n - *
" {, \8 e9 D2 f" x6 z4 m - * This program is distributed "as is" WITHOUT ANY WARRANTY of any. I3 [( l, C9 F6 m3 j
- * kind, whether express or implied; without even the implied warranty
7 C8 g! o6 ~% |& l5 t - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+ F: t. Q1 w3 M# h
- * GNU General Public License for more details.- b9 @; s) { }
- */$ t7 N$ w( _6 ~( R+ I% |2 o
t# g( f W9 `7 \ L4 u( r( n+ J- #include <linux/module.h>
% |8 D, q! O0 Q. s: z) W$ x - #include <linux/init.h>: y8 l9 Q) f$ J4 i, M2 C1 |, V
- #include <linux/errno.h>
3 s; u+ n( k) f3 W, D- }/ ?, a7 y - #include <linux/types.h>2 p) G+ m, w K4 t
- #include <linux/interrupt.h>3 ]' Y/ \# I# _. n6 ?3 D
- #include <asm/io.h>! O' P0 W: R( b. {
- #include <linux/moduleparam.h>; L9 f( `( g2 l6 ^/ A
- #include <linux/sysctl.h>' h1 W5 d9 k) B! K+ z. [! N% w4 e
- #include <linux/mm.h>
$ N! Y' z* B% G - #include <linux/dma-mapping.h>( F; T+ ~; Z t3 W E+ t; k
# n3 c# b. Q0 Y) h5 B( F; s- #include <mach/memory.h># v- p' f0 r. h- R9 w
- #include <mach/hardware.h>
- v# b" s+ P2 N( j+ g# K - #include <mach/irqs.h>4 B7 f, V7 F0 d! q; G- W
- #include <asm/hardware/edma.h>5 }8 {' ^4 Q& I/ U5 c
- D+ |! C- B7 w2 O
- #undef EDMA3_DEBUG
8 f# i: ^( r% s+ p+ b - /*#define EDMA3_DEBUG*/
- Y& w* m! R5 H - + a7 ~3 ^" {7 N% j
- #ifdef EDMA3_DEBUG) h% M, s/ D* Q
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS). z4 V- u9 S L1 L
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
% X+ G0 J1 u1 |% p+ u - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__); o/ ~3 N( T' K- Z* D" |
- #else# O1 L/ G, ~/ o1 y6 v3 o- d$ L
- #define DMA_PRINTK( x... )
6 _5 N# w( W1 ?/ _ - #define DMA_FN_IN
, \; H* `- Q" k W! A" o3 B" ? - #define DMA_FN_OUT4 W7 `. G! F! S& k
- #endif) v7 n% [6 K2 Z6 a% U7 ^( n
- ! ~. W8 b* z v
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
8 |. E: a$ B7 j6 l - #define STATIC_SHIFT 3
e& D9 A3 ?* @8 N - #define TCINTEN_SHIFT 20* R: z' t( R4 e) b5 O7 H' M$ h! c
- #define ITCINTEN_SHIFT 21
; M9 O' k9 L$ m- {) K$ h1 @ - #define TCCHEN_SHIFT 22
) {" F8 p# Y8 l0 | - #define ITCCHEN_SHIFT 23
; T$ t& P. O' m4 H: a+ [/ N% T6 } - ; D7 M* s3 p9 v6 ^
- static volatile int irqraised1 = 0;0 Z) h1 O; P! N- V; ~& c
- static volatile int irqraised2 = 0;
: ^/ Z9 Y, ?! t. A7 c/ p3 w
, n+ T9 `3 t6 W+ n: L- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);$ z( n }- D. u$ [* t6 X
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
1 m3 @1 D* o- m8 U0 D/ w7 C9 U3 s - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);+ R# v- _$ t* ^) a
; M. V$ ?7 k$ e, |+ E- dma_addr_t dmaphyssrc1 = 0;
) X [8 n5 W, {5 g/ Q l7 B, P# n - dma_addr_t dmaphyssrc2 = 0;
) U3 q T( q1 k( }$ n - dma_addr_t dmaphysdest1 = 0;
4 I2 g+ z7 X0 g - dma_addr_t dmaphysdest2 = 0;5 l+ W0 j' n0 q# T
7 C5 A+ q! A+ M2 Y! q( c4 Y8 D- char *dmabufsrc1 = NULL;
9 a7 s( X4 ^: F' G1 o - char *dmabufsrc2 = NULL;* b& R1 x% ~1 |8 v( @1 j
- char *dmabufdest1 = NULL; s3 Z/ L6 w2 h5 F
- char *dmabufdest2 = NULL;
' \ N$ A& [4 n- M/ S f. ?6 R: V - ! e r' b. S; ?$ {* {9 t
- static int acnt = 512;
" K# E; a( ^" p' A9 {) r. ] - static int bcnt = 8;" K; d% n- y$ f m9 |) ]! T6 [
- static int ccnt = 8;+ m! p1 X0 |5 j% v2 m/ i7 J, Q
- 5 M1 ` k3 R' w7 [6 v! j
- module_param(acnt, int, S_IRUGO);* P( p% _0 X3 v& B
- module_param(bcnt, int, S_IRUGO);
: J/ {; A* S0 |0 r/ x- m- u - module_param(ccnt, int, S_IRUGO);
复制代码
" |9 w- [7 y v- s) W; C, m: | K& {
/ F- |- i4 {( j 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
) R9 b( E5 H& j0 z: Oarm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
+ M# R9 f6 ]8 W9 B 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。6 J, l2 r# t6 h6 V$ W Y- k0 L
* A$ X1 L- I- ]1 @0 Z2 [, G5 T2 S) X7 h1 d5 ]% t! T2 g8 Y
|
|