|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 . _* b) F1 K( ]+ r8 }, q
- [code]EDMA sample test application
8 w4 s# d6 ~6 X0 l6 G B9 m: m - /*: @3 D# L6 K1 S1 N9 ^0 I6 ^
- * edma_test.c2 T* {+ Q" h) O. @
- * l8 D# f e; ^
- * brief EDMA3 Test Application
) Q' s4 @ R3 O: J; O a - *
" ~6 |8 {: e* l3 M - * This file contains EDMA3 Test code.8 v2 @) ~7 ^6 X# z
- *
& n% W" {% F% d - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE( a! _5 }! W; G$ o8 \
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
) P4 e+ a6 w1 N1 a- T - * TO CHANGE.
* `# \# \" s$ H - *
" l' h7 L' `+ K) ]5 ]! z8 N7 Z - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/6 g& \! C9 W6 T. a
- *7 v: h& e/ K# M& d6 c W
- * This program is free software; you can redistribute it and/or
* e; u y" U$ p7 T3 Y - * modify it under the terms of the GNU General Public License as+ V& _1 v$ i+ @. J% W! o: Z
- * published by the Free Software Foundation version 2.; A7 P: [4 }6 P) u
- *
" f( ~: k% w2 R7 M8 N/ O% r: C/ F - * This program is distributed "as is" WITHOUT ANY WARRANTY of any c l3 c6 ]. z$ f: t4 X
- * kind, whether express or implied; without even the implied warranty' R: k. m6 Q" M( J, g( a
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
4 R) j" k. h- s4 Y; G2 |* C \ - * GNU General Public License for more details.' v+ f& K+ F o. h
- */, Q2 X, P+ c6 e o/ {9 A: T
- x* h( U. D: R: _
- #include <linux/module.h>
# q6 v2 C' W) o$ k/ r. ~2 l - #include <linux/init.h>) r% }5 d6 B$ G7 G" o
- #include <linux/errno.h>
4 @5 G6 o# m& }1 U7 y p8 Q5 B; m - #include <linux/types.h>, k6 E' _) v4 B
- #include <linux/interrupt.h>
3 u5 T! E$ v# _8 S - #include <asm/io.h>
- E3 E) ?" E- `) \4 s - #include <linux/moduleparam.h>
$ x; x$ Z' n+ C( G' A4 s- @8 X; f - #include <linux/sysctl.h>
( D! J$ I. g$ L {! M$ B1 {! i - #include <linux/mm.h>+ v! M- X6 C# K% U; }% D
- #include <linux/dma-mapping.h>/ o% O3 w) R3 z. i) w3 ?
- 8 a( }, h) {- d1 S# w
- #include <mach/memory.h>
$ K- j, x* F; F& [. y7 [, O; |7 M4 U - #include <mach/hardware.h>
0 t" U) c. W, ^: b ]- ~6 V0 ~6 q4 ? - #include <mach/irqs.h>
2 d( k, y n0 Q - #include <asm/hardware/edma.h>
* n" Y" ~2 f0 m/ ]4 B
4 M& T: v* ?9 V0 ]- S: G- #undef EDMA3_DEBUG" v( z+ Z3 ^9 J8 d1 L; \
- /*#define EDMA3_DEBUG*/$ C2 v+ Y6 _* r) r ?2 l: H
- , I: _. w& j2 `( ^/ P9 B: e
- #ifdef EDMA3_DEBUG; o, A; e! R/ y6 j( a
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)! h- ^& q) G. y" _6 Z
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)- c8 w4 w$ X: Z' V0 O2 N
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
. x, A: z& f! x; U9 p: u - #else
4 u# {' V2 L9 @- o0 c9 t - #define DMA_PRINTK( x... ) T- m0 Y& V) F7 I. C9 E1 @- E
- #define DMA_FN_IN/ o1 j h+ t! Z& ?& c9 j) K
- #define DMA_FN_OUT/ Y8 u1 ?' y$ z0 ?* @. d
- #endif
/ S( ^* y/ C) l- B - 8 _9 W y8 l8 |/ T9 T5 N5 h) Y5 ^
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
6 _4 r( j6 }; G0 x6 T5 ~ - #define STATIC_SHIFT 3
; X3 N! [, v; ^+ a4 W! v$ h - #define TCINTEN_SHIFT 20
& z! r, w( H# h$ r - #define ITCINTEN_SHIFT 21
; T. H/ D: M7 p# Z/ [ - #define TCCHEN_SHIFT 220 e2 q T, L& h9 |
- #define ITCCHEN_SHIFT 23
# }+ l/ L" b" f5 b- P" i - ; R( |# P: a) C5 a/ W/ g
- static volatile int irqraised1 = 0;
1 G' B! v' ]8 K5 l1 y2 j9 i: m) e - static volatile int irqraised2 = 0;
p3 G; y) {, U: V/ `
3 m1 e# q6 G3 d2 g9 h4 y- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);$ T3 N( E/ d0 P& O
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);) k! x4 ]# E' C. t6 Y: Q7 ]" ~
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
/ T; i' m9 I! O- \8 f/ G% N c
, p+ j& v5 i' v5 M- dma_addr_t dmaphyssrc1 = 0;7 ]2 g6 O6 ^+ q4 I2 K* C& g5 j2 o
- dma_addr_t dmaphyssrc2 = 0;
" i, L, I+ a* ^ - dma_addr_t dmaphysdest1 = 0;+ F! V" i% s( ^9 z: Z
- dma_addr_t dmaphysdest2 = 0;
7 p; v g! q$ T% ` - ; y* h9 c) m8 I6 x2 Q6 s! |
- char *dmabufsrc1 = NULL;
3 B) e4 q0 |4 O% o4 @- | - char *dmabufsrc2 = NULL;
" N& r2 O. x8 R7 Y8 k8 e9 T4 C; A - char *dmabufdest1 = NULL;
, V* M. Z$ J) v9 Q: V5 [ - char *dmabufdest2 = NULL;
! r8 N7 `* W7 v5 u& y, G, x
, X2 S: R9 p% @/ D" Q: [+ x% A- static int acnt = 512;. a; q) F% c9 `
- static int bcnt = 8;
6 P+ v6 S( m/ @5 |" s K9 U - static int ccnt = 8;
2 F% b2 J1 @; S( n
0 \1 V: }; n) @4 o- module_param(acnt, int, S_IRUGO);; D% Z1 |7 S9 x' U* V( P3 T
- module_param(bcnt, int, S_IRUGO);
8 s" G" y1 I( U/ b1 k - module_param(ccnt, int, S_IRUGO);
复制代码 : [9 s. I6 B+ f/ s' @
5 Q; J& W+ B9 f1 N" f- z 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用/ }+ t- |8 s/ Q) ]& o! ~
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。% I2 q$ N7 E! a- q" |& r6 U- D9 i
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。5 k( N b9 n; Y3 E0 p
1 D" l2 ?1 F5 x# `+ h/ x' u& N
/ ^2 o; C, X9 ~+ x6 Y) d |
|