|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
" m& I# U8 A# q# R; [' a- [code]EDMA sample test application: ^- v# V2 ?7 u
- /*8 S- Q4 I7 g. _7 E
- * edma_test.c
% I, Y( Q( E( z! j& q - *" b) D* a- i4 p; N$ T
- * brief EDMA3 Test Application
% h/ k7 O7 x2 ?7 K+ L! e* R - *
5 L$ M6 A, _( R' ^+ l2 J6 Z - * This file contains EDMA3 Test code.
, o4 B1 R5 I8 v7 S" H - *
' W0 i# ~/ E5 n U5 r1 C - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
) r9 C! X1 L" u' T1 L! n - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
4 e; J& A! S, g( {5 h$ E - * TO CHANGE.! X) X, \: { G/ W r
- *, b1 E+ z4 Z* o3 n9 K: V" b
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
) g" G+ t1 A7 u- Q3 _% b4 X - *& }& |: D. w* X! t+ }& H
- * This program is free software; you can redistribute it and/or$ F" o2 S8 J) w- M. Z
- * modify it under the terms of the GNU General Public License as: f4 a2 P. ?% W6 |% E
- * published by the Free Software Foundation version 2.; c# | d" i* _" h8 I
- *
3 r8 x& t" y- d0 x3 ` - * This program is distributed "as is" WITHOUT ANY WARRANTY of any
( g. M; M5 W* t: G w7 ~) ^" ^5 F - * kind, whether express or implied; without even the implied warranty
# N" l. v* l6 O( Q - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* _0 t: I, n- H+ u - * GNU General Public License for more details.
& Q$ @. Z) L% c: h% p& T! G - */
& r ^3 T }. @4 t) ~- C, ` - * T3 N/ H, q, U( N& C, [
- #include <linux/module.h> K: F' }* N) _0 \3 a
- #include <linux/init.h>
- u; W4 {( G' j1 q `/ B7 l. v - #include <linux/errno.h>
* B/ c+ e( j. G: k7 | - #include <linux/types.h>
- ~+ [3 H2 A, O6 b/ i" ?( m - #include <linux/interrupt.h>
" z$ ~, ^0 ^5 M2 } - #include <asm/io.h>
) U2 t8 a1 `* w$ E1 z - #include <linux/moduleparam.h>
1 K8 H% z6 |, U, ^6 N1 u - #include <linux/sysctl.h>
5 }/ }; b1 w4 X: Z6 o7 d& O/ Y - #include <linux/mm.h>* N2 s; g7 H: @* ]9 U
- #include <linux/dma-mapping.h>9 y" H: o+ x) r) \1 Z: u, }
- 7 X" O' z% ]. S1 x D7 d
- #include <mach/memory.h>
7 B# `. q; c0 k% M - #include <mach/hardware.h>
7 }3 Y7 i- ~( d7 B - #include <mach/irqs.h>
- ?& v! E- Q6 G% K: z - #include <asm/hardware/edma.h>1 S4 I/ ]6 ?' ^) i4 r
- 2 P! a% g) L E" E/ J) C; B
- #undef EDMA3_DEBUG! ^6 S8 M# Z' m- O5 O1 Z
- /*#define EDMA3_DEBUG*/
: G" }! c1 L9 E* E2 {9 f
% X& d' N( [4 @0 O5 G- #ifdef EDMA3_DEBUG. M7 q. k2 s8 b/ T" L8 S
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)2 }% A2 w$ O) C0 X" R o- P3 |7 b3 ^
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__). m2 @( [! z1 i' H1 G& @
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)& i3 g3 D g2 B) j. v+ u
- #else: n+ W9 F1 f0 V9 \
- #define DMA_PRINTK( x... )9 f2 @1 h+ q! k. E* l5 t
- #define DMA_FN_IN) `& ]+ y! @6 S
- #define DMA_FN_OUT1 E: \; W* r6 o( _, ]/ A
- #endif
6 B. F" l- M( d9 ?$ {
3 x% |7 ]4 w, H9 L- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
: w+ k% u' q) j" A2 P% D. X+ K; T - #define STATIC_SHIFT 3% r+ J; W. w; E4 c2 P4 \- l
- #define TCINTEN_SHIFT 20/ h1 ?: y0 |' B5 l+ @( l( q! U: B! F
- #define ITCINTEN_SHIFT 210 v9 Q/ h. ^% [& T' b/ Q
- #define TCCHEN_SHIFT 229 `# n( I# G6 {, r
- #define ITCCHEN_SHIFT 230 U( j z" z& d a3 ?
- ' W5 D; L) l7 u% y7 t! G
- static volatile int irqraised1 = 0;1 h" I8 D$ V5 M2 K( Y
- static volatile int irqraised2 = 0;
9 l2 \: s+ h0 |$ N, R; Z, L - ) m0 ~ e, |) ^% q2 l+ N
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);- v% y5 l% T+ m- r. k, ^" ^
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
! k7 U; I, _5 r) b - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);8 ^8 a: T& @, A
( r& W7 P( a, [" n2 W g7 N- dma_addr_t dmaphyssrc1 = 0;1 j4 R; _( L) d8 S
- dma_addr_t dmaphyssrc2 = 0;
# o% s% B+ q. f( j - dma_addr_t dmaphysdest1 = 0;; k5 t% h- I5 E$ L2 J, s! W I! _
- dma_addr_t dmaphysdest2 = 0;
^, I4 ?7 M2 E- H
$ f# k8 q) q, @: }) e6 O- I- N# W- char *dmabufsrc1 = NULL;
1 O2 l( W0 p# A. E5 {% L% k6 A - char *dmabufsrc2 = NULL;
( r+ ]7 @, C! r3 c5 \ - char *dmabufdest1 = NULL;1 t! V: A' i$ i6 Y! A
- char *dmabufdest2 = NULL;
5 ]/ }* D% B- D, u# [# L
) m: e* G9 G3 W$ c7 J, A! H- static int acnt = 512;7 R8 q7 l L% s" Q5 h
- static int bcnt = 8;+ u1 M! |4 l/ c0 n7 I& N
- static int ccnt = 8;0 V$ Q6 r' @5 T; K1 s
- : O2 j; v+ i* }3 _5 b
- module_param(acnt, int, S_IRUGO);
% }4 @9 A) D4 {: }2 @ - module_param(bcnt, int, S_IRUGO);" {& v: t5 Q) O9 }+ I3 B- D
- module_param(ccnt, int, S_IRUGO);
复制代码
: Y5 c8 D5 e* E9 |
4 [9 U2 f% d/ p/ D5 T- N 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用% o9 U ?% i$ q; _. E( f
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
/ q! Y0 ]/ |' J4 B 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。+ ~- x% l1 x6 L) T+ x
- X* q) s7 L( v; j F. o
9 q* G1 i: N/ B" l& c1 R |
|