|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
* C) l6 j3 X* v5 n- Q5 V& z0 V- [code]EDMA sample test application
S/ D8 Z& O* [* ^- Z2 j7 S+ W - /*
7 t0 N" u5 j( C8 S8 F; i - * edma_test.c
$ T' Q! H4 a$ t9 T) l. H0 { - *! {. X. n+ \' a! Z5 g5 H- d
- * brief EDMA3 Test Application" Q' V1 S& g, Q
- *4 f& v& q- r- a) q7 ]4 O
- * This file contains EDMA3 Test code.8 I3 Q( [1 N) P" s2 o1 D
- *
d1 ~# D! u$ a" J - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE3 K6 v" {6 P. }, Y" e
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
% T" t4 A: e9 V1 L - * TO CHANGE.* R! w6 q4 g5 d* X9 }( z7 F
- *
* ` F* u9 P6 |, }) p1 m0 a3 n - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/. d4 g4 n9 g3 j( _
- *
; f+ ^7 M& l# T3 I' E$ v" I; K4 i - * This program is free software; you can redistribute it and/or, r- J* N. g5 b3 `' W2 G# D: _
- * modify it under the terms of the GNU General Public License as' `& c6 T, i* |
- * published by the Free Software Foundation version 2.
: w6 T/ q, Y4 Q2 e- v7 I+ l - *
+ a$ P" d( a# N) ?5 Z( ^ - * This program is distributed "as is" WITHOUT ANY WARRANTY of any
9 U' z- `( l* m8 x& B$ L) s" E6 K - * kind, whether express or implied; without even the implied warranty
1 F+ ^' h: B: l! C. `% W" o - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the9 H1 K8 O0 ^6 |3 c% w
- * GNU General Public License for more details.* |% K, C# J, m! W8 G
- */
6 b# H$ f I! I# N - $ V1 n6 F. j5 B4 f
- #include <linux/module.h>7 H. F+ K3 I6 y6 R+ k5 Q1 Q
- #include <linux/init.h>
4 @" l$ }6 v0 F) n/ A - #include <linux/errno.h>6 b+ t9 V7 X: i y% L
- #include <linux/types.h>
0 O! b* H& m* K F - #include <linux/interrupt.h>. i4 g( D" _+ a3 L# B
- #include <asm/io.h>: t- B: N. E; R, P8 W1 w
- #include <linux/moduleparam.h>
* s& I8 j" z, w: J; A - #include <linux/sysctl.h>2 y( K% {$ B0 i6 B- x9 e: Y
- #include <linux/mm.h>
Z6 E8 N+ h" t6 m8 X, R2 F - #include <linux/dma-mapping.h>( {' h1 V' q; K9 ]; }
: M b( y& a$ \4 N- k7 Q& @- #include <mach/memory.h>" {3 p0 X$ q* i8 l
- #include <mach/hardware.h>3 M, r, m3 T, o1 t9 t& C
- #include <mach/irqs.h>
0 [% X$ J: d' `( C+ W% \ v$ P$ O) g - #include <asm/hardware/edma.h>7 G7 w- h& T( {- w' A( D. y- `
& n# v9 x/ P0 ]7 z2 K- #undef EDMA3_DEBUG
$ C/ b" s1 d# @9 N6 r+ }1 f - /*#define EDMA3_DEBUG*/
; p, k5 ]& ^, Y: ^: q$ K7 u9 H! e3 {
9 Q# A9 P5 i' {4 Q# L& c- #ifdef EDMA3_DEBUG
0 x, \; V K5 ^- s- j6 w - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)& ?4 Y& R, l- i5 y( C1 N9 D
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
4 j* w: Z/ b1 p5 h x7 [8 l - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
4 W2 D0 x/ h! x/ K' u- } - #else
0 |! X1 h4 Z6 g* A9 F( o! ^9 G - #define DMA_PRINTK( x... )
+ N- B( \+ F8 U. F* K8 r' u$ e - #define DMA_FN_IN# Z2 {4 t9 w! V: F9 }$ M5 C4 b
- #define DMA_FN_OUT
( m5 r* J, u1 Y' d) y- I/ H - #endif
7 F$ d4 r6 S ^6 ^ - 7 p4 v7 p; x: N: Y1 O: y
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
/ X) [1 Q+ S* [; V; D - #define STATIC_SHIFT 3, Y5 T, y' h9 n: C" E
- #define TCINTEN_SHIFT 20
! N" a! l2 I& v" S. M5 W - #define ITCINTEN_SHIFT 21
1 q Y2 x- |7 O - #define TCCHEN_SHIFT 22
- A% _0 h& o3 q; K - #define ITCCHEN_SHIFT 23" t) u8 Q# L: q* ?" d9 [1 t
- " h! ]& b& c! {& k- P8 q
- static volatile int irqraised1 = 0;
2 s0 b5 t, a/ s4 d" H - static volatile int irqraised2 = 0;( d; y. v8 V0 @" s4 e$ ~
- ( t8 N) G0 O$ L- c# Y& P
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);+ q( E6 @* x, F* j3 b
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);& Y- k! j8 F0 I1 ]0 d
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
6 Z0 V' U! x1 G1 k - 0 R$ p: N( C o. o1 \
- dma_addr_t dmaphyssrc1 = 0;
# R. u1 v+ q% d4 B5 H; b: [ - dma_addr_t dmaphyssrc2 = 0;
0 W. i8 ~( A$ P, I - dma_addr_t dmaphysdest1 = 0;7 I0 R9 ^, v3 P5 m
- dma_addr_t dmaphysdest2 = 0;1 u, q+ z! k# f/ m9 j) J
* w- ?8 e/ t Y( D; j. p! z7 ^ f- char *dmabufsrc1 = NULL;
7 D* r( d, Y! P. T U8 e - char *dmabufsrc2 = NULL;$ Z; N8 T' L3 c9 j% c0 n
- char *dmabufdest1 = NULL;, {5 P3 ~# b1 e* G4 @
- char *dmabufdest2 = NULL;1 P% {/ l( T% I2 ?4 e* Q* H
4 y u2 y2 j) y7 D& g- static int acnt = 512;: }1 @ T) q, ?7 P4 X
- static int bcnt = 8;, w2 e2 ]0 T! E: C3 \0 y s) D5 s
- static int ccnt = 8;* x' U) ?. c3 ?; _& T
6 N. X7 j0 L) W( ? f8 s- module_param(acnt, int, S_IRUGO);
# L2 U/ }. o! }, E - module_param(bcnt, int, S_IRUGO);4 g0 N* j: Z. w- x; {0 a
- module_param(ccnt, int, S_IRUGO);
复制代码
- y9 B/ Y6 X3 b# H: ~" ]# Q P3 ^. j: D
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用* m' L6 p4 U% b9 F# A* ~* v
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
$ p( J; s- w; h0 L2 n% ~9 T; P m 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
( k5 A. [9 o' E: r* L, n, d8 S7 @3 Y, X% K* P2 W F" u1 d+ Z/ Q$ i, n4 x
# X3 ]. ]0 ?- ^" H1 P
|
|