|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
: n9 ?: j9 }6 {- [code]EDMA sample test application6 s a# ?) X) g. T* {
- /*' D3 O ~$ i# H* X( O7 l
- * edma_test.c
2 J# p8 [; F8 f( u7 u - *, \2 W7 `) o Q4 |3 n6 j
- * brief EDMA3 Test Application
4 t7 h) Q; f8 v7 a - *2 N+ D+ l# h+ o- i+ `7 Q- U0 R
- * This file contains EDMA3 Test code.& `' C: _( _) N) o# a c7 l7 O9 s
- *
: r5 r- @8 d$ [0 f# n - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE, P: ?- [; B, o# q0 L' R
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT" z: G# v8 [& b
- * TO CHANGE. F* A/ E( Z# Z$ F3 S& \
- *" n+ F6 f$ z4 z/ | u" _, x; P
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com// k( }& @! ~& }6 W/ z3 `( f
- *
, y9 j; N, v# @1 y* {+ ] - * This program is free software; you can redistribute it and/or: x+ |, L1 L% F1 \& E6 z- X
- * modify it under the terms of the GNU General Public License as
I! Z4 O' V& l: }0 f+ X' ^ - * published by the Free Software Foundation version 2.
( x5 a7 C! d h' ~+ @6 X Q) U1 U - *4 t! F% E/ l3 @+ ~% }3 Y
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any
+ S2 Q& ^0 T/ V; Q8 {0 `4 i& X2 j3 z - * kind, whether express or implied; without even the implied warranty
4 B' I) u8 a- d - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the) H' T L2 f' \, V
- * GNU General Public License for more details. y. k. _( B8 w! A. r& f
- */
2 h: W7 c! `7 J0 X: x( v( N
% E: M% G# _+ r2 N- X5 y7 F+ d- #include <linux/module.h>
* ^7 C7 p& A2 e0 D' h - #include <linux/init.h>
& Q5 X/ P0 j' F' x4 A) F3 g1 ~ - #include <linux/errno.h>; R5 n/ `1 _$ X+ x, {5 d
- #include <linux/types.h>
4 V6 B& q3 i: i, O( H p - #include <linux/interrupt.h>5 o3 A4 a9 c( W! W& W* ~7 ]
- #include <asm/io.h>
1 c9 a" O: S# }- B - #include <linux/moduleparam.h>- `/ i9 z9 q$ a" R6 I
- #include <linux/sysctl.h>
3 c; `7 ~/ ]: Z, A) z - #include <linux/mm.h>/ W, v0 e4 p4 g% @( I
- #include <linux/dma-mapping.h>; J p2 u& V) h! i# ?5 U7 E& l
: {$ ?( l" S W) L+ P7 y4 F+ p3 Q4 W3 P- #include <mach/memory.h>* S' j* F( t0 x$ K
- #include <mach/hardware.h>6 V, u6 S. q9 [4 O
- #include <mach/irqs.h>8 y, K& q+ x% E
- #include <asm/hardware/edma.h>( x7 u0 l4 h2 C1 `
; T+ A2 T8 h" Z" z5 \- #undef EDMA3_DEBUG" p9 v" p8 j( X* j* Z- A" G/ c
- /*#define EDMA3_DEBUG*/
; F, l; c) L$ `, { - & \3 ~5 B4 ^+ f/ b
- #ifdef EDMA3_DEBUG
1 d0 @& w; o( Z! j0 q9 f - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)9 @+ G4 H/ x) |9 g) W/ D6 a, G
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)" Q: A9 K) n" p/ \. @ U
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)( q1 w- E7 N- @8 R3 O7 h; g
- #else7 L& d: X9 O8 f( L D/ t
- #define DMA_PRINTK( x... )7 ]/ K$ q4 R, e3 j* b: M; ?
- #define DMA_FN_IN+ ?6 J! b8 u9 q* ?, p& S+ [
- #define DMA_FN_OUT
6 T- F- V7 f/ v+ a: ^& G - #endif
" d7 N+ O7 M A# ?: W. \5 H s
0 X" w# d' g- s" m! c! W2 z' [- #define MAX_DMA_TRANSFER_IN_BYTES (32768)# q. Y' y# Z: J8 o( v5 d' r1 w
- #define STATIC_SHIFT 3
' c2 K. U: {- B1 e( E. `; k - #define TCINTEN_SHIFT 203 i+ }# R6 r N2 m5 |& G
- #define ITCINTEN_SHIFT 21
; D. @4 c. A* E; N( w1 ^ - #define TCCHEN_SHIFT 22; J. s3 s2 r- k. L5 X5 {
- #define ITCCHEN_SHIFT 23- B3 X3 U3 o" [9 I7 i7 q0 H+ G
/ C: G9 @7 J2 e0 V/ |( ?- static volatile int irqraised1 = 0;
8 V( m" h9 K* a! y% W% k2 E - static volatile int irqraised2 = 0;8 N2 l/ @! E9 s" m( k" V) q
- / U9 A- C) s- i- s* n- L
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
" a: _1 c( U8 `- [' A! C - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);$ ?8 r5 P4 `/ \1 K% r
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue); \+ K/ v; ?7 q! d4 Z! Q" C( L
$ w; v) q: B1 Q0 R. p- dma_addr_t dmaphyssrc1 = 0;
1 A: o) j. t7 W% l! z8 l - dma_addr_t dmaphyssrc2 = 0;2 E# H& _5 ~+ v
- dma_addr_t dmaphysdest1 = 0;
. p1 s( M% {: W8 S- {$ T4 E# e - dma_addr_t dmaphysdest2 = 0;) o4 z2 A- W3 o$ F( e( C
- ' {; s+ [4 x" C2 ~$ u4 a
- char *dmabufsrc1 = NULL;# u- y p+ G+ c2 B5 Z
- char *dmabufsrc2 = NULL;
$ @6 l3 J7 k7 F4 ]* n2 P - char *dmabufdest1 = NULL;" L$ E/ X# S3 n" V
- char *dmabufdest2 = NULL;' O6 H: B/ _& o% k
9 w r& s' M* F$ x4 \- static int acnt = 512;
& T3 `1 L8 _0 n8 G+ L c6 P - static int bcnt = 8;8 n' G1 `: t* S' V* C! e
- static int ccnt = 8;
, l1 h1 ~. O6 L! g
1 B% }# J i2 _- module_param(acnt, int, S_IRUGO);
: T7 |0 c4 a! s% y; T - module_param(bcnt, int, S_IRUGO);2 e' Z* d" m( F" n; s8 ]
- module_param(ccnt, int, S_IRUGO);
复制代码 * Y1 a) I6 q* v) |) Y8 C- j
' T, q7 |% [% e! E/ E+ F9 m 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
# G8 h& F$ e& iarm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
, G* w5 V0 l7 G" b9 r2 L0 a 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。) @/ K- Y. x$ Z4 O
! |- A: O1 \: O/ I b+ D
2 `- B7 R7 e" v* n$ |8 j! v
|
|