|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
' k: r9 }* y& _4 E- [code]EDMA sample test application
. Q3 T) X1 ^8 `4 U- b! ?9 J - /*
+ u. D- p' y8 J- d* I+ E9 ? - * edma_test.c
* _, T; d0 l1 J! C2 a- P! g3 s- |) W - *, _! L6 W' G2 o* }! p3 @2 J. H
- * brief EDMA3 Test Application7 T' ?* f; f, l( R5 R7 ~$ Z1 I
- *1 ^8 @: _' i6 @5 O1 R7 X
- * This file contains EDMA3 Test code. X! [% M1 c# M# V0 T4 L1 L
- *
- K5 o& I1 U0 b - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
/ ]. r/ s. c- e& f6 A) T3 ^ - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT$ z% t: x# o- T2 ?; X0 _
- * TO CHANGE." b: R& E- I3 e/ C6 B
- *
! u. t3 u2 X8 e9 S3 t, m/ J - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
* N; W; u' r, p; i: \" ?: a1 Y# _ - *
% g* K5 Y( P% q- Y: J. G - * This program is free software; you can redistribute it and/or$ Y3 h+ J+ ?' _) l9 F+ o' _
- * modify it under the terms of the GNU General Public License as
A1 s# y) {- c5 s% ?* ] - * published by the Free Software Foundation version 2.3 ]* I2 s- C8 }
- *( M' Y5 T K9 ~7 ?4 P2 n
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any$ x" N8 \ i: x# ~! c) Z J H
- * kind, whether express or implied; without even the implied warranty
! w3 a; i+ ?1 e' H: G" h - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the; ?; L' @& Y4 l" `/ I
- * GNU General Public License for more details.+ R- i5 ^( b: Y/ H% V
- */+ A' O* w4 ^' ^' p7 p
- : h7 u' T( q$ V/ x: j8 _. j" D
- #include <linux/module.h>
# I" u/ o4 ^# k, h - #include <linux/init.h> f4 }- @7 e5 v/ Q& H
- #include <linux/errno.h>8 M* b& e, q/ x7 x
- #include <linux/types.h>
8 E. g: T7 k3 t5 N1 x; E O8 n9 o - #include <linux/interrupt.h>& U B, }5 `9 [" J& O) @
- #include <asm/io.h>
: {6 B8 v l0 a$ F- A; @! M8 y - #include <linux/moduleparam.h>
5 g5 z% S: m" Q d+ T; H0 M4 o4 E, \. k - #include <linux/sysctl.h>5 V( ~0 D) T6 l/ ?" T! t
- #include <linux/mm.h>2 x _1 x6 g/ F+ \4 c1 h
- #include <linux/dma-mapping.h>3 ?( B! O( ]! A2 x/ H) S: _2 @ `
- & }/ k- m# @; }
- #include <mach/memory.h>, U1 ~" U* ^2 B9 h9 x
- #include <mach/hardware.h>' h2 X5 s+ ]- c1 v8 `
- #include <mach/irqs.h>+ R/ Z. F I. m1 m# X& n9 X# A
- #include <asm/hardware/edma.h>
/ n# P: U7 X' ]4 ~5 L9 R( d' \
! J( U4 Q2 E( j o/ M- b0 M- #undef EDMA3_DEBUG z$ v& Z. ~+ _/ |# T$ _0 R: c
- /*#define EDMA3_DEBUG*/
6 S! v/ U4 R5 Q E0 R9 y2 ` - * T" c. A6 p9 X& a/ M
- #ifdef EDMA3_DEBUG
; i# c0 h# q' u7 k I9 x7 ~0 S - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)% m! h" S# o7 J( ^
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)5 _, q7 ^8 [ Z7 `* e8 p
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
6 W+ e% {2 z, W' v* m - #else
2 D: M, ]1 R5 e, j - #define DMA_PRINTK( x... )
( M7 R! M) C/ E2 z5 f; ?3 j - #define DMA_FN_IN/ n; A. V' w- x1 c1 B
- #define DMA_FN_OUT: t6 b8 ^1 b$ G6 j4 n
- #endif; C6 Q+ S1 S6 T, K
- 4 Y; \0 d* [0 B0 O4 ~' |
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
. J. R9 ?" I' E' s - #define STATIC_SHIFT 3
: u0 \# p: X6 C$ S - #define TCINTEN_SHIFT 20
6 B% j$ ^7 P# r3 P$ } - #define ITCINTEN_SHIFT 210 s4 K$ k/ @2 f; p8 L
- #define TCCHEN_SHIFT 22& D/ [9 F' _& a+ h) _% Y6 b' p$ j
- #define ITCCHEN_SHIFT 23( ^; x% R! S2 S' E0 \! @# Z) X
- ! Q1 h, a& p' Y6 F5 X1 D* F9 p
- static volatile int irqraised1 = 0;
# R% |5 W" f- P; `( Y2 R4 i - static volatile int irqraised2 = 0;+ M8 Z- E6 o7 g0 f4 U' t# c
! Z( l; i, q; |3 E2 j+ s, U( N- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);9 w1 o) u0 l/ K3 y7 D
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
) w8 k4 I4 y' S a% r - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
. f/ r. H }9 w* V0 g3 u: d+ G0 B
4 x( U/ {# J5 C& _( h6 [+ \- dma_addr_t dmaphyssrc1 = 0;
# s, A T7 H" s4 ? - dma_addr_t dmaphyssrc2 = 0;
' ]! r! h4 b( y1 J. E- P; ]3 e% Z - dma_addr_t dmaphysdest1 = 0;
9 W% m% I$ D% d+ E" w t - dma_addr_t dmaphysdest2 = 0;
8 Z. B/ ^. z) E' j' X
o8 L' t( Y1 U6 f; B- char *dmabufsrc1 = NULL;
7 x3 P9 G4 q7 S7 U4 }* T; S - char *dmabufsrc2 = NULL;
& l; |# C: z& s2 Z9 B - char *dmabufdest1 = NULL;
+ i9 }/ T7 M$ M3 h/ V - char *dmabufdest2 = NULL;
( f" x( y8 @9 U: S6 l' b: S- ^
0 S2 X8 X! w$ g- static int acnt = 512;
0 G' e C0 E+ S5 [/ ]. r; {* h - static int bcnt = 8;) O7 R4 |2 {; z9 Q, p9 _2 c
- static int ccnt = 8;
& P. \1 L1 Y R4 O R, V# {1 U; O2 [
2 V) Q; E. q6 e% Y, {* j1 k- module_param(acnt, int, S_IRUGO);
& o& d! B5 ] A6 K - module_param(bcnt, int, S_IRUGO);
/ x. J# d, }; q: M5 a; Y. J - module_param(ccnt, int, S_IRUGO);
复制代码 1 f% [7 P6 M- F; b
$ Z. ~ Y9 o% F; T. ^- } k
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用$ F! s' n E7 p( F. n5 D' X/ k0 g
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
% E! G. O; C C b7 r8 x 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。1 |- q) l( U/ d+ E h
5 E5 R. h) x4 H& {+ A+ u$ b6 \/ J4 W/ X7 }+ H0 [/ B0 t/ c
|
|