|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
( t. D7 X& H# F. b# i, i- [code]EDMA sample test application3 X: H2 p4 L9 ]6 G3 X5 p
- /*; T) v; q8 i' t
- * edma_test.c" Z% B5 c( r$ a c* z+ K* \; c
- *
7 }7 W6 X/ V" E - * brief EDMA3 Test Application
7 ]1 o1 J( C6 z3 ?- O" C - *
( l: Y7 {# @1 ?1 g! b - * This file contains EDMA3 Test code.0 t% Q* ^( \- I, T0 v7 O' H
- *
P+ l n0 \* h% S - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE4 T# e7 C% t, b) D
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
- j2 N4 h+ e8 y2 ` - * TO CHANGE.% c9 X% G7 B2 p# W. c8 o
- *, `1 Q$ Z$ W4 |2 P4 S$ z
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/+ W0 Z/ C% M* @
- *5 _- O2 W" J6 t/ \1 q j: [
- * This program is free software; you can redistribute it and/or
l( M- m# [# \6 U2 [% I. Z9 N - * modify it under the terms of the GNU General Public License as
. b- I _* t1 s2 ` - * published by the Free Software Foundation version 2.
* P, p0 k, p# e* K1 T - *
3 h' @9 S. a) W8 r6 a% J* f* I! v - * This program is distributed "as is" WITHOUT ANY WARRANTY of any0 j% m: i" V s: j5 ^5 z
- * kind, whether express or implied; without even the implied warranty# V0 G! u, X! _: ?. F( w
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9 H5 n6 X, A5 `3 N( h" r - * GNU General Public License for more details.
: v4 f. E" Z' j: \& b$ f3 @1 p1 @ - */6 B+ x/ \0 j; w! a$ C/ e! y8 I
- / I8 z# t& I/ [; U7 h
- #include <linux/module.h> |6 Q6 M' M) I' ?; C0 V% I
- #include <linux/init.h>% ], h, s/ m, g _4 I1 I6 ?
- #include <linux/errno.h>
3 \7 X5 m* f. H% G2 ]: P6 l; ^. n - #include <linux/types.h>
2 @' _/ ]% s* ~1 q0 r" K - #include <linux/interrupt.h>0 |; C6 q( L# ^6 V/ |
- #include <asm/io.h>- ~( X3 ]& I& a# ^: l, C0 k$ _
- #include <linux/moduleparam.h>
9 h7 z1 c( b6 W! t - #include <linux/sysctl.h>- h: {' a2 Y7 q! W
- #include <linux/mm.h>" I& Z0 O4 }! k5 U
- #include <linux/dma-mapping.h>
! _# T1 g A: ~6 ^5 G8 F - , D. S% t* ?: }, D; k6 |
- #include <mach/memory.h>! S5 {6 D/ S# X
- #include <mach/hardware.h>+ I$ Z% \9 M. ^+ [* ^0 m
- #include <mach/irqs.h>- q* y" N* ]2 C/ m8 N
- #include <asm/hardware/edma.h>: ]8 Y9 Q8 `/ e! q- P$ ~- K
- 5 c1 P* z R: w* s: _. q
- #undef EDMA3_DEBUG
% m2 b( @! g9 N, |; h% x - /*#define EDMA3_DEBUG*/
9 M1 y% Z; ]4 `& p: \* g( l+ D- Z
* u' u7 Z. f) G% |/ T- #ifdef EDMA3_DEBUG
9 e' b+ }6 M. k @1 t1 ^% j$ ?8 _ - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
- I" F) ?; _9 V% R6 F4 ~ - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)% s; t; e h7 C$ a. _
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
; n% q6 w6 K% t7 |: S' K; H - #else
$ b0 [: C3 x- z d - #define DMA_PRINTK( x... )0 Q- P- Y5 a- m
- #define DMA_FN_IN8 T* l9 q7 C) t3 T0 t
- #define DMA_FN_OUT
( {5 N, G5 c5 K; u4 g- h/ U) K5 l! m/ l; h - #endif& a% J+ `' P7 A! o& F
- / n) J6 T, J& j3 F7 v- V
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
! {# |7 J7 }8 ~* Y/ q - #define STATIC_SHIFT 37 b4 b2 W0 a4 G" L+ k O; I; d
- #define TCINTEN_SHIFT 20
: i; E7 o* w0 n7 E9 H - #define ITCINTEN_SHIFT 21
; h% n! v- }' L0 S7 x - #define TCCHEN_SHIFT 22
/ [3 |9 v/ @6 z - #define ITCCHEN_SHIFT 233 m) i# ~' W2 |; n8 K& ?( E& c
, {/ M" _ w; k' Z- static volatile int irqraised1 = 0;: U9 \8 J$ G' V7 x" o, V
- static volatile int irqraised2 = 0;
% c/ o. e f: [! H - 0 h' z7 N% b" d: D; [
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
1 A \: k' ]$ O3 u3 m6 V) N$ I' Z - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
4 T" T) S/ A0 ]3 N2 G - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);) I' W& |4 _; \; ~ ^
; i9 m4 E0 Z! C# _& t9 c8 _- dma_addr_t dmaphyssrc1 = 0;
7 i1 A& G6 \: _3 C - dma_addr_t dmaphyssrc2 = 0;
/ I% ~5 C J' x* [5 ] - dma_addr_t dmaphysdest1 = 0;
% _0 v6 w1 V1 u$ T. T# x& r2 h' O* i - dma_addr_t dmaphysdest2 = 0;
& f' q3 R" T( T, Q. d: d4 l! { - $ f+ N# u/ n, v6 _
- char *dmabufsrc1 = NULL;
/ b' K0 q5 ]; I- s$ x1 z, _ - char *dmabufsrc2 = NULL;
1 o% x" U0 i5 }% L - char *dmabufdest1 = NULL;2 L& O/ p+ q0 f% U: T
- char *dmabufdest2 = NULL;
0 T) @1 f7 q5 U5 p - 3 G" ?% @ O7 l7 F6 S
- static int acnt = 512;
" x1 G) K5 \* ?9 c8 W" }, L- a4 W - static int bcnt = 8;) s) [ @$ p( f) z7 k: M+ R. r9 N) ^
- static int ccnt = 8;
! T! j3 A" E" ^7 |; `. p- ]6 H - ! ~ |+ z9 ~( T! h+ }, e
- module_param(acnt, int, S_IRUGO);
* j P/ C0 i; p2 _ - module_param(bcnt, int, S_IRUGO);! T( ?# r$ c' U J# a
- module_param(ccnt, int, S_IRUGO);
复制代码
; ~: f2 U0 J5 h( M
& n1 r# r, {5 M& m 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
" \' [5 i" m8 D; P/ [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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。% }/ H. T ^$ [: V
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。5 U5 c, j P. b
' y" f: c% ~ I& T( {1 s, x4 Y
4 l8 K; s! q( E1 U( B3 H( _) y |
|