|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
6 e; A, i% L5 R( D, d/ g- [code]EDMA sample test application
+ O* R! C# I& }9 e - /*
/ v2 g/ R" S0 A5 i; c# c - * edma_test.c& Q4 t0 t1 t g" X
- *+ f" c9 d! N* m$ P2 j+ `4 e$ ^
- * brief EDMA3 Test Application
! N3 @/ d- J7 K% S, I - *" w5 U! ?! C \! C( x$ v5 B
- * This file contains EDMA3 Test code.. a" u+ ~9 p8 w: D: g
- *% f1 V: B- E0 X! Q# o, M: @1 d
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
" L% h: I' e3 p* m& d' {% n# P& p - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
8 B9 q0 I4 q, c( d - * TO CHANGE.4 M3 R) Z4 ^" r' F
- *
. [# _* ~; }# u7 s$ ~ - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/* k3 @2 Z* ]; M
- *+ S; Y+ P4 x( ^- R3 |" d# Y: P: H
- * This program is free software; you can redistribute it and/or
! k+ w2 O; @7 Q, o* \$ i4 Y - * modify it under the terms of the GNU General Public License as
% j$ F0 e( b! C* N0 [ - * published by the Free Software Foundation version 2.
3 W/ r6 ?: |! j+ o - *; C$ J; S( W2 Q0 x: i
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any
. z$ }, w7 W) i$ \# t' _ - * kind, whether express or implied; without even the implied warranty
7 a' M+ j3 E* d: ~ - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
( q. n; y/ p7 }& J; b4 u F - * GNU General Public License for more details.
5 A* S6 ^6 A7 a1 p x8 Z - */4 P; _( o0 D/ |. P
- C( i- N. _/ I6 N9 k( t
- #include <linux/module.h>
k; l: T+ m6 C% S3 ]' N# K# M3 F - #include <linux/init.h>
5 n3 B* _* ?* w, {! T - #include <linux/errno.h># ~7 H; z' O4 T& [5 O
- #include <linux/types.h>/ y; S: h0 [3 Z$ f' Y. |) y7 h. m
- #include <linux/interrupt.h>; F1 S) c3 B, @+ R
- #include <asm/io.h>( a+ g, P5 ?. {6 J8 v% w3 Z
- #include <linux/moduleparam.h>
' P' d8 l$ M; o" C: z - #include <linux/sysctl.h>3 a, f2 ]. B7 |) x
- #include <linux/mm.h>
3 Q* u, t( ~6 v# F. Z D2 O - #include <linux/dma-mapping.h>
- d) `2 n+ ~4 k
. n& a( @( ] D4 x9 n4 [/ `- #include <mach/memory.h>$ D% o- d# @) O( Q4 m5 T: w0 R3 s
- #include <mach/hardware.h>
/ d- l9 S3 M# P/ h4 d c! x - #include <mach/irqs.h>
# h$ u# k, i+ L: z; u - #include <asm/hardware/edma.h>2 @1 q+ u, Z. H3 m
{8 ], N& H/ S) T6 E/ @. N& R- #undef EDMA3_DEBUG$ h: B! M @( |- v- F, {/ m
- /*#define EDMA3_DEBUG*/
' m; k8 a, A; f
9 y1 u: T: s' ^+ i, S6 C- #ifdef EDMA3_DEBUG& T) L0 S: E, X+ O) G2 P
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS): P1 X( ` g- T8 a
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
: Q$ ^" x( u2 L - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)7 R8 f( M7 a1 ^8 e
- #else
3 A! {+ c3 k% i6 B2 O - #define DMA_PRINTK( x... )
, A4 U6 v6 D) @3 { - #define DMA_FN_IN* n0 d$ L6 f R- ]
- #define DMA_FN_OUT
0 F# ~ ~- S( C4 d. q) d3 C - #endif; R0 A [/ a2 H0 H' n2 e, l5 }
- 3 G; `7 _* m1 o0 T0 y: b
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)7 ^# C" R4 ?4 G ^. m: n
- #define STATIC_SHIFT 34 x4 q7 o2 P6 z0 `* p$ U9 Y
- #define TCINTEN_SHIFT 20' ]+ z7 m! v; ~# z# ]! m, Z
- #define ITCINTEN_SHIFT 218 z( `% U: C0 K; ~" V2 j
- #define TCCHEN_SHIFT 22: |+ N+ B! o& @
- #define ITCCHEN_SHIFT 230 C$ a& @; k$ Y% L4 D3 X6 ~
9 E& a+ P R2 n1 Y- static volatile int irqraised1 = 0;3 X2 R% p: h! n% y, h. |# J. I! ^, a
- static volatile int irqraised2 = 0;' ?, n. E0 g5 u
5 T5 |: d v' m8 o) k. f- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);7 `2 y; R* j2 O" s
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);0 B) X& m5 T, {( l# g" c5 _
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);; H6 |1 `( X5 Z+ G. E- J) v
- ) ~5 |% o8 G' [8 C0 u8 ~
- dma_addr_t dmaphyssrc1 = 0;
8 `2 K8 B" i0 X - dma_addr_t dmaphyssrc2 = 0;% w" t5 C0 i7 V: Y; _
- dma_addr_t dmaphysdest1 = 0;
" o3 m3 @) Q. L) E5 t - dma_addr_t dmaphysdest2 = 0; I1 n! K7 v$ m% ?- f! Z/ D
& r. @: ^& I- C @# O- char *dmabufsrc1 = NULL;
5 R8 Z' N6 _3 | - char *dmabufsrc2 = NULL;/ N0 u* S- R) e3 d/ a( r0 p/ m& u: Y
- char *dmabufdest1 = NULL;
I( T0 b2 E9 w. ^ - char *dmabufdest2 = NULL;9 E& @2 Y7 o1 ~# V; V( P, e
- 2 V& {- E" R [( C* L: q
- static int acnt = 512;
% g3 u, O9 ^; H: @ - static int bcnt = 8;. e& s+ G3 h+ | u6 b5 n% B$ Q
- static int ccnt = 8;+ |3 o7 }7 B ], m w( \
! I2 `* ^ F6 Z* \0 {( P- module_param(acnt, int, S_IRUGO);- n7 ^$ d9 \3 N( U. J; G
- module_param(bcnt, int, S_IRUGO);! a1 v5 f& e ]" D5 f
- module_param(ccnt, int, S_IRUGO);
复制代码 $ n+ m% c4 e3 K g( {4 |
) ]: W/ @2 z) D5 p
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
3 p! B4 e" H5 _; s8 ], |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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。 ?- [; n o7 i
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
$ s. t+ \8 `4 G x0 a8 n) r0 v! ], h" {2 B F! |4 ^
) v7 j1 i0 z; T; B# c |
|