|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 . c! G" J* R3 U" K& l
- [code]EDMA sample test application
5 g6 e' k1 o6 c8 V - /*
" s( M, S0 E$ C6 H7 ~ - * edma_test.c
, r4 t6 T0 G4 ?$ Q5 m6 K8 U0 R5 n1 G5 U - * w9 N2 }1 G: v8 \8 b
- * brief EDMA3 Test Application
! w* b. Z/ c, a7 p% H: ?& j6 B1 ]# n - *+ ?( Q* o4 I: M+ \! `: y
- * This file contains EDMA3 Test code.
- `5 J8 d& p6 l4 a' Y - * r6 M' o4 c) e9 Y5 I6 N
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE. B! |" w4 U' C' A6 q- I5 U
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT! ]3 w" k7 B: a3 j
- * TO CHANGE.
8 r$ Q! d. ^5 t* i2 w, t - *
- M b; a' @0 q! n; K - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
- T+ k- z% @0 F - *
- Q) Z' H# u- x4 ]. F4 g& l - * This program is free software; you can redistribute it and/or# T, x7 m1 z+ k( ?7 E
- * modify it under the terms of the GNU General Public License as9 B- H R$ Q4 u' v" @) ], _7 b
- * published by the Free Software Foundation version 2.5 x5 q+ S+ w) q0 E' w* H2 L: z5 K
- *
8 @' I6 h/ _( q1 l+ `7 S2 }6 d - * This program is distributed "as is" WITHOUT ANY WARRANTY of any
9 o X: n- H8 N" n( c1 f9 ?, X/ [ - * kind, whether express or implied; without even the implied warranty
7 h V( l) s$ a7 ^3 _' [ - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* d; f2 p Y5 y8 m: M* s S' f( A - * GNU General Public License for more details.1 q" V; u+ T! @3 H. J4 X2 k% [
- */* T/ J' } g8 Q
% s$ W% A/ c( [# k0 a) u. J- #include <linux/module.h># o0 b' p6 |! S) ^ s& w
- #include <linux/init.h>
" u9 g$ @& q7 E0 ?: g$ I - #include <linux/errno.h>
' I: o! o) z. ^% O; ~2 @% p- d - #include <linux/types.h>* _' N" r1 m8 B Q8 C7 E/ J
- #include <linux/interrupt.h>
; ~0 Y$ W2 o8 j+ T2 G) l - #include <asm/io.h>1 i+ m. P# `3 `7 `5 p1 l
- #include <linux/moduleparam.h>
" z; \" m- m) W, Z' H# H, g3 a - #include <linux/sysctl.h>
- Y, p7 y3 t7 {6 Y% H - #include <linux/mm.h>1 {% F% n0 D3 M( G2 Z* o- u. R, O
- #include <linux/dma-mapping.h>
# y. \5 B! r+ v- P+ i( n; _
. P# Q/ b5 X6 j- B9 w: y& d1 k- #include <mach/memory.h>" }8 i2 T' H/ `2 r* {2 w$ G
- #include <mach/hardware.h>
1 e) q$ A" E0 r - #include <mach/irqs.h>. q7 Z+ x+ V' j& l1 d
- #include <asm/hardware/edma.h>
! Q9 m5 m3 V/ R$ |3 ^3 N# q) l - 6 @# W4 {4 |+ [0 m: _3 ?& y
- #undef EDMA3_DEBUG
; R, a- D* P% b. O2 T; Q - /*#define EDMA3_DEBUG*/
- W; M8 ~" N4 Y9 e. p+ [
+ V& R! s$ H" K7 Z4 ~- #ifdef EDMA3_DEBUG( w; y% B3 F+ r- T. X( h
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS) L" I" E' ]" A( Z4 ?3 F
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
v; g/ S: \" @ - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)% x! c# n$ @. [0 e) j* G
- #else! Q0 _( y6 h4 _ g0 s5 _
- #define DMA_PRINTK( x... ): x9 J9 ` r# Q. `$ i! C6 ^2 ?
- #define DMA_FN_IN+ W: Z6 H9 {1 o) W7 V6 S
- #define DMA_FN_OUT* S5 ?6 r" R/ P5 K' F
- #endif7 @9 g5 J& w5 X+ q
2 ?1 H8 H9 q( u8 j- #define MAX_DMA_TRANSFER_IN_BYTES (32768)& F5 v1 q# N, @# ^
- #define STATIC_SHIFT 3
8 a8 o: b6 J h% I% v* t! D5 e - #define TCINTEN_SHIFT 20' s+ \8 V4 l( a) ?8 V5 Y+ p
- #define ITCINTEN_SHIFT 21* ~0 ^+ ]/ y Q
- #define TCCHEN_SHIFT 222 L$ m# x$ D: J. Z2 C* l. h
- #define ITCCHEN_SHIFT 238 P/ t* i' J" w( c
- 2 E* a0 R3 J+ U6 a z+ ^
- static volatile int irqraised1 = 0;
: A* ?0 F! I8 Q. {7 `, G/ E- d - static volatile int irqraised2 = 0;5 @* _# D4 r) C+ D D. p8 C% j7 C
( A$ I6 [/ D; b- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
6 c9 a* G/ w+ v" k - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
$ o0 `$ Q4 s& p" b( ~ - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);9 c$ t, E& L9 C* K: ^
* ?' E& F4 \. K; m" `1 L- dma_addr_t dmaphyssrc1 = 0;
, \, [+ P0 c# t4 C - dma_addr_t dmaphyssrc2 = 0;
6 m, h" J( O1 y( m; I4 J - dma_addr_t dmaphysdest1 = 0;0 e: E2 K" c. e/ N3 L: u
- dma_addr_t dmaphysdest2 = 0;
7 \7 X9 M; F; b. h7 g" p" ? - 9 ]1 t" N2 m$ O# b, ~2 m
- char *dmabufsrc1 = NULL;5 \7 w" y1 D; i Z3 N
- char *dmabufsrc2 = NULL;
9 W0 D0 C% ~! c& Z+ _0 `+ W - char *dmabufdest1 = NULL;
. {0 p+ {2 J3 H% m9 y - char *dmabufdest2 = NULL;
: f) C P2 h y) w" W2 Z# w3 L8 w - / |" z: m( B# K$ M2 b7 [
- static int acnt = 512;. a, \+ Y5 a8 [6 G6 G: H4 s9 H
- static int bcnt = 8;; Z4 @: e% ?7 A: F# J B
- static int ccnt = 8;
2 e6 _+ k& y5 @* L! X. K - & d! e- b9 r: B/ C3 G+ o! y
- module_param(acnt, int, S_IRUGO);
& k# s5 e- |$ p7 E - module_param(bcnt, int, S_IRUGO);: n* ]7 A% I. H; B. g
- module_param(ccnt, int, S_IRUGO);
复制代码
7 @/ i+ Z2 O+ L' n4 l1 _& q, q# X/ X5 V
8 M% ~9 W# N3 L/ k3 `$ { 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
; p- U) Y# D+ C! H* @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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。" a! `6 `- N a) f7 e3 `8 ^2 P; H+ x
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。9 q4 i; T7 L9 Z0 z! L
/ B `! p. ?; o4 u: y
9 E& O- `6 N$ g J' Y" ]( d" o6 `) N |
|