|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 : ^- |; r5 l, k! I* ~( I
- [code]EDMA sample test application, f% U" J. h2 U8 E8 c/ {
- /*9 T3 R% L- I1 x0 h; c
- * edma_test.c
, c. Y& e+ L- _2 r3 S$ f - *' G; C/ B3 r; G& C
- * brief EDMA3 Test Application
( j8 C& B; \5 C& [9 i - *
( `& `' [, N; W5 _ - * This file contains EDMA3 Test code.
8 J# A3 {, W0 [9 q1 \: g - *: U8 b ^0 X9 {
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
* Y8 T. a b7 [0 X( ^/ d - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
; `3 O3 W9 ?& Y. a - * TO CHANGE.
3 U/ ?! W' n& A1 M( n - *3 K$ Q' ~0 @+ J# V* P9 a( z
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/! x& f7 N7 F% S) v- s& Z u
- *- Z2 Q. h0 f1 W/ \. z9 F) O h
- * This program is free software; you can redistribute it and/or
3 I: j+ X. Q" u" P - * modify it under the terms of the GNU General Public License as
5 ?3 a `* y" \/ A( C; y - * published by the Free Software Foundation version 2.
4 r5 f! L2 {( w7 d4 @! v% B; G - *7 _( A. C) N! N
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any* L. P+ B/ G8 D+ T
- * kind, whether express or implied; without even the implied warranty
8 d) C8 j4 \, ~ - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
4 z7 K' b, v7 S2 s( _+ t% g; E! ~ - * GNU General Public License for more details.
& A: P& u9 f( f7 y5 W5 n c% J - */. x" c! V& [- r5 \
0 h% w) Y. Y+ U' s: u1 s# {! E, h; z- #include <linux/module.h>' g* C- A* s$ D& ]9 ]/ r6 u
- #include <linux/init.h>: ~7 C4 d$ |/ p( n! }
- #include <linux/errno.h>
* Q. F# \+ S: y! d5 Q- S - #include <linux/types.h>0 @3 q! F4 r% \$ V _% k
- #include <linux/interrupt.h>
) V% x C/ J |( \. X+ k; k# ? - #include <asm/io.h>
5 P$ Q; u# J/ Z# u$ x0 u. E9 \ - #include <linux/moduleparam.h> I0 n% d2 h( w
- #include <linux/sysctl.h>& S. s5 A6 l3 M8 ?/ w2 S8 J
- #include <linux/mm.h>
" L }; q% Y& b# K0 A' P" ~ - #include <linux/dma-mapping.h>
8 k) g8 ^2 i! g' m" ~
( E1 _, C* k3 k7 ~& u$ \, C& t- #include <mach/memory.h>
& Y: t' D: I' A3 O# A' ] - #include <mach/hardware.h>
' ~* O1 t* c4 T8 B* P - #include <mach/irqs.h>; i: r. U: r. L
- #include <asm/hardware/edma.h>
) \6 e$ L$ s+ Y/ Z- S: m - : x# }8 B+ y* T; g1 R! b8 e
- #undef EDMA3_DEBUG
1 K+ `% m* L; o1 T, `* w9 k - /*#define EDMA3_DEBUG*/( ^% k* y3 P6 B2 N4 R( J
, z$ H4 X L/ t4 t; R T- #ifdef EDMA3_DEBUG
/ {; ~. a ~- w - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)/ S2 j+ i! @; o$ G, h% o9 u
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
; V8 d7 z5 R6 |5 r# } - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)8 Y; q C6 Z% N( r5 y# v5 `
- #else
" A6 ]7 B8 a) o4 P - #define DMA_PRINTK( x... )9 i8 g1 R$ r$ g# Q' p
- #define DMA_FN_IN
4 p7 e9 Z/ f' J, Z - #define DMA_FN_OUT6 _! r: b. p) t
- #endif
# q# c. t; U# ^2 I
7 X. f+ y a4 e7 i6 L$ ^- #define MAX_DMA_TRANSFER_IN_BYTES (32768)) S) `7 g1 X. D, I4 m
- #define STATIC_SHIFT 3
9 K5 j) B$ ]- }9 b - #define TCINTEN_SHIFT 20
" `6 l6 f) Z- W. x+ L - #define ITCINTEN_SHIFT 21( D! R) ]5 |6 ?& m. E& Y
- #define TCCHEN_SHIFT 22
9 p. G, p/ U1 q% l6 Y( k4 z- X0 ^3 s, P: B - #define ITCCHEN_SHIFT 23
; K, U, M4 @- t$ V4 W0 D# R6 G5 F - & ~8 M& h6 p! H5 J
- static volatile int irqraised1 = 0;# t" ]. b! [0 o0 ]
- static volatile int irqraised2 = 0;7 V3 }3 x* ? T1 f! N3 }
' V- z( o1 z$ K* R, }* }- J- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
" f0 B, k2 R4 Q0 P, { - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);1 T, o6 Z& U* m6 d
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);6 I$ P9 A2 g! [' }! R4 C
/ F) Y$ b. B3 m1 T7 `. P- dma_addr_t dmaphyssrc1 = 0;/ I) B2 K: X, S& B# i
- dma_addr_t dmaphyssrc2 = 0;
6 ^/ T5 G, }+ e; \* h) e - dma_addr_t dmaphysdest1 = 0;
4 g# D7 t; o. f" ^& z& s, L7 n - dma_addr_t dmaphysdest2 = 0;
2 ]" ^, L$ v) Z% r: T# b6 S
6 S2 o3 q4 ]% C6 o- char *dmabufsrc1 = NULL;
0 \7 ~; l1 i' _# H& |* o" g - char *dmabufsrc2 = NULL;9 ~' L: {# f! y/ f) I- L
- char *dmabufdest1 = NULL;0 j- e% F, B u( q/ R$ _) T8 r7 V% _
- char *dmabufdest2 = NULL;- j( I# p2 d' `
1 c. f/ `& \# p. G0 V1 [) g* R- static int acnt = 512;
) O* q8 J! d! O" Z9 ? - static int bcnt = 8;7 Z% m/ a3 o: x$ |( F" y- \+ B
- static int ccnt = 8;& V( q% | S7 o
- + N, p( f5 d" Y i! d5 z6 Z# h
- module_param(acnt, int, S_IRUGO);
" {5 F, z( U: E3 | z! M2 m0 ] - module_param(bcnt, int, S_IRUGO);, x8 q L- o, _$ g
- module_param(ccnt, int, S_IRUGO);
复制代码
/ T/ x/ ?7 b' G1 G9 U
" D9 M; B! t2 C1 W 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
& R0 ^' Q7 S/ k3 u8 D: [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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
8 X3 W. T# {" T8 d) l, G 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。. `/ H6 }* t9 x$ R0 @$ p6 z" Z
& w2 M2 {2 q: a+ B) n, Y5 D5 @% Q( T, J4 \- A( W
|
|