|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
9 M/ \1 |7 P5 [ v0 e% r5 h' J, a9 L- [code]EDMA sample test application
: {& Q+ }/ x& Y g* y+ I8 ^; ` - /*- Q$ p# l$ w6 w0 [1 m% o
- * edma_test.c& z& K8 X; ^$ M) h* O* o
- *4 ?+ L }. U3 o. v' r
- * brief EDMA3 Test Application; @! Z1 t( k7 `
- *# S1 Y5 j' o; @$ Z0 g
- * This file contains EDMA3 Test code.9 R9 `* K7 q, h* t: \
- *
+ E' L1 N) T$ i3 n - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE) t/ N* |& j8 z0 S7 V+ c9 \( e4 |
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT# a& r& z$ z1 z4 A. I
- * TO CHANGE.
4 p$ ^' ], m8 C Q7 p( f |2 V5 C - *
5 w- J& h+ R. y0 V; Q - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/" J8 y$ |6 B" M- y2 A# U) s
- *
8 j$ ?! G$ P, y2 R) q$ q - * This program is free software; you can redistribute it and/or
. n/ g- u$ F3 B8 x4 d5 i. X+ p - * modify it under the terms of the GNU General Public License as/ \8 h! }! Y. z6 F5 h0 M- b. n
- * published by the Free Software Foundation version 2.
; t5 _( U) o0 J( a& n - *
( v1 V8 d, l9 D5 N* k1 S) V: M - * This program is distributed "as is" WITHOUT ANY WARRANTY of any" ?! [$ B' M5 r9 d# u: Y
- * kind, whether express or implied; without even the implied warranty
4 k" U7 u* ^1 Z* E1 R5 j; _3 Z; m7 | - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
/ E: v% Z& C3 W - * GNU General Public License for more details.
8 H6 j3 @: H$ v3 u7 p/ q - */2 J7 A/ H! y5 F M# t I
- . ?3 r! c2 o7 n6 e. o4 y
- #include <linux/module.h>
, E; F _$ N: o2 p1 [0 d& \- U - #include <linux/init.h>
! L, b# n6 W, h" s( F9 }8 M! o - #include <linux/errno.h>) a! O7 g' c( }# a4 Z$ u
- #include <linux/types.h>
/ f" X, s* g9 Z( t# g - #include <linux/interrupt.h>: A2 R; E' x4 c
- #include <asm/io.h>! b" k( j) V; |8 F2 U
- #include <linux/moduleparam.h>- z9 j( h& K1 a3 O& b9 c
- #include <linux/sysctl.h>. k0 `9 f* F6 E, p: f7 a" v6 |' l
- #include <linux/mm.h>
4 e6 g) T6 P- K/ E - #include <linux/dma-mapping.h>
+ j8 j: i) |! i! g) A Z$ e( ~; h9 a - % _1 |( W4 z1 V8 b
- #include <mach/memory.h>+ ^, W! }! C2 ^3 N* P
- #include <mach/hardware.h>
* I( X8 P; q* P$ P* k$ e9 o( K - #include <mach/irqs.h>
8 a# |1 l. c" f+ k% E0 A$ F - #include <asm/hardware/edma.h>; h* z5 h+ F" ?* n% o, d$ s; C
* ] a& I1 ~- i, D" o7 l9 D% o: h- #undef EDMA3_DEBUG
b, ~# f& Z0 R* a# D& d - /*#define EDMA3_DEBUG*/
% G( E# H1 b) {' l [# [
* c: M. Z# J5 b5 Q& y2 f- #ifdef EDMA3_DEBUG/ r7 [1 k* c% V2 [, r+ V
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)+ f! H$ o: _ m) L6 H& u- _
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__), G; Y2 d0 O9 _ f4 x$ D! s
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)' G3 v B+ Y2 P: \2 M4 @
- #else& d% t! M. H! g1 @5 F* p+ ]4 t* o
- #define DMA_PRINTK( x... )
/ F3 Z% j; x3 w# l - #define DMA_FN_IN1 \- U7 G+ |6 F) z, f' K8 t5 k
- #define DMA_FN_OUT
8 l4 N) j n3 l0 |5 Y8 n( g8 {2 }7 ^ - #endif
. g) w7 y |. w* c, o
9 d/ |6 g5 @ f. d! ?1 h- #define MAX_DMA_TRANSFER_IN_BYTES (32768)2 C$ U7 w6 W, Z% L
- #define STATIC_SHIFT 3) u9 _4 m' u8 ?3 b
- #define TCINTEN_SHIFT 20
9 [9 j- N0 Q$ S9 C. v; X0 N - #define ITCINTEN_SHIFT 21
" T0 N. `7 S$ M8 e8 q" \ - #define TCCHEN_SHIFT 22
3 O* z' J( @; n, k# E. `2 ]" ^ - #define ITCCHEN_SHIFT 230 h7 I8 ^# ~- l, {
- + g# [. E4 \3 n: w9 c
- static volatile int irqraised1 = 0;/ F% p0 g+ g0 @* Q8 i) x
- static volatile int irqraised2 = 0;
0 X. U, q2 P8 Z& S( P - ; l: q6 G$ o9 D" N% |( \
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);+ ?- s, B4 |1 v! W
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
- N6 i2 O! @$ I( \! o+ e - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);/ U. e3 C5 t" K0 R+ u' N/ ~; Y
* i; K- K' d9 s) x3 F2 q! K/ T8 r- dma_addr_t dmaphyssrc1 = 0;! V1 U @$ S) K/ \% R) I/ {
- dma_addr_t dmaphyssrc2 = 0;7 P7 l7 S P2 M$ m' `2 p! p
- dma_addr_t dmaphysdest1 = 0;: ?3 o- t* d5 W. R5 V
- dma_addr_t dmaphysdest2 = 0;, q+ q9 K- j! p1 P3 [% l/ s
( L, H2 P2 B$ B, @) C- char *dmabufsrc1 = NULL;' M* _$ S- c3 r4 Y- T
- char *dmabufsrc2 = NULL;
; K! ~' u4 C+ Y( S0 Q4 t+ z - char *dmabufdest1 = NULL;
3 t3 @* n- p+ W% Q+ h0 Y" O - char *dmabufdest2 = NULL;8 x! d6 O: M5 f2 L, |) n+ W, ^6 a8 E
( L( `$ k: i5 b' L& k4 }- static int acnt = 512;
o1 m @+ P. ?: v {' ^ - static int bcnt = 8;
+ O. }7 A0 |6 a+ o: M" s# o - static int ccnt = 8;
6 t' W& s+ f# i6 S0 m' I - ! L& c4 _% ^; P) a0 \8 k W5 N
- module_param(acnt, int, S_IRUGO);
8 h, K, e+ r; j2 f- ~2 H7 ~ - module_param(bcnt, int, S_IRUGO);- M+ N9 ^6 Y8 p/ ~+ ^
- module_param(ccnt, int, S_IRUGO);
复制代码
' O: F- u9 `& v2 X9 D( y! z7 B E' t, i6 m* N) ?; k
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用! R+ J/ d9 n- p: 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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
4 I9 p8 F, K+ E1 v V 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
+ Z0 {; v3 T# [* E, U8 a/ I9 \3 e; \& K( o `8 ~. f
: Z i, K4 v+ V& ]' Y- y5 T- ^
|
|