|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
0 G) @( m; M/ G E3 J8 H- [code]EDMA sample test application
* G6 V9 H, u9 Z Q1 }+ k% O4 g - /*
$ d7 u: o' r% s. x. k6 K# l$ b - * edma_test.c
; L# f/ b5 A# M7 o0 s+ ]+ A. S# Q - *
, b8 ?* R5 Z) `9 R& [# T$ \3 _ - * brief EDMA3 Test Application' ?' i- [- o. }
- *2 u& ]- R) F3 ]- x5 U
- * This file contains EDMA3 Test code.4 p _$ `( m9 @3 R5 F0 b3 q+ ]- s
- *, X2 Q4 `9 w7 ]) D; U6 ^. W3 w
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE K- P. g8 ]0 ^7 K
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
6 G: l, p* d# d: r4 i - * TO CHANGE.
9 _/ k4 L" k! V) j& t- Y6 F4 b) T, B: S - *& I$ ]. L* |8 g$ z/ v8 [& {
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/% ?0 h" R9 a* M& i1 b2 v
- *
; `# J; t' x# g - * This program is free software; you can redistribute it and/or
% t( ]% ` y2 @: x# Q- _0 c- S! F - * modify it under the terms of the GNU General Public License as
9 M/ Z! a+ A$ c% t) k% H - * published by the Free Software Foundation version 2.5 {2 k: M5 b3 ~1 F2 {$ M
- */ T+ S5 K+ P+ c- ?9 S/ S( \
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any
/ j Q- ^2 i+ Y2 Y3 J. x. ^ - * kind, whether express or implied; without even the implied warranty
6 g0 F4 i( P& B' n. g - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
. P! b) V% N0 L& ` - * GNU General Public License for more details.9 O8 N) {+ b H$ x" Q; c e
- */
( r" g% [6 A) H7 V# | - , B* p0 N9 M `
- #include <linux/module.h> Y* y2 P$ ]/ w" {- E
- #include <linux/init.h>* h. T& [4 T1 ^( [0 P, N# ^. v
- #include <linux/errno.h>) B. |* U! ^. C" l: N+ t
- #include <linux/types.h>0 k6 E0 S4 {. c: A8 [) S, e
- #include <linux/interrupt.h>
% x& }4 e3 K" G0 q3 {0 \- R - #include <asm/io.h>0 h0 G3 Z3 ^1 N1 {3 t
- #include <linux/moduleparam.h>
' U @) L/ f/ U - #include <linux/sysctl.h>
7 _( y9 n v2 c# b - #include <linux/mm.h>0 W x8 u3 B4 r8 L; J9 U0 ]
- #include <linux/dma-mapping.h>* P, |( c- F( `& q
! _2 M) H3 r! Q$ J- #include <mach/memory.h>, p/ A1 P) D1 q& ?* C
- #include <mach/hardware.h>
8 k4 U, n$ u% x( b! X9 l' [ - #include <mach/irqs.h>5 ]5 q: `2 X0 U: S
- #include <asm/hardware/edma.h>+ F3 t! p3 W) b) K) d
/ T4 ^5 T4 M' {$ W9 i% k% E- #undef EDMA3_DEBUG: G0 ]; e/ }' ]0 E
- /*#define EDMA3_DEBUG*/& f$ d$ W5 G' o# h2 ?" x# s* E/ M
- " F) B1 [+ l8 H' L$ |
- #ifdef EDMA3_DEBUG
" @$ X, P$ W9 ?* e - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
4 w) P! ^/ V2 q* t' C - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
, V9 k- |5 x q: ?5 b2 W- I( i - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)3 q. A& t( p# z8 V1 e7 h
- #else
2 T9 @' i: R/ v9 s) A! x: x - #define DMA_PRINTK( x... )- y) \+ ?/ U( `; g5 M
- #define DMA_FN_IN
! g. d# w u/ U7 V! I$ |2 E - #define DMA_FN_OUT2 ?/ Y M9 _) c6 s4 f3 y8 s
- #endif
G" S" M" ?2 e' O
+ m# N: }0 H& q& g' N4 R- #define MAX_DMA_TRANSFER_IN_BYTES (32768)* \3 b/ f* _8 E" c! }
- #define STATIC_SHIFT 3
# h3 X6 n" a& @/ ` - #define TCINTEN_SHIFT 201 d5 j$ Y9 A* Y g! g
- #define ITCINTEN_SHIFT 21( K5 W, K2 V1 @
- #define TCCHEN_SHIFT 227 ^( N" Z8 E0 \6 }1 R
- #define ITCCHEN_SHIFT 23# c5 f$ o) @% c4 o
- ) |/ c& o( |7 W* Q$ c! S
- static volatile int irqraised1 = 0;
0 y9 e- n+ Z1 K- X2 X. Y( s/ D+ X1 M - static volatile int irqraised2 = 0; L2 O6 d$ J4 j6 _5 b) ^
- , L, x/ I# b% Q& m; c2 R5 x
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);. \4 U) y. j$ E6 e% f- u
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);3 V: X `* e% G& Z9 y
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
. V4 n, F" O! H r; m( A) y
4 A. K, o1 ]6 y- dma_addr_t dmaphyssrc1 = 0;
5 m) Z+ O5 K0 m9 S& p5 t - dma_addr_t dmaphyssrc2 = 0;( I* `% `+ u/ p5 `5 r3 w
- dma_addr_t dmaphysdest1 = 0;0 a& w$ x% F* d2 C; G, p: `
- dma_addr_t dmaphysdest2 = 0;
* S* k5 H) T+ [- `! R
5 X5 i, G w7 K0 a8 L# _* z- char *dmabufsrc1 = NULL;
" z1 y( I3 a h8 \9 `& H6 y3 M - char *dmabufsrc2 = NULL;! t1 O5 @1 _! }9 W# L! ^6 ]- [
- char *dmabufdest1 = NULL;% K3 i+ ~# V, x
- char *dmabufdest2 = NULL;- s K- I$ Y+ c8 ^: c
& {; k, z+ S/ `1 J- static int acnt = 512;0 p( S7 P5 I4 i# G; ]% ]8 F
- static int bcnt = 8;
% o* k2 {& s, E* a I - static int ccnt = 8;
! e% [2 `( U) `0 U( F$ e - ! }+ y# Y6 G0 F# P/ k5 P
- module_param(acnt, int, S_IRUGO);
8 n- \0 X# N' W% c+ w( I, U - module_param(bcnt, int, S_IRUGO);
- H8 t+ `! h2 k - module_param(ccnt, int, S_IRUGO);
复制代码 % ~5 m9 m- y. _& ^! ?, S! \& h6 Y: x
" F5 A4 f9 [* ^* _! Z& B0 w
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
7 o' k: D$ t7 c! d- ^( p/ sarm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
B7 w1 x. p( f 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。( N$ |7 K0 e. S. K: G" e
. p4 f. l& `3 J$ l! p7 Y4 M
4 t/ v. l7 n) E% R, M |
|