|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
4 ~, m) ^' V* u+ m) j- [code]EDMA sample test application# D- \( C7 l# F. C
- /*
5 _) b2 N/ l8 r' ~+ T& \6 V5 }. f - * edma_test.c
y5 @, N4 j) v7 J$ D( _ - *" K* v+ D+ R f
- * brief EDMA3 Test Application
7 {: D+ R8 G9 B6 w3 Z8 k) ? - *& q# S$ w. Z- J4 R8 q9 F
- * This file contains EDMA3 Test code./ k2 b( K2 _0 z
- *5 k- F. B' O2 q
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
5 _" `8 `9 B0 [/ O. Z - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT5 P" p- C1 p% q! D( B8 x# w
- * TO CHANGE.7 Z, g6 X6 ^% C, O
- *
6 J& I0 F7 e: Q" f' ^4 `1 { - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
9 s- T2 m, b6 A; U `* K7 F$ Q( @ - *
$ X6 I+ }# r9 J1 L* C1 a - * This program is free software; you can redistribute it and/or, B- J% X$ c6 _# d; ~
- * modify it under the terms of the GNU General Public License as
9 K0 c4 Y6 M7 e& O! g - * published by the Free Software Foundation version 2.0 r, Q1 W0 ~; c! I- C- W/ G' h, [
- *
! ~% D) Q* J* b2 X - * This program is distributed "as is" WITHOUT ANY WARRANTY of any
" ]: ]/ S0 Q. S% R. K - * kind, whether express or implied; without even the implied warranty: Y, r7 _* `( B6 a) {; O
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the% ?( \- J6 e* n: o
- * GNU General Public License for more details.
; U" ^' u0 ?& r7 \ f' p - */
* i' b: m" T$ m- ]8 x
, R/ T! {$ ]) S- #include <linux/module.h>
5 N0 W C9 h! D: d8 J# \7 s. [ - #include <linux/init.h>5 o. w0 D) D+ ~; s0 R& P9 E# m
- #include <linux/errno.h>
& o- F7 x% `2 Q7 e3 K6 I; W' ` - #include <linux/types.h>
- {. \% M# v! C( h - #include <linux/interrupt.h>5 _6 G) b- w6 h) R6 ^3 e( N
- #include <asm/io.h>1 w1 O) o0 b) U& \9 N
- #include <linux/moduleparam.h>
8 G# v5 V+ u) ?6 x. m - #include <linux/sysctl.h>2 [; H" @5 |; G3 R6 ?
- #include <linux/mm.h>
6 m( C6 D/ a& w. H5 A- L$ ` - #include <linux/dma-mapping.h>& n7 P9 L7 c, L% n$ ^ I2 y* z
g6 N4 T4 l8 _- #include <mach/memory.h>
t" g+ J/ ~( m! Z: p) v1 o - #include <mach/hardware.h>8 w& |/ E& K% n5 _$ K1 H6 E, T. L5 X
- #include <mach/irqs.h>1 S+ u/ u7 }* l5 ?4 d! I0 ~
- #include <asm/hardware/edma.h>
, X7 b$ s+ K/ @; U# k5 P
4 h6 }% K) d' v' H' z6 M4 E! W- n- #undef EDMA3_DEBUG
) F# C/ C3 i7 F' A - /*#define EDMA3_DEBUG*/
( _0 H: k2 ^% O* h - 9 o0 E: a5 u/ X) O/ q6 U- _
- #ifdef EDMA3_DEBUG1 V' I$ ~9 i3 Q+ x! S2 A7 H. A
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
' M( Y: A8 Q @5 k& j: U - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
: U. D' v+ c& C. j - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
3 J+ d2 Q$ n6 B - #else
* e; U5 W! R' M - #define DMA_PRINTK( x... )
) N( c, s4 r( M$ z: z* j" _! n' `+ q - #define DMA_FN_IN
3 _( ?5 F8 U. |/ D* F+ g - #define DMA_FN_OUT. h q1 o c8 c+ ~/ Q1 O. e
- #endif' b; N" \+ t8 W+ v( i& D e8 V: H
- 6 B7 T% O5 v- G; f
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
( o/ V) x& `4 g5 m3 c - #define STATIC_SHIFT 3# N) G: N$ d9 x8 b' Q' G) A2 E
- #define TCINTEN_SHIFT 20+ E8 P4 x" q, o2 K/ _
- #define ITCINTEN_SHIFT 21
5 z N+ _ o+ [5 R - #define TCCHEN_SHIFT 223 C1 _* O1 q; h! a8 w! U; I
- #define ITCCHEN_SHIFT 23
2 K+ h. W- @9 }$ R j9 x
% A r9 x) D, N. n8 D- static volatile int irqraised1 = 0;- n) C' P7 g( @+ a9 I3 Q
- static volatile int irqraised2 = 0;1 E! x( H& T4 V) u0 [6 G1 v0 \# k I
# W& _. S/ w5 w' ?- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);- |8 l4 `' r# V3 x8 @" a3 L) U( t0 D
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);& U8 Y' H: a% w4 u6 k! S+ q9 z- J# j( W
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
% ]3 y3 H& b; [6 P4 d - ' }+ p. d" m) t1 _. w) r
- dma_addr_t dmaphyssrc1 = 0;
1 }0 F3 @! [2 A; c! o* [/ q8 S5 F - dma_addr_t dmaphyssrc2 = 0;
! U! m( m, A* ~3 J$ d - dma_addr_t dmaphysdest1 = 0;; _* G% N& C2 n( U) h
- dma_addr_t dmaphysdest2 = 0;% r$ R5 P- V" K2 S+ Z2 _
- % ]1 ^0 u7 G Y$ v
- char *dmabufsrc1 = NULL;
) H0 o |0 O* F5 G: P - char *dmabufsrc2 = NULL;
6 t- O1 ^" O, c: m( F2 K - char *dmabufdest1 = NULL;) V4 l7 A* b. Y
- char *dmabufdest2 = NULL;
^6 L/ }3 O' j$ N" N; |. |4 i - " ?/ Q0 ]% X: v1 v0 f$ c+ H
- static int acnt = 512;: `9 P- ?0 [4 Y% E
- static int bcnt = 8;2 w/ D- c3 q' h5 k# U2 J0 l
- static int ccnt = 8;5 o7 h$ U9 `5 V
2 ?# u7 [2 e3 c- \2 I# M/ u- module_param(acnt, int, S_IRUGO);2 {8 D4 }$ [. }5 c: Z7 o, x) I
- module_param(bcnt, int, S_IRUGO);5 e4 {" {& @, q! }$ A- g- e! q: t6 ]
- module_param(ccnt, int, S_IRUGO);
复制代码
2 ~$ F+ \+ \9 O& p3 B, u+ |2 F/ i& l j# _
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
. t; |: V! o* v; y4 Harm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。5 T/ `) W8 M7 P4 S7 }$ x5 t* x' c* n- _
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
9 Q- R7 L, T/ R: |) Y+ d
l8 Q: N3 n9 P9 h
7 Q @' O5 u/ X5 D |
|