|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 0 g0 g, U {3 p- Y F- l' g
- [code]EDMA sample test application
, F8 [/ [% o6 V+ k( w, l - /*0 V% U9 ?' }- P1 d+ Z
- * edma_test.c2 ^# `; ~8 y* C
- *% b# C' d0 { f( f) G- W
- * brief EDMA3 Test Application
/ C6 V5 i' v- ~' a/ A - *9 F Z2 h( ?- W( w1 I, n( q
- * This file contains EDMA3 Test code.& c) `" w+ m2 B5 ^$ E) b: K9 R' d
- *& v5 _* B1 @8 c5 E6 t4 y
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE! Z; V! U, Q7 {) `4 A* G1 V
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
2 N+ I5 q$ H) f8 O6 O( _8 ?$ k - * TO CHANGE.
2 f) @2 V: b! @4 |8 E - */ @3 e+ C. A+ p& U
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/2 M9 e' _2 t O% R. ?
- *7 k- L! G; W& r9 M* R8 e" m! {
- * This program is free software; you can redistribute it and/or' e/ R( n( u* K4 \
- * modify it under the terms of the GNU General Public License as* f6 r; r3 q$ k/ T$ {5 o
- * published by the Free Software Foundation version 2.
0 c% q2 M5 _6 ?+ w2 I" P+ f - *8 L% t+ a) c& E/ m
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any
: C' G E* P% u7 R( B - * kind, whether express or implied; without even the implied warranty
$ M' t8 e! o$ E( H" T8 F - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
/ d) Q) ~$ b" [0 m7 F! z* @8 P - * GNU General Public License for more details.4 p3 T2 X9 `& ^" ~1 u
- */+ }/ H l6 f6 J: `9 o# R- d3 z
6 P$ H$ e# a! f5 R2 W2 h( I- #include <linux/module.h>1 p% r% r6 u6 b k" Q
- #include <linux/init.h>; J$ E0 z: k. G) N3 e6 ]
- #include <linux/errno.h>
8 W8 l j0 `1 T. i - #include <linux/types.h>
( ~ {% c4 C7 I& e - #include <linux/interrupt.h>$ l/ t' L1 X* P* Q2 i) T6 y1 J4 u+ p
- #include <asm/io.h>
7 Q+ Z" B# @& e7 v/ p - #include <linux/moduleparam.h>
3 l [& F2 {4 s/ P0 a' B' }* h+ b& h - #include <linux/sysctl.h>
P& X0 D- l( U- A1 R5 E8 \$ o - #include <linux/mm.h>
# m ?; l n; p8 V5 o1 F7 i - #include <linux/dma-mapping.h>
7 y9 R2 I% N/ x* Q: h9 `# z7 v
( I1 Y2 i- a# G$ D- c- #include <mach/memory.h>" n1 @6 y r9 o: Z
- #include <mach/hardware.h>* R$ S S8 b; U
- #include <mach/irqs.h>
- ~4 p( |/ `: p$ A- j - #include <asm/hardware/edma.h>( q$ C7 h/ A9 @5 y
) \' Q+ J( Q$ }$ W+ g- #undef EDMA3_DEBUG& Z8 V) W; w4 ^- L9 _9 S0 ^
- /*#define EDMA3_DEBUG*/- e W6 f' Q! r- E0 ^; l# h& d
- , [1 e9 V. ?0 b4 h2 o
- #ifdef EDMA3_DEBUG
/ X+ Y, Y8 d: E0 b. x, |$ [ - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
: i7 p) Z i$ i - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)! K5 A9 P+ I5 W# C" I9 h
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
n! s+ z Z# ]9 h - #else* M* K" S/ p1 b) t% i/ v
- #define DMA_PRINTK( x... )4 Y* D3 c5 I w
- #define DMA_FN_IN
- S! R" F# _5 ` - #define DMA_FN_OUT% B( {0 E7 F; ]% }
- #endif, z% Y u8 [8 b6 e9 H: @
+ z" ]! N, W$ [& F) H& H- #define MAX_DMA_TRANSFER_IN_BYTES (32768)6 s% r3 `3 d Q/ P# U
- #define STATIC_SHIFT 3
0 R7 f$ o& \: B! M - #define TCINTEN_SHIFT 20
0 f1 s7 ^0 F& o! j1 r; b - #define ITCINTEN_SHIFT 21; o: K' w) R& A- p
- #define TCCHEN_SHIFT 22( }& t% `2 R' k# V1 }& B: d& e" ^
- #define ITCCHEN_SHIFT 23
4 P8 \$ M9 C# w, |& ~
\$ j+ ?9 O( j+ Z( t- d4 X7 Y- static volatile int irqraised1 = 0;
# u4 r# V" I) O# e% U) U - static volatile int irqraised2 = 0;
5 u% k; R0 Q g
0 c0 b0 Q$ k- b/ \1 I- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);; N! [) B( `3 V% d. Q+ X& W
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);* X, w+ e6 T/ |9 T
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);7 W) p! {) `. m( k( `' V0 ?- H
- # j" ?* u$ x7 B
- dma_addr_t dmaphyssrc1 = 0;
2 A9 n/ s# A/ c5 i0 i9 L' f, i% I - dma_addr_t dmaphyssrc2 = 0;, N8 g- S% Y, W, G& F6 [
- dma_addr_t dmaphysdest1 = 0; \0 K/ O) s/ `' u: O, I
- dma_addr_t dmaphysdest2 = 0;2 }* m6 T, n7 {' z) c
- 6 C. y" D0 M8 ]9 ]
- char *dmabufsrc1 = NULL;/ m" P& }4 U! x3 i1 m8 D3 U
- char *dmabufsrc2 = NULL;9 d# B U( P) ~% U; x. c3 t3 h
- char *dmabufdest1 = NULL;
! Q' u& k; t+ f - char *dmabufdest2 = NULL;4 ^9 P; |4 T% N) U2 M6 o
- % I! Z. V9 _( t5 y# Z' T
- static int acnt = 512;2 o' d$ c8 c8 H7 d5 ~5 g5 n
- static int bcnt = 8;
. a+ g9 E* Z t$ k8 ^$ m - static int ccnt = 8;
$ R3 n/ |& u+ `- t2 G$ f: T8 C+ ]
2 H2 X/ n. p! N$ N& z8 }* v0 ]9 i- module_param(acnt, int, S_IRUGO);
2 I% A2 X' O3 j - module_param(bcnt, int, S_IRUGO);
4 j/ h! ~) Y! W% v - module_param(ccnt, int, S_IRUGO);
复制代码 : ^, i N" g+ X5 P
~* j' h% g- k @* n0 j' F" W 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
9 s) v% k# e3 x; q% Marm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。7 E3 x9 m6 y& u3 }. d% m7 @" @
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。) `8 [9 H: |, q
' J% X4 g/ d4 d. B2 H* I
) E* w2 o& g7 c) E |
|