|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
% Z8 S9 Q6 r5 d7 n, Y6 Z# N- [code]EDMA sample test application
: z5 s Y; h# h. ^& K - /*
, A4 q. g% s# a5 e - * edma_test.c
+ i i4 s, D* o3 u1 G. ] - *4 P1 b$ v9 N4 Y x7 K+ {8 c* V
- * brief EDMA3 Test Application
: n, O. M& F. u. f5 t3 _# q E; H - *
3 U, e8 H+ f! \; {6 \$ z" f - * This file contains EDMA3 Test code.8 t, m* i- X& n# G6 }8 w
- * ~6 [( f( q t* j8 X% n8 V2 _
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE9 P. B0 E2 B4 _# n6 U# D
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT' @' [7 m) v! T- J8 \, Y
- * TO CHANGE.
4 q8 G- r4 B1 w. G2 K* e A - *
/ I2 n5 Z# l, u' U, u2 `0 m - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/9 w1 M: p2 C4 }2 Z
- *0 e1 v. l1 f( {1 P! u7 ~
- * This program is free software; you can redistribute it and/or
2 a4 K* C4 U, Z4 H0 H# I - * modify it under the terms of the GNU General Public License as
5 c5 X# |6 }+ @, D* p; a - * published by the Free Software Foundation version 2.- r; h% t4 c3 I: R S, R
- ** m( c) u8 l' @
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any! U( R3 C+ h8 Z4 |; |& ?0 J
- * kind, whether express or implied; without even the implied warranty& j! U" d8 I0 Y" U: @% A
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the; m% x, z3 \- X+ D8 |/ ?
- * GNU General Public License for more details.
" }( N4 Z! U8 K, ~, s8 X - */
_5 q4 a$ P- ~3 \1 A% { - $ h4 X! g8 \ p w# @4 K. F9 r+ o
- #include <linux/module.h>* w5 ^% o# L1 k8 _: U
- #include <linux/init.h>
* G; S R# [$ M4 b* R - #include <linux/errno.h>. G5 Y: r( F& a3 y
- #include <linux/types.h>! j) Y: Q& j4 n9 A5 {8 S" M( d
- #include <linux/interrupt.h>! q/ ]/ J) v% m
- #include <asm/io.h>
$ U/ I* I3 _2 U" K: C: T - #include <linux/moduleparam.h>
1 ^/ @& f. q6 o9 ^) O: F9 p5 K, C - #include <linux/sysctl.h>
0 B$ G& Z+ R; ~ - #include <linux/mm.h>
1 Z* Z2 }8 y, T/ h" N { - #include <linux/dma-mapping.h>; s0 }# L3 }' d" T2 q3 |2 ^
- i) |( Q4 o& A5 f3 l2 M- #include <mach/memory.h>
/ F- I6 [, S& T6 I: R- J8 w8 l D - #include <mach/hardware.h>2 Y- |3 |0 d5 Z/ ?4 n" P# W) u
- #include <mach/irqs.h>9 N/ @: `3 x* \( G
- #include <asm/hardware/edma.h>
3 n2 c% y8 I: p: z# @" S/ d: r) c$ g
3 s/ o" h8 s' [( S# _- #undef EDMA3_DEBUG5 N! ]! ~8 y' N+ U4 r
- /*#define EDMA3_DEBUG*/
) ]8 Z3 I7 k* Q9 d8 _5 c Z: f - 0 H) Z" U4 S9 V0 e7 n
- #ifdef EDMA3_DEBUG
+ J9 R" }) Y2 X/ t/ g% u0 z, S - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)3 E$ F4 a! x: M2 |
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
9 ]( d6 C* J$ R6 n - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
5 T9 d6 q. p% x2 Z - #else4 _* \4 ?4 q1 w X5 Q
- #define DMA_PRINTK( x... )
% e- w' f9 W, A7 v - #define DMA_FN_IN
8 @0 s. ~2 Q; ^0 r9 S% g: N/ o - #define DMA_FN_OUT
/ y, ?% x, v v1 v" y& y) H - #endif
0 }* E% @0 I3 f - ! S9 c* d+ b9 E6 [
- #define MAX_DMA_TRANSFER_IN_BYTES (32768), x2 k2 v7 }* i, \9 x: V
- #define STATIC_SHIFT 3
/ v* B2 O; t4 E" {% L2 x - #define TCINTEN_SHIFT 200 z" T" Y( z Q
- #define ITCINTEN_SHIFT 21
0 {. j( T7 D* g1 W( N - #define TCCHEN_SHIFT 22
- X* M. I% r2 S; j5 p; h, V3 U+ v - #define ITCCHEN_SHIFT 23
& T) h' @ A% c& D4 Y8 o5 k
6 E, h$ {( x) T; p* v3 S- static volatile int irqraised1 = 0;2 @, P4 {5 u% [, Y: T8 C
- static volatile int irqraised2 = 0;$ m; C1 D( O6 R
- $ {7 S& k. C) T4 ^! [. Z8 b
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
2 a' [( z+ P. A( h9 R3 Y - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
% X+ |! ?* U5 R+ v - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);7 b3 c, f3 `1 W
- O- {9 M) L' T. b- dma_addr_t dmaphyssrc1 = 0;; W. G! Q: J3 A9 f, u
- dma_addr_t dmaphyssrc2 = 0;5 U/ `- Z8 a; S, G
- dma_addr_t dmaphysdest1 = 0;( i" ~# f X' B2 m ] t( l& b
- dma_addr_t dmaphysdest2 = 0;2 K8 {' E1 B. p
+ _/ Q( ~. E' _- char *dmabufsrc1 = NULL;7 S' ?- _4 w6 n" X, e! \
- char *dmabufsrc2 = NULL;/ l1 {1 s! j4 D0 A% ?4 M! L" [1 H
- char *dmabufdest1 = NULL;: ~% }+ e! e' Q! F. K+ |6 l
- char *dmabufdest2 = NULL;
8 y# \! J5 W) g7 M% R9 [7 ^; t0 ]
8 y; F$ Z0 o) j d( m* F0 ~' K- static int acnt = 512;0 ?0 o4 K4 m* W3 L; i* `9 ]
- static int bcnt = 8;
9 p- S4 A1 u( R7 E& p - static int ccnt = 8;8 t. d2 H# C; X+ p$ s1 u# ]
! a2 e6 I p" z4 V- module_param(acnt, int, S_IRUGO);
" A) h1 o$ ]# s/ T& q - module_param(bcnt, int, S_IRUGO);# K* G+ E' E9 O3 N0 }5 u) a
- module_param(ccnt, int, S_IRUGO);
复制代码 6 w% `1 i- Y; \* ^+ v
( D. E0 R8 M6 Y+ o' y8 m3 ^. m& O 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用: g* W+ h+ M) ]
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。' o% L5 l0 ]. }+ T) K u6 o" V
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。: C# t" s. D+ T
6 }" o/ r5 q/ V; T S
6 @9 i5 q% l1 _3 j$ `& L |
|