|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
! N* a$ I* M$ w. {- [code]EDMA sample test application3 f6 T: m) F3 W9 D: S( B) T
- /*" H! M( c1 L/ J3 o1 R
- * edma_test.c
! e0 K3 }4 H: |+ W2 g - *
8 k' x# b9 w7 o ]1 C( p& v# v. M - * brief EDMA3 Test Application6 B6 Z+ M# W8 P- Z- B
- *0 I4 g2 m3 j6 q+ e
- * This file contains EDMA3 Test code.
8 p3 R) T: N4 _ - *
* G8 ^, @: [. s3 l0 [7 Z4 I8 j - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
3 k' e0 b0 G3 s4 k; e0 V - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
# x& p W! }$ r - * TO CHANGE.
0 d8 Q" M1 [5 t6 f% z/ d - *+ i6 e0 K3 f4 E8 O `; x
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/* G+ ^' m8 H! T S( S; t4 h! N
- *
& i3 ?' s" y! K. n5 x - * This program is free software; you can redistribute it and/or
# e' v0 w7 w* s: [4 c( D - * modify it under the terms of the GNU General Public License as
$ d& F/ q9 U9 E4 b - * published by the Free Software Foundation version 2.* Z# A1 j& E: i/ T, ]
- *, N: g1 \$ Y1 t! l/ q/ m
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any
5 L6 k, H' U R! c; @3 J( J+ p+ D - * kind, whether express or implied; without even the implied warranty1 `1 k- |0 H l$ y; Q1 a
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the/ n' \3 p8 f* V' y' v4 A& x
- * GNU General Public License for more details.
" M; V* [8 ~) _& I8 K# j6 s) T - */
1 ^/ J* d, u, `3 |) G - a, E0 N3 ]" E9 D9 v, w
- #include <linux/module.h>! n5 I* ^) J2 O' q* I A% k6 m
- #include <linux/init.h>
: d n4 U, M* w% L - #include <linux/errno.h>
- n6 q2 S2 n3 R. M- y) k4 C - #include <linux/types.h>
$ C' h& u$ Q; Y+ V1 B5 C4 ^ V - #include <linux/interrupt.h>, b1 w( T& W! x: x: P
- #include <asm/io.h>
5 \4 v- N. M+ Z$ [, u& l - #include <linux/moduleparam.h>( B2 X% q, g( C% M* P% ]
- #include <linux/sysctl.h>" p# T5 u; Y1 @4 I2 }. ]* _
- #include <linux/mm.h>
- m7 J5 [) L4 U: S8 V) R- q3 R5 \ - #include <linux/dma-mapping.h>
* S/ A; q# t$ }* ]
5 q& I3 p' L- ^ {; w& q8 V- #include <mach/memory.h>
2 R0 @' ]2 H6 P1 J - #include <mach/hardware.h>
1 h3 U6 U& e" K) Y - #include <mach/irqs.h>/ @. y3 q8 U) J8 @& F8 K5 \
- #include <asm/hardware/edma.h>
: S+ K8 O- k- ~2 M - 8 Y& L6 P& Z. I" G# e$ o/ c
- #undef EDMA3_DEBUG
1 y8 S" G/ X2 x; l - /*#define EDMA3_DEBUG*/% m2 ]8 \2 Q/ ?6 L1 F
4 ^* ?! N. Z5 |5 n0 }# W7 J- #ifdef EDMA3_DEBUG
, w2 Q1 b2 z; w; I - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
+ \' E- K6 M. ~# K+ E0 g - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__); x- c) K, @$ r0 k0 a
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)+ y9 \ B/ _' D9 f* o, C4 n6 ~
- #else/ v7 m- o5 n* l/ @7 J
- #define DMA_PRINTK( x... )
( h+ D7 O+ R( o - #define DMA_FN_IN
: `) m% B& G' X* ] - #define DMA_FN_OUT
* o4 F; n, i1 B5 S - #endif
% }6 k6 ^; F/ I, A7 E - # k% h. Z: {* a! s/ L* n
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)0 B# i; w6 m+ g
- #define STATIC_SHIFT 3' g, G$ g6 B, `4 A( K
- #define TCINTEN_SHIFT 20$ U) ~7 {* S5 K( @# [
- #define ITCINTEN_SHIFT 21
x5 r+ ?" }% J% F1 _" b1 F7 \3 @, {" z - #define TCCHEN_SHIFT 22
1 v2 ?. s% J0 m4 _! h( S9 o - #define ITCCHEN_SHIFT 23
( \* d. `# j# T1 u4 e
6 g8 Y2 _) O/ m3 ?- static volatile int irqraised1 = 0;0 r& M8 k7 R" m6 d0 w2 U: C
- static volatile int irqraised2 = 0;: F: t( o6 j9 `6 F" o: {
! K( S9 L* _# ~) q% l, }2 f* C3 t1 Y- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);# M0 L; Q Z$ E3 d! X5 i
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
) f8 N$ C# t* h# H - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
$ Q# b) }' T! y9 n. @, [
' x& ~7 e8 ]( V* x" @- dma_addr_t dmaphyssrc1 = 0;6 J8 w3 {3 q0 V7 B
- dma_addr_t dmaphyssrc2 = 0;7 J5 b6 J! u. K# m" N
- dma_addr_t dmaphysdest1 = 0;7 v$ I4 L% K; D7 s
- dma_addr_t dmaphysdest2 = 0;. T r) O' t$ R
- & n _& j3 T( z1 r1 S2 W$ M/ \
- char *dmabufsrc1 = NULL;1 F3 i1 g( \8 M, q) A
- char *dmabufsrc2 = NULL;
! K2 r6 u' n( H& w. Y j0 b - char *dmabufdest1 = NULL;
) e* X; W. l) S - char *dmabufdest2 = NULL; v+ D) d; N. W4 x0 ~
% {+ |; L4 z& f# L2 v- static int acnt = 512;
# ^9 ?' z W" |3 h" R - static int bcnt = 8;8 p" \3 x' b4 E7 d2 B
- static int ccnt = 8;' L& @9 Q% r/ C; g: e
- # g# _/ w+ C+ c4 _
- module_param(acnt, int, S_IRUGO);
. A. j7 y/ k8 Y4 C- K; ?* B - module_param(bcnt, int, S_IRUGO);# `7 x# l8 ^. S8 D& F, @, `
- module_param(ccnt, int, S_IRUGO);
复制代码 ( X" J, x: J3 A& D* C I
, i' Z3 ?+ H- ~+ }/ Z J 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用. D! ]# \5 R: X, h! v) K
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。3 t$ F% s H& w* W: P
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
! I( G z/ |. c4 r8 C; B: G* p: C! G2 p/ @: ?
( Y' o! h( l. r2 u5 R |
|