|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
! q7 m$ f4 A' p! r- [code]EDMA sample test application
: h: @9 b8 c' M3 {: ~/ S - /*- i) E" B- l! _3 L; E
- * edma_test.c, q0 Q- ]9 f* b, L
- *
6 |4 s& u; k1 F7 p. F - * brief EDMA3 Test Application
: O5 F6 t2 w, t - * ~$ Q6 y: W$ ^" C5 r
- * This file contains EDMA3 Test code.6 `' A$ x9 z+ U" ^
- *
. B" ?" H+ Z% G - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE; ?+ G, }$ H3 E r q' g* h
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT- U8 f8 G, B1 U; F9 c$ o" w
- * TO CHANGE.
& p% M( ]- [4 l- J9 C3 G. c - *$ M" x, y/ l$ i7 l
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/% p/ u, J- h [7 i/ g
- *
- g- i% R2 T( b+ w - * This program is free software; you can redistribute it and/or
" I( v$ _, E/ L6 N" j8 l! J: k - * modify it under the terms of the GNU General Public License as
+ M& \+ ^/ _+ s* M - * published by the Free Software Foundation version 2." y L, H9 a3 k9 e3 \1 B
- *9 d; _6 t3 w6 @! x; c
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any' O* L7 U0 |/ r) \" h* I5 v$ K
- * kind, whether express or implied; without even the implied warranty# y/ m( u9 d" i+ g& l3 r- o
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the5 Y; A( ] x* m3 n1 \
- * GNU General Public License for more details.
( _& U5 V: s1 @) N3 v. V - */( n) x. {. I% {* v& `, Q7 F
' I6 T; T3 ^8 _. R% [' `- #include <linux/module.h>
6 d" [; I1 b$ J2 F) B, [% ? - #include <linux/init.h>$ g' ]" Q- d0 V g2 C4 F
- #include <linux/errno.h> S7 y3 E8 `, q# ^' S" ^, j z, o
- #include <linux/types.h>3 C. V& N, ^5 A2 R7 H7 |. _% e
- #include <linux/interrupt.h>8 v4 z( y8 q7 f. O4 Y( W0 {6 y( [
- #include <asm/io.h>
/ ^, }5 d8 ?! n' o! e - #include <linux/moduleparam.h>! W! p! A2 ]7 ?8 I6 }8 [5 }
- #include <linux/sysctl.h>
* m0 L1 l8 Y$ ^+ Z" q7 t3 } - #include <linux/mm.h>$ b$ |- c$ a) D1 ^
- #include <linux/dma-mapping.h>
6 B7 c- A& b8 j" L
8 P& t) ]1 Z$ q% t( H7 D7 v3 Q) ^- #include <mach/memory.h>
2 l0 F) |4 g5 { - #include <mach/hardware.h>
0 N0 s4 A2 V2 v% ^! U7 r - #include <mach/irqs.h>
1 C1 b$ n; C6 B# [ - #include <asm/hardware/edma.h>& g/ d+ o6 [1 G9 B) y
- - u4 i) X* @' ^( {
- #undef EDMA3_DEBUG9 l* `& J* r- M( F
- /*#define EDMA3_DEBUG*/: i9 {" o( L5 ~3 I
6 @+ L; |, r3 j4 Q" F- #ifdef EDMA3_DEBUG4 ]+ j5 ~# Z% h% u7 f5 _0 ^
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
) w/ v: q0 b1 @9 [- [9 v - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
* o: w& ~& o) \, e# N+ W - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
I4 A* D8 P0 O3 L& P' |2 D/ \7 a - #else
$ m) n1 ` G: X4 i: g( s9 @ - #define DMA_PRINTK( x... ) a: [- r( I x/ B/ t. b# b# y
- #define DMA_FN_IN0 `! U5 J& _ z: N+ Z6 M* y2 t. ^
- #define DMA_FN_OUT
7 @7 n; u- \# g" D3 L, _2 { - #endif' t3 ?% D* Q x& B/ Y6 s
- - y& m4 ^% i% @8 E5 P% X# n4 U
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
4 H( O4 X; n! _) d - #define STATIC_SHIFT 33 N! T. W4 E5 O6 D- _
- #define TCINTEN_SHIFT 20
3 u4 L g$ f/ D" n* v; b - #define ITCINTEN_SHIFT 21" Y( D" F8 J- h
- #define TCCHEN_SHIFT 22
+ `$ O# ?# A8 D' m - #define ITCCHEN_SHIFT 23
& f5 o6 X- T4 Y - 3 Z8 P7 F/ r- |% {
- static volatile int irqraised1 = 0;
* D& [" k4 F" c8 _" Q6 L+ E: {* O3 O - static volatile int irqraised2 = 0;
% R7 ?4 H0 f0 i2 e
, G3 V5 K* I2 E' j' w! z- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);/ x7 ~% ~0 P$ z
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);5 b. t, ?$ I# S
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);% s- i/ g% F. ]; L
: w1 R& X% J' n- dma_addr_t dmaphyssrc1 = 0;
5 W( J: L* K+ o! X# T: b: k. z - dma_addr_t dmaphyssrc2 = 0;9 {, D0 S4 t$ B" |+ O" P; p
- dma_addr_t dmaphysdest1 = 0;
2 m' P4 s- s6 t e - dma_addr_t dmaphysdest2 = 0;
9 o" `- `, f7 t; |1 t6 t
4 k9 V% L f; m/ f4 D# l6 ]- char *dmabufsrc1 = NULL;; J' R- M( [1 p! ?
- char *dmabufsrc2 = NULL;
0 q% q) e4 k& [6 F3 l/ L# Z - char *dmabufdest1 = NULL;" ]( B, j! \4 D: x
- char *dmabufdest2 = NULL;
7 Y: R6 g3 Q. N6 `8 \6 Z
9 A8 F+ g! ?0 ^) H3 D- static int acnt = 512;
2 T: |0 f0 K- C0 d - static int bcnt = 8;
% F7 M/ d6 Q) \# M( @ - static int ccnt = 8;; ?" i3 Z; h# m. h. y
" P- H% D1 g1 A; {8 r7 _- F& i- module_param(acnt, int, S_IRUGO);
. a9 s4 T i5 v7 L1 s - module_param(bcnt, int, S_IRUGO);' ?3 p* v0 p; f* e3 c c
- module_param(ccnt, int, S_IRUGO);
复制代码
! n6 w' i! f/ S; {* G, M* c" c
& t# p. G" g+ N& ^3 Q 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
% Q! C, r( g8 V- e; e4 narm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
' l' j' F( t5 L% e8 j% A 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
# d& h9 e* o# k7 \5 b
& [! H0 z U4 y/ U* G
! z- g; W$ |7 o |
|