|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
# \6 z' u [2 g5 b$ ]* K- [code]EDMA sample test application
/ \: G+ D! m& |; Q! i* h* j - /** [4 ^3 K4 J. K: ~( [
- * edma_test.c! g3 R3 d+ u" b4 r
- *
% ]* p8 K7 x& ?( f4 G) J+ o - * brief EDMA3 Test Application6 B9 e7 k( W9 i$ @- \$ y t& D4 ^& H
- *
; D; V3 |- ~& P - * This file contains EDMA3 Test code.
$ a: p N, Z$ Y) G - *
) B, k) u! d5 Y% |! _" V - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE k$ b) a3 p9 f$ q" C
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
9 L+ `7 T$ r5 h - * TO CHANGE.1 @9 a- w. _. {4 r1 X
- *
$ o/ ^+ m4 L+ N8 h - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/+ [9 q- A6 h, I! j/ M* ~- Q8 J: H
- *
4 |& j0 l8 h0 k- u0 \ - * This program is free software; you can redistribute it and/or) r& W5 ?1 H2 z$ s
- * modify it under the terms of the GNU General Public License as+ J& Q b, {& X& {+ @" V/ M+ |
- * published by the Free Software Foundation version 2.
5 b- s: G. f' y/ F, ` n& n: a - *
% z8 f" _8 @) u! u) e - * This program is distributed "as is" WITHOUT ANY WARRANTY of any
+ O6 @5 q3 ` `1 C$ A1 k- d - * kind, whether express or implied; without even the implied warranty
* b r& e7 I, H2 A" n - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2 D4 B5 Q0 @" e* l! h5 U" W' x0 R* d - * GNU General Public License for more details.
% a i1 H' E3 C0 B! t/ m - */( B4 ^: M* l( M% }- e ?6 n$ ?
; k8 j/ `# Q2 g- #include <linux/module.h>2 I5 W G8 S% c X
- #include <linux/init.h>- z) Z6 N3 [3 x6 @! G$ ~
- #include <linux/errno.h>1 `4 E( y& T0 |2 o
- #include <linux/types.h>
9 n5 u% f0 y# U' x" D4 H - #include <linux/interrupt.h>
' [' x8 f$ G' b" x0 g) O( a - #include <asm/io.h># x# g: l& P, I8 D& O
- #include <linux/moduleparam.h>* Q3 r: u/ S! {- r- S
- #include <linux/sysctl.h>. A8 ^! Q+ Q3 g
- #include <linux/mm.h>$ O- p8 H7 W' f6 P
- #include <linux/dma-mapping.h>
8 t p4 u) n& K7 s' w" d+ r- x - - A/ N9 `) n+ H! H; O- |
- #include <mach/memory.h>
7 D. A/ w4 J( Y" @% H/ J& Q1 S - #include <mach/hardware.h>! t1 `( b+ ~* z3 d
- #include <mach/irqs.h>! _; h: W6 s0 q7 h" r9 c
- #include <asm/hardware/edma.h>. c) D, _6 x4 X$ x
- 6 S' t# R% S2 ]
- #undef EDMA3_DEBUG
) W( x$ L- A9 a% Z - /*#define EDMA3_DEBUG*/$ U! _5 d W k& X+ O1 K2 `# q2 V
- 0 ?/ T" q6 d& q6 |( h
- #ifdef EDMA3_DEBUG
& q8 ?% R; I- k9 ] - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)) p" e7 P( ?5 s
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)" X. b: q' a' @# _% q1 v% Q* O
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
+ W$ L3 I9 j9 Q! ]/ {' N4 G) n - #else) ?5 U$ U# Y0 G' A# |: r
- #define DMA_PRINTK( x... )
0 y+ p6 n! p8 o% D# s - #define DMA_FN_IN6 f2 \- j. w# x7 b6 A
- #define DMA_FN_OUT' a k7 b' M% J6 ?4 c% g7 p/ C
- #endif4 k& k0 B$ Q7 l$ Q" @7 j
7 ]7 D: ] p# M; T- #define MAX_DMA_TRANSFER_IN_BYTES (32768)$ p1 ^8 j! W. n7 }+ O
- #define STATIC_SHIFT 3
- x6 ]5 g @/ J1 J! K - #define TCINTEN_SHIFT 203 n L6 A+ {1 T& X/ Q
- #define ITCINTEN_SHIFT 21* h$ b9 A' u7 {! M: A1 H# T
- #define TCCHEN_SHIFT 22 Y! n4 u1 N/ H$ C* {9 y
- #define ITCCHEN_SHIFT 237 Q N- _, B' s5 P( M2 s( r" i! m1 ]
; U5 }/ i2 U& d! M0 c" b$ i- static volatile int irqraised1 = 0;* c2 p" ^( z0 f$ e8 c
- static volatile int irqraised2 = 0;
1 S. O/ v8 [4 D* q1 h# C2 D; N7 h
- z6 B1 g( B! {, P0 w- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
( }% ]0 R. k# `' K! w' n - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
! k% @6 a1 z& y! u - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);1 }2 l% B, L. o# l4 H' x5 j0 v
- 0 D4 ^4 c/ A( o$ Q+ Z* M- J
- dma_addr_t dmaphyssrc1 = 0; \$ w: `) N8 }" z D! N! S4 e
- dma_addr_t dmaphyssrc2 = 0;
5 m0 b9 L# U5 d/ Y: i3 O - dma_addr_t dmaphysdest1 = 0;& [1 ?! W/ I0 [# v# m4 T
- dma_addr_t dmaphysdest2 = 0;
" i1 R( C) t% M* f6 y2 x2 g: p! W - 4 J" \/ t4 K0 s6 F! a8 T! X5 I1 ?
- char *dmabufsrc1 = NULL;7 F7 X0 M! B! i# z8 e: P, {
- char *dmabufsrc2 = NULL;
+ v% ?; _3 ~* u2 t% |7 g - char *dmabufdest1 = NULL;$ [: F5 t3 I( n4 i+ S2 l
- char *dmabufdest2 = NULL;
1 }0 |9 U/ p. G& e- I
S7 P' f/ V% ^# q4 J/ u# _+ l u, W- static int acnt = 512;
% J) k- Y/ \8 \ - static int bcnt = 8;8 k# f2 P }; y. ~( I: w" I7 l
- static int ccnt = 8;8 ~4 f: c0 {1 ^4 y/ v
- % [' T' _: i/ U# o$ l* N
- module_param(acnt, int, S_IRUGO);/ f1 Z+ w! Y# s5 D; Z! @: q
- module_param(bcnt, int, S_IRUGO);. V& v& P) ^! r0 t& P- y: [
- module_param(ccnt, int, S_IRUGO);
复制代码
1 I1 A$ M7 s" L7 A. W' T( S6 r8 [* c) J% Z w, S X* q O& ^
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
' F- j1 }3 m( g3 x/ O% Qarm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
& t- c! ?- C6 h- D! ^ 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
# B- J% x. H5 ^# c! |' p* _: b4 ~8 u# b/ J" b, e- j
+ Z: S% n0 U1 F$ X' }+ j5 [. W6 v |
|