|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
! B8 H; L6 u+ l' H- [code]EDMA sample test application
9 }- D4 w8 B+ \4 u& s) l$ v - /*" t& g8 W, G$ G4 B) u5 W7 y
- * edma_test.c( x4 V3 m3 \# m% n) j/ h
- *
, j6 a; Y+ t1 T6 I; U* R - * brief EDMA3 Test Application& S7 y7 V2 q7 a$ R
- *
$ q- U( \( K: L/ l' r0 K - * This file contains EDMA3 Test code.
: b v& |3 h5 p, C$ o6 j - *5 c9 {* w# R' P
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
% E/ q+ F8 u" t8 s) L& A - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT- N- x- g) O, i* g6 U
- * TO CHANGE.
! }) w K+ T& V5 O( i) X/ T8 g - *
, C) f# @ _5 ~- A% ] - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/ I% s! Z- F6 T# A
- *
( ` a2 ]" C2 B - * This program is free software; you can redistribute it and/or
1 M! K/ h0 Y, u - * modify it under the terms of the GNU General Public License as
9 T. Q$ H3 C; O - * published by the Free Software Foundation version 2.- O! X. T8 D$ d3 z# ?/ W
- *
- T1 o5 G' ^) u& b6 ]: Z! S" W$ c - * This program is distributed "as is" WITHOUT ANY WARRANTY of any! J1 l7 S2 n; b/ i( y' Y6 g$ r
- * kind, whether express or implied; without even the implied warranty' D) p9 H, _% Z
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the% n- l; Q6 N/ u9 v# _) |
- * GNU General Public License for more details.
z0 J: P1 D. X! `7 O9 m - */
8 T% Y( m0 K7 D( d - " T: p6 K v, K! A2 H
- #include <linux/module.h>. b+ x7 x S& N
- #include <linux/init.h>
' U/ W) t, g5 K8 X, O0 s - #include <linux/errno.h>
& |% \! h, r( O2 ~0 p - #include <linux/types.h>9 F2 c6 B) M$ G# r0 W# e$ R
- #include <linux/interrupt.h>
' T: s; K0 y2 i1 P) m( } - #include <asm/io.h>5 _: P; B3 f8 [' H5 M2 \2 n
- #include <linux/moduleparam.h>
5 v" B1 n' B6 E; x- j" ` - #include <linux/sysctl.h>
3 q: z! g: ~. r: d" ]* Z. ] - #include <linux/mm.h>1 u3 W: p* Z/ v5 m9 W \
- #include <linux/dma-mapping.h>
$ x2 ]9 U. j+ ^% C1 f; V" Z
( h7 ~7 l; Y& I- U! V! b- #include <mach/memory.h>
9 Q8 G" X- W- q2 ]- O+ F - #include <mach/hardware.h>
8 C9 b, C8 J( E. y* g% ]2 e2 I2 x - #include <mach/irqs.h>. ]% S- a$ B1 R4 a8 ^
- #include <asm/hardware/edma.h>
3 b2 x6 t9 A; y* U7 k2 K- T - 0 s. \' i, L5 j& p& t$ T3 `
- #undef EDMA3_DEBUG
* p% K8 R4 z1 W7 i - /*#define EDMA3_DEBUG*/* ^& J$ i6 s& }! M, S
- ; W3 R4 t1 _& U
- #ifdef EDMA3_DEBUG
/ G: F4 T% g5 O2 o1 V$ n - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)6 ?2 {# R1 H1 I
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)& G" h/ k* [7 K2 [7 P% }, y
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
) p: A+ U0 n; j0 y6 z' z - #else5 G, m2 n% X8 w
- #define DMA_PRINTK( x... )
' a/ `; R! j5 [6 Z3 g - #define DMA_FN_IN
" |: K' }, R9 j& b0 l( L9 ?( Y+ } - #define DMA_FN_OUT
/ D8 H( c i U2 p: g+ U* L - #endif
1 r/ s' Y. g" e( W' k6 Q, h6 a
( g$ I! p( g/ m- ^( p. R, G i- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
; q+ T4 r3 f1 o9 ?4 `1 b, V( p - #define STATIC_SHIFT 3
' p3 R# \ K* c9 b+ g" P! k l - #define TCINTEN_SHIFT 20
( q0 k& ]1 f0 ?5 A9 Y' E6 F - #define ITCINTEN_SHIFT 21( }3 E* I4 z$ z
- #define TCCHEN_SHIFT 22. j% S- F: o* n
- #define ITCCHEN_SHIFT 23: _; \" V2 c+ f4 z% P' g+ V
( p; N {- P6 ?3 l' U0 U- static volatile int irqraised1 = 0;1 `% ]- h+ H. y0 O
- static volatile int irqraised2 = 0;
' V, i; `4 T! S; z/ \8 a1 v1 y' Q - 4 d! j1 Q' V! U8 F a
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue); K7 h! x. }5 g1 a
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);9 \4 O) |1 A: D2 @- X
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);+ T0 [6 k6 c' | a, k% Q/ _
9 S# K' f$ i. @$ u" S' i+ n( J6 j2 t4 H- dma_addr_t dmaphyssrc1 = 0;
6 @) H# \ y0 d5 J4 _ - dma_addr_t dmaphyssrc2 = 0;
B6 ^* T' f% `5 ~& ~ - dma_addr_t dmaphysdest1 = 0;
& j! z3 y& f2 U: z+ d b$ Q - dma_addr_t dmaphysdest2 = 0;
2 _/ {) Z: k2 R3 E, _
6 e, y; U3 w! l# Q& Z- char *dmabufsrc1 = NULL;( D7 X) p" f& \; b$ S1 \7 K
- char *dmabufsrc2 = NULL;
% J- a/ f. m3 {. L# G9 G' J - char *dmabufdest1 = NULL;
" R, h: k6 M( {: A$ U - char *dmabufdest2 = NULL;
, E5 a0 z, ` N1 Z4 l8 i- V+ r - ! D$ h x. @" m
- static int acnt = 512;9 b5 {7 H% |% n
- static int bcnt = 8;" C: G* q' {. o5 L5 V
- static int ccnt = 8;
/ k( O3 |0 k3 r
0 k* H3 y* s0 ?( I- module_param(acnt, int, S_IRUGO);/ q; {- _" _" x' Y1 d
- module_param(bcnt, int, S_IRUGO);2 [6 L6 Y6 T- Q5 Y
- module_param(ccnt, int, S_IRUGO);
复制代码 ) b" Z. t) S( f
0 u& J2 l. m0 D4 c# _
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
+ N5 x& l v# Z2 @$ r# ^' Darm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。9 B( h' @; h6 {7 b5 ~
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。6 N5 J: x5 \$ A+ c @* v
, }8 M- o1 I M. p' I
: X f8 K* }1 G) O$ S
|
|