|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
8 \2 L D0 m5 h3 h- [code]EDMA sample test application
4 D% h: q+ M) S# r) c% _6 T+ H - /*
; @/ @% o v3 n/ S0 n - * edma_test.c
, q7 @6 T# H+ I) m8 k7 o, a5 r - *
7 h- m. p; _- l$ s; N: d - * brief EDMA3 Test Application
+ v& W8 ^& ~+ I$ l' D - *1 F. {3 q* f! q8 E0 x
- * This file contains EDMA3 Test code.
$ V' q. g: e* {) A - *" w2 ~: _8 Y0 ^% D% f) G$ M# X
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE% M {, u( O$ N3 V
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT2 q! w! d* V8 B1 y
- * TO CHANGE.: O4 s1 ]& F. G" `& L
- *' e# _! B; T) G
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
, i0 r, o0 F; J: }- ~* ~4 A0 D - *
3 G6 F! F, Z9 \* ] - * This program is free software; you can redistribute it and/or+ t+ ` `: i7 p3 b0 U# e' x
- * modify it under the terms of the GNU General Public License as3 I( E/ X/ L- t s
- * published by the Free Software Foundation version 2.
/ m6 w0 I9 Y4 @7 ~ - *
4 C# x7 B* ]& |/ r - * This program is distributed "as is" WITHOUT ANY WARRANTY of any& T% R. j1 G" x+ P
- * kind, whether express or implied; without even the implied warranty
5 j$ x+ ~& f3 D* r( O - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the5 [1 e, j8 _ ]7 T0 y9 s! ?- P
- * GNU General Public License for more details.
' _& o% F; o' y - */2 ?0 |2 _8 O! k& E
- * P1 L) Z9 r: ^0 y# S
- #include <linux/module.h>8 V2 |1 C9 E( e' L5 ?0 h. ^
- #include <linux/init.h>1 u6 T* S" ?" r- b# O; I! a" D3 h
- #include <linux/errno.h>
) V& U5 A; B! q# D - #include <linux/types.h>9 z! ~; {2 v7 }
- #include <linux/interrupt.h>6 H, h* G! K/ c1 E* Y7 r
- #include <asm/io.h>1 W* H9 S6 k6 J( D4 f$ Y
- #include <linux/moduleparam.h>6 I4 _6 w a; a" t# x
- #include <linux/sysctl.h>
: B: S+ {8 K7 C! `( u" T - #include <linux/mm.h>
& Z& g* A4 k$ I D1 o! c' u - #include <linux/dma-mapping.h>
5 B% J: Y2 i/ d# K( W
+ @9 t" J" B! m' u! J- #include <mach/memory.h>& q% l# ^. s. W% T. s
- #include <mach/hardware.h>
) w1 v) Q! K7 h+ j K# h# n) ] - #include <mach/irqs.h>
, s: _2 J, N! L - #include <asm/hardware/edma.h>
) [$ ^( |1 Y; Q$ C - 2 C: k* S# X) g; a$ {
- #undef EDMA3_DEBUG4 O% N3 e7 {$ ~8 P
- /*#define EDMA3_DEBUG*/8 V9 v( [8 K; K& p+ B L
- # E6 g- }. F1 }1 D5 N$ X
- #ifdef EDMA3_DEBUG
' B y: e; l; Z) I) O - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
% Q! _, R7 a' }/ d: Z: N5 ] - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)) d4 A* @, O. \% B: \7 u
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
$ W# G. p: A2 ^! {4 T& I6 j8 N - #else
4 f) p. W( G6 z1 ^ - #define DMA_PRINTK( x... )
$ V! F! S' \$ U* k" n. P' f$ R+ Y - #define DMA_FN_IN$ Y$ Z. |6 \" f
- #define DMA_FN_OUT
$ e+ j) t) A( z* E - #endif
; K. [5 P$ {3 ?6 ~ - ! b- r9 o5 \5 S. _
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
7 g( Z7 S# ~# } n9 I# m# m0 O4 r - #define STATIC_SHIFT 3
! `4 u2 E0 ^! D9 p - #define TCINTEN_SHIFT 20. A$ `6 h5 ]# J! D/ n% m
- #define ITCINTEN_SHIFT 21
! f- \* {( l: I, s! ^0 } e+ v# x - #define TCCHEN_SHIFT 22
0 L- n' t7 h) u& K - #define ITCCHEN_SHIFT 23 r U. \- p* @+ t
- % d4 |8 H" r- N$ O& p9 K6 E; ?0 e
- static volatile int irqraised1 = 0;
: J$ Z6 l h6 M+ n( g8 z {" U' n - static volatile int irqraised2 = 0;- e) ~3 v2 m5 {# _$ F" h( j# \
- 3 s1 W, b! `! ~ J
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
/ }# `- F! Z$ _2 R. M - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);% C2 v* Q! |& z: t- l" K# J) m
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);( |( A: F4 i- ~
" I6 V1 Y. Z P8 ?- dma_addr_t dmaphyssrc1 = 0;0 B1 b+ `( A5 @" V0 e
- dma_addr_t dmaphyssrc2 = 0;
& `' O3 a+ ]3 q0 z8 z: p - dma_addr_t dmaphysdest1 = 0;4 U; O* B V8 G, W( K* B2 s
- dma_addr_t dmaphysdest2 = 0;9 \3 H5 e5 M# Z( B" ?
- ) n4 X2 } D& i- V/ L) S: Y
- char *dmabufsrc1 = NULL;) V" r- c* @! h" Y5 j
- char *dmabufsrc2 = NULL;0 X. @' S \+ }$ L! S7 ^ X
- char *dmabufdest1 = NULL;( X( V1 R2 f& H1 V
- char *dmabufdest2 = NULL;
- s# B4 @3 |! H" B6 H6 l1 ` - ; H0 _; X v- G' E
- static int acnt = 512;2 \& r S- O/ o3 R" [
- static int bcnt = 8;
6 Y3 |: `* m# ]3 R - static int ccnt = 8;
* G* P4 K' J9 _9 B - . `# v. E+ d! P+ I, o
- module_param(acnt, int, S_IRUGO);
. }, r1 L- T) ]0 R+ y, M - module_param(bcnt, int, S_IRUGO);/ z& a! k; h# ~9 D& n" T: C$ h
- module_param(ccnt, int, S_IRUGO);
复制代码
$ w2 i9 }8 \! L7 o
5 }' p. z6 d3 t2 P8 X$ t 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用; M; I3 b5 b. }* _
arm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。' Y1 i7 Z9 j. D0 J' F7 ]3 k# A" n. T9 d3 _
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。/ Y3 _# f- y( F0 f
, E1 d$ n+ O& z' E
# r* H( M8 ^1 r: F& S' j |
|