|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 . f" G* q- n7 P8 `
- [code]EDMA sample test application
( x' q% t: I; E( u( W' w - /*8 o+ E3 k2 x9 j: T
- * edma_test.c
& k! C- {5 a6 F - *4 `- }+ g1 ^0 n+ A0 w
- * brief EDMA3 Test Application9 n e6 _6 f9 G" x j0 j& a& X
- *
; ^4 n4 I5 l9 J4 c' J1 r - * This file contains EDMA3 Test code.9 g2 i4 y: N1 s' X% {. @) x1 ]3 h% I
- *. b9 ?" Y: P. m# [& h
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
0 U+ D o, r v+ H: n0 [, D. i - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT! Y/ q9 N {* d, E2 ^1 h }% i7 `. M
- * TO CHANGE.
( }) v# c; N0 {) a$ Z! t+ l u - *: b2 z6 `6 m* @" ?8 o; n9 k `
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/; b: q# L! s: f& q( A
- *" X+ ^3 k& ?4 M, s2 x( o8 `. ^
- * This program is free software; you can redistribute it and/or
9 g; h9 v# e+ b! [) Z7 \. Q0 p' t k - * modify it under the terms of the GNU General Public License as7 f3 l. h0 c. ~( N+ W. n4 P
- * published by the Free Software Foundation version 2.
# H5 O* ~6 u% B) c/ ]. q - *
* F6 B1 U7 ?( m. F0 ]2 J - * This program is distributed "as is" WITHOUT ANY WARRANTY of any
1 k7 Z+ c- `/ G8 U1 j6 k* H - * kind, whether express or implied; without even the implied warranty# D" r& M3 Y0 A7 C; K4 L3 R6 g
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the! b; ]8 K. P! t( [; Q# A# Y
- * GNU General Public License for more details.. q) R' f& X A
- */
+ E% d& I7 X9 v* K2 {: q
: _; N; x, w+ Q% \6 V- #include <linux/module.h>- `- P' `' U/ X1 e3 s
- #include <linux/init.h>
l, `, `, H5 F5 [) a - #include <linux/errno.h>
+ v4 M7 r. k2 R; e* h" G - #include <linux/types.h>
( A# T# u& ?. d, s! H - #include <linux/interrupt.h>
2 H; X* r. n8 ~5 S* Q- b8 f - #include <asm/io.h>: J' A. X/ {1 _+ d& q5 O
- #include <linux/moduleparam.h>
5 F% k) N* f2 y0 X. c2 R - #include <linux/sysctl.h>
0 q: L* G/ u, P# v$ h - #include <linux/mm.h>
8 b/ G8 q `6 n! ~) ~ - #include <linux/dma-mapping.h>
' y, I) v# Q1 p; l! B! r: E
/ ]7 K$ y# _0 b6 F# ]- #include <mach/memory.h>+ g' h3 Z4 L! h, [4 q- ^+ ~7 |+ p
- #include <mach/hardware.h>8 Q2 K4 }# ]& ^ [8 M' f) L# c
- #include <mach/irqs.h>
0 v# Q { p: x$ {. } - #include <asm/hardware/edma.h>
' C3 F6 E, o' ]% K* _* U; d& `- m5 U; {
, |" e# m4 e4 d! C: b8 J- #undef EDMA3_DEBUG
- @$ Y7 u* m' S+ n, F: q8 U - /*#define EDMA3_DEBUG*/3 ?# u/ f) j4 ]8 H& c3 z6 V
5 S/ |$ [4 O! [" k- k- #ifdef EDMA3_DEBUG
! y* d- F- G( t# F4 \ - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
6 _5 f( v& I: b+ h) }; C( G - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
7 T' u$ [) Z( m' `& S) @9 W0 ~ - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)/ { P' e( R! U& Z" \
- #else
% C; ?5 x3 P$ |/ g+ }1 z - #define DMA_PRINTK( x... )1 ^0 t/ f `: F, O5 x
- #define DMA_FN_IN
& v d. j! \1 T) ` P3 R& A - #define DMA_FN_OUT" g) W; l: Z Y; V7 X5 Z
- #endif% V6 }5 H) j. k. p9 R( S; y
- 1 a, B% F! u$ e3 e; k
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)7 m2 k# L8 m8 k, ?* o5 @9 D( D
- #define STATIC_SHIFT 3
* {1 w2 I4 G5 ~ - #define TCINTEN_SHIFT 20& z* } l' Q+ _' s/ V
- #define ITCINTEN_SHIFT 21
- k, ]; q* K6 m2 z% @1 j - #define TCCHEN_SHIFT 22
8 A3 ^: p3 K# w) a+ _7 i - #define ITCCHEN_SHIFT 23
/ K- x6 \% y6 g% Y2 a+ @
' D$ m3 w' V" O7 B. k. q4 z" P- static volatile int irqraised1 = 0; ^) Y4 |6 l; S! }# E1 N
- static volatile int irqraised2 = 0;+ v9 r+ Z1 W3 T4 b; X9 X
- ) f* Y, X# v/ } N( f0 M" I
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);8 H8 V1 _) f( E0 b
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);! N+ P8 _/ ^2 u7 ^- e8 t, `
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
" f' _+ W% P) C# K5 }. m
' O" Z) F0 Z- L2 v$ R: B4 ?- dma_addr_t dmaphyssrc1 = 0;
& [. |' @. h+ U ^) H! x - dma_addr_t dmaphyssrc2 = 0;
* x E: E$ C8 e; k3 g - dma_addr_t dmaphysdest1 = 0;0 S3 |9 ~# h. m2 T
- dma_addr_t dmaphysdest2 = 0;
& g- q0 ^! U6 m& ]& a! t - ( n; H. [' q) N
- char *dmabufsrc1 = NULL;' Y9 U% c% ^* H9 P" y( N1 _ U, t
- char *dmabufsrc2 = NULL;
* J" c/ ~+ G! \# p - char *dmabufdest1 = NULL;" d% E0 Y" z3 d. n2 U2 T8 ^
- char *dmabufdest2 = NULL;! j1 _0 {9 g0 a9 @
- ( e0 U% P3 a( U% o8 B( ~
- static int acnt = 512;
" C2 D! E+ s1 Y6 N, H: ^ - static int bcnt = 8;- O( w" o' Z. e5 i$ R7 f3 Y
- static int ccnt = 8;2 i# R& Q. h q6 n: [, Q6 v
6 e( T) e; Z- `" Z* m# V4 N- module_param(acnt, int, S_IRUGO);( J: }# q6 P5 F
- module_param(bcnt, int, S_IRUGO);
% a( X7 v3 @2 j6 A' @; B" i - module_param(ccnt, int, S_IRUGO);
复制代码 - E, R$ [/ _5 h% M% [, m3 y# |
; ^; u8 }8 s: A4 J. N 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用& u/ N+ v, K/ V' F( t) 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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。* b. Z2 \+ n( N5 P( x+ P' z
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。- O$ b# s7 p( L- O- f1 e; V$ a
# U* ^/ [/ B& A+ j0 [+ J
0 Z* {1 G5 u' ]# s; N+ V |
|