|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 : J2 I" H7 E2 g
- [code]EDMA sample test application
* v2 z1 N: n1 F1 `9 L6 @5 t5 I: l - /*
; Z$ n c; E S7 J7 g6 N: Z9 r" N - * edma_test.c2 X, i$ g& X o, P5 a, Z. c5 i
- *
: f7 T& u) g' C! [# Y1 h - * brief EDMA3 Test Application
0 B0 k* r- ^6 p5 k' p/ v( L/ O* [ - *6 v$ q% ]) B Y7 v+ j
- * This file contains EDMA3 Test code.* b9 M: o: \8 u9 h6 |3 j# l
- *
p C9 ]0 `" T - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
, E7 t z& Y: G% L) ^; Q - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
$ B- K+ t0 v2 H( N* d" L; }% X - * TO CHANGE.5 J6 J( c$ U( _2 ?3 R
- *5 U! f2 \ p) O- q# i4 W% [
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/& y& V7 |7 e% U; t9 `
- *# g+ y0 d! j4 Q/ f# C' r' u
- * This program is free software; you can redistribute it and/or. c$ ~7 R ~# l6 {0 ~
- * modify it under the terms of the GNU General Public License as" C( C6 L9 [0 i5 H
- * published by the Free Software Foundation version 2.7 z) H! J& [% k8 e+ Q' L* N( Y
- *
- p# D- O; v3 P - * This program is distributed "as is" WITHOUT ANY WARRANTY of any' H* ~) \! q1 G* Y! y7 ~
- * kind, whether express or implied; without even the implied warranty8 u' Y/ |$ A+ r# J4 ^" Y V2 R
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
, @3 F, s. R8 w2 N2 G0 L; `/ A - * GNU General Public License for more details.
) L& g9 D3 W: D) C, v/ v - */9 E3 g7 V K6 R& k
) f: O) I! u2 l- {- #include <linux/module.h>
& ?1 D( W( x/ C1 x7 n4 l t( u - #include <linux/init.h>- B/ u3 k3 A. j! Y ~6 }; x1 x
- #include <linux/errno.h>
. k5 k- G$ D: Q* V1 _. R4 S - #include <linux/types.h>
, V' O0 ?; V V - #include <linux/interrupt.h>8 F6 N3 ?- \1 [1 j7 {: E1 x
- #include <asm/io.h>
6 _7 c4 Y: d7 D; N9 U: g - #include <linux/moduleparam.h>
4 X. i% G Z4 U5 e: A% M - #include <linux/sysctl.h>8 u! v; z- \8 O0 x, r6 Q, O# a
- #include <linux/mm.h>
+ E9 h1 T/ Q0 h0 M7 z; { - #include <linux/dma-mapping.h>
% L$ ]% v; v7 ^! W1 y- L - 8 Z N9 v8 z, j
- #include <mach/memory.h>6 [" k, g7 r: W5 K2 |
- #include <mach/hardware.h>5 n% f# u" c- q. X/ e
- #include <mach/irqs.h>
`! L1 F8 L1 b# |: @( d b& O - #include <asm/hardware/edma.h>: ?7 U: ~. J8 q; V* K$ i/ y) h
% |$ _! s, T" W- _. _- #undef EDMA3_DEBUG
2 N! I& [' v% W0 m% J) T - /*#define EDMA3_DEBUG*/
6 z, u9 n# Z& R9 n$ K% D: s, m3 q: D
9 `/ D$ {2 ~+ k& r! m- #ifdef EDMA3_DEBUG
5 s4 z ^' x u5 }' T: g5 J$ b+ m - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)+ _8 Z' F I: \' y
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
; l" U# F" u. C* W9 O - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__), M" e' B5 `+ W6 V
- #else, w% ]" I- |3 M7 C7 m8 f
- #define DMA_PRINTK( x... ): |. @. Q9 ^- L' W
- #define DMA_FN_IN
* _. ?. W, ~- v# d3 \( l, @/ k - #define DMA_FN_OUT5 e) }8 Q1 R* q1 B
- #endif
0 i0 l( J7 y; n0 V0 n; k - 2 T; c' }; o/ Z
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)) t6 t9 i- U; Q/ b- A* \9 `
- #define STATIC_SHIFT 3) ^9 |& ~' S0 I; N% c Y* h
- #define TCINTEN_SHIFT 20
# \( t2 |. d. M8 X7 z0 H - #define ITCINTEN_SHIFT 21# L- I( X! e% I* f3 D
- #define TCCHEN_SHIFT 22' O8 Q t8 L( p, N8 J) x
- #define ITCCHEN_SHIFT 23
N8 F2 b$ }2 j - ) i7 V; T; g$ e8 G3 g; k
- static volatile int irqraised1 = 0;1 A/ Y* t6 a. Q9 g, \6 `$ G
- static volatile int irqraised2 = 0;
9 L H% ^, @1 f5 a- K) C! } - 3 W. }1 `) j k, v0 U' U+ A$ Z1 m
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);, b% b% G9 x& r, u0 h$ a
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);6 V% Q2 `4 a, w6 m$ u
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
( L3 f7 N7 N$ G$ a [ - 9 D8 u) t3 F3 `% T: g z5 ]! i
- dma_addr_t dmaphyssrc1 = 0;
! j6 y9 i# `( a0 p* i( Z - dma_addr_t dmaphyssrc2 = 0;
; W* ~: m$ [8 y* j - dma_addr_t dmaphysdest1 = 0;
4 ], k' C8 b% b3 _% n3 ? - dma_addr_t dmaphysdest2 = 0;% G- i0 r) O5 H l6 s; x+ |
2 ?5 S; Z8 r2 }- ?/ c6 ^- char *dmabufsrc1 = NULL;
- Y# k! }/ g# k1 K - char *dmabufsrc2 = NULL;
' H( V \4 M6 p L5 m+ ^) h9 m! `1 L - char *dmabufdest1 = NULL;
5 m4 p2 t6 u* h. Z& { - char *dmabufdest2 = NULL;" { h/ `1 `) M
- 5 ?& h- f4 x: K) Q
- static int acnt = 512;8 L/ ]* Q& A X! Y! a
- static int bcnt = 8;7 S# |1 `* k& _- s- j& F
- static int ccnt = 8;6 _- |$ N% c4 J: e! }. W$ p# T3 f
- 3 y+ ?$ U0 G) c3 n: _
- module_param(acnt, int, S_IRUGO);4 g% l8 Q8 r% H
- module_param(bcnt, int, S_IRUGO);4 K( R: L' y/ C% q3 v8 H
- module_param(ccnt, int, S_IRUGO);
复制代码 : f. @# _; }: n3 q$ v6 x
1 T, W6 O k7 h) O6 ]0 H! U 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用2 K( {5 q/ I2 V4 |
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
+ E; x- _5 ?5 g& E+ o! U3 y8 Q 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。% i& h: ^3 @! K7 v9 A
/ Y/ x6 g3 c* z
" w' u* Q2 v1 Z* b6 a |
|