|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
c7 F; A( w+ E* }- [code]EDMA sample test application
, C4 @6 |7 H8 ]' I - /*
F* e8 Z- V: W4 N9 J- G - * edma_test.c0 r( _+ T* {4 E) y. G8 @! u
- *1 ~# H2 o8 a% g9 |( o j; Q
- * brief EDMA3 Test Application
; b% Y6 B% A/ m - *
. U% }5 f" I4 B8 g( @$ A - * This file contains EDMA3 Test code.0 d- P4 Y6 i# _
- *2 x% u- B6 ~+ |3 ?0 b, K9 N
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE( o! x3 l* J) n+ Q) o! v
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT, q3 Q8 _* y! @7 h" p
- * TO CHANGE.# |) X4 x5 B Q$ l- n2 ]4 ?
- *
- P; G8 m( |# c6 ` - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
, J4 x- ~$ }! S" Y8 t# l - *
# e3 ]8 c! z. p: v - * This program is free software; you can redistribute it and/or$ @5 x1 I' H$ E+ R r2 O
- * modify it under the terms of the GNU General Public License as* V/ D* b: j% H! t1 J
- * published by the Free Software Foundation version 2.
9 I+ K+ c+ j2 |; T - *% E o8 ~. c; @/ K) Q2 b
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any
' ?4 L* c" v8 q - * kind, whether express or implied; without even the implied warranty
0 \* G# I8 m5 B' G$ ^- e; @. {/ a( k* g - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the# A% s) z) J' e* T. M$ o. _( B0 T
- * GNU General Public License for more details.0 _" i% o: d m3 B6 v9 J
- */4 p" f: w! z" `/ |. U1 [
- 3 s% x( @6 {, L
- #include <linux/module.h>
) ^5 U d% K |9 g1 ^ - #include <linux/init.h>! M; ^: k" S1 q2 B* ^) o; H1 Z; D
- #include <linux/errno.h>* V6 u5 s; m/ k1 c. G2 [, `
- #include <linux/types.h>
) s1 W1 M4 j u& | - #include <linux/interrupt.h>
# A0 |3 P& H+ \ - #include <asm/io.h>7 }0 m; B% {" z! k* Y! `2 P6 o# P
- #include <linux/moduleparam.h>
3 N9 Z4 h7 m' D2 s, z3 d - #include <linux/sysctl.h>
& z/ |) u- n( H4 w - #include <linux/mm.h>
# A _5 ?* c& q9 q! x2 ^ - #include <linux/dma-mapping.h>' w1 l5 H- |' C: [
8 F/ ~# m3 A* |- #include <mach/memory.h>
0 N! Y6 h1 n, Y6 K+ c7 ?) i - #include <mach/hardware.h>5 ~2 b9 V) q# m
- #include <mach/irqs.h>: }1 E+ h3 N8 Z, C' g& n6 k
- #include <asm/hardware/edma.h>3 u9 w$ B% ~3 n3 k/ r7 R3 P# j
- R5 Z9 A+ x* u3 m; a0 e- #undef EDMA3_DEBUG8 N4 h6 I/ o+ D% ~
- /*#define EDMA3_DEBUG*/
. P8 n7 y4 A% \( b. D+ f6 {
# C0 w/ D, z& N: t# s) G4 U0 e) t' X- #ifdef EDMA3_DEBUG3 p6 j" S# _ S( }3 ~- U
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
8 X$ f5 \' k: M. c. I - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__). {0 `: f$ A" R* Y4 Y' C+ ?/ F
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__). [" H5 ^& t9 k0 G. h
- #else0 k. C' d7 [5 C5 _3 g6 n+ Y5 p) M
- #define DMA_PRINTK( x... )
* K# j* V% ~& I - #define DMA_FN_IN8 S- [" t7 V7 j3 ^6 i
- #define DMA_FN_OUT4 e6 W! D' x9 [: {
- #endif
) [2 c3 Y+ c8 r4 w( G3 P% V - ! k" L; ^) ~+ l% d9 i
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)5 t& u/ a7 c/ o7 L
- #define STATIC_SHIFT 3* V) L: y' h7 j
- #define TCINTEN_SHIFT 20
- |1 ?% u+ P- a% `" w3 t: B0 N" Z - #define ITCINTEN_SHIFT 21
' r# x1 U0 C2 X6 C% M - #define TCCHEN_SHIFT 224 w" \2 O' }! w. p3 i# k0 S
- #define ITCCHEN_SHIFT 23
# x; K n, n, I m2 n) E - 3 S2 b3 w/ u: m# E. F* D: K. o
- static volatile int irqraised1 = 0;6 D$ I# Y+ @6 ~. P W) D
- static volatile int irqraised2 = 0;
% F4 j% X+ H) I# w; G8 @ - ; O X4 R8 Z2 m# y
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);1 G1 a h i. v5 `
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
' K7 s R% @! Q4 T) ? - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);$ U: l/ k+ [# f9 m5 a, Z
& z" z3 Z' K6 _( u% G' T- dma_addr_t dmaphyssrc1 = 0;
; [ o! D6 Q) \, _ - dma_addr_t dmaphyssrc2 = 0;
/ l' n2 a/ V2 f3 o& R/ z - dma_addr_t dmaphysdest1 = 0;
+ n5 K7 e* Z( B9 \4 j( u - dma_addr_t dmaphysdest2 = 0;" \- S* `- z! T
- 6 l( A4 k! _2 t* N4 i/ G
- char *dmabufsrc1 = NULL;
$ f8 A8 K/ b. f3 l+ S0 X$ p: w- f - char *dmabufsrc2 = NULL;
/ w; Y4 S$ [- }. D/ S k8 O) w$ c# A - char *dmabufdest1 = NULL;1 C& |% F- d9 K+ N8 @. ^- j
- char *dmabufdest2 = NULL;6 ]3 l( @; G$ c; |% J9 t
8 p9 e! |. K3 Z6 n/ D X* Y- static int acnt = 512;! G( ~' ~. l& h$ s- d' ~
- static int bcnt = 8;; c% g0 p# Y- r
- static int ccnt = 8;8 H4 r: E( ?. o% d
: h" c5 B: O5 e- module_param(acnt, int, S_IRUGO);
- Q! o- p6 N* W( I- y - module_param(bcnt, int, S_IRUGO);
9 Y. G' Y F1 [; t' a5 Q7 |, c - module_param(ccnt, int, S_IRUGO);
复制代码
' B, S( K1 y7 E' }+ H8 N# x2 P9 v& E9 W; Y9 i9 a$ G8 F
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
- d* a# A$ ~! j5 [, ^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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。* c5 p) F9 D. _9 W) `1 {* b
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
) c# B, W1 D* j! B3 ~* p) a3 u+ ^' \; y4 O
/ d6 d' f2 i) s# n1 m |
|