|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
! }$ C) b- R" C, j7 Z G- [code]EDMA sample test application
: {9 p% p5 j& T2 H' A8 _! w - /*) I/ U6 c- d- E: `* x$ o
- * edma_test.c/ `* m1 O9 L4 c8 W a. X1 [
- *
/ | {' `; n8 D, V - * brief EDMA3 Test Application
3 o* e0 u7 K3 W3 p' n1 z - ** k, Q: y0 c1 w6 l6 Z k
- * This file contains EDMA3 Test code.! q& _# f& ~: v1 p3 u
- *
& N& h+ z2 v: |3 x4 h0 j - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
9 s4 }8 Z, v1 r" p6 ~ - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT v! d$ }) U v5 x# {) ]: G! y
- * TO CHANGE.
' k. N6 ~) X' [8 U* Y- m% w - *
8 c5 y3 y0 I' v# ^ - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
) b$ H4 i5 h/ Q; d9 q5 k0 b - *
# c& y) t8 {& K8 B [& `6 X' Z - * This program is free software; you can redistribute it and/or
$ p8 F8 l! T2 H0 J$ r: k4 e - * modify it under the terms of the GNU General Public License as
& q! B5 v; U: L6 s% Y7 d - * published by the Free Software Foundation version 2.1 z4 s" t( q, {9 W1 s* P
- *
/ b5 {5 h! n7 m$ k) v2 |. R - * This program is distributed "as is" WITHOUT ANY WARRANTY of any
9 m3 x- [& I0 n, g - * kind, whether express or implied; without even the implied warranty, W6 b: x' F6 K4 q4 J* ^& H
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
% x/ Q9 R: m! T; p1 I' A, Q - * GNU General Public License for more details.
9 U6 G% p( K+ F$ M& i - */. e" A$ Q$ p7 O# b
- ' e5 g; U( O5 A! R$ v
- #include <linux/module.h>
+ k3 m7 ]2 H7 C: T9 W# K+ W - #include <linux/init.h>4 p# A u1 E. K4 x# P! m- j. C
- #include <linux/errno.h>$ E2 P3 f3 n3 T" V7 q
- #include <linux/types.h>7 ?2 h$ i5 u5 K+ w9 J" j
- #include <linux/interrupt.h>
1 U |- J( h+ A; | - #include <asm/io.h>. ^6 u" W9 r% e
- #include <linux/moduleparam.h>
, H9 O' C' V( p# j' | - #include <linux/sysctl.h>7 L1 C( O3 L# q% t
- #include <linux/mm.h>
B5 s5 X) s$ j3 L) F. G - #include <linux/dma-mapping.h>! S& G0 Q, e2 T! ~- V) X3 V
4 y; @3 d# o0 D, p9 ]& [9 Z- #include <mach/memory.h>: t2 \& x" \% y
- #include <mach/hardware.h>) N- @& g/ g1 z7 h2 z
- #include <mach/irqs.h>
, r% v: E) @3 r# A - #include <asm/hardware/edma.h>4 V6 J" ~- q. j& _, P' u; y& A/ s+ Q
1 O- n1 @3 E) f; `& z) ]' L- #undef EDMA3_DEBUG' K) ?+ z. m4 I l! t$ z
- /*#define EDMA3_DEBUG*/
f6 z+ d- d+ C
# b2 Y: W3 K4 d6 Y! p, J4 V; n- #ifdef EDMA3_DEBUG
7 a7 V' l I9 d! B2 [% q; N - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
) A5 _1 s9 a4 p5 |- q- w1 ~ - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)# g) t! t: y) B5 {0 x/ ]' x
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)1 [3 H! }0 A+ k) D. |2 J/ D" w
- #else) X% E: J4 p) ]; b1 H
- #define DMA_PRINTK( x... )
A, ^" |6 b3 S1 a6 o# Z4 w* q; c - #define DMA_FN_IN
# a0 v0 u- M4 U$ v& \: w - #define DMA_FN_OUT% I, n- W/ K, h( d4 g6 m
- #endif3 e/ ~" O3 v& a
- 9 @; T6 r4 p R2 X# I9 m( u/ N
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
% E, g# I E2 R- Z( @6 P - #define STATIC_SHIFT 3' \" P& j1 c; Z& j
- #define TCINTEN_SHIFT 20* ?- @- r0 g5 y* s5 ]
- #define ITCINTEN_SHIFT 21
/ E) C6 r4 ]& p2 B - #define TCCHEN_SHIFT 22
( e- I4 W. u2 H5 v; I - #define ITCCHEN_SHIFT 23
$ h, G G( e9 b' ?! e: ?
7 |& S8 ~2 l1 X/ @: t' r3 U6 Y7 R4 S8 ~- static volatile int irqraised1 = 0;
. m6 ^) R# ~0 E9 s% S, F4 e - static volatile int irqraised2 = 0;& \; o I7 s1 M }) G$ l g
- 7 E! _/ H2 l! N4 j1 d! E1 |
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);; d* G5 F9 S: }$ \
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
6 o1 c* S. t1 T0 O# \, X$ ? - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
1 z+ l* Z3 ]* b* f* l! j, C$ _ - / b) O6 a8 H+ c' w
- dma_addr_t dmaphyssrc1 = 0;* V! G" J6 P4 A: e7 U
- dma_addr_t dmaphyssrc2 = 0;- ?) i( @% t9 ^, ]8 y) y
- dma_addr_t dmaphysdest1 = 0;0 q1 R4 ]( `2 V4 Z7 u
- dma_addr_t dmaphysdest2 = 0;
1 F3 ~2 {. g, l$ [' ]( P
0 y: A2 r- r/ N/ S$ z- char *dmabufsrc1 = NULL;/ l e8 o# J6 X5 d5 ^9 q2 Z
- char *dmabufsrc2 = NULL;, h- M$ p" o1 x
- char *dmabufdest1 = NULL;: u. R5 r, C, m# W% M; A5 l* m4 E
- char *dmabufdest2 = NULL;
3 V6 d' a" e) _2 Q/ g0 @& t1 Y# F
6 [% d d% ~8 V* G0 N( {- static int acnt = 512;8 y* _4 L4 x/ B. m; C( b7 E" D( W' j5 m
- static int bcnt = 8;! `) ?. K' i0 w
- static int ccnt = 8;: z9 M+ y' K' ?7 |, Z/ Q0 B" m
- , p: J/ B0 h( L# K- m. A# Z/ X
- module_param(acnt, int, S_IRUGO);
" G7 I. S a, V. T+ R' @( B" O* w - module_param(bcnt, int, S_IRUGO);5 X+ e* L- F7 W/ o
- module_param(ccnt, int, S_IRUGO);
复制代码
% J8 j, [* l# z- G
4 d9 c6 b/ o# D N! |3 @ 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
6 e, ~' b$ T* m/ h2 S: g2 Earm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。+ K) [( }9 x4 }$ F1 A# i
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
9 @) M3 R4 ^. k" V& S4 c- F
( l- D5 k0 \' d; w6 W* ~$ b. U
! E4 \- T4 i2 o; @: i; |7 ^ |
|