|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 ( a2 ?" O+ R7 J5 U9 M! y E
- [code]EDMA sample test application( [+ y, G! t* E) L. q& p
- /*/ x2 h8 {" q0 g0 _9 V: d. C( U
- * edma_test.c
% [, r, m0 V: i$ m - *
8 H. \2 r# L8 z - * brief EDMA3 Test Application" c. }2 b: h7 n* y% @+ \
- *
( W6 m2 T$ w# E% t% q* { - * This file contains EDMA3 Test code. b) P6 X- a+ r, T
- *) ~0 X5 l2 }& y
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE1 p1 [0 P( n6 p" U0 @: C
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT4 d; u. B+ b3 @# [
- * TO CHANGE.
! ~$ R D- H! e1 u2 H( q6 w) h9 B - *
& d6 Z$ G) x' ? - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/* ~+ `2 @! w( w9 ^2 ^( q x0 T6 v
- *; o, g7 c& w O5 K a' V3 a$ D
- * This program is free software; you can redistribute it and/or
% `, l5 v( v, H - * modify it under the terms of the GNU General Public License as+ ?7 w! e P5 d" G2 V, ~4 M7 o
- * published by the Free Software Foundation version 2.
. v* q3 R$ ?$ H1 g5 ~ - *6 E) j2 G/ V' p9 O5 B- m+ N9 Y
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any
$ {: N$ v; |5 T( Q0 W! E - * kind, whether express or implied; without even the implied warranty( W- G: [* B1 `
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* d, u( z& ]3 t; m$ P0 U, ~1 z - * GNU General Public License for more details.
9 g% |1 E! ~" t1 o+ O - */9 Y- P; u7 B. f3 y* C
1 Y. g. q3 H2 [9 `- #include <linux/module.h> ]& Q) N+ S" f. j+ {2 z: r
- #include <linux/init.h>
2 Q* l" N% F! J, e/ A+ Y - #include <linux/errno.h>
' [& e/ x- N- o - #include <linux/types.h>/ r' Y( ^; U/ o% v& I) u" _3 u
- #include <linux/interrupt.h>" I% `& I5 Z. I
- #include <asm/io.h>
0 _* D2 x3 r% M5 _& z$ N4 P# G - #include <linux/moduleparam.h>
$ F" T. V; _3 c; P& s - #include <linux/sysctl.h>( a0 g+ A6 d1 Q! I
- #include <linux/mm.h>
6 {' `1 P- l7 ]6 c- Z$ J+ [ - #include <linux/dma-mapping.h>
% s6 q# T* @$ L) I
3 d; J# Z4 h, M3 c* g- U" }, @% R! Q# J- #include <mach/memory.h>
* h6 r, n& @/ h3 \% }7 w - #include <mach/hardware.h>
7 K! X# d9 s+ g3 } - #include <mach/irqs.h>8 [: N/ y% c2 X! B
- #include <asm/hardware/edma.h>
* ?: _3 f0 n' J; B }! O+ [ - 4 C( \9 ^ \5 {$ g3 D/ G V' A! b' I
- #undef EDMA3_DEBUG
/ j3 g( l$ r: H! F - /*#define EDMA3_DEBUG*/
& F4 [. ?) [2 M: i$ O; Y& |- Z
. \8 b$ W) ^8 h2 M% ?- #ifdef EDMA3_DEBUG
% H3 N) ^( \$ Q4 S - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)4 F: p# j! }- X! K; i$ I4 m
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
Z; X- X1 A; C- c2 d - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
8 E2 `4 r- y" O' }" r, |( ]9 r9 ~( f - #else- t, W7 n" b, _0 {
- #define DMA_PRINTK( x... )
/ Q |9 j2 ^+ n& q: P - #define DMA_FN_IN' {( R* @$ w" T6 ~3 n) [" t2 J
- #define DMA_FN_OUT
7 B* Z, x( Y, U" o" P; e" ~7 h - #endif/ g& u. C( l5 |5 C5 A' o' U7 N7 @4 l5 h7 t
; P0 C; O" S% b/ L) A3 w3 n6 {% f- #define MAX_DMA_TRANSFER_IN_BYTES (32768): T5 |: H4 C3 T4 N a, ^6 Y
- #define STATIC_SHIFT 3# C/ s$ {6 y8 ?
- #define TCINTEN_SHIFT 20
2 h& R5 X6 n( r7 @- A8 ] - #define ITCINTEN_SHIFT 218 K( [. T1 s: Y+ R+ b
- #define TCCHEN_SHIFT 226 C0 f2 R) l' k. Z! P. _& n4 `& X
- #define ITCCHEN_SHIFT 235 ?# N1 K7 @8 ~) s0 W: N
$ Y- S: }; r9 k7 d- l" A- static volatile int irqraised1 = 0;- d' O7 y1 k O
- static volatile int irqraised2 = 0;3 X; O! O4 l7 r" ]6 h
% q9 o7 z! i! ]' U4 Y3 M0 T! v( q3 x- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
' v i" p/ V2 V% v8 T1 a - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
' ~1 F& X% \1 X( | - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);/ D8 H3 d- M. M
- 1 ^% V- W9 a2 Z) }
- dma_addr_t dmaphyssrc1 = 0;
/ C6 u5 ]+ Y k* y - dma_addr_t dmaphyssrc2 = 0;' K; r B) G7 S+ {: P
- dma_addr_t dmaphysdest1 = 0;
- t) n1 a" K/ [. `6 Y1 ^ - dma_addr_t dmaphysdest2 = 0;
$ D3 \7 D$ ? L; U
' D& c7 b# e+ _- char *dmabufsrc1 = NULL;6 V7 L: ?: {# J( B; b9 w$ F2 h
- char *dmabufsrc2 = NULL;
4 E: G$ c1 g5 O - char *dmabufdest1 = NULL;5 w5 Y7 e) {( g/ ^* ]: B- F; m
- char *dmabufdest2 = NULL;, k4 N- y _ Z" A
- 8 o9 V$ ?% C" n
- static int acnt = 512;
% i: g8 W2 y' H6 x! v1 A7 y1 U - static int bcnt = 8;2 R- F" G9 Y$ }, w
- static int ccnt = 8;4 S& I0 ?) {& ?! J; b4 E5 P( J0 [
. g! f o& \6 ], ~1 O6 r- N0 y! f( V- module_param(acnt, int, S_IRUGO);1 _* [: w6 Z, X+ V$ p8 F$ q
- module_param(bcnt, int, S_IRUGO);0 I( |- | B1 \" G# h1 Y: s* D9 j
- module_param(ccnt, int, S_IRUGO);
复制代码 # U( }! z% {. o3 K \
) t) r# B: o ?& k5 K# \/ U+ j: Y3 G
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
/ M- s% I9 R# l2 b2 t. N( {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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。& e1 M+ v' U3 B3 B9 R
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
O1 ?- X5 X! n6 I0 f7 l: L" F t9 s. k
1 ^4 o) {- {3 Q0 {+ { |
|