|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
( H# g6 Q+ M: i8 G3 \* r* C- [code]EDMA sample test application
" ?; d1 p0 u0 W1 `! z5 m9 T1 K# Q - /*
8 b# m8 J( Q- S% J - * edma_test.c( }9 e$ ]! K' [
- *6 h/ E7 d) H) M. \4 _% j7 c5 \
- * brief EDMA3 Test Application. ]2 }; R" H0 H$ ~4 L+ ^
- *
; j$ x6 ?! \8 v# d - * This file contains EDMA3 Test code.
9 a* I' m) M/ a f% ~3 K8 H - *
$ R, l5 C& D3 ]- _: U7 C - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
1 v- K: l! y3 _/ \ x5 z# o - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT; b0 F/ p8 b; Y# T( c9 U
- * TO CHANGE.* t4 @: p, M9 L F4 d- O
- *9 d3 R0 s, U2 V- j, U
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/% A! C! z( E: j
- */ f' R1 [5 O3 ?
- * This program is free software; you can redistribute it and/or) l5 E. P8 H/ b% e) Y
- * modify it under the terms of the GNU General Public License as
: I2 B {1 y% Q' s4 S - * published by the Free Software Foundation version 2.
" t# S$ e9 L# t1 Z - *8 I2 v# M' n% A: u6 B
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any2 Y( Z2 y3 b5 W& Q# F O3 f
- * kind, whether express or implied; without even the implied warranty
/ @. `5 i" `" U% I' S+ C, F - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
" [$ P* B; L) \4 x' P - * GNU General Public License for more details.
9 z, b3 v2 j% A - */, R5 t" S& b, z
- & m" B* X$ ?5 t6 z2 `9 X
- #include <linux/module.h>3 {" Y4 A/ v5 K! `5 J) M+ B
- #include <linux/init.h>- ~* s. C: W- [3 e! j
- #include <linux/errno.h>
0 \6 v# s4 Y d, A3 X - #include <linux/types.h>" @; p. K0 v; z5 R9 H2 Y
- #include <linux/interrupt.h>
* v' S+ e x' h9 M9 T. T - #include <asm/io.h>8 o) V2 Y7 N; y! E8 o1 ^3 Q H# y
- #include <linux/moduleparam.h>4 ~, V! L8 ^% S$ q
- #include <linux/sysctl.h>
! W1 D+ _* m/ G& @ m; @. _0 P% k - #include <linux/mm.h>; m# l0 o! q7 k5 A9 X- }
- #include <linux/dma-mapping.h>% }/ ~6 Z0 M2 F+ }. b
$ o" p# Q- p' e3 Q l$ o- #include <mach/memory.h>; u- R9 G, V5 C
- #include <mach/hardware.h>, f h- I5 ]7 b1 }
- #include <mach/irqs.h>
, B# Z6 S; U# k9 p, I7 \ - #include <asm/hardware/edma.h>: K3 n' k2 ]$ I5 F" G
- 5 n4 f+ o3 c' t- p( s8 F/ a9 r
- #undef EDMA3_DEBUG4 F2 r% J+ Z$ D
- /*#define EDMA3_DEBUG*/9 @" R: b3 \! T
- g+ ?$ } L% X% X1 R- #ifdef EDMA3_DEBUG
& o1 a6 P' J) S* S - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)% ^1 K* @, }' j+ Z+ c5 s& J5 f
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)$ K8 b' v/ Z2 @* v4 G
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
, K/ X' h8 k/ z/ T" o5 ~7 g7 C - #else
, U7 p; k ?9 P8 w - #define DMA_PRINTK( x... )3 C/ m/ z9 I1 C# k" u" p) s; U# |
- #define DMA_FN_IN
. A j& n. @7 J6 p1 K" A - #define DMA_FN_OUT; [; H$ \" m }4 K/ t- {
- #endif7 J+ y7 _ U& w$ W5 z3 p& j) a# l! k
$ ]8 X x; W7 h& k' o5 L& G. h8 t1 E- #define MAX_DMA_TRANSFER_IN_BYTES (32768). q4 r' Q# Q' R d
- #define STATIC_SHIFT 39 `( c h& M( i' J
- #define TCINTEN_SHIFT 20
9 q! C+ [7 D) T; O - #define ITCINTEN_SHIFT 21' m0 @2 V+ Z, V+ S- I
- #define TCCHEN_SHIFT 220 k. n& P2 g( i2 Q
- #define ITCCHEN_SHIFT 23, u& C7 F0 x- |% J
3 {! f, U4 j9 e- static volatile int irqraised1 = 0;
/ `4 x4 Q0 @) W) E0 ?, m% d+ U - static volatile int irqraised2 = 0;
6 a& t+ [3 ?" a' `0 m
0 [( Z: R8 t. r; y+ \0 a. \" X, T4 z5 Y- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
+ J1 D; N% X. B - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
7 y) @6 V" A1 N$ z; d' J; o - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);! l0 s; E" s+ I- F) k1 e3 b& a
7 Y5 ^& K; G- p i: |- dma_addr_t dmaphyssrc1 = 0;* a; \5 k/ k6 Y0 h& D1 Y1 s
- dma_addr_t dmaphyssrc2 = 0;
. U+ f. Y5 s- G& I4 _6 r4 c - dma_addr_t dmaphysdest1 = 0;
1 n/ n6 H" A& K) J" \# D - dma_addr_t dmaphysdest2 = 0;; u9 V8 Q W3 W. {2 x3 h% e3 Z
- ' F* n7 q! ]$ ?- f& N4 g
- char *dmabufsrc1 = NULL;
" e5 w0 B9 X3 P. V! w3 i) S$ U. e - char *dmabufsrc2 = NULL;$ o9 e$ G8 _6 n
- char *dmabufdest1 = NULL;' U' p& ~! ^7 d& f2 e M1 D
- char *dmabufdest2 = NULL;
9 l2 ]" q6 p/ x" |7 Y - ) _% v: U; N% l. ~9 D. R( O* ]1 C4 Z
- static int acnt = 512;/ ~0 v2 w* B4 e+ s$ }! w2 k
- static int bcnt = 8;* R) D. R1 S% W+ @8 J
- static int ccnt = 8;
1 t6 F8 r# m& D# r- p7 _0 Q0 n
1 s0 ?7 y, A1 m2 V; [5 O- module_param(acnt, int, S_IRUGO);( |2 x: O6 N5 |1 _' [7 d( n
- module_param(bcnt, int, S_IRUGO);3 w M" n7 K' y5 v' S! }' x
- module_param(ccnt, int, S_IRUGO);
复制代码 ; _7 D: D0 {. Y
1 l; ?& c# S7 H- s/ |% L 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
3 x7 _9 q5 \5 C* S W0 \# Q0 W9 parm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
5 s0 P; g: P; r, h0 `" {5 h D+ l: t 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
* h! K) s: c0 f
) P7 X$ H7 R* N' C" M; K! Z1 ~& x) r: [ C
|
|