|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
. N* E/ |$ l7 Q- [code]EDMA sample test application
8 M/ ?% {* K4 O4 N9 R - /*
( K) f1 B! w2 d+ g! }$ B5 T/ @: t - * edma_test.c9 I0 T5 I: ~6 F2 p. P5 f3 {
- *- K- [7 Q2 m |
- * brief EDMA3 Test Application
9 ^4 c% ]* I" ]1 R1 b - *! _% Q9 W6 j- I! |
- * This file contains EDMA3 Test code.2 X) |0 ~( b6 ~, R& i$ b
- *" M$ r2 e- `: L& } m" I& }
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
' ]+ K3 j& d0 j1 y/ T& G+ n - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT. X" v- R, W9 E
- * TO CHANGE.
# J# E: N' d& f - *
4 ~% y- T3 e% ~ - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
# u( v7 u& i% u, x! U- }$ a- K; y - *( Z0 |7 J$ ^+ g9 X
- * This program is free software; you can redistribute it and/or
$ j/ o& E; U; R# Y - * modify it under the terms of the GNU General Public License as/ ^5 |1 u9 L2 A! a2 r
- * published by the Free Software Foundation version 2.: @0 G# k( e) e; g G
- *
* F3 V' |/ i# q* M w - * This program is distributed "as is" WITHOUT ANY WARRANTY of any
8 k! R0 M3 `, g, O3 U4 f - * kind, whether express or implied; without even the implied warranty
* d+ ~+ Z, `+ K- W# @ - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the, |" Y* [; a( s6 ^; i6 B5 A
- * GNU General Public License for more details.$ c* E" l k F) x1 \* C& F# _
- */5 o( o1 X" {" I) x. t
- + K% r1 |( H! t" F! ^# M* Z
- #include <linux/module.h>
9 G5 U. v0 V# e0 W- A - #include <linux/init.h>0 _, a9 d: d( R/ G
- #include <linux/errno.h>
3 E8 [* l- I$ }' c - #include <linux/types.h>! r$ C9 I4 r) [! o( H
- #include <linux/interrupt.h>
: s7 i' L: \ e5 H5 O3 {4 M - #include <asm/io.h>
, N: A1 r0 E, i, e1 v6 S) t B& f - #include <linux/moduleparam.h>
8 J/ |" l& H; ~) m/ _( Y0 I - #include <linux/sysctl.h>
. z1 a; N- J2 U* I7 a - #include <linux/mm.h>: N2 \2 J( ^6 B# ~
- #include <linux/dma-mapping.h>$ j5 `- M( X5 L4 ]5 k
- 5 y( `" ]+ @% O, W; ~
- #include <mach/memory.h>3 w1 t' g" K6 s) L% e
- #include <mach/hardware.h>2 t P$ ]7 b3 F4 o% V$ @
- #include <mach/irqs.h>
, L: j4 m6 N: @8 @/ I* y0 J, G! b - #include <asm/hardware/edma.h>, K. w1 \7 M! i9 [ k
- & W) {! p! M- ]. V$ j. @( y
- #undef EDMA3_DEBUG. g- c( U* V) j) B$ s4 |
- /*#define EDMA3_DEBUG*/
2 b0 I% ]0 W3 w3 A/ L - 4 M, d, S; Z4 Z, W' R& @( ~
- #ifdef EDMA3_DEBUG
3 q( ^0 }8 N) X- Q8 u% K - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
8 n9 X: m0 y0 N+ }( p% \ - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)% @4 G' z: C6 w3 J8 W3 Z, ~
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
# |9 V5 t5 V, ?' G) r0 f - #else7 h1 w3 T( @/ p" U
- #define DMA_PRINTK( x... )
0 X- W9 ?6 w) n8 g - #define DMA_FN_IN
x0 _& `4 l" \: C7 L - #define DMA_FN_OUT+ J$ y% M- ?3 l
- #endif
3 q( j6 ~) @& E1 N& L
5 s3 b# h4 b7 y; E# n3 q- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
6 j4 C- \; {4 P* @* r) S - #define STATIC_SHIFT 3+ I1 j5 D- b& T( W
- #define TCINTEN_SHIFT 20
9 R2 |& X: Y0 M+ c G; R7 \ - #define ITCINTEN_SHIFT 21' T- {6 f6 G% R1 j/ y# y# c
- #define TCCHEN_SHIFT 222 V# |# X3 ]- I7 c# f. x: b) ~9 x6 l
- #define ITCCHEN_SHIFT 23
' E. x0 ^1 e9 v1 e p9 W
7 o" t: b$ _- J- static volatile int irqraised1 = 0;# d) _# b; r# [) _+ Y
- static volatile int irqraised2 = 0;: i# o. p! |+ w# T5 Y
) f, R3 O4 I. ]! R# y6 \- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);9 i6 h1 _$ I, o+ Y7 Y3 M# e
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);" R; _1 Z/ l3 W0 w p
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);3 l* x3 S) h+ r+ C& Z
- 4 t6 w. a1 d% z. j! m ~9 L9 ]
- dma_addr_t dmaphyssrc1 = 0;' s2 W* U1 v7 H: V, D
- dma_addr_t dmaphyssrc2 = 0;4 L! e1 G* y1 T0 u8 Q9 T% M
- dma_addr_t dmaphysdest1 = 0;4 T! x4 S: z( i, W2 n
- dma_addr_t dmaphysdest2 = 0;
$ K, H; ?, P1 u5 ?7 N
! w) N! t1 W& |- u- char *dmabufsrc1 = NULL;( W$ q7 N, {3 ]% N" c
- char *dmabufsrc2 = NULL;* L, V6 T5 d" a# j
- char *dmabufdest1 = NULL;' W$ M, H% H& Z! h' R% K" g0 b
- char *dmabufdest2 = NULL;
3 [$ _/ v; t) o6 ^; o: b2 ~ - + d& n; s3 v2 ^4 k0 B8 W
- static int acnt = 512;( }; ~8 D9 r5 B; X
- static int bcnt = 8;" j# E: b) J8 {) q4 Z; P
- static int ccnt = 8; i, w# ]& H6 E& d3 J! R; p& z* o
- : o0 k3 O/ r( ?8 o, Z' {
- module_param(acnt, int, S_IRUGO);
) _" c# Y( z$ u$ d5 O/ |- ~ |: J7 T - module_param(bcnt, int, S_IRUGO);2 r- i, A. p" ]( A) L
- module_param(ccnt, int, S_IRUGO);
复制代码
Z; R& u2 J* Q9 g3 Z
( g8 U7 T$ S" D) x 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
& g0 N- a0 i) l) }, K6 Aarm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。; d. h+ V& F$ w9 r
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
0 q6 m6 m. ~2 s- M1 F5 K4 K Q7 L9 h( N! l3 Z5 @* y: |; a
3 a2 O+ e/ Y/ J; c |
|