|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
5 r1 C3 Z p& | {% O& f- [code]EDMA sample test application
2 |( _6 e4 P& V3 m# n - /*, F& \4 D3 J" H: j0 v
- * edma_test.c
$ i4 o% Z4 b3 Y0 j5 o - *
) i8 t5 ^9 b1 B$ ^7 f( W - * brief EDMA3 Test Application. s, @/ r' B% E2 |, L
- *, o7 J! [/ x* m% n& k' R+ X
- * This file contains EDMA3 Test code.
, l7 T1 U, t% z4 V6 l - *
: J! o+ u; R( ~' f8 L - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE! x' B% J1 l3 h
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
# f+ w7 D: F7 \6 j) L y) o" Q - * TO CHANGE.8 ~( }3 ], M- \* r8 V/ u' ?( E+ L! z- Z
- */ F" a1 M! ~4 p; Y, J% c d
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
1 L/ A% f, i, @9 }+ v, Z - *- }; m+ |) @! f1 m3 u' ~) U
- * This program is free software; you can redistribute it and/or7 V3 P1 w8 H- U" s' R4 E! H' r
- * modify it under the terms of the GNU General Public License as, z6 m& M! l8 S+ Q# C9 u/ m! y1 H
- * published by the Free Software Foundation version 2.
% H7 ?( h$ r- ?* E8 { - *
& P) i) h a5 k1 e) T5 T/ v - * This program is distributed "as is" WITHOUT ANY WARRANTY of any
7 p5 L" `0 V% A8 F% B L - * kind, whether express or implied; without even the implied warranty% w1 P) u/ M$ S. s2 @
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
% t1 h9 X/ W$ }5 a0 d+ y6 m - * GNU General Public License for more details.
1 x3 S7 g2 C% D( s! P - */
) K7 g4 _8 \2 D1 s
J2 f, i2 @! l6 W$ e- #include <linux/module.h>
2 J' J' @6 d- ~ - #include <linux/init.h>" l! P: E; j Q4 p" E
- #include <linux/errno.h>$ h5 ?# S7 ~1 T. ~
- #include <linux/types.h>! t+ o& k5 g4 n! L/ U. m8 N
- #include <linux/interrupt.h>) r; Y' ]: n1 X! H
- #include <asm/io.h>7 l) A5 G' [1 C5 D5 s$ \
- #include <linux/moduleparam.h>; h2 O1 V$ R9 ? K% \& E. O
- #include <linux/sysctl.h>
5 w q! [# V$ H6 q- c - #include <linux/mm.h>) K) d4 [) i: s" }
- #include <linux/dma-mapping.h>2 k: }, j' G4 _/ R5 l
/ e; }) }3 p( l) F- #include <mach/memory.h>
z$ @4 T3 m& v/ t5 @2 V6 |4 ]& U - #include <mach/hardware.h>
& A5 V* f6 u. p9 m: A0 m - #include <mach/irqs.h>2 j+ W, b4 y) S" c# K6 z4 ?
- #include <asm/hardware/edma.h> f2 R2 @* ^( a1 M+ O1 { b
% e+ r$ b; |$ P2 H% } X- #undef EDMA3_DEBUG3 [4 m" w& `& U% r5 ^! V o& b
- /*#define EDMA3_DEBUG*/, }, o$ x E% M5 G' X
- 2 X2 @" P, ^3 V" Y( z% H! i
- #ifdef EDMA3_DEBUG
8 P |1 A3 m9 u( {$ t - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
9 G9 B; n) e% G& c9 w - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
7 N$ _/ `5 o2 p - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
) i! Y$ R- g! W( l3 E- x& C - #else
4 r% ~0 f/ {2 V: n6 J' W2 T( l - #define DMA_PRINTK( x... )8 {1 L* A/ Y1 N* g+ d8 \4 l3 a
- #define DMA_FN_IN
; {/ f5 P$ Y) ?, }+ W0 q* f - #define DMA_FN_OUT3 K i7 t% s" R1 x, u5 O
- #endif6 h, x% h3 h6 s+ i
- 9 u' Z4 X( o! O/ b9 F3 M' P
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
8 x# d# x9 {; t' R0 i/ u$ y% R" U - #define STATIC_SHIFT 3
! Y! B8 t; K8 [1 x - #define TCINTEN_SHIFT 20
( f% }# j& s' ? - #define ITCINTEN_SHIFT 21
- l3 ^4 p2 }/ v* ? - #define TCCHEN_SHIFT 222 d6 P, W/ Z- V1 p* M
- #define ITCCHEN_SHIFT 23
$ H3 o* ?* J" `: D' d5 F* u
' Y& ]; o2 K4 ~2 }1 w- static volatile int irqraised1 = 0;$ L* f1 [4 ?8 n" p" H9 c$ C
- static volatile int irqraised2 = 0;5 e, U6 U2 L, m/ d& l. H) L1 k
- - v) U1 g9 X7 C5 o5 a/ C
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);( q3 Q# Y I y5 C
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
" E8 `) O2 }6 a" d% q( | - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);! p! U9 V$ M. ~5 N) I
* I! S% r/ y' r- dma_addr_t dmaphyssrc1 = 0;
. b* @( |- O! O; X& Z1 N1 } - dma_addr_t dmaphyssrc2 = 0;
) i* I- d/ T5 y) w* @' A q - dma_addr_t dmaphysdest1 = 0;
9 M6 ^% \. o% T3 B& v - dma_addr_t dmaphysdest2 = 0;
9 ?( ]8 u/ h" J" C - : r$ \( Q H" Q
- char *dmabufsrc1 = NULL;
$ W6 @2 ?1 k4 ?, ~' c# k# B% Z% ` - char *dmabufsrc2 = NULL;
5 `" u7 F% E$ d2 F/ i! ?" [ - char *dmabufdest1 = NULL;, Q& l- v) _4 r' P* a/ r
- char *dmabufdest2 = NULL;9 o4 ?! k x5 Z6 C5 V! s, p
7 t5 e# u: P- `- x* l- static int acnt = 512;8 |: K; B6 }) t: F( l
- static int bcnt = 8;3 b. L- b- j. t) m
- static int ccnt = 8;1 Q1 Z+ h* C& P7 d' S
- $ w0 p$ |. w R1 b1 f
- module_param(acnt, int, S_IRUGO);
9 ]# B9 M: n" a2 Z( g+ k - module_param(bcnt, int, S_IRUGO);
$ L. k' X! X6 t$ y3 Q3 Q4 W$ W - module_param(ccnt, int, S_IRUGO);
复制代码 ' K( A$ F" Q7 D# r4 u2 p* o/ G
2 O( c% B; b0 X5 \ 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用- V8 R' `$ T" i/ C T0 q
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。# M4 v3 X2 v9 b: n1 y4 b/ J
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。- v% [! W! E! o3 G
2 ~* w/ _8 d; h1 z' H$ K
& B6 j4 j3 z' X ]; s3 B7 u |
|