|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
: s; m7 }. L% Z3 x2 j- [code]EDMA sample test application
7 }2 \* g' V/ \0 e! x/ z$ V - /*
- g U) k0 e" }- a( B" V# i - * edma_test.c2 _: `( y6 L: }2 k& \1 k* @, C, N
- *
" l+ I+ v! R& d5 R" e0 ?" z# A - * brief EDMA3 Test Application
- v* x {, s" ^+ z: a4 Z* S6 d - *
4 _- P" `) ~: c% `( N' N" ?. T L - * This file contains EDMA3 Test code.
. \ `5 k T1 n! q- T$ W - *
3 B9 {; K7 \' Q - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
& g- Z; b7 T; o - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT7 `3 G+ d, f* K0 s( Z
- * TO CHANGE.
: x) h5 Q( u/ G, \! _/ l2 X - *
+ n4 [: }3 H3 @. ?* U - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
+ J0 M6 E% a, }$ y% I - *
7 q2 f1 T+ Z" V" } - * This program is free software; you can redistribute it and/or% w' f5 E4 x. N8 r8 N7 J
- * modify it under the terms of the GNU General Public License as3 {8 f( G; ?; b9 o
- * published by the Free Software Foundation version 2.- Y2 p. u1 Z: A
- *. L$ |; X! n/ w# j+ k! r. T* K
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any$ f$ H- G* {$ X2 l9 f9 v
- * kind, whether express or implied; without even the implied warranty# |. T" \2 S0 n5 t5 I/ y1 [8 I. k
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
8 P0 p: o* x) Q - * GNU General Public License for more details.( C1 b- P+ K9 T& `4 _& q- d, f: t
- */
, v8 a. W o# \ - : {) ]0 k6 H j7 a
- #include <linux/module.h>
" N; f* Q9 U- ~& q& ] - #include <linux/init.h>6 c% @1 {; b9 A+ k9 n, l
- #include <linux/errno.h>
, f+ k0 T" O7 `% j - #include <linux/types.h>6 P3 J) E, k; S
- #include <linux/interrupt.h>
# e3 D# I) f$ q0 u$ L - #include <asm/io.h>
/ K9 a! n$ ?5 ~: e# E7 q/ x - #include <linux/moduleparam.h>, P# ~3 T: T- ~+ Q* p. x& A
- #include <linux/sysctl.h>2 F+ \" {0 v- {- Z8 }/ r
- #include <linux/mm.h>9 z7 B( W9 u- j; e' F
- #include <linux/dma-mapping.h>
+ ]+ B0 \6 h) U% k5 b0 r - 2 K! M% ~1 N7 @. H2 R& \) k8 G7 u4 S5 c; ~
- #include <mach/memory.h>
# c; X; Y7 y/ F9 V - #include <mach/hardware.h>
/ e* h8 O# U n( e9 Y - #include <mach/irqs.h>
6 L# \' Y1 F! b; I) C; C - #include <asm/hardware/edma.h>5 h) a1 T. k+ [
4 g& m* J" c9 ^* h- p- #undef EDMA3_DEBUG
) V2 E4 N$ [: f3 Q - /*#define EDMA3_DEBUG*/
- }% w/ O! `: K( C: _! U - $ X5 H4 b5 b) E) t1 R4 N3 [
- #ifdef EDMA3_DEBUG
/ ]. s% G3 C w9 C/ d( n3 _; I) w - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
) t- p& \ d4 T5 w) m% r& m6 B - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
2 W# L4 P7 F+ U - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)* c, D4 ], w* a% K
- #else- s8 `' u3 R) k( C) K
- #define DMA_PRINTK( x... )
! ^4 s5 j5 [% F - #define DMA_FN_IN" _5 P7 O: a. h0 Y2 c0 i+ e
- #define DMA_FN_OUT" e1 k$ g2 Y3 a$ k
- #endif
* w% v$ o. }0 ] S5 Z
% M/ K& ^+ }+ u/ Y8 R% c5 M- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
, E6 Y9 V) Y- F+ z - #define STATIC_SHIFT 3
3 y7 o5 g u1 f, z - #define TCINTEN_SHIFT 20* y$ @# G1 `8 L1 _2 d
- #define ITCINTEN_SHIFT 213 n8 N( c# |, y
- #define TCCHEN_SHIFT 224 b% I% d% K# C! @* v$ p+ _
- #define ITCCHEN_SHIFT 23
$ ~6 s7 K \& ~" `
. d' B" u# t4 V, }- V- static volatile int irqraised1 = 0;
: `' {# ]) t7 h( S - static volatile int irqraised2 = 0;: v. j/ o u$ {: c/ N2 `
- 7 T, o9 {: s; Q" j# }! b7 H" y9 c, F z
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);. m" g; e, K7 _4 ~- y* \
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);9 [% a8 K: N: E/ e
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);5 g- c I0 Q' I1 Z* V; V# g
+ _/ s* I( r& B1 z' {- dma_addr_t dmaphyssrc1 = 0;
, F, d/ Y$ ^- o6 \& Q: X$ ~6 L - dma_addr_t dmaphyssrc2 = 0;
9 d2 _# c3 K! l/ o& d - dma_addr_t dmaphysdest1 = 0;8 Z6 k/ k) _* u! v
- dma_addr_t dmaphysdest2 = 0;
6 o+ I4 h6 s2 T5 @' o, ]4 S# s7 d - E4 u3 P4 ]' ^% o- U
- char *dmabufsrc1 = NULL;; j0 T1 y/ q! {2 K7 s, @/ J
- char *dmabufsrc2 = NULL;
g, ~* k- Q- z" u0 Y8 N) Y3 ~8 i - char *dmabufdest1 = NULL;
% U9 w5 P4 Y8 @% W2 N - char *dmabufdest2 = NULL;
& ?$ o8 x4 }* n3 w1 e8 ^2 s6 @
3 t# ^7 @1 ~2 ^2 K6 Q- static int acnt = 512;
. \! E( M# \6 C$ k2 Y2 ` - static int bcnt = 8;+ O4 U% L- O2 I( Z7 a) X8 B+ B
- static int ccnt = 8;( ~# g5 m, x; g' d) n3 C
: @3 ]( t2 h v# m2 r6 ^8 z+ D- module_param(acnt, int, S_IRUGO);& |' F: l3 n8 e# O0 P
- module_param(bcnt, int, S_IRUGO);
; o- N! s1 J* K" y! @/ M2 D - module_param(ccnt, int, S_IRUGO);
复制代码 . |1 S& \# I$ m& T
% \3 @' m+ K* T7 ~% _
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
9 o8 U/ l1 k) t, u# _% T5 [; garm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。3 v; E& J' ^6 R/ Y; A6 D1 E
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。- e8 _& \6 c, T. M$ \( I
/ S# `7 g8 S( I3 g8 n: T) ?1 G7 {
6 H) {& f* v. }, z- e |
|