|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
% ^6 O7 D4 i- \+ i( V- [code]EDMA sample test application
9 F5 i( o% t8 ]- e, G5 c - /*" {/ M( g' d! k) p' K! X5 Q2 b: v
- * edma_test.c
8 N6 s+ p2 @/ H) A$ F - *
& h8 X7 G; k8 }* m& w - * brief EDMA3 Test Application3 e2 q. @' R) m, y
- *
- l2 O7 j' f0 [0 T# [0 h - * This file contains EDMA3 Test code.
9 F, U D6 N2 x* d - *6 G* p0 N1 z* m* ]+ K
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE( o. p8 Y5 N- P
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT# `# E$ t6 D$ i
- * TO CHANGE.& T& t9 ^- u& y& N i" ^# p
- *% N& P S) E- |
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/% a: i' l. O% H+ B
- *% I1 Y8 ]$ |) ?" Q& [9 W$ X4 ]
- * This program is free software; you can redistribute it and/or
/ m1 {( x9 B! Q& \* B1 y% W1 O" B - * modify it under the terms of the GNU General Public License as, p0 n5 [. A ]8 a l5 w
- * published by the Free Software Foundation version 2." _8 R+ t: D& p0 y& Q, \+ ~1 i
- *
$ ~* V6 m2 E' R7 U l - * This program is distributed "as is" WITHOUT ANY WARRANTY of any
& p5 q* L7 {! n - * kind, whether express or implied; without even the implied warranty2 T' ?& ]+ B, }4 h
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the, h. b" Z" t! @# m ~, D5 ^- ~# f
- * GNU General Public License for more details.
2 n$ f2 |2 X# x, u - */3 M6 j: h8 k' o; b: z1 S$ z m* L
8 Q9 S& Q+ Z2 {- #include <linux/module.h>
$ V. q' {6 a, p7 H! R - #include <linux/init.h>2 j& D$ ~* l6 J t- }
- #include <linux/errno.h>
$ k# a3 ?, q7 s" G: o; D - #include <linux/types.h>
$ ?* t$ b& D7 W2 P - #include <linux/interrupt.h>
c7 K+ _2 B' E/ p. k - #include <asm/io.h>( j) b. u; Q0 H6 |4 n9 L- Q6 k! l o4 `, y
- #include <linux/moduleparam.h>( W2 W1 Z, {+ Q: @3 O
- #include <linux/sysctl.h>4 } f c0 w. d1 I- D) @) Y. Q/ J
- #include <linux/mm.h>
' f* y* C/ L( s8 C' \- } - #include <linux/dma-mapping.h>: p8 A5 }& c5 V
9 n1 ~/ I: }9 }/ e. G' R3 E- #include <mach/memory.h>
* u# U. x* B; O1 r$ x. @' {$ P - #include <mach/hardware.h>8 j1 x+ V1 x F5 d: d) ~+ F# V; X2 p
- #include <mach/irqs.h>
- f [" A' {" M" ^5 I' ]* h - #include <asm/hardware/edma.h>5 f; Y5 M7 B" [9 Y9 Y# I
- 8 @/ g8 T6 b! v0 Z) O
- #undef EDMA3_DEBUG5 r1 I, D" i8 j* s
- /*#define EDMA3_DEBUG*/ f i% n1 E9 @ \: e7 w7 X
1 |' m) _8 J5 Z5 n, e! T1 A- #ifdef EDMA3_DEBUG
+ b$ \, q: r! T8 W) E - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)' B& w% c! a n7 _7 H+ C; I
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
9 \4 ]$ q" ^ m9 H& K( _! d - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)/ Y" U% ^6 Q' q
- #else6 m7 e2 o6 K5 T. d
- #define DMA_PRINTK( x... )) h/ @7 H; I' v6 |9 |
- #define DMA_FN_IN! h# l- C4 j- i6 k7 M
- #define DMA_FN_OUT4 H" |; g$ f# f+ ? e
- #endif6 U9 Z1 O9 y5 x; H
) X h0 W! f/ O |; d9 p+ Y- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
: G1 `1 e0 o; @- \' N, `) b - #define STATIC_SHIFT 30 u# s% `. _' n* [, ]: L1 T- |* E
- #define TCINTEN_SHIFT 20
; s3 R) o- E/ d- N - #define ITCINTEN_SHIFT 21
* [3 \+ k s1 g5 |7 Z+ b6 ~, p - #define TCCHEN_SHIFT 22
2 }8 Q; j( r& e, L: C - #define ITCCHEN_SHIFT 236 V5 [: v) c0 D4 k; }9 I% B( s
- $ V; \1 I3 M/ X! f- v) e! e
- static volatile int irqraised1 = 0;
. a+ p- X/ ?) z2 [ K0 ] - static volatile int irqraised2 = 0;
9 i8 Y# `. |- ? - 0 B+ Z: d, p3 n+ K. a+ a
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
' O& h" _# x/ T+ x: f; u& i - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
* d" C) D6 \0 B' I/ f - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);+ ]4 `5 k6 S3 A2 J3 ~. h
- ( R0 `* e* E/ t F0 l
- dma_addr_t dmaphyssrc1 = 0; ~" w: x4 H/ n3 @: N
- dma_addr_t dmaphyssrc2 = 0;1 O7 x, W7 z7 I/ ~
- dma_addr_t dmaphysdest1 = 0;
) b8 D+ ^; v- o) D - dma_addr_t dmaphysdest2 = 0;
$ V8 P) l- o. l+ z
' G2 U! s/ ^4 g" @' q2 |- char *dmabufsrc1 = NULL;5 M1 t7 V* y; j1 H6 M
- char *dmabufsrc2 = NULL;
5 ^2 n+ J- g4 h - char *dmabufdest1 = NULL;
# \5 ?! k% m- n3 F1 \7 d! B - char *dmabufdest2 = NULL;# P/ A1 ? w, H+ i. T7 c
/ c; s9 e9 _/ e8 {9 i+ R! M- static int acnt = 512;& k4 _$ o6 }+ O$ s# c$ l
- static int bcnt = 8;
+ |- q. s, e6 ?6 U - static int ccnt = 8;
- N8 Z4 S' r0 t7 h* n - 9 z1 N9 j K2 _
- module_param(acnt, int, S_IRUGO);! }5 _+ B Y+ o8 K o7 B
- module_param(bcnt, int, S_IRUGO);; a+ Z( S# l6 s; P2 I7 i* T6 Y; v
- module_param(ccnt, int, S_IRUGO);
复制代码 2 ?, z! B4 M2 d/ C" }+ ]- u$ |
: |/ z0 R) e0 G+ Y* I
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用# |, V2 b; p" i" d' F3 f e
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 d9 [5 y3 y! [# j
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。- v' H0 V8 ~/ o7 m) N9 {
. }" G7 b* t5 n6 ^( \& }
* D) c! P& H6 M/ E |
|