|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
4 R" C R4 r$ H8 F! U- [code]EDMA sample test application
2 d. W1 A9 M5 t1 P7 X% t5 q - /*
! u* H1 X0 W( s" | - * edma_test.c& l, q" x- X% e, J" |
- *
* m$ ]4 O% A9 Y - * brief EDMA3 Test Application
( a% k/ d5 w! ` v1 \1 h; w - *
" H1 s2 i4 X1 {9 p - * This file contains EDMA3 Test code.
1 c7 A; G8 y& V. b( ~7 |9 n% [ - *5 ?* }1 o/ s4 h$ G7 y7 o0 a/ D, T
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
& [8 U, @' d9 M! \ - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT8 X% V% c, j) ?* |; r
- * TO CHANGE.
' R+ t9 [3 k2 Q9 K - *& ?- c/ x% n7 ]4 u* `( S
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/8 Z8 o/ U, O2 i: Y4 i1 \
- *4 N, B5 K& d6 u8 r3 ]% N
- * This program is free software; you can redistribute it and/or6 d- q3 K9 f( h6 D# E8 R- ^1 x' _& Z+ l
- * modify it under the terms of the GNU General Public License as3 r7 U4 P/ X+ l4 c, G2 k" @5 o
- * published by the Free Software Foundation version 2.
5 m8 p3 r1 y& |; d8 N- a- p* A - *
1 A7 l% j$ m3 i6 q1 \ - * This program is distributed "as is" WITHOUT ANY WARRANTY of any
; j8 C2 ?% _# k - * kind, whether express or implied; without even the implied warranty
% x* D$ }$ W9 t - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
) Y- o7 s6 E/ F - * GNU General Public License for more details.
+ Q$ i0 O+ g+ `$ j - */
' e5 i# g8 r# O7 I - 1 B" c3 B+ o% Y3 l K
- #include <linux/module.h>
% }, Z+ {/ U) ~. I$ x - #include <linux/init.h>( }) ~! u- ^# r) o' Y
- #include <linux/errno.h>$ g, G8 i- y1 S1 S. x! @
- #include <linux/types.h>3 b2 W; u* p! u& U4 @2 C5 `
- #include <linux/interrupt.h>; [% Z i. k% F' r6 x
- #include <asm/io.h>
- x; E9 G" Z1 e) P$ Z5 e - #include <linux/moduleparam.h>0 @% L( _5 x3 n$ n2 {( M
- #include <linux/sysctl.h>) E- c1 F) c# B. m6 A+ B( |) P1 C! ~
- #include <linux/mm.h>
# R+ ]3 g- M# t( z - #include <linux/dma-mapping.h>
/ ?- a4 r% A5 C3 X7 ~ - $ U4 ~ v9 U- q* I
- #include <mach/memory.h>
6 H8 m! }9 w. Z4 h" j - #include <mach/hardware.h>3 q( P: t7 r/ B
- #include <mach/irqs.h>
0 Z7 S# E3 j: o- K3 h- L; ` - #include <asm/hardware/edma.h>
5 _9 r2 G0 R+ [# X/ [( J% n+ U$ D! z4 o
. D8 }: ~& `/ x1 i. a+ i# p6 t- #undef EDMA3_DEBUG
' W1 G$ U2 r- C; W - /*#define EDMA3_DEBUG*/: a: h) T$ j; y8 t0 m
, `5 }8 {! Q+ L* S- #ifdef EDMA3_DEBUG
1 F0 T7 C7 O5 Q% U - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)' ^5 B9 r5 p5 x. s: G
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
$ ?6 M6 n' o5 j - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
8 x# H% p4 Z6 t/ _$ s' Q - #else
, u2 ]) S8 x; u# [' a - #define DMA_PRINTK( x... )
! F& C! D) z6 O; L+ v. z2 d5 w - #define DMA_FN_IN: }$ m3 E, C: l, \+ r0 S
- #define DMA_FN_OUT
5 q2 C- V2 ^& n& H - #endif; U8 |& t# _2 r( N
* [- A; e6 B5 _: q7 X$ j- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
0 F0 B7 h! T7 x; P2 z0 h, L - #define STATIC_SHIFT 35 m6 T4 J. u9 P: a. n: ~
- #define TCINTEN_SHIFT 20
5 x. n; q) B% s; M - #define ITCINTEN_SHIFT 216 J7 R0 W# g6 d6 U0 r. Y" Q
- #define TCCHEN_SHIFT 22
5 r p; @; l- N3 }! I - #define ITCCHEN_SHIFT 23; l$ w/ y; {- \. X2 e; K/ ~
1 v1 }2 k& d! u, g% _- static volatile int irqraised1 = 0;/ S8 n( o4 k& K5 }( W3 x( Y8 O" h
- static volatile int irqraised2 = 0;
8 T! c" h2 t! f0 _9 ? s' v4 {
- l: \! N z* t* k1 \. j! k- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
& d0 L, h$ P2 I1 n5 U% q. G# W - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
) u$ }1 R" s9 p- p - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
0 F; ~1 ~! m' I. @& ?7 C/ a3 ?
# B# i/ B1 B8 C0 ?' R* l) K* h- dma_addr_t dmaphyssrc1 = 0;8 s1 d' v$ u$ ?8 @- a
- dma_addr_t dmaphyssrc2 = 0;! T; r% a3 g$ A) d9 w
- dma_addr_t dmaphysdest1 = 0;
) N& Y8 K. R+ ~- M+ J - dma_addr_t dmaphysdest2 = 0;" j# H4 E3 b% s% m9 t( M
* p/ z" A3 m3 I8 R* }/ g0 O- char *dmabufsrc1 = NULL;
! d8 o7 F+ ~3 o' m! p& E4 H8 e0 {, @ - char *dmabufsrc2 = NULL;& o6 U- ?0 A" D! f6 [; w
- char *dmabufdest1 = NULL;
8 G3 \4 p6 n7 z P, } - char *dmabufdest2 = NULL;
% b! `4 j% z( S& v3 t' R+ o
8 S. @' R7 H6 v* q8 r- static int acnt = 512;
3 t6 A4 N- ]$ g6 b2 K0 ^ - static int bcnt = 8;, t1 q- ?0 \" I* N, X
- static int ccnt = 8;: h. K. g4 I) Z s
- & r7 U' q5 v$ h8 j$ R( a7 j( a
- module_param(acnt, int, S_IRUGO);
% k2 S$ F1 r/ D# H1 _" N' i - module_param(bcnt, int, S_IRUGO);
6 C/ G0 a$ f- b& e) O" a+ J7 f% m - module_param(ccnt, int, S_IRUGO);
复制代码
! ?" |$ x: M. @5 _
I. x7 O# Y4 b0 s 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
! ?$ y* H9 c# E) n, o6 y6 C# Oarm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
# z B$ _5 k+ B C( J& m$ X 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。" i0 v- O+ g! L U$ t/ I* b
& P2 W1 x0 o) a8 F* X8 P, K, u/ `
- x4 q8 O `" U |
|