|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 % K9 v. N1 P( y4 d* O
- [code]EDMA sample test application7 u8 g( y! s; ~) A
- /*- P$ k4 n9 k5 `
- * edma_test.c- h/ a/ H, W) |% L) [
- *
7 e* ~: Y( g0 Y2 \ T* M - * brief EDMA3 Test Application2 C R q1 U7 Y5 U5 g" ]
- *5 ~, L: G, \: A5 _
- * This file contains EDMA3 Test code.
5 p5 b. j- G% p+ R9 C: N - *8 @& w6 {# k: W2 @( W
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE% t( W5 i9 N" ?* i ^: V
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT) w3 Z2 W/ D! [/ ?0 p/ ^
- * TO CHANGE.
, m( }6 c2 Y$ o1 S9 K. e/ L - *
' x# o2 S6 W6 ?* z3 k - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
: a% }7 m2 K1 l0 V0 N9 N - *3 r+ C% T( j; N' X2 q# z2 e3 F
- * This program is free software; you can redistribute it and/or
3 {7 g! i2 ?* E+ f - * modify it under the terms of the GNU General Public License as
9 m! U! |6 W, p - * published by the Free Software Foundation version 2.
; i/ v( c E" M) \ - *2 F* |( H' T8 G+ F @# }9 m. n9 o
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any6 S) h+ S3 i: z' Z
- * kind, whether express or implied; without even the implied warranty5 T1 [8 r0 k' i
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* y$ z, w; k3 T7 X. o" C9 S- f - * GNU General Public License for more details.
3 [8 i2 W3 k& d% D/ h - */
, H: y5 |4 C* X- D3 F. v; X
: o$ H6 y8 n4 L& E- #include <linux/module.h>/ s0 ]( Q( E& j
- #include <linux/init.h>: e: e) K8 Z- J9 q/ m H( F! a
- #include <linux/errno.h>
2 |7 _' P$ x" z9 S - #include <linux/types.h>
" M2 M# w1 L+ `* V( |( N' Q- @7 |( } - #include <linux/interrupt.h>+ U# q8 c3 }. @
- #include <asm/io.h>
u! x; _+ s5 l - #include <linux/moduleparam.h>
# g: V$ L; E$ @" L, e0 C, A - #include <linux/sysctl.h>
J" [1 h' ^+ U5 \ - #include <linux/mm.h>& c G. C2 z6 b! W
- #include <linux/dma-mapping.h>. u+ J+ S9 a5 j
/ w$ [; b |+ d+ f* k! h y% u2 \. H- #include <mach/memory.h>
; F$ q8 ^" W4 ~+ Z. }+ P: n - #include <mach/hardware.h>6 h( h# N( l+ W2 N9 n
- #include <mach/irqs.h>3 C; H1 E! h3 l" O+ ]
- #include <asm/hardware/edma.h>
, T6 l4 K9 i4 F4 y3 K - 8 R* g6 n9 y4 G
- #undef EDMA3_DEBUG
2 I7 ]) w0 S6 W% | I* T' ~ - /*#define EDMA3_DEBUG*/
' U8 h! ] f7 t: c - - G Q/ C0 E, h- Y1 t# ^
- #ifdef EDMA3_DEBUG
. H8 }6 I4 o" W( o- p - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)% f7 V Y) y+ }. ~7 h
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)5 _6 {; F% L; i8 W
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__): U- I! _- U3 L6 V* T( R( e
- #else
3 y, i# `9 [( S: L - #define DMA_PRINTK( x... )
9 C9 r' }6 \4 O$ r - #define DMA_FN_IN
* ^. ?- ?& B2 l' L$ A. M - #define DMA_FN_OUT
% j# o- L+ `' w - #endif' ]* f* }1 D/ p/ F( m$ ~
- , e: F' h& S$ K) [4 N( S
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)* j( B2 J7 D( w7 W
- #define STATIC_SHIFT 33 u W& I9 @+ c, M, H- @- u
- #define TCINTEN_SHIFT 20
' V1 X, P4 N! T8 }& G* v - #define ITCINTEN_SHIFT 21% ~( i) f& v L' N3 M! j: {% X c
- #define TCCHEN_SHIFT 22, X ]* L" M2 o9 U
- #define ITCCHEN_SHIFT 23
) y3 x0 E4 H# {% O: I - & y8 P# A6 f8 {8 @0 V: s) V# |
- static volatile int irqraised1 = 0;
0 u# `* ^$ t/ Y# o0 ]4 } - static volatile int irqraised2 = 0;4 R" o4 y1 F- `. W: h! {
8 B) D/ H" O* N6 D' L% P- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
3 Y: \) M7 v; h) a' J - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
; k/ l6 J) W0 D4 `( q9 d. { - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);, S/ n* O" v% [) f
- I' Z6 `7 y1 ~7 [: Y
- dma_addr_t dmaphyssrc1 = 0;
0 B; @5 b7 o8 F - dma_addr_t dmaphyssrc2 = 0;
! I" ^$ Y& G' m8 H' \7 o5 i - dma_addr_t dmaphysdest1 = 0;- C5 b. f! B8 o
- dma_addr_t dmaphysdest2 = 0;$ v; Y% o0 r8 U6 L( u; X7 q
- # S i. |' Q7 ?4 s" y
- char *dmabufsrc1 = NULL;. T+ E( S5 w& j7 W1 p& D J" u
- char *dmabufsrc2 = NULL;
; z7 x; [9 M& H3 C( o) ~0 b* D - char *dmabufdest1 = NULL;. M" R: q f2 K3 I# S3 z
- char *dmabufdest2 = NULL;
( K8 T9 O& T, X
& I9 Z7 x$ x9 o1 @* P8 s% Y- static int acnt = 512;! l- Q( C7 h" @3 r2 n
- static int bcnt = 8;
9 f* z- T7 R# n5 ~ - static int ccnt = 8;
9 F, P+ U& \- L: K( e: g1 J - 9 m) N ?8 [2 R- [. s2 t# x
- module_param(acnt, int, S_IRUGO);
c+ X6 t& b; ^/ m5 Z - module_param(bcnt, int, S_IRUGO);* N1 p" P5 t* N, ]- B+ l n
- module_param(ccnt, int, S_IRUGO);
复制代码
1 e) w5 P' ]# F) U' M% g9 D4 x$ J% `! R" @) x1 J* H
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用, Q* l# \+ m& [5 i7 H0 l, A
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
2 z. z$ _+ B$ i6 k) Y0 |, }! x C( d 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。2 f) s1 Z% b3 j U+ o
4 O& P5 R" a# J" {& R# i0 g
3 G1 ?3 s6 o7 @1 X6 v) Y, n |
|