|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
+ k% c4 t' ~9 s: ]& F$ ^3 m4 j- [code]EDMA sample test application
2 i' J! S/ r$ R3 t5 n( Y) { - /*
- A) Z) i' a* ]! L3 |: s9 I6 V - * edma_test.c3 v' Z9 o; ?0 ?2 m0 \
- *
/ S4 R$ K2 H" I3 b. d3 Q! I8 g - * brief EDMA3 Test Application
& A X9 \( Z0 ~/ v& q7 j - *1 n i# U- V1 ~ J' a8 }; }3 p
- * This file contains EDMA3 Test code.8 R7 |% a0 [0 S [
- *
& E2 U( a |! x) \ - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE. [+ a. \7 C% A8 M& v0 @. ~
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT+ j& I# m d' r( O( o( Q3 w, X
- * TO CHANGE.
5 X: i: C) e6 `3 L8 e - *
8 W# ?/ S: E: O - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/: a2 Z6 x7 J2 O8 g
- *
% z' {5 M1 O% C. m9 ^$ M5 q$ N+ y - * This program is free software; you can redistribute it and/or
* j; ]1 L Z# X; H' z6 o k$ O - * modify it under the terms of the GNU General Public License as6 V7 H# E3 B' L
- * published by the Free Software Foundation version 2.
% P( L* ]5 ~/ x5 h! T% c - ** @- a% m$ i$ ~# I) V8 I
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any2 j4 W# f8 a( t H( ]
- * kind, whether express or implied; without even the implied warranty9 u- i4 q# r) J, j
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the& O. {. S& p: Y# v
- * GNU General Public License for more details.
/ }, D2 B! I4 M- \* z - */! E) _! w: Q6 w( e+ c6 ^
- l& r9 H" i* {7 m# Z
- #include <linux/module.h># W$ n" f4 k( s) F7 o7 o8 M( j$ \
- #include <linux/init.h>
* J# {; J" {# i2 X- i. I4 H - #include <linux/errno.h>2 |3 [ A+ E! p; o1 E
- #include <linux/types.h>
$ q- h" X% H* z* Z* C$ e - #include <linux/interrupt.h>' C2 K& |/ v0 u z2 U7 j. _
- #include <asm/io.h>
6 {8 [, x0 f' u# T4 b# S/ S( F% b - #include <linux/moduleparam.h>
3 r. p% K5 x, G - #include <linux/sysctl.h>
* ?; c# z. L, J4 _# x9 F" E) F+ y - #include <linux/mm.h>7 [* {( H5 A5 n B
- #include <linux/dma-mapping.h>% E6 _4 a2 Z+ H. X' T2 d
- 1 u! n" G; [" D
- #include <mach/memory.h>3 m0 R# } |4 `* V
- #include <mach/hardware.h>
8 E$ Y, n$ t; n* r - #include <mach/irqs.h>
, p- y8 }+ I9 T+ y1 @% j - #include <asm/hardware/edma.h>
6 ]* z, u6 _' K: n% V4 y6 Q' X( V - + ]3 Q: y4 Z- b% ]4 M
- #undef EDMA3_DEBUG
0 |$ C7 u+ \/ X; x - /*#define EDMA3_DEBUG*/
! p5 s) ?- l0 x0 @ - 5 M% E. I9 |0 i# L2 t- z8 [- {
- #ifdef EDMA3_DEBUG1 C( i0 Y% D$ [% _, \# A
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
2 m: {( E) G: l' Y: E0 P - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__); |2 u% B# f, u4 g
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)* R) H4 r W. Y! ]
- #else
* I# ]' w# p9 C' l+ u - #define DMA_PRINTK( x... )
: x) V2 r& H! V! [ - #define DMA_FN_IN
. i: ^* D- w* T, _1 L - #define DMA_FN_OUT' \; b0 ^3 R+ n8 {
- #endif
* l7 F; I) @9 _1 O. [
?) C, _5 H0 U- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
8 n! Q: w+ K3 j; P( u* S - #define STATIC_SHIFT 3( e7 ~. E) b4 ?
- #define TCINTEN_SHIFT 20
5 a3 E: ^/ f* f) T - #define ITCINTEN_SHIFT 21
w7 f7 I! O* ~4 s, F - #define TCCHEN_SHIFT 22
5 ]+ g( ]+ Z9 d8 N* o - #define ITCCHEN_SHIFT 231 Q! l. ? r( l; R
- _7 l$ E9 u: d( m- static volatile int irqraised1 = 0;! I ^) K( s* P3 d l: a2 {
- static volatile int irqraised2 = 0;
% m& o# J8 M/ ~7 b
7 @8 y$ L6 W3 F" Z* y! X- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
; q- A: f {# k% Q - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);* T5 V5 d3 b1 \8 ^% E3 C
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);$ a8 R( e, ]0 ~
. a) Z0 ?) t2 p- dma_addr_t dmaphyssrc1 = 0;
/ f& S5 T1 d: M/ z - dma_addr_t dmaphyssrc2 = 0;& k3 p$ y5 A: q- K) W. F* B
- dma_addr_t dmaphysdest1 = 0;5 Y8 G; R' w; Q d# h2 p
- dma_addr_t dmaphysdest2 = 0;
0 \& e, _# c ~' u! ^ - 5 q: I- n7 u! g* |
- char *dmabufsrc1 = NULL;
l- O1 L& N5 w: J - char *dmabufsrc2 = NULL;
3 a! s$ f, d, F7 Q3 k; o" K - char *dmabufdest1 = NULL;
1 E# A( _5 F$ G2 c) s* k# v7 W - char *dmabufdest2 = NULL;
" m) z% O3 y7 f; S6 j4 F+ s4 P( q - ( J x2 {, c5 B& |
- static int acnt = 512;4 u% E4 g: Q2 l) [
- static int bcnt = 8;
. ~; I4 W3 _2 A7 g( ] - static int ccnt = 8;
. | O/ G; A1 ]7 a( @) t
$ c' T4 c" t) t- module_param(acnt, int, S_IRUGO);
4 \, { @0 h! ]5 z( f7 ]( @ - module_param(bcnt, int, S_IRUGO);
1 q* ?+ p2 E1 Q; N+ b - module_param(ccnt, int, S_IRUGO);
复制代码
2 m1 C# ^1 |2 z& X1 R% H7 C G* _+ D3 k0 w4 c& l
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用5 h, U- u% R8 W D. q
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。; P) E9 V% A9 i0 ^1 T2 K: X
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。& [4 Z- D1 u8 }# O2 r7 h( B
6 ^+ c- Z9 E; a) @- }; Q4 a
; M4 p+ R7 h5 t7 \; D" r& C
|
|