|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
2 m# O. ]& Q( \3 c+ T$ z. a. F- [code]EDMA sample test application
) M$ D" ?$ X$ n% } - /*
0 [+ n+ S% B* I' B - * edma_test.c
0 N) `% r3 E; x. a( k, X - *
4 L4 @7 D) r8 _. ?5 k/ K. f - * brief EDMA3 Test Application7 a2 O9 F, d2 @
- *& a, Y' H* p1 h! j l
- * This file contains EDMA3 Test code.
6 c' Q6 v3 R5 w/ t - *
$ h% b1 i# w% J, Y6 J& G2 E - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE3 Y9 [; g! v1 D1 `: r
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
! k8 G6 U* s$ o' J" U) t: V/ d. ~ - * TO CHANGE.
# }" u, P9 D4 p& J# `, W - *
. @2 k# D! z" b& g/ J$ ` - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/8 \+ q: Y; }- V/ I
- *
8 h* w2 j% n& c - * This program is free software; you can redistribute it and/or5 ^" r: A" h4 A1 ^) N( C
- * modify it under the terms of the GNU General Public License as
% D5 g0 J6 n8 k0 B! p9 ] - * published by the Free Software Foundation version 2.
; ]0 ]" R0 h5 x2 u- d- v3 n# B3 Z - *
- g7 m" ?0 V; ~2 U - * This program is distributed "as is" WITHOUT ANY WARRANTY of any
& g' L5 \6 h9 L/ l" Y0 d3 O) F - * kind, whether express or implied; without even the implied warranty/ f5 z0 k* @- m5 I7 G9 V
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the n3 Y5 c: W' E- m, L
- * GNU General Public License for more details.7 O5 q+ c7 B, ^* V/ s2 o7 d
- */9 Q: n9 |; K! t2 ^
- 5 ?& |& a* F7 K8 J
- #include <linux/module.h>
9 ~- s) t4 q+ B3 G8 I$ F# I. S" n( y - #include <linux/init.h>
% x! `6 z( D+ S3 n5 r0 ?! S9 J3 k - #include <linux/errno.h>: S5 e8 s, N" r; U2 m) W
- #include <linux/types.h>
2 O3 v4 ~9 p1 Y; {- o - #include <linux/interrupt.h>/ a5 k5 g- W8 m# ]5 @
- #include <asm/io.h>8 {; v, F7 J. E8 y/ n$ @- c" H
- #include <linux/moduleparam.h>% [4 e; t% k- o$ b
- #include <linux/sysctl.h>; u1 f, X$ D% O$ \5 `
- #include <linux/mm.h>: s [- `5 }* p$ V! E7 I0 T
- #include <linux/dma-mapping.h> M7 k0 _+ i- A" N/ [( F! Y$ Q f3 {5 g
- K5 k! W" ?, l7 H& L" B
- #include <mach/memory.h>! T: b6 y+ ]9 K5 H; G, e
- #include <mach/hardware.h>* [: F5 M7 y( T* s2 F, `1 h
- #include <mach/irqs.h>
4 i* T8 N% R5 R& F - #include <asm/hardware/edma.h>
$ S$ |1 I0 F1 ]# \
: I' E) n2 i9 R; u, ~6 {- #undef EDMA3_DEBUG7 @4 C" c/ I+ ?1 p
- /*#define EDMA3_DEBUG*/
" S- w W- T" X% V; [( t. \/ X
. q4 O5 m- A2 L8 a9 Y$ [, A! Y- #ifdef EDMA3_DEBUG
. |' p; e s( i' s - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
! R) @# ~7 R0 h. ] - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
& K; @" ?6 G- n0 [ - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__), u# y/ }, ~5 x
- #else
4 [. M+ N1 c, }) d9 [- b5 d - #define DMA_PRINTK( x... )
, `/ s0 n2 S+ B$ a# f& f0 c& M* A7 \ - #define DMA_FN_IN
# m, h% W" w8 W7 h: E' Y6 u - #define DMA_FN_OUT
0 n, t2 [. A+ m0 e. [ - #endif% z3 w& B. d/ }' _
- 1 y8 k' j- T! D% t2 h- s
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)! b" Z! R/ w& @% \2 t: p8 e
- #define STATIC_SHIFT 3
1 C9 }' @3 W, u5 f0 b3 V - #define TCINTEN_SHIFT 20
+ _( `. ]& n) A- g3 W; ^ - #define ITCINTEN_SHIFT 21
4 {' W( O1 z" T G - #define TCCHEN_SHIFT 22
4 z$ F8 _- E8 u/ z1 W - #define ITCCHEN_SHIFT 23
6 X/ b7 z) d0 z# o - 7 u/ u$ o2 S, n& h7 c+ _
- static volatile int irqraised1 = 0;
+ s4 {/ N; `! k5 ] - static volatile int irqraised2 = 0;+ k' P- F: Z' S0 X2 _8 h: `
& \- h, I, Z: M# b/ N- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);) v9 a2 s) u$ Z2 f
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
' P+ f1 T* l& d' \1 }% V7 V2 J( \ - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);8 ?! n% O5 V4 G. B7 Y
, Q! O; U& P% n; q0 D- dma_addr_t dmaphyssrc1 = 0;* V+ i3 _/ X! V
- dma_addr_t dmaphyssrc2 = 0;
3 A7 x# I& V" \6 A - dma_addr_t dmaphysdest1 = 0;
T, x# J0 j H" ~: e - dma_addr_t dmaphysdest2 = 0;+ p4 j1 s/ B% D6 n" R+ n
- 5 X; Q$ U# h1 P$ d4 N& b
- char *dmabufsrc1 = NULL;, c$ m+ s" ]0 n4 N
- char *dmabufsrc2 = NULL;, ~( l$ U: h6 D" J
- char *dmabufdest1 = NULL;
# V# r7 f% Q+ T, ?% A - char *dmabufdest2 = NULL;
& p% q. @1 O8 J5 F1 I4 Y& }
' O6 o& W5 @4 ?- static int acnt = 512;
) H9 u+ Y9 t3 u8 n6 d1 i - static int bcnt = 8;
5 [! w' J, K, R - static int ccnt = 8;
) z) e7 n: k7 K& |
x- s- p) A4 o( \6 E- module_param(acnt, int, S_IRUGO);
6 f, t1 u# `! @ - module_param(bcnt, int, S_IRUGO);- n# ?* E, [5 X5 C- J8 g% z
- module_param(ccnt, int, S_IRUGO);
复制代码
: j" T& B. F8 P0 N! y- h: o- N8 c5 ~# T1 g! V5 h, \5 G
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
) S6 {/ C) f$ k" barm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
9 M: m* ~5 |' \ L ] 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
5 i5 b9 L* h/ n
5 U2 W( S4 ~- @$ O
, c5 M$ z* W# Y6 J; u+ v5 q' ] |
|