|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 : x; w3 p2 A9 E% w2 a5 p
- [code]EDMA sample test application4 O: _6 k4 y+ ]7 e; r; H$ d& X" g
- /*
7 S& P% U `7 d8 o) A F# p - * edma_test.c
8 R7 Z: K' u! W! A - *
Z0 x: V& _. E - * brief EDMA3 Test Application. d- I, R' u. s8 o* w
- *1 r$ C$ B( P0 G' O8 r/ [0 [
- * This file contains EDMA3 Test code.
) B) m0 J `: F, \! y' h - *( s& ^) K# h) r; F J6 y
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE; ^ }5 s' v/ u# n4 m( D. z5 m7 J( x
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
9 ]* I0 D# Z( G9 v: X" Y X - * TO CHANGE.; C. r- B5 P9 t* S
- *1 D# ^: H$ [3 `- J7 s
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/# A9 n/ k: N5 u$ X+ B3 ?6 f0 B# b4 [
- *% @5 N4 J- @1 h5 n
- * This program is free software; you can redistribute it and/or8 t% l: o- p1 y1 I$ B9 D
- * modify it under the terms of the GNU General Public License as" m0 G \ {* b
- * published by the Free Software Foundation version 2.
2 a# k) G) P4 Y - *
, p3 v) H* d* Q! T - * This program is distributed "as is" WITHOUT ANY WARRANTY of any3 w- g2 h+ F" b( s9 O
- * kind, whether express or implied; without even the implied warranty3 j, s& b: d" s9 c/ _' ^ J
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
8 K3 s) Z U. I3 ^: B - * GNU General Public License for more details.
) w# x+ Q0 P) y9 Y - */+ r( t y, V: N* z
- 4 K6 h& k8 s# m
- #include <linux/module.h>
( w+ @% E4 i: m% P$ D$ c U5 t - #include <linux/init.h> d5 B4 {4 g ^1 ^# ?1 P! S' u
- #include <linux/errno.h>
! p# Q/ {; e# r4 P; |5 i( o" d3 D* ` - #include <linux/types.h>. `, d4 O3 }& w3 t
- #include <linux/interrupt.h>
9 v; n0 B N* f/ r/ y6 T - #include <asm/io.h>
6 F* v+ l# r+ A. d+ |! z - #include <linux/moduleparam.h>
3 P6 j" ` {' _ - #include <linux/sysctl.h>
6 v1 c% }; D% r - #include <linux/mm.h>. r9 f2 Z, i) H3 ]; G6 n
- #include <linux/dma-mapping.h>
" Y, G2 `: `9 S) J% _0 j5 @1 c - 6 L; u! ]& R+ N
- #include <mach/memory.h>0 Y; r+ q) k0 K8 c3 u+ P
- #include <mach/hardware.h>
& G& Q8 {0 a1 I% D! q/ S( z% K - #include <mach/irqs.h>% s) l3 B3 ~. ^4 U+ E3 A; b3 u) K
- #include <asm/hardware/edma.h>
+ ^$ ?. W3 i" c+ v - . w0 P: J& W2 V, D2 i G3 l
- #undef EDMA3_DEBUG
6 K8 g/ s0 t: [% K - /*#define EDMA3_DEBUG*/
9 V3 T5 v5 P: g( G - 3 u1 p# E: ?0 O. @; O) F, v0 {; M/ P
- #ifdef EDMA3_DEBUG
. f0 L/ t) M, M+ E - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS) A: x: I6 S" X U/ r# [. Q
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
( r q- A- I; |) }1 }. r4 B - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)* ?/ A n( C" c5 P( e Y
- #else
* a6 O S1 Q) H) o - #define DMA_PRINTK( x... )0 p5 {: q2 m1 B# {
- #define DMA_FN_IN: t' Z' y, ?, g) i B. M# G
- #define DMA_FN_OUT
" ]0 q- I0 i% _4 A8 ?- ^ - #endif/ F4 n; V2 Y1 o) b# k8 N
# g3 n: x% a0 X4 K- s, |1 ?- #define MAX_DMA_TRANSFER_IN_BYTES (32768)3 t" r4 L1 J& `9 a. O
- #define STATIC_SHIFT 30 N7 D" k3 W1 [4 L. N% q8 O
- #define TCINTEN_SHIFT 20
: u# q- R7 ?; X+ b/ U" ^0 m - #define ITCINTEN_SHIFT 21
& k9 J$ _3 J$ w4 |3 s - #define TCCHEN_SHIFT 22* E- E9 B3 D2 r4 c1 Q& T: E4 P* {
- #define ITCCHEN_SHIFT 23
, ?( I( r* a" X( x4 W5 b
. w0 W5 g3 x6 e4 j+ F7 T- static volatile int irqraised1 = 0;
( t5 k; y, ? {& I8 A- B - static volatile int irqraised2 = 0;& U6 e6 q2 t0 r; B
- 6 W- g' ?8 c; Z0 n
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
, H$ z( v& t: t/ L0 h - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
$ L9 g0 u- ]1 R1 t0 A2 F0 o+ c - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);) L5 I( f' C: d( ~( L
- 2 j% _/ B E# K3 {5 I, m! ~6 g5 s
- dma_addr_t dmaphyssrc1 = 0;3 H0 R1 w) b+ u: G* V2 _! b! n
- dma_addr_t dmaphyssrc2 = 0;
- s! s% B3 F g# F4 h, _6 U1 D - dma_addr_t dmaphysdest1 = 0;
9 P/ h( k. K, p. _ - dma_addr_t dmaphysdest2 = 0;
' [" D$ p% H2 ~: l' Z) m0 y
' X; e" H; l: x/ R [- char *dmabufsrc1 = NULL;& o! Q+ n: L: n7 f. W
- char *dmabufsrc2 = NULL;3 l; N9 Z3 |6 ]- k6 `- P N
- char *dmabufdest1 = NULL;# C; z* b F, f. ~7 O6 J* ~6 L
- char *dmabufdest2 = NULL;" Q) h# f% I+ Q, Y
5 X2 y) z5 _% w& i7 I r- static int acnt = 512;9 U. W: i, a6 H: X
- static int bcnt = 8;
' C7 z. V5 n* B6 G7 `% C- t - static int ccnt = 8;/ `. K _- {/ s- c, E
5 a B0 I3 }2 R% @' k: b; z# @6 W- module_param(acnt, int, S_IRUGO);3 `6 s1 O' ?$ n* T) `! K' \
- module_param(bcnt, int, S_IRUGO);( I+ I# @: J& K+ K9 ]# q! a, I
- module_param(ccnt, int, S_IRUGO);
复制代码
* a* z5 ~+ M% l9 X7 Y$ H) }/ G, p! X; C0 q, u3 \
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
/ ~# d3 {3 p: t" }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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。; F9 b* i# ]: l& i
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
9 o8 _; a; J/ F3 A) C$ h) r% S
2 R8 t, J6 w* M" F0 A
|
|