|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
. }4 `) ] E( D n8 k- [code]EDMA sample test application
: ~+ h, X* D3 k - /*
- j0 _! `5 p; ~" f4 I% W - * edma_test.c
( E1 P1 z9 Y+ Z7 i1 Y - *
9 s6 T4 R6 z- f$ b# T - * brief EDMA3 Test Application8 G/ w( Z* t) X$ ^
- *
1 o c- i. Y1 A# i# @6 J - * This file contains EDMA3 Test code.
9 Q& Q% f# B, k - *9 P/ Z. n% r3 H, f+ o! \
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
. I6 Q- q* M# l1 J! n - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT! |7 K. [2 y3 }9 e1 @" y! z
- * TO CHANGE.( y' b2 T! x" \' [
- *# f$ G0 g( y8 U
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/# S* L* }, C$ F( B$ M. K7 q/ `
- *
* a+ k$ f. I. h - * This program is free software; you can redistribute it and/or
/ o$ u! a7 A, | N9 w& w - * modify it under the terms of the GNU General Public License as
Y, [% k3 a- t# n - * published by the Free Software Foundation version 2./ t z3 l1 J/ P/ }, [* ~% }
- *
* }. Z0 e" T: a- X7 h: B - * This program is distributed "as is" WITHOUT ANY WARRANTY of any
* q P' }. _: ~ - * kind, whether express or implied; without even the implied warranty
/ i' `6 R3 n! ~ e: v! M( g) R) G - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the R5 H* n6 F5 }9 x
- * GNU General Public License for more details.
0 a' d- y' j' }6 R$ g/ ~ - *// x2 D0 w$ O5 j W: P: u
- 7 p$ x3 a& v3 m) k: h
- #include <linux/module.h>
[; C, w, S/ c7 n$ o1 ` - #include <linux/init.h>
9 l8 Y3 Y+ P. D) ] - #include <linux/errno.h>
3 g. {* p1 s% I) C g4 d# w* f - #include <linux/types.h>8 w% H1 J' a( y3 T8 U8 e3 y9 L! }
- #include <linux/interrupt.h>
! l B, r) ^& w& d- a f% ~/ W o - #include <asm/io.h>
" F. c; {9 V) L/ T2 z8 j) i/ v - #include <linux/moduleparam.h>0 i% l. E* u/ n7 }
- #include <linux/sysctl.h>+ F4 o6 j8 `/ K4 K2 p
- #include <linux/mm.h>
- {$ T. U6 ~1 @3 p - #include <linux/dma-mapping.h>
% L, O* v# b" L' W' E; g
, W2 k& t9 |4 N# A1 h- h- S- #include <mach/memory.h>, F, F! T+ i7 H5 e) B9 l% L# L0 l
- #include <mach/hardware.h>4 A+ Z% m8 ]7 u( e. F( Z
- #include <mach/irqs.h>( M8 ~$ R) `$ j$ `0 o9 Y& u
- #include <asm/hardware/edma.h>
% ~" ?- _3 n/ }, Q( L1 @2 Y5 z4 V - 8 O. b! s M; ~" g# q& d9 c: J; ]5 o
- #undef EDMA3_DEBUG
$ J7 T; e; L ~5 E - /*#define EDMA3_DEBUG*/# P$ m0 _& E7 q l3 X& O, j
- + A9 l! i% h- H$ w; Y7 |' C2 c
- #ifdef EDMA3_DEBUG
7 x" N3 p: [! s( g: B7 s - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
: q0 | g0 l. K7 T. N6 \* H8 _2 d - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)( o& C# f6 `6 ^8 O
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)2 {$ n7 h8 v. Z; `' W
- #else, v6 X6 y' d: m) H5 z8 s: v y: l
- #define DMA_PRINTK( x... )
9 z2 J1 c+ F* Y+ z0 s% w. v c - #define DMA_FN_IN/ i% z+ H1 q% V; d+ \
- #define DMA_FN_OUT7 q$ t5 A% T, h+ t" {
- #endif: ]* Z% J5 J2 L9 `) ]2 {
- : H- q. O" B0 g$ X7 L
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)# M# Z. C# h4 C. I
- #define STATIC_SHIFT 3' @7 e: M. q. z( h
- #define TCINTEN_SHIFT 20% \$ {* q: u/ w6 h0 }
- #define ITCINTEN_SHIFT 21
5 |$ c( O' U' W; E6 L - #define TCCHEN_SHIFT 22
8 v2 E9 w Z5 } - #define ITCCHEN_SHIFT 23/ {% l7 i5 w6 p$ b8 Q; O1 n
- 5 V" p/ m; D9 o$ M7 Q/ j
- static volatile int irqraised1 = 0;
; ` w: ?- \ L4 v: t* T - static volatile int irqraised2 = 0;
~: K8 T8 W* I0 Y6 ?) i
3 v, y& _$ Q6 N; D: b, H- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);8 T0 S: l6 A" z" r3 I
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
$ Z& q8 Q4 G& L/ g8 t' B9 y - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
4 C$ h2 P) Z* c* E - / B: z8 l+ N( G& z1 x% I
- dma_addr_t dmaphyssrc1 = 0;
, e+ N+ d4 g* {4 v - dma_addr_t dmaphyssrc2 = 0;
) \6 F0 s1 T, g* T - dma_addr_t dmaphysdest1 = 0;
6 y9 X/ `) U; `8 J7 d1 H: x* \ ` - dma_addr_t dmaphysdest2 = 0;1 w, o: y/ y+ B0 O& _7 z) v2 g
- , Z0 n) [7 Q" T" C& b1 H) Y' B
- char *dmabufsrc1 = NULL;3 T4 ~+ @* R; f" V7 C
- char *dmabufsrc2 = NULL;
5 d; j( {/ R" K9 |8 D4 f! k - char *dmabufdest1 = NULL;
, B4 S: g5 Z! ^3 ?6 h6 G" X - char *dmabufdest2 = NULL;
/ Q3 F* E8 y" ]* S2 R9 B# U - - O2 f2 D3 X2 m
- static int acnt = 512;
: |( n3 N* |% y1 ~: _% n; ~ - static int bcnt = 8;
: m2 y3 z$ i- T - static int ccnt = 8;/ ? j$ ~2 y( e& f V q% z/ i$ {
% e' m1 {) U4 y3 g+ ]: U" C- module_param(acnt, int, S_IRUGO);1 H& g' T. ^9 v3 u1 {/ z; Q* E/ m
- module_param(bcnt, int, S_IRUGO);. l# d% S" ~. e3 B& Z2 Q
- module_param(ccnt, int, S_IRUGO);
复制代码 # S8 ^& s# w/ }9 ~6 F
# N( G! `! F" h3 p 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用3 U' M6 R" g \% D3 b& ~6 C
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
6 b ]4 \7 i0 o 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。" _6 R# _. A2 _# {# M2 P# r3 Y. l
5 O( F8 o9 D1 w3 T B
' s6 x& o }+ C% I; H/ h+ y/ f. i
|
|