|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 6 i& k+ i8 ]9 }( D
- [code]EDMA sample test application
$ B; f$ u( ]) x- ?' A( I+ L& e - /*! x% P- E1 ]3 j1 Z5 V
- * edma_test.c" I! D. d5 `& e- h$ \. ]
- *: c/ o& B& R5 }9 ^- b4 o
- * brief EDMA3 Test Application' N5 ?) p- K& v; k' H6 A
- *: m; k7 o; p5 E& r" f
- * This file contains EDMA3 Test code.
M: V: O1 e( |7 Z; P# W - *6 Z6 V# x* v+ k9 v' `
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE# ~ X* y; q/ c
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
- B; E/ o9 h& ]) f' T+ i- s4 s - * TO CHANGE." G0 L" j" ]6 O/ n! X
- *
/ O2 p! H+ J' y" v# C - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com// ? g/ b) t) m5 _# A* W, ^( N! k
- *
' w- |+ q* s0 S a! O( z2 A - * This program is free software; you can redistribute it and/or1 g6 b. I( a, ?* X) A
- * modify it under the terms of the GNU General Public License as
1 H0 Y' d3 r; B+ E - * published by the Free Software Foundation version 2.4 }/ ?$ m8 J0 f6 v7 e
- *' B$ O2 Z$ V6 c" B4 Y8 Y, G
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any, Y$ W* h# `$ q$ V# \
- * kind, whether express or implied; without even the implied warranty
1 Y9 v8 H, a) Y& d - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the( h( `: ?9 Q/ x- y0 I5 `
- * GNU General Public License for more details.
! s3 z/ N" { ?4 E3 B- w - */
. ^' z/ U, f: v6 T
3 K2 C+ b6 t6 v7 y6 ^- #include <linux/module.h>
# d+ y* {' c8 K- m( e - #include <linux/init.h>
' `# o1 [1 F3 F - #include <linux/errno.h>
! Y) T' q$ W1 j- o - #include <linux/types.h>
. N7 p- ?1 }) Y$ W - #include <linux/interrupt.h>
! n o- C+ x) b7 O2 x; f# z- d8 A - #include <asm/io.h>
6 \+ ]$ d( p/ t6 p/ F - #include <linux/moduleparam.h>
# X8 s' T* H. C9 @2 `- p - #include <linux/sysctl.h>4 f+ x9 S9 G" b
- #include <linux/mm.h>$ D) N7 K2 v5 m$ c# s# F: m
- #include <linux/dma-mapping.h>
7 t+ G; ~- b( T. _
$ w% w& C0 Y6 E5 y' ?, i- #include <mach/memory.h>: v& \" n6 o: @, V: v3 R9 {
- #include <mach/hardware.h>
. Y" Z0 ]3 a o* W7 V4 J/ j - #include <mach/irqs.h>; C6 K7 ]3 ~& m) J) [9 L& |
- #include <asm/hardware/edma.h>$ _6 ~0 |9 M, `" M% H
% b- n& x/ \9 ~, \ k( X- #undef EDMA3_DEBUG
) T! m( k' h2 E - /*#define EDMA3_DEBUG*/* E) g0 ^' e+ a" T
+ v4 h/ h* t# n1 Q# D- #ifdef EDMA3_DEBUG
# e* m. V/ Q9 ^- x: X- v. W - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)9 t0 l: ]- F! u2 R; O( J
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
/ Z& F, r5 {& |1 v p! k; y& n - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)1 e& q" ~( O8 c0 H ` B7 T8 q
- #else
R* K6 l, d% K* b6 V# N& U - #define DMA_PRINTK( x... )
1 p6 F7 g: m3 m - #define DMA_FN_IN+ R7 i, m D* r# C/ t
- #define DMA_FN_OUT
8 B/ M" l) G7 y( ~ - #endif
5 a0 H& M& P% v - d/ t6 L! r' [* s3 e; Q
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)3 c5 E) u! O7 x5 T2 X% M
- #define STATIC_SHIFT 3
* s6 Q: Z9 k* z7 Q5 A: k - #define TCINTEN_SHIFT 20
3 Q6 x* w. I2 Q' S" Q - #define ITCINTEN_SHIFT 21, w$ z b5 J# Q x9 i% \. Y7 Y: r @
- #define TCCHEN_SHIFT 22
$ E& ~* x8 `8 Y: f9 }( Z) s# l) A - #define ITCCHEN_SHIFT 23
- o" b. n" F: b' A1 X - ) K% E) f) \% z3 f2 i d, N9 I
- static volatile int irqraised1 = 0;
y+ V( |2 ^1 E3 x, v+ Y! ?2 Q+ i8 [ - static volatile int irqraised2 = 0;
d5 e6 E& v* j Z! m E! D. C - & u) k# a4 l2 r9 U
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);+ J8 }, Y, v& k9 S w9 Y8 X
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);. M) @5 g7 ^3 h" r. x# }$ P
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
. T. Q6 B d) ] n1 C/ c - ) Z+ ^" u- j& H7 V
- dma_addr_t dmaphyssrc1 = 0;& [" `- L0 y d2 s
- dma_addr_t dmaphyssrc2 = 0;
5 D N4 J) U: e: d0 ` - dma_addr_t dmaphysdest1 = 0;7 G/ r" I, R# O% M# {7 N
- dma_addr_t dmaphysdest2 = 0;5 ]. Y) `# B7 w# [
4 j5 P: S! j8 s( H4 `/ V2 s- char *dmabufsrc1 = NULL;9 Q1 F: S6 z/ }; g, G5 E# h
- char *dmabufsrc2 = NULL;
1 [7 J! X( e$ r- E/ s+ M - char *dmabufdest1 = NULL;2 d+ ~- ~) }9 w, S t
- char *dmabufdest2 = NULL;2 R1 [$ o% g4 o' Z/ w, _" Q
3 L" W+ O4 q& a/ b- static int acnt = 512;
8 u" _0 c: E0 m* A! I - static int bcnt = 8;
. r1 N1 \5 u6 I: D, H8 B6 h/ O - static int ccnt = 8;
+ D! [3 g, P! x( k7 k4 m - # Y$ n+ t3 y4 O
- module_param(acnt, int, S_IRUGO);0 I3 L9 F f' E. _1 d" c
- module_param(bcnt, int, S_IRUGO);. m5 U8 k* N) U; S7 R6 p
- module_param(ccnt, int, S_IRUGO);
复制代码 1 f- n7 X$ t- p1 F6 H }3 q
$ X3 N: p2 s% j- \ 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
" ]# _: z+ Z& `& |, S* @: Jarm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。0 n2 `' E5 U& V6 y; z4 g3 B/ V
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
/ R. I- j" w. P& z7 r4 R+ K3 p4 j/ x" E
& V. d R f7 y3 c5 l
|
|