|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
) q3 L' j" K$ Z9 L( l. N- [code]EDMA sample test application
* O2 q! m& L# `. T# ~+ J - /*+ V; ?" r3 Q( k( S4 _, o
- * edma_test.c2 h% W" X# f7 M
- *
& z& q9 D$ S7 r5 ^6 s7 `9 S - * brief EDMA3 Test Application2 M+ |0 b/ ?" \$ R1 I5 w
- * S: T3 t( g6 E
- * This file contains EDMA3 Test code.- {7 Y0 k: C; m+ n4 A
- *
' c8 V, Q# M( K' ]' ]- |; p - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
5 O4 l. W: d" G$ p4 W7 q - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
' z9 r& b2 t6 k M0 d- l) o% ] - * TO CHANGE.
) O$ m4 V0 k* }; L4 D* `- f, f - *
# A& m; j0 u$ j$ M9 I; X& W4 A7 U - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/" Z( W+ m" d/ u
- *4 P/ E2 ]4 O0 m. s; Z3 R4 r3 J0 P
- * This program is free software; you can redistribute it and/or/ _) P8 N2 b& h* Z' N
- * modify it under the terms of the GNU General Public License as: N8 A4 M5 b/ r9 S) a$ H' ]
- * published by the Free Software Foundation version 2.
6 H! l0 E3 O6 x/ }9 g4 c! f - *" l- n, D8 z9 ?, f4 ? L5 s
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any. S {& B8 ?% s+ b7 A7 \
- * kind, whether express or implied; without even the implied warranty! e# Z+ o3 X) C- [5 n' _( k
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the* E) m2 l/ J( n' O& n7 Z, i
- * GNU General Public License for more details.) v+ W; q: n8 m& }
- */
0 L* T. V7 [3 g0 T& f- i, d* t. p- ] - - b- C; e n5 k! w
- #include <linux/module.h>6 N/ {( N2 a9 \+ E3 M$ p# S
- #include <linux/init.h>. e; t: K3 }5 q4 [4 ?5 ]$ ~5 W/ P3 d) d
- #include <linux/errno.h>
, B: I( e( f' C* |: I# l b1 K - #include <linux/types.h>9 g* \) ?! z; Z) ~0 N
- #include <linux/interrupt.h>. A$ b& c0 {9 q% b" ~
- #include <asm/io.h>* |( ?$ K8 o7 x, E
- #include <linux/moduleparam.h>& y; E; P' N+ b9 [
- #include <linux/sysctl.h>
" Z c( N3 N0 x; W8 n% M/ F - #include <linux/mm.h>4 ~' D0 j! [8 ]* T/ |2 U
- #include <linux/dma-mapping.h>
7 `7 w' N( f) ? - * [8 l. t3 A: C: P
- #include <mach/memory.h>
% R8 T* ?$ B8 T* V - #include <mach/hardware.h>1 y$ R' S" |3 n4 X$ J
- #include <mach/irqs.h>8 Y* _4 G$ C2 {6 U# u$ d
- #include <asm/hardware/edma.h>5 e0 H3 z& ]# E
2 v: a8 R) L1 Y Y- #undef EDMA3_DEBUG, v7 c# `: s2 ~, b+ y# p+ }
- /*#define EDMA3_DEBUG*/
7 }, J1 i9 a6 q
) j Q; i- s$ j2 v% C- #ifdef EDMA3_DEBUG" P! H1 Q# S4 B1 [, V/ D* V& R2 m
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
! K) u$ W i7 l% d - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__) E9 I" Z4 O2 c: R& V5 g
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
6 w% W9 r" r# P: e - #else
% s5 Z1 R/ J' D - #define DMA_PRINTK( x... )* W, v+ T1 r# U3 c
- #define DMA_FN_IN
3 |! v0 A2 O' S( H, C7 ]: r - #define DMA_FN_OUT5 p4 r! B W# i: f: _! e0 Q
- #endif
! ?/ U. y2 z/ s( u2 q& ~ - 4 z* _' G7 _. e. @9 I' c
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)& k7 V$ o% j# B6 B
- #define STATIC_SHIFT 31 J; r4 D% j; b0 h0 H
- #define TCINTEN_SHIFT 20
: L$ }$ p3 a8 ^' Y- q4 E6 L - #define ITCINTEN_SHIFT 21" B4 ?' B9 X7 K% f0 c. g
- #define TCCHEN_SHIFT 22
& p% Q1 ]7 H, r - #define ITCCHEN_SHIFT 23' L- h( Z7 I! e0 e8 m; o5 ?
+ |; F7 u9 `. o2 {9 ~: n- static volatile int irqraised1 = 0;
' a6 @1 n5 E0 i' M( i% X - static volatile int irqraised2 = 0;0 |# E- K* r" [- e
( r& f5 j5 j* t3 ~5 y5 I- J8 o- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);' Z/ s/ w- i- I/ M7 o. `- e
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);4 t7 L4 m' h! y6 I* A: x- {& i
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);. ^2 e8 E) N7 X) K) `! I I
# b0 ~8 l: i$ Z1 H6 \- dma_addr_t dmaphyssrc1 = 0;; }& y j' B# Y3 c
- dma_addr_t dmaphyssrc2 = 0;& Y( V5 L$ h) K
- dma_addr_t dmaphysdest1 = 0;
% O. _7 J: k4 V( t5 q - dma_addr_t dmaphysdest2 = 0;
6 m. F. c% s+ L5 m
# l$ f4 o+ H u- char *dmabufsrc1 = NULL;
3 c% l8 W. v& ]6 a. ^$ j( o( R. T - char *dmabufsrc2 = NULL;
; n) e% g, p/ G5 H5 C; W - char *dmabufdest1 = NULL;
3 a8 M. n- |" Y7 r - char *dmabufdest2 = NULL;
0 Z# U9 A/ i5 @% W) V4 v
. I" C9 u6 g& w5 r- static int acnt = 512;
) @# m/ y% Z& l% \, b% p - static int bcnt = 8;
9 b ?3 h4 `" I+ k$ F - static int ccnt = 8;: v$ s1 U5 T. @; c1 N% l @' i5 Q
- 3 y9 i6 |$ M% N+ Y
- module_param(acnt, int, S_IRUGO);! R/ w/ o; e& X7 @1 p
- module_param(bcnt, int, S_IRUGO);
; v' E! a6 [/ a! E |. S - module_param(ccnt, int, S_IRUGO);
复制代码 - b" o3 j( w: w- S$ S* O# G
/ r% |. `: t8 V9 S6 W- ^
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
H3 H; u; P( iarm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。! C2 H6 s" P- o) b d2 i4 W
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。 l% \% g; H) V6 I' [
; | J/ f* Z# U) H6 `4 C7 U- T5 N6 A
# h. {$ B: s ~ |
|