|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
6 A- F' v! |/ w, K- [code]EDMA sample test application0 u. f9 ?2 p+ _, d6 |7 o; i
- /*
. }. r: o2 u) ]; K6 a( P' w' v - * edma_test.c
0 S0 y+ p6 I* U- B# l5 g; h - *3 h* p, _ B: c
- * brief EDMA3 Test Application
# z& _4 m; F" W8 B# q6 R+ O - *0 w0 _5 X( D) x! O* y# {3 V
- * This file contains EDMA3 Test code.
H6 J" d+ D# \: O - *
; J( v' y+ u& o4 N, \ - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE; ?% M; n5 y5 o" {' B
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
9 [/ c2 T# p; U/ S - * TO CHANGE.
, ?& H% r( W6 r! L G; ^% j; W - *$ z( A) |7 R+ k o
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
8 w. L; Q- v2 c4 h9 |+ Q# p" E4 } - *
9 u3 E5 b7 i# K4 l+ c+ L - * This program is free software; you can redistribute it and/or8 m* Q! k6 ]" M8 l$ W
- * modify it under the terms of the GNU General Public License as8 e! i0 L X# Z) l+ D
- * published by the Free Software Foundation version 2.; T! ], z4 l' ]# k) N V
- *+ | C* r) r: L+ L; K& k* @
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any
}' r- U Z! w - * kind, whether express or implied; without even the implied warranty c: ~0 y) W( ^# d
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the) n, P- S; y4 J( b
- * GNU General Public License for more details.
5 z8 d. B/ g/ L5 s! H, t - */. a( X7 r+ P5 |7 B0 K
- 4 q O: l9 ]5 V! @8 l
- #include <linux/module.h>& c1 E% p0 ]9 \( _! ^$ V$ A4 V5 E
- #include <linux/init.h>, b2 I/ e/ O+ V* f0 }' D
- #include <linux/errno.h>7 k* t0 w: l" m
- #include <linux/types.h>: ]3 |* `6 W2 R. c ^+ }! h1 W
- #include <linux/interrupt.h>
8 D5 p. ^3 `& j' @- K4 K3 E# h - #include <asm/io.h>
, a, R) y/ l% N) M( o# W; } - #include <linux/moduleparam.h>
$ N" D7 [' o2 \3 ~( K5 D - #include <linux/sysctl.h>) [% O! a( S1 e
- #include <linux/mm.h>/ T7 q9 @3 |; v! i8 y4 Y; Y, C) i
- #include <linux/dma-mapping.h>/ x) o8 {. k. M) P/ Y
- $ _5 V u( V5 D6 {1 i
- #include <mach/memory.h>
) e# x) b: K2 e& o: ]% J0 V% w0 [ - #include <mach/hardware.h>2 m4 g# K% b# N. }! W
- #include <mach/irqs.h>9 n0 d5 t4 d5 N. z$ b& ?
- #include <asm/hardware/edma.h>" e# K& p; a( K9 ?( x/ P& z
A z; H* X, I5 V1 ?/ M: f- #undef EDMA3_DEBUG* |+ e* _$ R* L2 K$ K- m
- /*#define EDMA3_DEBUG*/
' R" S/ x/ K! j: s, J1 K
* g# R) d A, n: f6 M( V* \- #ifdef EDMA3_DEBUG
9 V& H0 G- w9 v" V0 C) [% Y, _ - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)" E- I5 z! \. w" q4 y
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
6 N' k6 {" D, t0 G& O; E8 m - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__): X I9 i, y. b l! e. b
- #else
( {2 d' V1 h1 N8 C - #define DMA_PRINTK( x... )! h7 [' H u$ f* j( R
- #define DMA_FN_IN' |" H* T: _ B1 |
- #define DMA_FN_OUT
' b8 ^! w- f- L+ @9 b- H - #endif
8 S- C$ k7 O) `- D, Q4 X0 T3 s* |% k3 @ - " c! r; s, d( A0 E
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
! \( ~4 Y1 n+ ^/ }7 T8 O( v - #define STATIC_SHIFT 3
5 ?# v2 R0 v: J2 x - #define TCINTEN_SHIFT 20
) L4 q7 `3 O* g( |& D+ y& Q - #define ITCINTEN_SHIFT 21
" k- v! W* L7 U" O( T - #define TCCHEN_SHIFT 22
- X( D1 D1 m9 _ z - #define ITCCHEN_SHIFT 23. U' m; {6 O0 o' i! [& A
* U5 ~0 Y5 L2 b6 |0 G/ o# Z- static volatile int irqraised1 = 0;2 e5 H7 o" H9 ?
- static volatile int irqraised2 = 0;4 S5 d9 O7 C' I5 p8 H
- + p) w- v& |6 u5 P! T
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
$ S& N/ A9 p: }9 c, H8 _/ S( D - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
$ W, U' E3 }# F" R' M( q. F - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);) A1 M5 T; W# B
- 0 M4 t6 ]8 [( O6 a+ S8 p
- dma_addr_t dmaphyssrc1 = 0;. @3 |0 [* N8 p l5 I2 ?$ r
- dma_addr_t dmaphyssrc2 = 0;1 \9 a, m! k- O1 x- C" W
- dma_addr_t dmaphysdest1 = 0;- t+ e! S$ t* y3 O* q' i
- dma_addr_t dmaphysdest2 = 0;
& P5 F" T! h# \5 i6 L4 @$ r; @6 S
: G3 |0 R! e9 U* S& {) W+ l2 J- char *dmabufsrc1 = NULL;
5 r: H7 y& o9 p9 F - char *dmabufsrc2 = NULL;
$ E' F/ D7 a' R+ w5 H6 @ - char *dmabufdest1 = NULL;9 W4 g8 X# R, ?1 w; b3 H8 u/ D- w
- char *dmabufdest2 = NULL;8 W# Q" t! u5 H7 B# h `* b7 A
1 k2 q8 A9 C4 \0 S9 m* l$ _- static int acnt = 512;& \5 f& x4 Z/ s. X0 _* N, ?& E' \
- static int bcnt = 8;
3 d* K* Y; u9 }6 F4 d3 S7 r& U" S$ H# n - static int ccnt = 8; H% \$ h$ ~7 @; v5 @# N! C/ j
+ A- M# g7 c0 U, { f, M1 E* \- module_param(acnt, int, S_IRUGO);
: @7 ? o) O Q( b+ c9 | - module_param(bcnt, int, S_IRUGO);
4 x9 w3 V9 g8 n0 b) Z0 y2 ~ - module_param(ccnt, int, S_IRUGO);
复制代码
% U$ d0 M) F1 l2 p- }6 B/ d" S+ `9 a! l0 }$ D4 X
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
t6 {( o R7 O# ?/ Varm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。7 ^4 I# w" L) s* n: A1 r2 S) C9 C6 h
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。% _* M" P- f" F- |0 a" s
* u# I( d, K4 I+ c4 a; j- b
. w) X" @2 P% @# \# X |
|