|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 , h# l8 z- q& [( o( s
- [code]EDMA sample test application
, p$ R2 d+ X8 ?. W" b - /*
( N# g. A v* ]" m0 H+ S- K6 t. _ - * edma_test.c' f! v6 \9 x9 Y$ k5 S& [, A# R3 M
- *
4 F& Z# i; I1 ^9 U* k: d0 x - * brief EDMA3 Test Application
5 P8 i+ O# F; q - *
! I/ R- _3 T" Q1 ]; u2 m - * This file contains EDMA3 Test code.0 t; S- i; J/ y+ Y" W- c. F, A
- *
9 X m# d3 {3 z, ]" {3 u; ` - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE- B5 u: C, e$ x A" F
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT- b/ V# a! F) N' d4 h% J
- * TO CHANGE.
* w Y; t: h* n9 S! _2 C - *; S; g! k/ J9 a
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
2 L& F7 m: }1 S/ A$ z" C. b2 o - *
7 Z1 i4 w t! G - * This program is free software; you can redistribute it and/or
) m/ M: D/ I9 Q0 ?9 T - * modify it under the terms of the GNU General Public License as
% H8 \" f6 l' K, y - * published by the Free Software Foundation version 2.
& P4 Q. e9 G# L; S( L% k - *
3 y6 n( V+ A5 H8 | - * This program is distributed "as is" WITHOUT ANY WARRANTY of any& ?% A$ ]- c- s2 f3 K5 e9 I; J
- * kind, whether express or implied; without even the implied warranty
9 M* S& y5 I9 f( v4 ?+ F - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the# e: P% T7 l g# a: x+ y, c
- * GNU General Public License for more details.: ]0 C' T! x' w# C. `
- */
, R6 n0 @4 [& ?/ d/ {; y
/ T+ j* P: c+ c- #include <linux/module.h>, L! E- Y" Z/ o2 A, D
- #include <linux/init.h>
" m U. _ W5 ? - #include <linux/errno.h>
4 N- p3 D l4 H# y R8 N6 k - #include <linux/types.h>' ]5 S, ]2 I# [7 a# E
- #include <linux/interrupt.h>
0 w* J9 I7 w4 `; K* c - #include <asm/io.h>4 ]8 b7 w# W2 [7 J5 b4 B
- #include <linux/moduleparam.h>% y; ]- y" i( O3 v7 Z
- #include <linux/sysctl.h>( n* }: p. n0 o: o: B
- #include <linux/mm.h>
2 X4 {+ z) J1 g- J - #include <linux/dma-mapping.h>8 T- \: w9 N) H4 u+ A' c
0 S, r, _ G6 F) \* H- #include <mach/memory.h>& t! O: n& v/ H0 i( H t- V
- #include <mach/hardware.h>
; D* M% m) g( z - #include <mach/irqs.h>
% w+ r3 h/ q$ ~6 k& {5 |; C5 y - #include <asm/hardware/edma.h>! b! f* r, _% o% H& }4 `- q
- 6 P% j" A2 D i7 c5 @- F, I8 i0 \
- #undef EDMA3_DEBUG
: P. Q( \, {- P. n# L% ] - /*#define EDMA3_DEBUG*/
* v% @' p7 O9 I! @& K3 q
: a/ P8 s0 C9 V( U% L- i; e6 o% y- #ifdef EDMA3_DEBUG$ u& l) \% C% S$ E5 F
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)( n. B8 v" E4 p4 ~4 f
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
. } \" l# m: C: k6 T - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
w& w5 y" ^& m* s7 z; k - #else
2 q; k' I8 u6 j+ |5 |- [: { - #define DMA_PRINTK( x... ). ]. F! h/ K* `- [ ?3 i
- #define DMA_FN_IN( b) a7 N8 z( c! R
- #define DMA_FN_OUT( H; B9 F' }# p& W
- #endif
' U1 p' m/ i- G7 \& ?- l
2 z# P( w' ]% f& A- #define MAX_DMA_TRANSFER_IN_BYTES (32768). M- E$ S9 N: Y: T/ @, \) l& {
- #define STATIC_SHIFT 3
7 s* G9 Z4 \6 i6 y - #define TCINTEN_SHIFT 20
5 E8 ? {/ ?8 h - #define ITCINTEN_SHIFT 21
0 m k F" I" z - #define TCCHEN_SHIFT 22. x0 u( D* x9 v' ~. H! V, r
- #define ITCCHEN_SHIFT 23
% @6 @4 f+ ]0 ^* y( v& ^8 M - 1 g" w# \$ t- i7 {+ t
- static volatile int irqraised1 = 0;
k% S" m, [: B! ?+ {8 f& }* p - static volatile int irqraised2 = 0;4 N( s7 r, o( S) z7 {1 ]& d' t, C
! ?6 j) c% ~+ @- D0 h' U3 A- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
; x* ]9 `$ u! e2 H0 m - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
J( B" U5 k/ v) | - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
8 T0 ]% r1 n8 v - 2 P3 d) z4 R( M" Y) v
- dma_addr_t dmaphyssrc1 = 0;
: D, ?) i, O$ C4 ^8 ^ - dma_addr_t dmaphyssrc2 = 0;; K2 { G' x' a! a
- dma_addr_t dmaphysdest1 = 0;
* \1 D! }' N' F( o - dma_addr_t dmaphysdest2 = 0;, r W; e" v7 {) `/ g: B( [
0 e& U4 i5 v, r- char *dmabufsrc1 = NULL;
8 I, O' J% V0 n( ] - char *dmabufsrc2 = NULL;
3 y i7 d2 C5 x0 N, ?" J# Q u - char *dmabufdest1 = NULL;0 g& W) D3 X1 U7 t6 _
- char *dmabufdest2 = NULL;( t& M4 k- y+ B0 i2 g' q) c
9 o2 `# d* G2 h7 W. q0 m* a2 u. e- static int acnt = 512;& S- B- b3 p9 l" B: p& C+ r
- static int bcnt = 8;
+ m2 x6 h' ]" F8 A5 }' N1 P4 D - static int ccnt = 8;7 P6 k% u. H- g( [, J2 d. z0 Z1 d
- + r* ?. r2 h8 S; r
- module_param(acnt, int, S_IRUGO);, @6 e; i X: H: w# e
- module_param(bcnt, int, S_IRUGO);
" b0 V3 v7 ^( s+ l$ P* N - module_param(ccnt, int, S_IRUGO);
复制代码 6 g+ M& D# N$ Z( _7 f
" t6 `- Q- S2 w/ v; X( ? 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用 _; ]5 Z' A( ~% n+ K6 h( U t
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。* Z2 F' [+ q. J/ M' c
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
9 J- x% g* ?% Q, o' n
7 j) Y1 U5 G) ^% S" V" {$ Z5 B) t& M/ w M
|
|