|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 / h7 t2 V. S; D: j! W) @
- [code]EDMA sample test application& W9 x5 F/ U" O3 S( H9 a
- /*
7 ]$ D* B) |# a6 t4 l - * edma_test.c
- ~+ p0 P" l7 L7 A% Q - *- s: W9 e [7 Z0 G. O
- * brief EDMA3 Test Application: h# e2 Z( M7 H0 `/ Y: q
- *
5 s, m, ]; g2 a" q1 j9 y - * This file contains EDMA3 Test code.
9 F" H1 U5 D3 e/ X ^ - *# x p. D" B+ m, Y
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
' y( O; u& c7 r" ] - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
9 |2 z# y& s7 m* k& E - * TO CHANGE." q' s' Q& `1 I# q4 e
- ** v9 z9 j' H4 F: a. T1 K
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/( b9 W' H8 P& o( @9 z6 U
- *
8 p" a% P$ l2 ?9 m5 t8 B% q* ] - * This program is free software; you can redistribute it and/or! \; i7 O* o! w! K* d" k& K# I
- * modify it under the terms of the GNU General Public License as5 O6 c- X& u5 c! M& c% l2 Q2 k* C
- * published by the Free Software Foundation version 2.
9 H, H' |, n, F3 H - *
3 T$ w: E" H" J0 E% g - * This program is distributed "as is" WITHOUT ANY WARRANTY of any3 g ?. U( \8 S7 t* Y
- * kind, whether express or implied; without even the implied warranty8 f4 M! ?0 K% l, v( I9 ]. S
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the o& {+ q/ A O6 N. N# @* g* _
- * GNU General Public License for more details.
* Z1 v+ m5 ~; m( y( j - */! x% O" Z/ T3 M/ L6 p
8 H, U8 D3 O6 D& b- #include <linux/module.h>1 v9 @0 f2 R9 t% r
- #include <linux/init.h>
" M% `7 S: y! z" I# I+ i - #include <linux/errno.h>
! c; @2 M, z! ^! b7 f3 n - #include <linux/types.h>
, v+ v" m6 n- c$ [' M2 S - #include <linux/interrupt.h>+ Z" F0 i" f, W3 t* s6 q/ N
- #include <asm/io.h>; `! |" y9 h0 t' y" m$ P; n
- #include <linux/moduleparam.h>. Y1 G: ?2 f8 D4 V
- #include <linux/sysctl.h>1 f& G0 M9 R" l& W8 A) A% K7 |! |
- #include <linux/mm.h>
" A( K0 Y: f8 X6 d% |- @ - #include <linux/dma-mapping.h>8 z( Q' z# y. p3 l+ @3 O
1 }1 v. k7 H2 E6 r( p4 f9 E- #include <mach/memory.h>
' m% }! `- i* w2 [ - #include <mach/hardware.h>" z8 v, f2 `. `1 O' j) ?+ m
- #include <mach/irqs.h>
* O" ]: R% k' A8 R( A - #include <asm/hardware/edma.h>
0 P1 g9 A0 m$ E. x, U
8 a! N, Q/ b+ @' m( g- #undef EDMA3_DEBUG6 d _% C1 V/ R% p: a
- /*#define EDMA3_DEBUG*/
1 H% [8 ~) E+ j4 V7 q, s8 t! V - + s/ X$ ^+ T5 q* |
- #ifdef EDMA3_DEBUG- n: b' @( P6 s# f3 e4 c
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
y7 u- |& S* ^# J3 L% ? - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
/ @. L4 t0 I2 S$ G1 ^: O - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)+ g8 k6 P0 ~; Z: F
- #else$ L6 R. }* b8 m1 U I& e% @% y
- #define DMA_PRINTK( x... )
9 q6 |) X6 e3 I: u( B/ n& }5 U - #define DMA_FN_IN7 b4 z8 o7 N- a# ^
- #define DMA_FN_OUT
$ B* ~5 Q6 k2 y% S! v/ @0 I - #endif+ w! ?9 n2 N: w. ~4 s# U
7 e8 O- l- E' N- #define MAX_DMA_TRANSFER_IN_BYTES (32768)5 D8 c% I$ Y: L g* K* ?. X
- #define STATIC_SHIFT 3# t2 c( K1 r* w; c
- #define TCINTEN_SHIFT 20
( a6 K& f( E9 Z$ x2 M - #define ITCINTEN_SHIFT 213 S q4 f, S, i9 B2 A# T4 l. O9 t
- #define TCCHEN_SHIFT 22
7 _0 Y6 x4 I% P* ` - #define ITCCHEN_SHIFT 23: r7 c5 c$ m' \2 R* c* x
- 5 j; z8 F* p% o4 e2 a, @! z$ {% W
- static volatile int irqraised1 = 0;
9 [5 O) i- z1 ^/ \9 b - static volatile int irqraised2 = 0;
$ h, g) P6 K ?3 q! X - ) |% B6 i$ I' N7 \! d% s
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
" e4 r% j+ l9 `) d5 b% H# ? - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);3 Y. K& a: X8 F% @3 \$ W
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
" H3 _) r/ G2 r, b
. M# f0 J$ P4 b+ t- n3 N- dma_addr_t dmaphyssrc1 = 0;+ N' k2 o0 v7 F! L
- dma_addr_t dmaphyssrc2 = 0;3 D# T+ |8 F- l0 m7 |8 ^
- dma_addr_t dmaphysdest1 = 0;
0 o- j5 H6 w8 _- ^5 r9 z - dma_addr_t dmaphysdest2 = 0;
. V0 x! z6 _9 i6 o* P! {
. J5 @% |# F( ~6 ?& Y2 n- u, Q- char *dmabufsrc1 = NULL;
' U# k3 S0 ?# V D - char *dmabufsrc2 = NULL;; a& y6 g+ Z N Y& k6 j& C, R" V8 l
- char *dmabufdest1 = NULL;
/ E4 H: U! L# ?- b0 k6 s, ~3 H3 Z T - char *dmabufdest2 = NULL;7 A5 j- Q6 G" x0 }+ k
- / ~# b) u) v0 G2 |
- static int acnt = 512;
- X: \( j2 P7 M7 @ - static int bcnt = 8;
1 v9 ^& J6 z2 U i, s8 t$ E - static int ccnt = 8;2 D5 i, G, p0 m4 a
- 4 Y6 ^- V3 u8 Q
- module_param(acnt, int, S_IRUGO);
?+ M1 c) k6 I - module_param(bcnt, int, S_IRUGO);
3 P1 Y7 ]. g6 U6 m* F9 J3 q5 T - module_param(ccnt, int, S_IRUGO);
复制代码
% Z8 _1 i" ~& ~0 V0 Z, f( w2 l
: [) h3 I( s$ J6 G 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用9 c& ^* \9 Z- l0 ~5 _" y
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。7 R* V1 X# H- R# z
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
' X8 ]) A! W' C. F
9 L$ n) f$ m9 T# b& Z7 R0 P! S
& D% ~7 M3 ?; v0 w9 V& i0 d L" `3 V |
|