|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
: a. e2 W! Q( y, I0 t- [code]EDMA sample test application
) R7 J! a1 D: ]+ C6 O# a! J - /* h8 G& q6 \9 s6 P) q
- * edma_test.c& }, G; I/ I2 C1 J [& i9 u" |
- *
/ f1 G8 I: Z* H+ L! C - * brief EDMA3 Test Application4 N! @) B0 [/ {6 T. o/ [( A
- *
% o1 q9 \# f9 J# Z - * This file contains EDMA3 Test code.
! }6 I; a' V4 d; M' M - *+ Q% U: E& g! l3 }& |
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE2 c6 h' j8 b5 G2 s' e
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT X7 w0 O* F) }+ F6 D. ?6 J
- * TO CHANGE.
" P( m. |! K$ b8 |& d9 e - *
+ Z# w9 h. ~2 G0 O - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
# \ t2 b- N% p4 h- q" K T - *
8 j' b8 z+ M2 V* K$ l - * This program is free software; you can redistribute it and/or8 d: l/ [! O7 }9 I l5 R: }
- * modify it under the terms of the GNU General Public License as( E Y+ g s% i
- * published by the Free Software Foundation version 2.
5 L2 B+ s* a' K( M1 g' m' D - *
5 |: X3 p; ]0 p - * This program is distributed "as is" WITHOUT ANY WARRANTY of any
- j9 w# t- K, U& j$ V2 _9 m# x5 K - * kind, whether express or implied; without even the implied warranty
5 c: D" k0 W; \) M+ X6 B - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the0 p$ Q; u; e' \; }0 K
- * GNU General Public License for more details.( G% I" t0 `: V) `" C. o
- */
, F! H: N0 f7 h) G8 P* y- W- H2 q
% U& V( W! u: v5 s3 D4 `" g- #include <linux/module.h>1 e$ a+ E6 {, h8 W
- #include <linux/init.h>/ J% l% l9 Q6 \. v S
- #include <linux/errno.h>
J9 s. W* V0 z* y - #include <linux/types.h>( S, o k% X& c8 [* `1 k q
- #include <linux/interrupt.h>
4 [3 w2 R4 p0 _& { - #include <asm/io.h>
6 ^9 w+ E6 `5 x( P( G) @ - #include <linux/moduleparam.h>$ J9 P: N$ P: y9 B2 j
- #include <linux/sysctl.h>
7 C, O5 y! a/ m6 W - #include <linux/mm.h>
' M' n0 y1 @4 _, m: W - #include <linux/dma-mapping.h> x: i) k; j! `: E7 Y w9 F
- ( r$ }# A9 u$ Q. [2 S& e
- #include <mach/memory.h>
: J* \5 g" ]. ~# U; p$ p, H - #include <mach/hardware.h>5 `- z9 ~+ \+ A _
- #include <mach/irqs.h>
# v! X. I! T. L7 o: e3 b - #include <asm/hardware/edma.h>
n0 k. ^- V$ ]
# |3 B" r9 |0 z- #undef EDMA3_DEBUG
) h4 R+ Q8 e* x8 h4 J - /*#define EDMA3_DEBUG*/
8 u- \1 e4 T. l+ u" H6 A) ]) ^2 ?3 a - * k# T M C+ M
- #ifdef EDMA3_DEBUG
- D$ ]# v0 {( b6 b1 y - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)7 _ V" E" z1 f, F' K
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
) G0 A: h* f! S0 d" {7 X7 V0 s. T - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)6 W* @: w3 G( z' p5 g r
- #else
5 x1 Y" }1 t- r* I; f, ] - #define DMA_PRINTK( x... )
$ H2 P8 x9 F. K - #define DMA_FN_IN
/ {. D- D/ `# } K* H2 R2 t - #define DMA_FN_OUT
0 Z! D7 C' Q& |& ]2 U8 G4 L+ ? - #endif0 ~& z8 ^0 X' A4 O: n) a4 ~: V H
1 Q' }4 @& o, S- #define MAX_DMA_TRANSFER_IN_BYTES (32768) B& b1 o* @; D8 i4 R! t3 _
- #define STATIC_SHIFT 38 u3 O; i* R! {% e/ U/ t! X9 H8 T
- #define TCINTEN_SHIFT 20) |) B3 u: J, w% Q$ [% ^& J
- #define ITCINTEN_SHIFT 213 Y6 b9 ?1 G3 P: c* _. A) B
- #define TCCHEN_SHIFT 22
1 Z% D7 f5 l0 ?4 q6 B - #define ITCCHEN_SHIFT 23
. b4 ?* @- E7 P2 d0 V9 ^
5 F& t, |/ z* x9 `, V- static volatile int irqraised1 = 0;
6 ^+ P$ M- S4 c) R - static volatile int irqraised2 = 0;
" B/ n9 ?1 \# [# d0 U - 5 M: F' A+ g, j$ V5 q
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
" y R+ h9 j+ o1 B, P- u0 L+ z - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);7 V( k$ w2 _% a! F k: L7 A
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);* C6 | ^) E5 \, M( m* k. w
- ; t" K i2 H& [# Z- |: y
- dma_addr_t dmaphyssrc1 = 0;6 `1 w' x, @3 g2 B
- dma_addr_t dmaphyssrc2 = 0;# s2 H/ H( z( f& L; E
- dma_addr_t dmaphysdest1 = 0;
4 Q* f8 y0 c/ C6 \( s0 D8 c7 Q - dma_addr_t dmaphysdest2 = 0;- s% S. ?7 V/ _9 U" x. ^
- + ^4 D8 T/ |! D& V4 o
- char *dmabufsrc1 = NULL;: z- S/ L& T5 _7 E1 C2 Z( G
- char *dmabufsrc2 = NULL;; }# D; }( S7 Y! [
- char *dmabufdest1 = NULL;( M4 ^4 |0 K2 i, d' y$ a7 A
- char *dmabufdest2 = NULL;: `* E% N- g: r2 G$ L) ^8 U
- 4 i& N* J0 c/ p6 U; C. ~
- static int acnt = 512;( V- P, {+ Y+ n0 l7 u
- static int bcnt = 8;6 Z W5 u" [1 r) X2 P
- static int ccnt = 8;
7 S- n' _7 M) w3 C9 o
" }: _/ s* s7 P9 {* A- a) k- module_param(acnt, int, S_IRUGO);9 F% B* x4 |' {$ w2 @
- module_param(bcnt, int, S_IRUGO);( Y) Q7 g" r* I
- module_param(ccnt, int, S_IRUGO);
复制代码
# K- g% ?" M5 m# O6 V& k" a- w; t& c0 Q' n" G4 t- ]
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用5 k3 Q( I* A+ ~, K
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。 R9 J* P1 U B) M" V
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。5 j" n* X) g/ f
( t# Y0 D m9 f( u3 e }7 ]. k" T8 Z& J
|
|