|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 0 ~- u q! U3 Z1 D& ]
- [code]EDMA sample test application
7 Z9 g6 I. Y: F/ J6 y( f5 B. D/ G7 [ - /*
; p: m4 X' O& C$ `' K; G; m - * edma_test.c
+ c5 I( h, K& `/ V: g: B - *
C8 a3 @5 [2 M6 i6 r - * brief EDMA3 Test Application4 ^4 G4 \7 k+ a; K' `% E+ {
- *4 X# }2 m7 e' |" c6 r& A, g/ I
- * This file contains EDMA3 Test code.
, @/ p( w" z U) i- p' H - *
; ^8 t6 H, ]+ o - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
' c. v* |% p3 N+ g - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT7 G4 i8 v/ E( L5 k$ R* O6 ^
- * TO CHANGE.
8 D: ]+ g! G5 G+ a' D - *
( m' m7 I) n+ E8 S% x - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/ y" @) U1 ?* d7 g- R" \
- *5 T6 H. V) i8 R. g5 B. d
- * This program is free software; you can redistribute it and/or
6 @1 o6 t$ ^( ]8 U0 \' y/ k0 S - * modify it under the terms of the GNU General Public License as5 e w7 G' m+ C( ?9 w
- * published by the Free Software Foundation version 2.
8 ]! k1 t7 i/ w X$ g9 a7 l - *0 d4 O: R9 H/ n
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any
# h3 {* o8 |6 Q1 \! [ - * kind, whether express or implied; without even the implied warranty- Q3 P2 R, Y6 B; p. [
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the7 {7 y& t O0 @9 B5 N5 I
- * GNU General Public License for more details.
; {+ J: Y# S8 E3 c - */
( o5 a% h# H/ n, ^6 H) o" l6 | - ) o7 o3 i& @* M& I0 N. K6 `9 M
- #include <linux/module.h>
& J# F; m+ m7 ^! j' ?' [% }3 h- a% C6 v - #include <linux/init.h>
; N5 C4 n8 W* ? - #include <linux/errno.h>. i& @1 s- R- x& I( [
- #include <linux/types.h>' h# |0 h' Z6 \3 e9 b7 i# W
- #include <linux/interrupt.h>% f# l0 o4 Z& e$ H+ Q* V! u. h
- #include <asm/io.h>
4 o- Q1 Q, L4 B& }9 j/ r3 J - #include <linux/moduleparam.h>
$ G; b* y% F4 E- v% s - #include <linux/sysctl.h>
$ t9 `. ]. L: O, R# o# b - #include <linux/mm.h>
4 {3 K, ^% _- M! p! u - #include <linux/dma-mapping.h>0 e, r) Q3 i0 e# g! _! R
- , p) H1 ]. P! L8 }
- #include <mach/memory.h>$ \+ Y6 O% D; V" p! m0 A( N( H
- #include <mach/hardware.h>
* k* ^0 Z: I; ~* _2 m9 i - #include <mach/irqs.h>
# @8 K9 K; L4 u( N8 M: S - #include <asm/hardware/edma.h>
/ O. ~6 c4 N5 Q" d
% C- o4 v6 t% \- P% c6 l- #undef EDMA3_DEBUG
9 q% R u d P2 s - /*#define EDMA3_DEBUG*/$ L& f$ t. p. ]6 a1 z' ?5 @
- : c+ S: @0 y" M# U- q
- #ifdef EDMA3_DEBUG/ }" I5 r% H1 {; r3 Z& w! M; a1 b
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
/ }: l: R0 w. c/ S# X' @% @ - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)& {$ W& _- c) `! D5 r8 _
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
' I) f0 C; `) L - #else; F$ h& U" h! F
- #define DMA_PRINTK( x... )7 j2 `. I3 H% L" ]" S/ w; l
- #define DMA_FN_IN
" x1 Y4 h+ f% d( h- e - #define DMA_FN_OUT5 j- f2 J$ ]% z. J6 ~9 H
- #endif( {/ q4 x7 j6 c! V; S
& d2 r `" o5 {: k8 |- #define MAX_DMA_TRANSFER_IN_BYTES (32768), L4 B) f+ R% W0 S& s- q. B: @, d
- #define STATIC_SHIFT 3
7 B9 w. Y; f& ^7 ` - #define TCINTEN_SHIFT 20* q# X# ]* O2 y/ i( y( g0 s* k6 U
- #define ITCINTEN_SHIFT 21# }5 a) v4 ?) P# w3 f6 ^: G
- #define TCCHEN_SHIFT 22& [9 x% u2 X0 d5 @' t
- #define ITCCHEN_SHIFT 23: ]3 B( L* C$ N. u5 l
- + q% |2 [5 j8 a- m2 R: H/ i
- static volatile int irqraised1 = 0;
% {( Y3 o4 m8 y: G! S# i8 I. O' P - static volatile int irqraised2 = 0;
4 `% U: ^, d, F) w" B; s! ]2 p
4 E& Z# M1 z$ u' q$ @- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);" v- R) R+ L7 c& V! J4 o: }
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
; y$ n: a, l& i$ ` - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
- ^' a9 ~0 J- D; p) w7 B - 2 E! c( s# k$ r7 `0 Y: P
- dma_addr_t dmaphyssrc1 = 0;
8 d4 `4 }* G n8 x1 v' e- M - dma_addr_t dmaphyssrc2 = 0;
7 G5 ?9 Z9 A' h2 L2 N3 S# ^ - dma_addr_t dmaphysdest1 = 0;( L: s+ ^, \- g1 h) b
- dma_addr_t dmaphysdest2 = 0;
) b/ Q6 z; n' k& o9 [! Q; m" t
9 d" n1 M; \4 }- char *dmabufsrc1 = NULL;: K. x1 ~+ z. N" A$ E
- char *dmabufsrc2 = NULL;3 r- Q* o! V/ T5 `1 }
- char *dmabufdest1 = NULL;
7 V9 E* N0 Q6 K/ S3 Q, o - char *dmabufdest2 = NULL;1 }, ] B0 h7 r
- ' _$ C1 ` p1 R
- static int acnt = 512;
4 f' Z& f* Z" B }( V - static int bcnt = 8;
5 X5 h* w& D# x) u1 Y5 M- _ - static int ccnt = 8;8 z3 z) t7 t4 j4 y4 e( R4 n: M
- 3 @. |% x& _+ i8 O- l& o/ ]
- module_param(acnt, int, S_IRUGO);
7 F7 X, C$ N# H4 u* o: _( I3 w4 Y - module_param(bcnt, int, S_IRUGO);
1 c/ s: l9 X( ]# G: O4 `1 L5 e - module_param(ccnt, int, S_IRUGO);
复制代码
" R! j' O5 l6 a3 F3 U) M6 H
; I8 T% s5 v$ Z7 f" U 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
. f, O. z# f1 k; O/ Zarm-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 ]0 K) Y$ c+ z 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。" \+ b6 P t9 F$ m( U+ n; J
4 A5 y3 y6 H, @+ x
' Q6 q) v* w" S5 M3 j% c+ s( R |
|