|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 3 W5 {) b9 o% E; Z1 ^
- [code]EDMA sample test application
" ?% c/ Z+ d6 D- g; Q( J - /*8 ~( P- Y3 A3 f" r, \. Y
- * edma_test.c
5 c- B1 V+ U3 i8 t; b+ d. @, E - *
0 x$ w1 M1 W0 v* z - * brief EDMA3 Test Application' @" S! h4 n! k2 P# Y% s! W& [" Q
- *6 P) e% j5 C6 Z" s* W" n1 E* ^
- * This file contains EDMA3 Test code.# o% C5 {' F" y+ R
- *# b0 {/ \: r$ y+ _0 ?( n
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE! i- W! W" P/ @/ S7 C5 [; Y9 B
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT% x$ `& @& u3 V
- * TO CHANGE.# l" g0 u& g% K" Q5 k! b
- *7 {* F: r' b3 ^( c/ P$ k$ _ q4 R
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
0 q! {8 M& Z# @% V - *' n, t( ^& I" V! p
- * This program is free software; you can redistribute it and/or/ S" f- [+ b1 b" K9 I0 J0 N
- * modify it under the terms of the GNU General Public License as
" t) w7 ?0 H8 N B5 R6 A/ H8 F4 y4 R - * published by the Free Software Foundation version 2.0 J$ t1 f) y% n) l2 Y
- *
8 c% X" C: }) Q; @ - * This program is distributed "as is" WITHOUT ANY WARRANTY of any5 c2 \8 i* \7 q8 Z, |
- * kind, whether express or implied; without even the implied warranty5 U/ F3 j, u; q! e. N
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the: u. J5 h& F$ z. E1 S; k& ~
- * GNU General Public License for more details.
# S' T9 U& s. Z* U' \9 J - */
' C4 n5 c d, m- s( X O
. b% a. [8 Y S- O# J- #include <linux/module.h>! o1 I: M( [$ b, W% g( h
- #include <linux/init.h>
" a" H9 D0 v- Y7 ~1 @5 _ - #include <linux/errno.h>7 }0 Z9 y) E: B1 x& ~3 r0 {
- #include <linux/types.h>
1 o) e8 B- E+ o/ X; m - #include <linux/interrupt.h>
/ x% t4 c' t# J - #include <asm/io.h>8 B+ l9 j; ~: O: w" Q
- #include <linux/moduleparam.h>
- z* I4 s: Z6 Q8 L1 y - #include <linux/sysctl.h>
: @; C) |$ l" ^. o4 {2 j$ H2 q. A - #include <linux/mm.h>: Y' T2 y1 e2 Z `9 c8 l+ i
- #include <linux/dma-mapping.h>
/ N# J* g( l# g
, c/ r0 N- m3 P- G9 Q- #include <mach/memory.h>+ ~* b$ C" m3 I; i
- #include <mach/hardware.h>
* A3 G0 S' K A( ]3 ~1 E - #include <mach/irqs.h>
% {0 c3 A+ ~: m/ x; a: }5 f3 f - #include <asm/hardware/edma.h>3 s J$ [% ^# s- U! ~5 _
! M7 |4 h; C; b, }/ f- #undef EDMA3_DEBUG. ~5 ^+ j) I. r3 S0 W5 L
- /*#define EDMA3_DEBUG*/8 ?9 i4 H9 F% |
# p& q8 z) g5 X' R& n' D- #ifdef EDMA3_DEBUG
8 [9 ]0 ]" Q7 |! r - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)* l3 d3 ]( S3 I/ o: Z# P
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)1 C1 p' W& K, D) u+ s, O i
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)! K6 N) }1 p( j
- #else
3 |* @. o8 y( r% @$ ?$ |9 Q4 R9 u' l - #define DMA_PRINTK( x... )
: H7 O* d' L1 G2 d- u - #define DMA_FN_IN6 Z% s, _; u: c
- #define DMA_FN_OUT
4 [, l) Q8 ?) n7 B. ]; ^ - #endif
4 R5 \' Y* F1 H( \0 ~% N
0 R6 k7 M5 x0 H) u- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
9 w' `, R, h4 A5 G1 h6 ?4 M - #define STATIC_SHIFT 3
- X& j/ _% p! h" T8 m - #define TCINTEN_SHIFT 201 h" C2 A# |* L1 K0 O
- #define ITCINTEN_SHIFT 21$ a4 D1 w% q6 O: U4 v, _% h' j6 Y" o
- #define TCCHEN_SHIFT 22
: W/ z) h: x- Z* A - #define ITCCHEN_SHIFT 235 b' N! X$ [* s/ k4 R' L& a
% q) h. G& e8 L3 O- static volatile int irqraised1 = 0;# a! V2 q7 \/ E; |* F$ z% A
- static volatile int irqraised2 = 0;3 `7 t( W F* `3 h) L: M) M: Q$ H
- ; c. b* n4 u2 o) m3 Y$ E
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
4 D# Q' e/ h* {% N5 ` - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
. Z' S: \9 H% b0 o/ m - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);& B# V. R) i+ ?
9 N* n6 \5 Q2 j8 W5 Y R( J- dma_addr_t dmaphyssrc1 = 0;7 B. w2 P1 C& u$ I Y* H5 n
- dma_addr_t dmaphyssrc2 = 0;5 E5 [& e1 R. t4 s# x; L3 U5 p
- dma_addr_t dmaphysdest1 = 0;. f! ]5 b. `1 J! o) e
- dma_addr_t dmaphysdest2 = 0;& {/ M) C9 |) g; Z" y) D8 |
/ b" h* n/ E! {9 z6 ^- char *dmabufsrc1 = NULL;0 ?5 x2 T$ e( J+ J) X
- char *dmabufsrc2 = NULL;3 Q3 L; @" T# [- z
- char *dmabufdest1 = NULL;1 l: x$ }/ N3 F8 k8 }
- char *dmabufdest2 = NULL;! y2 h! e* [. J
. }5 J- H/ e9 u. F2 y- static int acnt = 512;
- ?" V3 ~- P# ] - static int bcnt = 8; I" W! ]* Q9 _" g9 h
- static int ccnt = 8;* c% |- f2 \( t- k
- " g/ c0 J+ ^ a3 N9 q
- module_param(acnt, int, S_IRUGO);
% z# k# b# G% } - module_param(bcnt, int, S_IRUGO);
0 e7 Z9 u& g4 b. w9 h, ]/ S* [ - module_param(ccnt, int, S_IRUGO);
复制代码 3 X' ~* y. |' g+ q2 @
$ c$ Z/ z4 y. j d3 I" V( I
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
$ |( V/ h4 K' Zarm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
# P) h4 F- R3 J3 E; g% v 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。6 _$ U: G" l" [% x6 z+ f
b! w( q( ~6 j5 b0 D- A+ J
7 G. M/ ~) C% X/ Q! ]9 ^ |
|