|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
3 v- c7 J, ~5 \# `, U- [code]EDMA sample test application# X9 @( W5 ^' c% m: [: w2 v1 h
- /*6 I0 |( W' b' W* V" z1 X0 _
- * edma_test.c
# T1 y$ @7 i* e/ p) d - *
3 Q3 O$ t$ X# u: | - * brief EDMA3 Test Application
/ d. h& q: Q% D - *7 M4 u/ B5 J2 c" s7 X4 ], f0 k* M; L
- * This file contains EDMA3 Test code.
$ s+ z+ C* E6 h# N- o4 ]+ Q# j- k5 X - *
) M& K3 N- g0 x3 M; F+ L4 A - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE9 `: o% f1 g# q1 a. E7 y/ L! A
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
$ f- v. Y. B% K5 Y$ K3 B% g+ m t - * TO CHANGE.0 x h7 a; ?, V# M
- *
$ ~5 M: }2 a! |& s, x' }* \! \ - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/: z! V$ T6 [) n& o4 r+ `& _; O& Z
- * m" O- O7 i% ?6 P c' M4 o7 g, ]
- * This program is free software; you can redistribute it and/or6 O6 Z! G" |9 j! ]
- * modify it under the terms of the GNU General Public License as
; u/ f/ P" L( g9 w+ u3 q, w5 Q; d - * published by the Free Software Foundation version 2.
9 U8 g. u( u8 B5 ]6 |8 a' U2 F) q0 V - *, f) E. \5 [0 `, b6 p( w. q
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any' Q5 Q0 @/ \ h5 I, y8 r
- * kind, whether express or implied; without even the implied warranty
; m }# U4 z0 K - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
' t3 K1 `1 _$ N( k3 T1 w6 y! x- O, o - * GNU General Public License for more details.! M' @+ d! O" `% @9 y
- */
" ]2 L8 J( R( F6 {* X - % S9 }1 m; i# M
- #include <linux/module.h># U& o! x- J3 k* \! F/ P
- #include <linux/init.h>
0 D% O9 E6 t8 ~3 P8 n5 A8 a - #include <linux/errno.h>
# L9 L: r) c" j6 J# M - #include <linux/types.h>
; k" J! U5 i/ u1 t) A" p - #include <linux/interrupt.h>6 Y$ P1 B5 b6 Q$ M/ w
- #include <asm/io.h>; d5 y0 p/ Q: S; W. l& [
- #include <linux/moduleparam.h>
, A* K! w4 N- { - #include <linux/sysctl.h>+ I. `& [' |5 J4 R
- #include <linux/mm.h>
- n% S5 d+ H" ]4 m$ X. U - #include <linux/dma-mapping.h>, ?- Y, d* p g
- ! U# T C6 d% T& R7 ]" H f
- #include <mach/memory.h>9 _; K2 H* z2 a& V. q$ u) y
- #include <mach/hardware.h>" B& G/ g4 g$ F; l
- #include <mach/irqs.h>
5 z! L: w4 d1 W4 G1 }- I - #include <asm/hardware/edma.h>
) W& B/ j: n, S5 B# H% b( \8 n2 Z
) z4 @4 h6 q m8 z: e V3 ]; W- #undef EDMA3_DEBUG# N" i* J5 s. {! Y/ t
- /*#define EDMA3_DEBUG*/, }2 t, z9 o. ^& h# P
- 4 r- D4 \+ u* h
- #ifdef EDMA3_DEBUG6 L4 A! I4 s; {4 Q1 e2 ]6 ^$ U
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
2 J- \" M" N9 l, A5 ]1 X - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
& o o0 J x7 X8 O - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
! r8 O, ^4 K6 G9 { - #else" |( m6 J0 a8 {* W
- #define DMA_PRINTK( x... )- z. j9 {5 z2 f9 `
- #define DMA_FN_IN2 r/ F4 G. u/ O! ?
- #define DMA_FN_OUT
" K& v8 T' x2 i' N - #endif
1 r; m( v8 M* @% ?* w2 W
: q g5 K5 F) `$ `; { F- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
+ O) N7 C2 S! e - #define STATIC_SHIFT 3/ }) n4 U4 q+ O
- #define TCINTEN_SHIFT 20' Y4 t4 W- g. g. H1 a& s: S1 x
- #define ITCINTEN_SHIFT 21, E9 I2 X8 p& k1 W7 h
- #define TCCHEN_SHIFT 229 O6 d- i. h# N$ U* ?
- #define ITCCHEN_SHIFT 23
4 v/ P* K( v6 q - & i8 X7 j; l4 f$ ?
- static volatile int irqraised1 = 0;# W) S0 U2 |, [7 t; z
- static volatile int irqraised2 = 0;
% g1 t$ f" r* L; n. U
$ b/ r1 L: m' m& G- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);- n# w3 }- Z/ U% o* ?
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);% j3 u% K+ T' H1 F1 l p) V
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);9 ^9 ^% Z1 @4 r. X" B2 C6 k" m* Z
- m5 g- L( T) z) ?1 z- dma_addr_t dmaphyssrc1 = 0;( |; L6 ]# U3 V
- dma_addr_t dmaphyssrc2 = 0;
2 M$ K$ M7 ^5 E3 _7 {" A - dma_addr_t dmaphysdest1 = 0;4 U# m! \, D+ A; F- C
- dma_addr_t dmaphysdest2 = 0;: N% s/ G' P8 x6 e6 ]
7 g, d) `; l/ T- {3 U- char *dmabufsrc1 = NULL;1 p! G- m3 a2 D' |6 c5 p
- char *dmabufsrc2 = NULL;
' f' y, ^ S9 x8 p- D' I4 G9 ] - char *dmabufdest1 = NULL;# i: B6 j2 d7 V
- char *dmabufdest2 = NULL;8 g- T( K/ c5 s
- 0 U7 L; ]. u7 t1 L1 \ \ }# j( ]
- static int acnt = 512;' N. o1 `4 y( L/ B5 l$ t
- static int bcnt = 8;
( N: m" b3 P* t5 R7 \. M - static int ccnt = 8;
2 I9 a6 f8 Z; ^, v
6 G, e, v$ x2 t1 S- module_param(acnt, int, S_IRUGO);
; u* m0 J8 @; @ - module_param(bcnt, int, S_IRUGO);& \# `& f7 y7 `. `( W
- module_param(ccnt, int, S_IRUGO);
复制代码
9 y# s7 \4 h2 l) H9 g- Z! |
5 I" n& S, n( h$ l8 Y: W 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
: L# i! j$ h8 Y3 C" |' ]: E, xarm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
' d( t+ X+ y2 ]6 \5 c, G 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
4 \% `. B* @* @9 j5 d
9 D$ A; x8 {* \
6 [7 @: [2 d3 R8 ~/ J6 i |
|