|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 # y; u; M* B" x& k# F/ s
- [code]EDMA sample test application, Q2 @; Y+ F6 \; k- U W
- /*
$ f. r5 w+ c# I- t% j' ] - * edma_test.c; _; f% K8 w5 W4 B4 q# o2 w0 a
- *
, j! s& Q& ^" u# ? V - * brief EDMA3 Test Application% _- F% q# n/ i% S' t1 ?" d a3 A
- *
- C0 r9 Z2 D( V& M - * This file contains EDMA3 Test code.( q: q1 {3 D- Y9 ~; A8 X( r
- *
. g& C5 N* G1 f - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE, U6 h# _3 \5 u+ e; W ~
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
9 y% D7 k$ V& Z4 [ - * TO CHANGE.5 O) R' [/ l; x6 J/ f
- ** c& A& o6 K9 W+ [0 K
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
1 w8 Z; Y2 k. h$ ?! i - *
# T$ @( w- W E - * This program is free software; you can redistribute it and/or' I! A( G! m, ? e: h7 Y' y$ ~3 S
- * modify it under the terms of the GNU General Public License as @6 Z `4 _1 S# R- d \3 ?
- * published by the Free Software Foundation version 2.0 Q }3 C/ t( e L* }( }
- *
7 B1 f# {3 ^/ f4 v) G. H - * This program is distributed "as is" WITHOUT ANY WARRANTY of any+ s3 S$ z0 |; q5 H. Z' m6 x! ]
- * kind, whether express or implied; without even the implied warranty
0 T) g$ t! t6 |2 d - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the/ `, Z8 q7 i% @& L: r! I
- * GNU General Public License for more details.( i/ J5 K, Y$ `; e6 f" ], K$ v
- */8 N% c$ `+ q/ A8 M
- 4 a* ~0 L& \( C* f
- #include <linux/module.h>
: R* t! Q$ ?7 w+ D! O - #include <linux/init.h>
2 C$ ], {% [# m3 `3 K, P' @! N - #include <linux/errno.h>
' }; Z1 A4 B, u y$ d/ e$ M - #include <linux/types.h>- q1 b+ r- U" R& q. u* O( B) D
- #include <linux/interrupt.h>
& R) I) v; ~0 H) a/ I - #include <asm/io.h>. L- o/ T& G+ R4 t: Y- s
- #include <linux/moduleparam.h>9 v* Z7 S( R! |6 x4 F' T7 D" E
- #include <linux/sysctl.h>& S1 D y- g- Q
- #include <linux/mm.h>
& K* X% s( Q; y! \. q# ^6 r# ^' s+ C: N - #include <linux/dma-mapping.h> b1 F7 I9 M, i6 { S
- & ^# L7 Z3 L$ B0 j5 o3 M W
- #include <mach/memory.h>7 H' j1 l6 t4 T. @2 [0 e/ V4 r
- #include <mach/hardware.h>
2 n- F0 H& o4 t, P! e - #include <mach/irqs.h>5 T; p0 O& ?6 ~% G
- #include <asm/hardware/edma.h>) p {. A: D. {6 h' w8 g, E
- 5 ~, ^2 l& K# k' k% k
- #undef EDMA3_DEBUG2 w; o( _2 O1 o; `* g, u% S9 {
- /*#define EDMA3_DEBUG*/
' C8 j9 F- P; s# a% F$ ^& B+ n - W$ @8 U9 d8 y- {. s, G/ H, m
- #ifdef EDMA3_DEBUG
8 l) [$ W6 j! R- @. B' h - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
# c) H( O- k( L4 u% e - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)) x! h0 @- N' d0 p. D B
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)! M4 _, ^3 H- Q8 r, e' D
- #else7 p) H2 T0 g( ?- l
- #define DMA_PRINTK( x... )* X' i( p* B+ |- ?; e# f7 C
- #define DMA_FN_IN/ R+ ^2 Z5 S7 Q8 I, v4 U) i
- #define DMA_FN_OUT
4 h- n [( ?3 l! y% s0 X- g - #endif( b2 R) J! g2 C) u2 @$ g9 M$ P
+ p* d8 x; Y5 }- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
- Y4 m( r# [" A1 M, \4 c" W6 Z( j2 d - #define STATIC_SHIFT 30 N* F% j& K. s! f/ f
- #define TCINTEN_SHIFT 20
# R( z2 h" R: I7 f% z* O - #define ITCINTEN_SHIFT 21) S) o3 t+ [+ Y- H* k
- #define TCCHEN_SHIFT 228 X9 M+ _8 X, l
- #define ITCCHEN_SHIFT 230 m2 B6 G3 ]4 t# q3 e
- 2 r% r+ f! x1 c* z# T2 n
- static volatile int irqraised1 = 0;0 Y/ |, K$ v9 k5 x
- static volatile int irqraised2 = 0;
. }5 n0 R2 C! v; y b* o. u1 w$ V - 2 m) e) Z( N( Q2 ~* p" l
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);, m7 x! E( `% l. ?; ~
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);" l3 ] n7 b3 e$ Q5 t6 B5 a3 n
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
! M9 [. [ y1 f - + V9 Z q, l% j
- dma_addr_t dmaphyssrc1 = 0;% B. m/ w! t0 i
- dma_addr_t dmaphyssrc2 = 0;. ^# I) A1 _0 _$ w+ l
- dma_addr_t dmaphysdest1 = 0;. ]8 R* Q: h6 a( R3 u' l
- dma_addr_t dmaphysdest2 = 0;* n6 g( m+ k2 ]+ i+ W$ @: A
- 9 u$ b3 d# h/ Q8 g
- char *dmabufsrc1 = NULL;
3 c8 A! ]9 }& u, C2 F - char *dmabufsrc2 = NULL;
/ ]; X# F0 p' _. T" A+ K - char *dmabufdest1 = NULL;3 ~5 K8 C, v i( p! u) s
- char *dmabufdest2 = NULL;: Y/ B8 r( Q' u5 ]
6 j( R% n, r6 ]- H, o. d- static int acnt = 512;
W' a L! ]; b; ?- G4 F - static int bcnt = 8;' W4 w- _& @5 ^6 U3 W& y! x
- static int ccnt = 8;
9 M+ k* i4 s, I2 g& w9 j - - ]* b4 ?; `+ g7 r- N
- module_param(acnt, int, S_IRUGO);8 q% X" i/ j- V& P1 P0 a
- module_param(bcnt, int, S_IRUGO);
( e/ G* a# ^3 V1 _7 Z& h% e6 Z2 h - module_param(ccnt, int, S_IRUGO);
复制代码
) { i2 m; o4 H) \7 n. q( H& l) R3 v5 ^: J* u6 l3 }- \ e
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用8 r# J* F/ M- m5 P
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。. n7 ^8 ]9 n6 }: M. X
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
" l' m) O- M& Z* n+ ]) m- X/ S+ z# w6 I3 {, m
- g% c# u7 D0 W% s w) R! z |
|