|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
x) D a/ }6 P5 t+ y3 z+ r- [code]EDMA sample test application
2 {- [) `' q; e7 l - /*
6 J( C7 a) M2 X' G. y: }5 E - * edma_test.c
% l0 c. }4 z H/ k: h - *
; C* F7 M' y0 {; t - * brief EDMA3 Test Application
. K3 x q" ~& @9 ?% j. t - *! d5 T3 a4 L' }2 [" I6 _
- * This file contains EDMA3 Test code.
& U* A9 p8 t5 t0 s3 h: g% Y6 K - *- {4 _% G: H5 F) p2 Q' R; O
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE% n# L7 K' Y% g( S, e; G4 B/ d( Q
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT8 a r+ S7 L: q
- * TO CHANGE.9 R* n' t0 d/ d; H
- *' [0 K. I( D f& e! ~9 \4 A
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/8 V( `0 x) o6 j. l* Y3 t- L
- ** {6 g( [/ [9 W( m
- * This program is free software; you can redistribute it and/or1 ?# h! G" A. M& l
- * modify it under the terms of the GNU General Public License as
) j* n T6 _5 v - * published by the Free Software Foundation version 2.4 U, ~3 I% I- ` w% x* Y
- *5 Y4 r) M" c0 J# Q
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any9 s# g- A: ^% a; \% k" p
- * kind, whether express or implied; without even the implied warranty
" _; E) G- K- k [/ d: w; e - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the0 W- |- u, n4 o7 {5 _2 x$ E
- * GNU General Public License for more details.
! N( B' U6 Q" K5 k( a - */* u" T% Y, s3 d- Y [
9 f* T" z# r2 M. @. q- k/ e; }- #include <linux/module.h> J6 q4 e) N% ]6 E. `. `$ Y% [
- #include <linux/init.h>! g& ?8 r# A5 Y0 V( p' f' K
- #include <linux/errno.h>) P1 V5 w; x$ c% L
- #include <linux/types.h>
* W H/ A: r4 |% n' e - #include <linux/interrupt.h>
' X& j) V' i4 F, t0 X* f# S6 n - #include <asm/io.h>
; I" e+ ~- j: p6 m V) U - #include <linux/moduleparam.h>
5 d; ^5 R$ t( B ?; J1 }. c - #include <linux/sysctl.h>& @' Y1 L: V! z( k; [/ e
- #include <linux/mm.h>! s9 l R9 f2 V1 S
- #include <linux/dma-mapping.h>
' w2 b1 j* o; }3 G
( [0 ^; U) E- [( S' Y" G- #include <mach/memory.h>
- n* A5 C( i; v2 o3 X( h8 k - #include <mach/hardware.h>
1 ^1 r& I5 ?6 K! e - #include <mach/irqs.h>
7 s( x# t3 N5 k - #include <asm/hardware/edma.h>
4 _# H8 {8 z9 h1 W: ^5 U) I2 j
7 s7 J" J5 s- L ~) V* S- #undef EDMA3_DEBUG
4 }$ }/ y, x: K/ Z( p9 z - /*#define EDMA3_DEBUG*/3 U1 V4 N! ]# A0 L" d
0 H) Y6 i8 j1 B- X- #ifdef EDMA3_DEBUG1 ]1 h+ J& B2 h& p
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
- e2 m; {6 J1 V - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)' M. @. _+ d. I! T2 q: c1 j
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)# o# }/ C1 t# D5 N
- #else
& D/ e" V$ j3 X9 F, ^& S7 z - #define DMA_PRINTK( x... )
8 ?1 z9 h* ^- Q4 c. x - #define DMA_FN_IN
; \1 Y9 X9 y& v" [ - #define DMA_FN_OUT% q$ o4 E% w2 i5 Y
- #endif
% y. L5 @0 X5 l& ^/ A
9 ~* P# U! c) A% ~: `8 J- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
$ l0 w! t1 @6 J2 _2 Q" |8 x - #define STATIC_SHIFT 3: T" |/ }8 `% t5 m/ `
- #define TCINTEN_SHIFT 20% _0 V# J R. N! w1 {: i6 Z2 J- B- O% |
- #define ITCINTEN_SHIFT 21
" e/ z) V+ M8 k: a/ @ - #define TCCHEN_SHIFT 22
& p& o% \* S! J - #define ITCCHEN_SHIFT 23, I1 q* r' D! Z1 j5 Q, \! u
2 C, [; A* F6 [. B3 Q% q) o- I- static volatile int irqraised1 = 0;1 P! K- P$ `5 c# ~: V
- static volatile int irqraised2 = 0;
! O: o; E; X: ?% f# l3 u2 U# j
' M4 S/ U5 g; _. v+ L6 |- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);9 I- [; P x" P# T/ Z
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
) | E% g1 X! {4 J9 u - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);) F! E; o8 S9 F3 ~( s* h8 }; ~4 M+ \
- / B+ }; V! E7 r& y
- dma_addr_t dmaphyssrc1 = 0;: D" ]0 |* m# n( a
- dma_addr_t dmaphyssrc2 = 0;9 @: N% \' Y- H& g1 p8 R) Y
- dma_addr_t dmaphysdest1 = 0;
* {! U5 k* [; q* p2 f, ]; M& x( S! R. @ - dma_addr_t dmaphysdest2 = 0;
# n$ K/ F- M" ?1 x! f% v - 2 B5 E( {6 A7 ~
- char *dmabufsrc1 = NULL;1 M G$ b8 C0 S' E4 m
- char *dmabufsrc2 = NULL;8 i3 p. L+ V, b9 j: P' w6 S
- char *dmabufdest1 = NULL;
2 V# n ^4 n) L* S5 I* W$ _2 u - char *dmabufdest2 = NULL;
5 X0 s9 T! C0 V. I- S; q - 0 l- q ?7 u8 @
- static int acnt = 512;0 F3 f- B6 z2 |8 L( B' j* C
- static int bcnt = 8;% ?8 A+ q$ W: l2 W) M1 T' \& j
- static int ccnt = 8;( h2 `1 M3 a$ z
- 5 c8 S+ o$ J7 D# ?% U$ E) u2 R
- module_param(acnt, int, S_IRUGO);$ ~$ |$ K. u% V5 M
- module_param(bcnt, int, S_IRUGO);
2 [! K$ w8 r( l& ~ - module_param(ccnt, int, S_IRUGO);
复制代码
7 y' u2 G' @9 g" E2 u) ]! K
* e* c X- u( v! N' T 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
5 d1 {2 M* z0 B. q. N! m, iarm-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 Q9 s1 T2 b: y9 Z8 d; C 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。1 m$ M3 L2 M$ _3 d
8 l) E+ ^* c$ j* z( W# v# J
~& J6 F5 h3 s1 f4 b) y |
|