|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
$ B% n3 Z* m3 j4 u/ \- x5 H- [code]EDMA sample test application
5 Z" `7 q7 p+ v* T. _- O - /*4 H5 O8 k0 t0 _' r3 e, Q
- * edma_test.c
& l& I( j& a4 m* b - *
7 s5 E; z' t6 [8 [: p" Q - * brief EDMA3 Test Application
" V0 Y% Y. @3 x - *& O( O* m7 W6 F) b* \/ w% O
- * This file contains EDMA3 Test code.
/ S& X- Z% ^! C% G3 z- J - *! h3 L A5 q I2 c1 X
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE6 v, _. q9 L0 Y) O. \, w5 x
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
* e: Y- N/ J9 ?8 d9 R/ K - * TO CHANGE.
9 H0 T6 i/ a+ }2 K( ] - *: g1 t7 g& _% `4 r
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
' Z. F2 |0 B- ^4 E - */ D) W* C" O/ X( q7 U* G
- * This program is free software; you can redistribute it and/or1 J$ n" [1 @9 r) E3 q- k
- * modify it under the terms of the GNU General Public License as' o- C3 b% Q1 T: a2 N% y
- * published by the Free Software Foundation version 2.! L, {! q& s- P$ n
- *
# H/ }) \7 ~: e3 K - * This program is distributed "as is" WITHOUT ANY WARRANTY of any( [- c7 k% I0 _) f6 u4 q0 _# a! V
- * kind, whether express or implied; without even the implied warranty6 l% z; d, B; j7 ?2 ]% \9 F k. M
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
) J# o; J6 O$ Y& R- g, P G: ~ - * GNU General Public License for more details.* |# i( X' A# |( \
- */
# I/ }7 E+ e. E" ^ - / k5 s4 a: \& h( _
- #include <linux/module.h>
7 S. f8 K4 O; C) x0 W - #include <linux/init.h>
$ f) a8 X$ N, b - #include <linux/errno.h>, U m! @. r! x9 s: ^: V" C) \! _
- #include <linux/types.h>
! [& L! r+ T2 H& e' O1 `7 Y - #include <linux/interrupt.h>
2 T2 A2 D$ b- X' J& M - #include <asm/io.h>
: L; u2 d, H9 q: r" s. W; z - #include <linux/moduleparam.h>% ]( s6 N! ?+ h* T- i: i5 d
- #include <linux/sysctl.h>
5 a$ L* p9 {1 s) s - #include <linux/mm.h>
* b& y; `, e: w! R- W/ p% w+ |8 f - #include <linux/dma-mapping.h>" R T( g& s4 J0 G- K
$ M5 M, X H2 E1 ~- #include <mach/memory.h>
" A j2 g2 o0 G) ~3 P S - #include <mach/hardware.h>
7 [+ F2 K; Z! L% C- S( _; x2 [5 | S6 n - #include <mach/irqs.h>
) M: o+ F0 e% J+ p; s - #include <asm/hardware/edma.h>/ ]0 [, b7 ]7 l# g
- ' i o7 u6 j' H1 w
- #undef EDMA3_DEBUG w& H2 L0 J0 J& k \$ x5 `
- /*#define EDMA3_DEBUG*/
% a3 W) E3 C' l% ?$ A
" L( v0 v/ q* e# k& @" j7 R- #ifdef EDMA3_DEBUG- P! h; b/ ]/ Z6 r
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)2 d# K2 O3 Z& x ?# D) P$ T
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
* r- q K2 ^% z6 G& I - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)0 T* h+ o$ ~, x2 x: v5 T, n9 H% j
- #else \8 u. r, k7 D) y& T+ \2 U
- #define DMA_PRINTK( x... )' H& Y. g" g" u8 J% L) F
- #define DMA_FN_IN
9 G8 {( Z- w5 Y: { - #define DMA_FN_OUT2 B/ k8 q( l# A ^5 j$ K5 ^/ R u# W
- #endif
( o4 s" S* W1 u2 z$ x2 r
i3 W7 I# P; X- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
5 \ D; }5 n( C8 z7 F - #define STATIC_SHIFT 3
7 r- Q- N U" G0 u! Q, ]1 X - #define TCINTEN_SHIFT 20% o$ z. [3 I8 Q
- #define ITCINTEN_SHIFT 21 l0 H+ z' c) w
- #define TCCHEN_SHIFT 220 u- x2 @1 H) Z: |. t/ X0 x& E
- #define ITCCHEN_SHIFT 23; C6 a0 N+ o2 y6 X) r% H' W! \& {
- & h' f# u+ T1 ?
- static volatile int irqraised1 = 0;
: U8 G, _2 ]# a8 |1 w - static volatile int irqraised2 = 0;
9 U/ ]- F1 z2 u2 s" U7 r
* i* R# B. _" C+ ^. u1 f" {- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
' u; G A3 w( I1 h/ S - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
- u1 B5 h$ A; w/ C& `; \: }; } - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);9 z2 O4 L- M7 N4 F' h* ^* W
4 W9 o2 R( M. ^& d9 T) D% P- dma_addr_t dmaphyssrc1 = 0;7 D3 B; P, J1 S' ^
- dma_addr_t dmaphyssrc2 = 0;; D. B( w9 B6 Q; P2 x# c3 B0 c
- dma_addr_t dmaphysdest1 = 0;1 {' \. c2 y# {. B
- dma_addr_t dmaphysdest2 = 0;
+ F% x, B' E( Y7 }, C
. n# A9 n/ M# L4 z8 z2 ]- char *dmabufsrc1 = NULL;3 W3 z# F8 C% f3 q) N# y/ U* j( R6 v. y
- char *dmabufsrc2 = NULL;
$ q$ d# H& h; G+ Z/ b# u1 ~ - char *dmabufdest1 = NULL;; B2 p* x1 z% C
- char *dmabufdest2 = NULL;
( H) a4 {; m* r' O, U/ v' w5 v( w
# z2 ]: E8 [2 f! V/ p c+ z: e4 d- static int acnt = 512;
2 T- v; o! z, H+ S4 S - static int bcnt = 8;
' D O9 H: n2 S3 h* n- v: D - static int ccnt = 8; X3 U5 w0 m6 H8 b" f L5 ~
) i2 H5 I" b# A+ \' A- module_param(acnt, int, S_IRUGO);
' D+ L9 O( ]( j2 w" X - module_param(bcnt, int, S_IRUGO);
2 X5 i, r8 C. s$ n - module_param(ccnt, int, S_IRUGO);
复制代码 7 C4 K& a+ u1 x3 P/ N2 q4 H" T. E
8 _+ P. A: O5 n n E/ [
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
+ P9 Z) k) v9 q% o( ~9 }8 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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。1 F! `: A9 s7 Q, ~
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。6 S2 X4 Z# ~& K/ O N
; I f! S# y2 N7 F
6 a( }+ Q8 e8 \: S |
|