|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 , \9 E+ y* P1 m4 u$ t$ e: b! s7 q
- [code]EDMA sample test application
! t5 ?. u2 J \2 B, g6 n' } - /*
' w; p2 A* S* ^; {3 U - * edma_test.c# I5 S, V9 o" H% v- V; m- n
- *
: M* G7 _# M* k/ v, e - * brief EDMA3 Test Application; u0 I. p- J# g) V% s6 z6 z$ _; ~
- *7 W2 y" d' u5 `, n/ z0 z1 S8 H
- * This file contains EDMA3 Test code.
; B( G/ W4 n, ]' w" C- f/ @ - *0 X5 X9 A; C- l; n7 ]% y/ }" l5 }, ]
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE) \ z& j h# n
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
/ o( w4 @: ^$ L7 t- m9 s4 D - * TO CHANGE.& N/ b2 K! ?1 g: `0 r) \6 C" L1 B
- *
- D2 H8 O- C K7 D - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com// G, i. G* Y2 h& t9 a& k5 q0 ?
- *7 d, o: I! _7 ?4 X) G" Q
- * This program is free software; you can redistribute it and/or; d" P0 M0 P, {+ e( B( K7 L9 d
- * modify it under the terms of the GNU General Public License as
7 s! _ i$ V8 [ - * published by the Free Software Foundation version 2.! h3 S% N5 Q* u+ t( h0 l6 n
- *
6 `/ _! |# e" _; u$ j - * This program is distributed "as is" WITHOUT ANY WARRANTY of any
- r9 R% ^8 S4 P3 L/ g - * kind, whether express or implied; without even the implied warranty; N [3 A% {( Y4 F7 g
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the7 F) F- I( w" E% n0 O
- * GNU General Public License for more details.$ G$ Q/ B4 Y1 }, ]
- */; E1 t. Z8 r1 e3 o6 E
- ; m( x1 y6 x2 B5 \6 i: w
- #include <linux/module.h>; r( ^$ q: }% Z1 t- T6 L
- #include <linux/init.h>
; d6 v$ ]; t6 j ^* k - #include <linux/errno.h>
% R8 r! [- T5 }+ `8 c. s9 ~$ q - #include <linux/types.h>: S: X6 q( h# G, q. U% {% ]) K( t
- #include <linux/interrupt.h>! b3 q$ ]7 I' w2 K# ?
- #include <asm/io.h>5 ?; X0 b( o7 U% j
- #include <linux/moduleparam.h>0 d0 X* q9 B- G& L
- #include <linux/sysctl.h>
$ {1 [+ k [& C! q1 G3 P: y - #include <linux/mm.h>
7 x6 A$ q/ ?# q - #include <linux/dma-mapping.h>4 }9 k% X3 \2 k* ]
- $ r4 N% H* q: ]
- #include <mach/memory.h>" R/ X# `- H$ V1 _1 s# a
- #include <mach/hardware.h>: I" r0 m' C9 }! C) U
- #include <mach/irqs.h>9 o8 \( u/ j* B- F4 f" M; P6 S
- #include <asm/hardware/edma.h>
7 w' A$ f, T3 }4 P& G9 f, I; H - 2 p8 P. v, r/ F7 H+ |- d/ ]+ `, t9 @
- #undef EDMA3_DEBUG8 S; K! Y: o ^- i' j" W; ?/ e
- /*#define EDMA3_DEBUG*/3 `; z5 J# j2 O5 j
: O4 A, O' h) V! _- #ifdef EDMA3_DEBUG
7 i4 c: v5 u' G# a3 n; r0 j - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)/ H' p8 Q$ d) d- j0 v5 ?! v% S" ?
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
5 X0 @ q/ m2 O- c - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)# q* o0 E Z! Z( b
- #else
+ M* M! ?5 }: ~0 L - #define DMA_PRINTK( x... )
- t( r9 z+ ~6 P# [: [# Z - #define DMA_FN_IN
" _8 }' u% ^( v6 { @# v5 B - #define DMA_FN_OUT
* P/ P& `+ x @( Q5 z, ? - #endif
1 P# i/ a2 y$ z2 y - ( e3 P# D- s& {7 L; T, C# {5 p: ~
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
9 p4 L7 X0 a4 } T- U9 q - #define STATIC_SHIFT 3! L! r# P! M+ a. d6 Y
- #define TCINTEN_SHIFT 201 z" Z r7 C- r: g- H; i5 ?
- #define ITCINTEN_SHIFT 211 I' p5 O( k5 U" W) D/ ` {
- #define TCCHEN_SHIFT 22% e+ A) b1 ]" S2 W7 x0 {
- #define ITCCHEN_SHIFT 234 E3 `8 ~/ p3 X0 z% `" c
% i% f' j. i- h* U- f- static volatile int irqraised1 = 0;$ }" F, \* C: p3 g6 f
- static volatile int irqraised2 = 0;' F2 w) d1 V5 U6 J8 d X
/ E) {2 H: k8 _ G* r6 o0 y" E6 k- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);; G: }1 Z' q6 S, w! g, C
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);) p. U) O- [1 o7 w$ k0 ~7 ~
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);$ W( _# z* q! C8 P3 K! [, E+ |
8 m* ~ _5 o3 ~/ d5 s. y% Q- dma_addr_t dmaphyssrc1 = 0;
! P7 g" m7 v" P% R& m - dma_addr_t dmaphyssrc2 = 0; w1 E$ B, @. g8 |
- dma_addr_t dmaphysdest1 = 0;: H! w( D, U- |; Z$ K
- dma_addr_t dmaphysdest2 = 0;" W1 H2 {& [! Y- }' C
- 4 ^$ T! i& [) D! {5 @
- char *dmabufsrc1 = NULL;9 |0 m. ?+ @" Z$ U. |- K
- char *dmabufsrc2 = NULL;
' [$ O4 q; f- _8 ] - char *dmabufdest1 = NULL; u& W; l1 r1 E- ^+ m
- char *dmabufdest2 = NULL;; i3 n( S# ?$ n& R4 Y
- / T% Y% m$ j9 I( K) {) T
- static int acnt = 512;2 H4 ^- X7 S9 E* ~0 Y
- static int bcnt = 8;
9 B( I1 Y) S- i0 e/ I8 X% t7 y; y - static int ccnt = 8;
. \& c- L% Q* }5 K' [6 o8 h - 3 ?" W% m) B0 [3 H) h3 Z$ v- q
- module_param(acnt, int, S_IRUGO);! R$ m) m! F! ]) U. {3 S8 z3 U
- module_param(bcnt, int, S_IRUGO);
8 q" N$ }; x. j$ l& \% A - module_param(ccnt, int, S_IRUGO);
复制代码
7 X& k1 s c! Q4 n/ H+ A/ f5 e
. Y1 H2 N/ k0 Y! |6 J 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
7 [" B/ n# H% u% {: [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 q: {3 k5 v3 K- o 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
' o' N3 I' Z" T0 I+ L# ]7 A6 A
! Z0 o H( T) q# o
* f& w& y5 ^' V |
|