|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 . P0 D* H# V K/ H- V: O
- [code]EDMA sample test application0 y3 m9 } u c' p
- /*
0 q1 `# D+ R3 @9 A) z3 y$ M$ o - * edma_test.c- m0 Y4 Y8 a. C
- *
' a6 v+ q5 I* n - * brief EDMA3 Test Application$ j1 L5 @$ I" S9 k+ v
- *- C' M4 R# Q, Y6 a; s: S
- * This file contains EDMA3 Test code.& i* j8 S/ O: B& O; U: S+ U
- *' _/ X5 A; g2 o% B" W- W4 z$ A+ [
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
; A7 R! d8 w6 \" _. \/ a6 Y; L - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT0 D& O" S* F* v
- * TO CHANGE.6 S( g& n$ p3 h) ]: ~ I' `7 I
- *! p* T. Z- v3 ~: M0 l( p! X. Z* j
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/; p- r; G: T2 m5 v
- *
& P* f1 Q# Z; M3 T( O, s - * This program is free software; you can redistribute it and/or
) `5 f* Y: Y( t( s. G1 C! W$ _2 { - * modify it under the terms of the GNU General Public License as6 i# M8 S; N1 t, |/ O7 V
- * published by the Free Software Foundation version 2.
( F1 O( {) p% p. h9 C" p - *: l- s- F& w: o! y
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any" q" s0 ^! ]" B8 A( x& D$ K; l
- * kind, whether express or implied; without even the implied warranty3 U6 }0 g+ ~. T* {9 O5 o ?# \
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the. K1 }# U) s) A4 F
- * GNU General Public License for more details.% X1 g y/ w- f% I+ Q- C
- */
7 b+ l i3 N2 Y0 L4 F- U# H
- c* w% ?% N' D4 N; Y% Q- #include <linux/module.h>
: Z; h2 U. [4 L+ a - #include <linux/init.h>2 h `: p6 X% B m- w$ Y) h0 k
- #include <linux/errno.h>
5 i7 ~3 e+ e8 E X - #include <linux/types.h>
5 D, Z* Z: h, I: b/ V - #include <linux/interrupt.h>8 b6 f) P5 Y5 \, K0 k5 w
- #include <asm/io.h>! }5 a/ p# V6 t% t* S2 f$ t+ Z
- #include <linux/moduleparam.h>1 s, w. l* R ~5 S) O
- #include <linux/sysctl.h>0 b, c# i K" v
- #include <linux/mm.h>
( w! q6 q4 c: w7 b- s4 p @) J - #include <linux/dma-mapping.h>
; K# p6 f9 {7 o5 @4 W
$ O, Q D# k. p- I* [' w; e- #include <mach/memory.h>
1 F4 ^; K' I( [" T - #include <mach/hardware.h># u& s3 M5 F/ e% L( b
- #include <mach/irqs.h>+ f# k+ B' R" S4 K6 m8 @) ~! ~ `
- #include <asm/hardware/edma.h>& }; ? T7 H- P
" y% @# R/ B( Z- #undef EDMA3_DEBUG. W- l/ }/ T$ v5 Y' r& ~% V
- /*#define EDMA3_DEBUG*/
1 E& p d3 O7 l% F+ |
' I' x- I% t& h. n- #ifdef EDMA3_DEBUG
8 H% v% K3 \7 k7 ~9 o. F* d - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
7 O# E$ x9 z6 }# d, O, S; h - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__), j5 O0 r7 U9 N: u
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)6 f, q' m/ I& ?
- #else, M' a" E( \# z7 E& A
- #define DMA_PRINTK( x... )
. f1 ~' e" x3 g1 r+ V3 v1 r - #define DMA_FN_IN
! m, @& b3 O% _ - #define DMA_FN_OUT D! b$ [$ t+ l7 ?2 O7 N: l
- #endif1 _% e9 A# m3 j$ ?$ u
- 1 E" z$ A+ ~+ F3 j% ]4 L- `5 v
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
" s0 w% T1 u% \3 ]5 |0 o" i! a - #define STATIC_SHIFT 30 _( w3 A) O( q& ?, x
- #define TCINTEN_SHIFT 208 `* Y8 p! M9 X- Z2 [4 p
- #define ITCINTEN_SHIFT 21
# J8 v M! ^- k2 F& k1 I - #define TCCHEN_SHIFT 22
* x7 ]+ ~: a& k7 @+ H0 Y - #define ITCCHEN_SHIFT 23
+ p9 B' j* R0 F4 n7 R" a, W8 M! y
# Q! S/ J) x* P M7 T/ y$ e- static volatile int irqraised1 = 0;
/ X2 I& |3 j# `1 p' H, R - static volatile int irqraised2 = 0;
, F/ a4 }( O0 U: }; P* A+ z
" j+ o. F# [! ?- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
4 ^' i9 x8 }& M7 x# p - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);& d: R1 }; J' r
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);8 y" t/ D3 o: }/ M, l
8 }) y: Y8 G, b x# U0 s- dma_addr_t dmaphyssrc1 = 0;
( t4 Y) [+ S1 p( `+ J% s& v0 T% { - dma_addr_t dmaphyssrc2 = 0;
9 B% [: M! |2 d2 }8 M3 I - dma_addr_t dmaphysdest1 = 0;
8 O/ \# e! `# M: q2 Z! W9 l - dma_addr_t dmaphysdest2 = 0;
$ F/ c% `9 T! i7 f - ) v- T( D. K, b2 a
- char *dmabufsrc1 = NULL;
6 p2 h: p. }7 r, l - char *dmabufsrc2 = NULL;. i9 l2 i/ [' E' n& _
- char *dmabufdest1 = NULL;, I, C( B; E. N. t' b% f
- char *dmabufdest2 = NULL;
: @, H) P2 \( F - 8 J- |# r& M3 E& [" e7 O# k
- static int acnt = 512;
/ H7 @! ]! Z: l' o1 x7 ~- n - static int bcnt = 8;
* o7 D" a# p3 k6 i/ k! h3 X3 k% G - static int ccnt = 8;- N5 Q2 X# u. g; ?- q1 o8 k# w
- : B1 y1 K0 q- _
- module_param(acnt, int, S_IRUGO);
8 l5 V1 ~. _2 P& { - module_param(bcnt, int, S_IRUGO);
* k$ W. Q# I( K! Z - module_param(ccnt, int, S_IRUGO);
复制代码
! w1 a: l6 d, o1 J4 T. i5 _4 s& M! c* \3 E7 |) G9 X
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
/ ]; H4 m" E/ Q5 I! Carm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。! `( Q- O U! W1 S7 h+ S
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。5 X) c3 C4 } l
. ]8 g7 m4 z2 N4 A' D
7 P. Z3 ?; i' g7 J |
|