|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
B% l7 k4 y$ P- o- [code]EDMA sample test application
$ h; x5 z& W) Q - /*
: m* g& `% q# _( d' Z - * edma_test.c
. c1 m0 q$ {( K& I3 V9 m - *' C0 a7 s: w* M0 Y) [0 r) L
- * brief EDMA3 Test Application
$ y3 ]. S3 ?3 a2 `0 g - *' I/ T/ Y9 z3 K4 n6 h
- * This file contains EDMA3 Test code.
) j. X. F$ {6 ]" u( a - *4 G3 e1 N" a7 g# v4 n6 V, C( Z! ?! f
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
/ A, f* L1 ^7 r - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT" o N) s( h' ^) U; V
- * TO CHANGE.
: P/ i x( g& o5 f. w# I8 ? - *
3 V: t: v$ B/ F - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
: E4 i1 V- y" \) m: _. b& G4 y z - *1 R/ e8 A1 n v1 H) w' O& A
- * This program is free software; you can redistribute it and/or& F- I6 M6 {/ l6 j2 M
- * modify it under the terms of the GNU General Public License as) T9 M. l' P2 W4 ~3 u" d% P" {" |5 }
- * published by the Free Software Foundation version 2.
& o' Y/ K8 z' l, L/ o - *. Q8 i Y3 s5 M, _* c0 ~3 z
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any
- F! p1 l' O% c# Y& z - * kind, whether express or implied; without even the implied warranty: y* n( k) Y/ c
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the9 t9 j& i) j# r7 }; a
- * GNU General Public License for more details.
! S) q/ \( G; M9 ^' b3 x; g6 n - */8 \$ a* ]! ?7 [2 E5 m
l' L: K+ @* }3 {! }5 v3 c2 R9 f- #include <linux/module.h>9 k, L' W2 X6 Z1 c3 s
- #include <linux/init.h>
( n# V+ R% J! x/ v/ W6 i - #include <linux/errno.h>
; y x0 i/ u1 l2 v; ^/ r/ p" v - #include <linux/types.h>0 ^- j+ x. n9 U G
- #include <linux/interrupt.h> d, D z' x3 [% r9 h1 o; {. d1 y
- #include <asm/io.h>) e9 ]& S) j: t
- #include <linux/moduleparam.h>
( w2 J* U( t1 ~7 z- p3 ]# ?- a) Y - #include <linux/sysctl.h>
% j! X; `' i! ~5 {9 i/ k - #include <linux/mm.h>
- z, N; `" h8 u% p! } - #include <linux/dma-mapping.h>" `, J0 Y* V/ H) l3 J+ V+ P
0 M, \; F5 J6 @5 H- L( ~- #include <mach/memory.h>
9 [# T8 ~8 f6 j- ]( g" o - #include <mach/hardware.h># Y- M) G( E$ m& E
- #include <mach/irqs.h>9 t# \! M- D1 b' \5 s
- #include <asm/hardware/edma.h>8 \# e1 s3 y8 v O0 a
( K8 c# m( P0 m! a6 c+ f/ C- #undef EDMA3_DEBUG z! e* q R- t: L: @
- /*#define EDMA3_DEBUG*/* E! S" f1 ]( |$ R0 @$ f
- " M, k& K0 |1 y& ]+ D) L: H, [3 b
- #ifdef EDMA3_DEBUG
7 g5 ?. C4 M5 ]: ]2 k8 l, P - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
8 v$ X# S( c5 \4 w+ \3 | - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
5 V/ |. o/ m t+ \3 ?+ A7 | - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
" ?$ g$ m' ]% ?/ s6 T" P7 E - #else
~# r6 T8 O& N5 U7 E( X - #define DMA_PRINTK( x... ): x. e9 s' D8 I0 d8 K3 }
- #define DMA_FN_IN
. A6 Y! I0 X. ^9 C! Z4 u0 S - #define DMA_FN_OUT
6 l7 s6 M- ^/ C* b# H' | - #endif
2 C, l( ]9 u k: ~/ V
9 ]5 {- N: Z$ v7 T- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
+ I$ v5 [/ y4 a5 b5 S* O' I - #define STATIC_SHIFT 3
; Q2 G9 b! D3 g4 w - #define TCINTEN_SHIFT 20
1 v+ B; G- Y8 S& S1 ?3 N) h$ ~ - #define ITCINTEN_SHIFT 219 r7 G8 I; @3 U. f( Z# `
- #define TCCHEN_SHIFT 22
1 ^7 w4 t9 m% |) \6 j1 @9 ` - #define ITCCHEN_SHIFT 23* i9 _0 f/ T# y+ s" a- i
- 7 A. i" D/ |: `
- static volatile int irqraised1 = 0;$ A# ~1 U8 {3 M- a- P# T0 A# u9 A& M1 x
- static volatile int irqraised2 = 0;- U. K% j9 y" s% t+ o$ k
; n3 J2 |' Y/ _5 G9 F4 |- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);& ]3 W1 K% c# ?- n6 P1 x
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);. r" D6 l8 s/ [
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);3 p9 p$ ]4 E* @+ p6 g9 [8 [
" x8 Q& C3 O2 q0 X) H- dma_addr_t dmaphyssrc1 = 0;7 o1 H c: b3 U5 _' o
- dma_addr_t dmaphyssrc2 = 0;
. s& r' ~! v1 [' u/ ~0 w - dma_addr_t dmaphysdest1 = 0;: p+ B5 I B% p, G( g
- dma_addr_t dmaphysdest2 = 0; Q: k3 l2 ^# [: [ t2 y# c
( B. b; ~7 A1 Y/ I( A3 c3 R9 y- char *dmabufsrc1 = NULL;' D9 ]0 E3 s( J& b
- char *dmabufsrc2 = NULL;( M0 o( s6 y- \( [# N8 Y. [1 b
- char *dmabufdest1 = NULL;
$ M! Z, R. \$ m3 i1 \ ? - char *dmabufdest2 = NULL;2 f( i' K+ q$ ?
- 2 m: S* U" \. N5 f# {$ ^8 Y
- static int acnt = 512;
4 Y* J& a+ e/ q! k; |' s - static int bcnt = 8;
9 S+ T, |, \# m1 A - static int ccnt = 8;+ W" _: J; m) O' Y( W# p
# C. r% ^/ i) Z6 m7 c- module_param(acnt, int, S_IRUGO);5 k! }# d3 n% @/ i' I
- module_param(bcnt, int, S_IRUGO);3 b& l! b* P2 {/ J% f# O
- module_param(ccnt, int, S_IRUGO);
复制代码
. w. ]& Q+ C% B* J
5 o" y4 K$ ]. E# j m1 g 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用* T6 t: s: O+ `3 K. V5 e3 }
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
; w/ U6 U7 s$ C/ U: K! P3 } 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。# _ u; Q' g/ s% K8 i3 C
$ L/ y4 M8 Q, [, x3 A- y
) }2 b8 c) b8 K |
|