|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 & U( m; J6 J! W ?" G; d
- [code]EDMA sample test application
6 m& q0 S4 F, }; P* ? - /*
' P J. t! J2 n3 \ - * edma_test.c( L/ b; f/ ^7 V0 d% s, Z# v5 X
- *0 Z5 ^& {3 {' o+ P# J/ X
- * brief EDMA3 Test Application
y/ `' P( t/ F. z - */ k* \5 K$ h! I1 v+ J- U( |4 `
- * This file contains EDMA3 Test code.
# q& |" I9 Y6 M - *
5 `* n# P7 [1 I3 b, q - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE4 n _+ {. t8 j$ u& ]5 N- D
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT4 ~: ~1 e$ H6 U% k
- * TO CHANGE.
0 w: h9 `" w, B - *- r) U$ s& i* \7 n. v
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
5 M0 r) }* C# M) W! A# A - *5 |( p5 N }9 L. w; ^: m+ Z2 B( W2 U) [
- * This program is free software; you can redistribute it and/or
$ K$ Z- k) o+ G x" m O - * modify it under the terms of the GNU General Public License as
* D @: G5 ^3 e m& V- k - * published by the Free Software Foundation version 2.
5 W3 V+ q9 L- F - *
1 W% ?9 e2 e* l) d. r - * This program is distributed "as is" WITHOUT ANY WARRANTY of any" Z1 Y1 i& S0 [3 [
- * kind, whether express or implied; without even the implied warranty0 ?4 F0 q5 Q! ~. ]+ U7 v6 L3 A9 O
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the1 S% R( y$ Y( k. i! l5 e. M' ?
- * GNU General Public License for more details.
7 O3 S0 b1 U& O - */
: b& H, _2 m2 A3 N H+ Y
( @9 `! K3 \) F9 n- #include <linux/module.h>4 U" i- _, }9 J
- #include <linux/init.h>
2 D: z6 |$ n, J% \$ L$ F5 [ - #include <linux/errno.h>4 V+ S! P3 B9 g* G8 _& ]
- #include <linux/types.h>
9 n) L' y. `) K# e - #include <linux/interrupt.h> \6 _" m) D( S- X1 O- w# c
- #include <asm/io.h>
" _8 t' B9 V5 R. q' e9 P* @$ V7 N5 @ - #include <linux/moduleparam.h> E, O7 _% V% g6 L% H1 ~- E
- #include <linux/sysctl.h>0 j+ t6 r& e* x" e! a* {# l9 y
- #include <linux/mm.h>6 L' A. p7 Y" ^
- #include <linux/dma-mapping.h>
. g- c% v! t7 H: I9 |
7 `+ ^) R m X4 |# X- #include <mach/memory.h>" [. b: ?3 z4 Q$ Z6 r: k6 c- I D1 P- D; Y
- #include <mach/hardware.h>; p- U% D( |. O
- #include <mach/irqs.h>- Q* Y+ e0 i! o
- #include <asm/hardware/edma.h>
2 l! v! ~) A' V e* u - + T; q( z0 G9 c8 y" V: [
- #undef EDMA3_DEBUG
5 U8 g. m/ q+ T6 W - /*#define EDMA3_DEBUG*/
" n3 ~1 i S3 @) M; @; E
0 h0 M- ^( r4 x" T9 x6 I8 Y$ I" C- #ifdef EDMA3_DEBUG) c6 n, Z" T9 J0 i O( ~/ h
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
; k9 b5 ]- D m' e& Z, S: w a - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)2 p6 k5 u& j1 x! u) ~
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)$ i/ I1 Z2 r# f
- #else
/ `$ o' M8 F1 X' p) U" j' F - #define DMA_PRINTK( x... )% @% R0 T8 n+ j& I
- #define DMA_FN_IN
@- u% B& G- H4 T( S - #define DMA_FN_OUT X) r8 z/ R( k; ^$ a3 ^* M1 \
- #endif
7 J5 h _" l9 J* V# f - + F. o6 U, J7 u( O0 b) r9 ^
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
$ c6 A! L) i2 R% T! @ - #define STATIC_SHIFT 3* E, B* Q5 x: [7 {3 _
- #define TCINTEN_SHIFT 20
- v* O0 j. S% Z( C0 v - #define ITCINTEN_SHIFT 21
5 D2 R6 i% d5 I9 b; e( d6 I) v" o2 D - #define TCCHEN_SHIFT 22/ ]; t' Y! g& m
- #define ITCCHEN_SHIFT 23
% Q& m _) V1 ~8 i9 I- Z - % y L+ T2 j" O' f. v
- static volatile int irqraised1 = 0;
1 f# R1 y/ P Q8 C% u - static volatile int irqraised2 = 0;
9 u7 H% [+ A. C* H - % A$ n; ?5 Q" P5 b/ g1 z
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);# I1 U3 S( [7 M# C0 W+ _
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);& R0 E0 U; r( c/ P, X2 Z' j, Z, ~, X
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
1 T5 Y9 {) F$ K* u/ x
7 N6 W$ W! s. U7 f$ ^% ^- dma_addr_t dmaphyssrc1 = 0;
9 |' C9 q0 w# ]" X - dma_addr_t dmaphyssrc2 = 0;+ X4 ~( @) f) ]
- dma_addr_t dmaphysdest1 = 0;8 w" Z. H/ Q6 g/ V: C
- dma_addr_t dmaphysdest2 = 0;- ~9 p. R; G" ^' o0 A( L. `
- ) H. F( p* O* e( Q* l
- char *dmabufsrc1 = NULL;9 l# g' S/ s1 X* c
- char *dmabufsrc2 = NULL;( c5 p3 u. K( a* d
- char *dmabufdest1 = NULL;; j j6 r. j/ B w. R
- char *dmabufdest2 = NULL;3 ^5 u U2 q$ k A$ g
0 d( ^" y# e4 k- D% b& C- static int acnt = 512;+ b7 z) n L, y J7 M$ R# J
- static int bcnt = 8;* P2 c2 h) [4 F) ^8 K. k
- static int ccnt = 8;
1 h' C8 l' q! u2 b" E
, N) k7 I' }- y- module_param(acnt, int, S_IRUGO);
4 u' w7 [7 B% O - module_param(bcnt, int, S_IRUGO);6 y0 ^ c3 t( j( \; Z! n0 j. a
- module_param(ccnt, int, S_IRUGO);
复制代码
4 ^- n. {6 T' @
4 N2 N+ z1 C* {. }- C0 A: ~( \# b 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用) R: T9 M- e# J5 c5 v" g" S' H3 [
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
" c+ |% e: `9 V/ q 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。5 k1 f6 ?2 W- b ~) Y$ g
1 [6 y9 ~; x9 L9 @
& b* i' B( D- q, N. ^/ z |
|