|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
' O; e1 H% R' n' C6 b3 H- [code]EDMA sample test application
* |/ L3 d& \( q" v9 Q8 G% C - /*
8 M! E/ X! C s3 g& M4 J - * edma_test.c$ N1 T" W& n2 A! P
- *
, w& H3 z2 _) ]. A7 t# D. \4 G1 V7 M - * brief EDMA3 Test Application4 } ^6 r7 x0 A
- *3 J. y) {* _# r% @! K* H: G2 P4 y' `
- * This file contains EDMA3 Test code.
! O% A* t, O4 G1 k5 Q& b6 y& r - *1 y$ }0 Q1 I" W% N7 H
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE6 b3 C7 r5 \ |$ O, w+ P/ T4 C" a# Y
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
( S) t* ?# B2 i, h4 Z, @' Z - * TO CHANGE.+ o4 y. h K* K! e9 B
- *4 P, v+ D4 Z& a& o) B/ t$ A
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
5 l2 w0 @ \8 Z3 Q - *
3 a& v6 R9 X5 y6 R, h& T! ] - * This program is free software; you can redistribute it and/or
$ t2 c6 f9 q0 ?4 j: c0 p1 \) t. } - * modify it under the terms of the GNU General Public License as
' w7 E9 E7 `" k& e - * published by the Free Software Foundation version 2.
% n- k4 B! m4 z( t - *; z, _# J7 b) X
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any
3 V0 p' w x$ N - * kind, whether express or implied; without even the implied warranty9 ~. A' }2 y& N( P& S- b+ s" L
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
8 C2 q: K) g3 _# ~ - * GNU General Public License for more details.. M8 l( m1 m: x) c
- */
) l% j3 ^' T+ u* ^$ }+ S' ` - - P- S b9 j, `0 p) `
- #include <linux/module.h>
( A* Y9 Y0 n: g& T - #include <linux/init.h>
4 K& z/ c; V8 z6 I/ R, i - #include <linux/errno.h>
! e7 w3 ^( W N: W2 ? - #include <linux/types.h>
* v) [7 ^9 J5 ]/ t - #include <linux/interrupt.h>2 G/ ~. Q7 e" Y- Z
- #include <asm/io.h>
0 [: w& F s3 z5 ^" }6 i - #include <linux/moduleparam.h>
! B' j$ A% v8 l# W& J. q. e# j - #include <linux/sysctl.h>( w, v. n& W" I3 I; U' u' m) ?! I3 u
- #include <linux/mm.h>$ e( G9 v, v" L$ G! r7 J* f9 H
- #include <linux/dma-mapping.h>
: ?: l: J" j; A" E: l- L - 1 y0 {+ T! V; v* S$ ^
- #include <mach/memory.h>
$ g3 o0 R, s2 S) i# c- v - #include <mach/hardware.h>
% B# z0 X& s; y - #include <mach/irqs.h>
4 X) q$ c& {5 I$ z9 ]- M" j' f - #include <asm/hardware/edma.h>
) v* N) X3 W0 k: @4 U/ p - * O! W1 E2 h6 n& G# g( F b' _
- #undef EDMA3_DEBUG
6 N# B8 Q* h+ h+ N) f2 O - /*#define EDMA3_DEBUG*/7 w) `3 _ B0 Z( l u" c( T. a; ?
- 1 j N6 D9 U+ f# s b Q
- #ifdef EDMA3_DEBUG6 L7 m7 t8 L; m& j% F
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)! S9 U( w/ w- P/ z
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
4 u) ]& e: d. I - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)0 u% L8 G6 ^' {' ~& h" r* [
- #else$ \6 j& R6 W0 X( V0 o+ [5 t2 D6 r
- #define DMA_PRINTK( x... )3 z" d! x+ L L$ S! Z* C
- #define DMA_FN_IN6 G2 N) Y. R# r" D
- #define DMA_FN_OUT
$ J$ k0 m4 _# n/ _/ O" D - #endif
- [- z3 m/ l+ l. m, q - 5 B! J, {. M' h: ~
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
2 k( u1 \" T: {( c+ E* _8 p - #define STATIC_SHIFT 3
7 O1 l! j/ M& t' b7 g3 {5 W' `4 x - #define TCINTEN_SHIFT 20
0 y! J& e- q G. ` - #define ITCINTEN_SHIFT 21
+ M- G( Q5 H6 r' v3 X% T - #define TCCHEN_SHIFT 22
6 |: N9 H6 w+ D1 @& | - #define ITCCHEN_SHIFT 23
0 w' E& K) G' f
: R: _% i9 _7 _2 y* F+ n6 g$ s: }2 J- static volatile int irqraised1 = 0;
4 H6 A/ L' @- \( I$ r* C - static volatile int irqraised2 = 0;+ v0 R) H0 b6 v' i5 A! p6 n
- 2 {! M8 `: |* o$ F; h
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
2 E2 `9 D! R( ?* X- O" r' Y( W - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);( Y$ @+ a$ \$ d1 `
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);- ^( p) f+ R) ]9 u& y \8 X! H. D% j
5 ^* W9 s6 ]8 e7 p! L! [5 J. p- dma_addr_t dmaphyssrc1 = 0;2 s* D9 @' h& a( C1 h
- dma_addr_t dmaphyssrc2 = 0;9 n, f% }1 c1 P6 |" Y8 x
- dma_addr_t dmaphysdest1 = 0;7 ?4 z2 s3 f E' K, Y! L4 @
- dma_addr_t dmaphysdest2 = 0;$ _0 o- j# N5 ?. D# W
- 4 x0 ?7 u$ Q$ N1 e* S2 n0 z4 R
- char *dmabufsrc1 = NULL;8 O7 v; B- b; s5 d
- char *dmabufsrc2 = NULL;
1 L3 t" ^6 f/ p4 [3 W - char *dmabufdest1 = NULL;
$ x. |0 A# ~7 a7 U' Y( W - char *dmabufdest2 = NULL;
& X6 q8 `6 |% D& V+ d% X; `9 ? - $ E4 Z; R) _9 h( B1 Z9 X
- static int acnt = 512;! o! h- c: G% e" i
- static int bcnt = 8;! M& Z( p- o. Z3 _) \# K$ b
- static int ccnt = 8;* m. `- h6 r+ C" |! }, I! _# N
- ! Q& T J/ g0 ~' b
- module_param(acnt, int, S_IRUGO);/ M$ T' U1 M: x J: F1 _
- module_param(bcnt, int, S_IRUGO);
/ ] _9 b4 k! h0 ]* n a! j t: _- J - module_param(ccnt, int, S_IRUGO);
复制代码 / F! M: }/ y" ~3 V" Y$ a" u) G
g+ T2 m: a! L- h( u- m4 | 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
! q& x; o; _6 H, B5 Larm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
. V) y: d* `, K- y6 i 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。# f$ }% e _: I1 ?% o
+ z: O2 _/ i5 @" x3 `% |
4 I- @' |6 y4 D: i$ h |
|