|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 : G1 _, A+ j6 S4 M: k
- [code]EDMA sample test application
$ J' x! |$ m, |% t - /*
$ d8 E9 A6 p. f2 k - * edma_test.c* h' e8 p9 p( D+ Q
- *" v# t/ {4 l8 C" G o2 w. ]2 }
- * brief EDMA3 Test Application
4 W8 z0 {" p# `6 V7 n - *
7 ?5 Y4 C4 P r* o8 J' ] - * This file contains EDMA3 Test code.
% _+ I* Z* i) i7 b2 F; F - *7 a; ~; e* Z0 K# H
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE' ^5 J; C. M7 n4 `, C/ U
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT* K; ^: S3 ^1 N
- * TO CHANGE.
- O4 K) L7 _9 a! c - *
! e. P2 r# B0 d* M$ y* G - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/2 R: W0 {+ u5 o' D6 e. ^# k& ?
- *2 x# H# @7 P5 M, Z, v& f0 R2 P
- * This program is free software; you can redistribute it and/or- D) }7 r% W0 R
- * modify it under the terms of the GNU General Public License as7 M2 | v- g- O% a" A3 K
- * published by the Free Software Foundation version 2.
. n; e, w% u4 e, K. v( a" V - *5 v# ] U$ }9 b5 l6 K
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any
' ~2 f$ x+ E; k& H - * kind, whether express or implied; without even the implied warranty
- v9 p9 O: ^6 e5 E3 S5 a+ o2 o - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# c2 n" i& H1 t w- f0 Y - * GNU General Public License for more details.
' G1 e7 ^/ f/ d- N: O8 d" X - *// G% x+ F( U) s; g- y
7 }9 |" ~! A# T0 O4 K$ u- #include <linux/module.h>
4 G5 K, I, O' ^ - #include <linux/init.h>( `2 f1 T% P/ v8 F" j
- #include <linux/errno.h>7 |9 [3 Z. ~2 I; R2 \% @: V/ W% C% a
- #include <linux/types.h>; w2 L* w8 h2 j2 J3 Q# z
- #include <linux/interrupt.h>9 ]+ }: r: {+ X, H, H( r
- #include <asm/io.h>6 `3 J1 c5 q+ p- S% `+ D
- #include <linux/moduleparam.h>
5 h4 l" G; C* q5 k N: l - #include <linux/sysctl.h>4 }; \1 E- F2 Q. D. E
- #include <linux/mm.h>
0 |# ~7 f, M1 X; a; x8 [0 U" y - #include <linux/dma-mapping.h>
7 E1 R7 b, u' I C" p# ]
1 X2 n( R- A* v% ~' x) v/ y- #include <mach/memory.h>
: Q/ d9 y J3 i+ D - #include <mach/hardware.h>
; a7 ^3 G( d8 q, J6 B9 c - #include <mach/irqs.h>
, [) [1 _, d; L6 s/ A( D& u6 x: P( ~ - #include <asm/hardware/edma.h>4 j; n6 K3 R* T, a
- 4 D% F* U7 v# R* l7 M, i
- #undef EDMA3_DEBUG
, j0 ^; b2 P+ f+ t1 Z2 q - /*#define EDMA3_DEBUG*/
" D7 g- \, m$ z( C- |! D! N
/ o- M( Q- m5 {& x& D- #ifdef EDMA3_DEBUG
- \& }! R# x# q) B8 C - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)1 n& a4 N8 U2 c
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)( j, z6 e' ?3 q
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)3 c) Z4 |7 x" Y4 X8 r
- #else
8 b" X+ H( Y( X - #define DMA_PRINTK( x... )
, u; J; K* U7 x$ s5 g: w - #define DMA_FN_IN
, ` G& Q7 r; Y* O3 l9 K - #define DMA_FN_OUT
" U0 Y. W9 L5 c* Z: k - #endif
! w0 G3 Z: R2 @
' s7 C1 ? U/ _- #define MAX_DMA_TRANSFER_IN_BYTES (32768). k) l9 L" }4 F5 i
- #define STATIC_SHIFT 3
5 D% T$ V2 [; i3 z: b( R - #define TCINTEN_SHIFT 20
% p' e2 [. }7 v$ h8 w - #define ITCINTEN_SHIFT 21
, d; {9 @! e) L% W6 f - #define TCCHEN_SHIFT 220 w: ~: C+ @6 t/ K& X6 z
- #define ITCCHEN_SHIFT 23
' K7 Q/ E C# e {$ d - + X9 |# V, H9 V: {2 x+ f
- static volatile int irqraised1 = 0;
7 l' l; V' l2 G9 ^$ ~# b - static volatile int irqraised2 = 0;+ E, n1 I, @! r! j! H
- |- t! B4 N, R7 K/ l- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
' R" J4 |0 i) i. w - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);2 y |: `4 \" v9 D. G" K1 M
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
. r# l: m! n+ G5 b9 O( B
: }, D' I, Z$ E% V- dma_addr_t dmaphyssrc1 = 0;
; c# Z4 ^% t* `- p( B! F# a - dma_addr_t dmaphyssrc2 = 0;4 G% P1 `, F5 n0 D3 d" n# {
- dma_addr_t dmaphysdest1 = 0;
5 c( {# O$ s! w% z2 d6 ^; v' } - dma_addr_t dmaphysdest2 = 0;
+ n# X! ?# ^) ]9 Z* G; E, I! X
, p' E# U* L& I( [+ z- char *dmabufsrc1 = NULL;
: o4 \$ f3 v8 W/ D1 T$ R - char *dmabufsrc2 = NULL; E; @/ C2 q4 i
- char *dmabufdest1 = NULL;1 a" }) T1 R2 |9 m
- char *dmabufdest2 = NULL;+ N3 K" j, b" W7 ?" {
2 U9 _2 D/ d' J. X$ S8 i- static int acnt = 512;# r; W" ]$ }' \, k, \4 I4 ^# K
- static int bcnt = 8;
9 I. v' k1 F1 ~ - static int ccnt = 8;
1 ~# J- D% [8 r$ L/ B b1 c3 S0 X
0 M1 T' [& i. w; v/ a- module_param(acnt, int, S_IRUGO);$ K9 e. Y* u% n+ _+ P4 T* B6 C+ \
- module_param(bcnt, int, S_IRUGO);
. v) ~, S L7 P! I; v, u - module_param(ccnt, int, S_IRUGO);
复制代码 # X. Z; N }6 ^# R* R
a9 p* c6 J1 c4 N4 k
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
# `0 v4 \: ?$ k* t* Yarm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。& k1 [% u0 x" c+ z
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。! f- i6 {) f4 L! t% ~' c5 ^7 K5 i
. l" Q$ k. v& R& n+ ?9 h3 s7 \. I
" l. q- H( A2 W& ?- H! s1 p |
|