|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 # M" Z, J0 U0 ^2 n8 e4 k, S
- [code]EDMA sample test application
4 s- [+ t) n; j" q1 D& ] - /*
& U! Z: D4 z) d! ~ - * edma_test.c
) j; j4 E( R: q3 l/ F - *
/ F' q+ m, C# C% M2 n' i z - * brief EDMA3 Test Application; h! ^2 H! a+ ?0 _3 E9 c: Z
- *' J' z& c- u* i, R/ b k. L
- * This file contains EDMA3 Test code." w% F; W4 J: e: k% r" z- w
- *4 }* ?: m1 l/ r1 e6 a1 m c7 \ W% L
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
# [% |% [! p3 X1 N( a, v - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT, v5 ~$ @* ^2 Z1 }; v3 q* [4 w
- * TO CHANGE.! r0 X- Q% f, Q
- *
- D- Y2 X: \1 a% S! ~2 b - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/. M) r& E: J1 T' G
- *& p8 e+ o$ N# J. L% e" C; s* x& ~
- * This program is free software; you can redistribute it and/or
h* @6 p( b, A W6 S& K2 S8 X+ @ - * modify it under the terms of the GNU General Public License as
) W0 m+ K# J( I1 O - * published by the Free Software Foundation version 2.4 x3 j+ r4 a8 x. p* t9 v
- *$ @ U% d! |5 K5 S
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any# t8 t+ E* \3 b
- * kind, whether express or implied; without even the implied warranty
! Y9 K) H8 I8 L+ S; n - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
& A) y& T/ e; b1 I - * GNU General Public License for more details.
) N7 F, Z1 n. q1 m5 v3 U( }! U - */6 Q% w! b( x. H0 u0 j
" ~5 N/ y; [2 O+ I0 p& w* w- #include <linux/module.h>' E2 V, t9 H2 L( c7 R3 c
- #include <linux/init.h>
3 ~/ ~8 j, N- j - #include <linux/errno.h>
2 F6 ]. e; r- Z9 T; r3 N - #include <linux/types.h>
& o2 F! A2 ^% k8 Y: [ - #include <linux/interrupt.h>6 ]! A7 a0 S& m3 Z4 n# x F
- #include <asm/io.h># W* x3 B \2 y
- #include <linux/moduleparam.h>
) l: O+ ~, o. i4 p - #include <linux/sysctl.h>
\# w5 L( B% N1 |9 D - #include <linux/mm.h>
0 E8 J+ G& W, r5 A6 \# S - #include <linux/dma-mapping.h>
6 u# y" L/ s! b/ { e. D/ O' Q - , l. Z8 l0 c# h @
- #include <mach/memory.h>
Z- x6 c4 I* H - #include <mach/hardware.h>
& S; w+ K5 _. K: P8 c n& N - #include <mach/irqs.h>
2 O7 Y- w! ]; S" R$ B3 w - #include <asm/hardware/edma.h>
$ G% _5 ?4 D" P) A+ _* i
2 v9 E3 ]- {; \' i& P a- #undef EDMA3_DEBUG$ p0 H6 a. z3 K0 ]/ o
- /*#define EDMA3_DEBUG*/9 B8 n* ?; \& v
6 S# d' Q# |- ?5 m, P2 ^* J! Q/ p- #ifdef EDMA3_DEBUG
+ ^ k! k/ ~# W- N7 e4 L - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
0 t0 N# I3 Y" j - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)" J: |& C+ @& _. }
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)! ~% W6 F& u6 v3 _, R5 ?( d
- #else
8 o9 |7 t) R) Z7 \ - #define DMA_PRINTK( x... )8 A/ O+ K7 U4 _# F% o! V5 b" p
- #define DMA_FN_IN
. S) h: q* B& j0 K$ A0 X& ` - #define DMA_FN_OUT
, l5 v4 @5 j, l! |+ H - #endif3 g! G- ?2 w4 T! ]! ~) d
- 3 J# X# a5 A/ z8 k9 _7 j
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
* O" b! k! ?# g; ?6 \, S; ]$ { - #define STATIC_SHIFT 3
% g- s2 I/ z7 o( O# C$ Z - #define TCINTEN_SHIFT 20
3 r$ O& F# ^) u9 j# P0 n3 d, c - #define ITCINTEN_SHIFT 212 d4 o0 E. v) i) e
- #define TCCHEN_SHIFT 22
" x3 S6 R s B" B0 w/ y - #define ITCCHEN_SHIFT 23
6 p! R5 ^/ i) s* Z) W5 T3 E) J - 8 d" I& l& w0 c: R, C7 p
- static volatile int irqraised1 = 0;7 l5 L( v% @: o% v
- static volatile int irqraised2 = 0;
/ |, I- V9 N! r( r& P* R - ; T: z5 }7 C4 z# F. o* D
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);: P* C; g: l, C( S' @4 n3 A
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);2 W1 w1 q( Z; t9 d8 d0 ^
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);; b7 }! t" w$ z, B
1 s# f: C! s- r7 f- dma_addr_t dmaphyssrc1 = 0;
) R3 }+ S7 {0 i5 k5 h/ N* @3 w - dma_addr_t dmaphyssrc2 = 0;
9 }4 {1 v+ F: a - dma_addr_t dmaphysdest1 = 0;+ R" m1 f- m3 S* Z6 L2 E
- dma_addr_t dmaphysdest2 = 0;
% v" Q+ g' Y% _1 E& x5 P
# X0 X8 `) t& n4 M' d& }& L- char *dmabufsrc1 = NULL;
+ H3 { ^; k' ^$ O9 m X3 ~3 `1 Z - char *dmabufsrc2 = NULL;
* h+ e9 o( a& k3 L7 n+ D - char *dmabufdest1 = NULL;& y6 s/ |& \: i. s, d* e) j( M
- char *dmabufdest2 = NULL;' F8 d2 b- v3 K! K C( d
8 N- w1 m6 g4 i, f3 X- static int acnt = 512;
8 {; o: B2 I- x5 D* u( |& J& y m( X - static int bcnt = 8;$ l. }$ I/ z( v, Q' x9 q
- static int ccnt = 8;& |9 m4 q2 e# B: Q" c6 i! N; l
; [3 _/ P. t7 |9 y$ H( d, ]- module_param(acnt, int, S_IRUGO);# Q: y7 [4 E" V; I
- module_param(bcnt, int, S_IRUGO);6 E6 @5 v/ m, p0 |
- module_param(ccnt, int, S_IRUGO);
复制代码
t( A, Y. M+ h1 ?' {* c4 a
. G/ T# P5 q5 U# I% q4 o$ R 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用7 H+ |/ O8 L6 A7 I
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 ]# y7 @+ A" }# h: ~2 E
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
) ]2 ?! T8 h: p. K; y \* U" s1 ?+ D& j# Z
+ z: |" A) a. x9 [ |
|