|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 9 R1 W( R" T' U0 n7 T0 X D
- [code]EDMA sample test application
8 h ~3 p3 ?0 ]4 W7 b4 u - /*+ i! C$ J' G+ ^) ?' K
- * edma_test.c& Y e5 k' Q0 R: t3 p1 ?! `
- *) z$ [, J8 `9 A; p6 [4 G7 J8 ?
- * brief EDMA3 Test Application: }6 u& Y; ?! d) S7 s
- *3 A% a6 G' w/ |( j0 r
- * This file contains EDMA3 Test code." ]" O: `! N) p; B1 W- p
- *) i0 i- O5 ]* E* g8 ^6 T+ X
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
5 D/ r" u3 D7 K: O - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
; h' v+ U( N& y6 R- } - * TO CHANGE.3 U8 M4 [2 `! S
- *
6 s# [/ W' z8 P: E8 b - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/8 L( w' S( f1 K Q+ T( j1 S* s
- *. z6 v# o( n7 o, L9 }4 {; Y
- * This program is free software; you can redistribute it and/or( j, B# Z. m I7 U5 m1 _) ]
- * modify it under the terms of the GNU General Public License as
7 _8 }/ j3 Y. \& r, f* C - * published by the Free Software Foundation version 2.1 p: }$ j- Z% h( [; v* Y* h
- *, r/ y: A2 W+ Q E: ]8 u/ l* h2 ]
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any: l7 [/ G2 c G
- * kind, whether express or implied; without even the implied warranty' [, o5 ~; c4 L, [
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
0 M+ F3 t; |, H+ u3 c5 Z z - * GNU General Public License for more details.
% X' h4 ~7 ]- d' B( Y( S4 G" \8 F3 O - */
. |0 b5 v; e$ _/ V/ K
. T, |* h( ^8 Z* e+ a; V- #include <linux/module.h>
2 ]! s$ K3 ?' i( Q3 f - #include <linux/init.h>
8 x' F3 B0 O% r3 A - #include <linux/errno.h>* R& s0 t u1 P
- #include <linux/types.h>* v g7 a* J- i& F$ s/ d8 G
- #include <linux/interrupt.h>6 D3 J' w& M, g) V( z6 ]" `: u
- #include <asm/io.h>$ V+ C T- l( F, } I5 f
- #include <linux/moduleparam.h>: @: c; h: d! c- i3 T: o; H" I
- #include <linux/sysctl.h>
. W& j; \2 q: x/ ^: ? - #include <linux/mm.h>
# s( C) Y3 i! O - #include <linux/dma-mapping.h>
( [. `9 v+ N6 T% k/ V O7 t - ) P/ ?- k: N/ `. B1 L! I
- #include <mach/memory.h>
( R c) c; {: H - #include <mach/hardware.h>
7 g+ ] C% A+ a4 ~ y - #include <mach/irqs.h>
" _% T. J% d! V7 T - #include <asm/hardware/edma.h>9 u7 ]& X e- P5 Y+ N0 ?8 S
* x9 g7 }- J h: x- #undef EDMA3_DEBUG
+ n! A5 R9 P* ? - /*#define EDMA3_DEBUG*/- K ?5 ~! Y8 o$ b
- 0 a, H0 P$ i# M1 d: D# L
- #ifdef EDMA3_DEBUG
$ b8 o- Q \3 d9 P7 Y, T+ x# ^/ \$ K - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
2 ^6 Y; J" {+ F" C+ J- _- [. {! t" B - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
# u( v: M( G! E0 m7 T4 T& {% s - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
& K' F3 U' q0 h - #else
2 R& ]) r7 G) l, U+ R( v" _* L - #define DMA_PRINTK( x... )
6 @3 W& n5 D4 d% I+ j1 S o% y - #define DMA_FN_IN
8 | _6 \3 k/ |( x* d0 ^, o - #define DMA_FN_OUT- f. Q% ?0 z- l8 W8 f& Y3 l
- #endif0 x# y+ u& L& a4 n7 x3 N4 q
- 5 v' ~) |! i( S# P" U; a
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
8 y: E, F& L2 [ - #define STATIC_SHIFT 3
* ~, d0 D2 t6 H4 y. B- @( ? - #define TCINTEN_SHIFT 20
4 H( \, x/ ^' x) w! b0 P8 d* K, R - #define ITCINTEN_SHIFT 21( I \, ?! k( p/ e0 ?, O
- #define TCCHEN_SHIFT 221 p, @/ q3 @2 Z, Q: s2 h
- #define ITCCHEN_SHIFT 23/ h6 Z1 y+ i% M6 d6 l
- 7 f* n8 ?5 U7 R9 E3 Z H7 Y
- static volatile int irqraised1 = 0;5 ?( P! ?/ Z. k* _3 w; I
- static volatile int irqraised2 = 0;0 D' T$ s4 P9 Q" c5 P4 [$ f
- 9 s$ D6 [8 U7 I. }! U* T
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
( @0 ^0 Y5 `/ h: ] P$ D - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
: M2 E) ]/ B; V* K9 |4 Q - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);9 y$ R( w4 b* F0 ?1 l# d
3 Y. F6 r: m. ?- [9 K9 Z- dma_addr_t dmaphyssrc1 = 0;3 y3 i# e+ x+ T5 H
- dma_addr_t dmaphyssrc2 = 0;
e9 n w. t# I: e, V& {; f( `( r7 Z - dma_addr_t dmaphysdest1 = 0;1 }; g% r. @5 c# C( M3 `3 T) P
- dma_addr_t dmaphysdest2 = 0;9 R; X' ~. J' f) |8 U6 s$ b
- * b9 _ P; J# l. G) D2 e
- char *dmabufsrc1 = NULL;
* _& ~& t+ L' S2 f/ c0 |+ u - char *dmabufsrc2 = NULL;& N# b# u! j6 v% w
- char *dmabufdest1 = NULL;) `6 j* @- ?/ R! k
- char *dmabufdest2 = NULL;" |; n9 ?$ P. T. \8 t
- : W- [1 \9 F% l" _5 |
- static int acnt = 512;$ X+ {) r+ A" a z" ~% y
- static int bcnt = 8;2 x8 ?! N7 [; p: [4 P6 K
- static int ccnt = 8;. @% r/ I* N9 M
0 l9 w0 i8 n# L; o4 H- module_param(acnt, int, S_IRUGO);
; G4 J; v4 |2 Y. f - module_param(bcnt, int, S_IRUGO);
% O! e% S n' v J - module_param(ccnt, int, S_IRUGO);
复制代码
9 z; \0 P: y+ T: R: ~7 W1 Z# M+ n# h) C/ N
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用# f) a* s6 g! @* n3 u6 v6 W: S) D$ }
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
: L9 ~( p0 y7 {& q& _# W 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。5 \9 J5 e0 q) N5 w$ W2 m
$ T+ p' }) O( N/ c$ j) N, ~& d* w9 w/ d2 v: R4 m
|
|