|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
8 j/ |4 s3 \. K- [code]EDMA sample test application
" \ n0 V- W2 Y: r5 _# F# I, t - /*
5 y& v6 L" ~+ H5 x: _ - * edma_test.c4 \; p4 u8 z2 _9 J) `& t, U' Z
- *9 J* \( c8 ~9 T6 r3 z a/ w
- * brief EDMA3 Test Application
, Q7 i$ ?+ C4 M y0 N% ]6 U7 @ - *
G+ ?' k2 q4 p4 \. u' j. _+ r - * This file contains EDMA3 Test code.
, d: K: [, `5 }: B- o' v2 z - *
+ H0 p: D5 v1 q1 \7 _& ]% Y - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
5 O4 h1 _! J& f2 [ - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT5 L+ O! D5 j0 W' b( R- o7 F
- * TO CHANGE.
! O9 r& l/ h6 H2 r/ \ - *
) k4 p$ O* l0 v" y6 E) o8 R3 ~ - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
3 Y. N1 `% F- i1 Q) c3 s, ^ - *
- W) l# F1 H$ x0 d3 K. E. I$ ^" w - * This program is free software; you can redistribute it and/or5 U- K- P/ L3 C' H/ j# @
- * modify it under the terms of the GNU General Public License as
) }. y j R _$ y% N$ n$ A. j: G - * published by the Free Software Foundation version 2.' p' D. Y2 I6 T$ m; P, w- G4 U
- *
! d; E4 \/ X4 i2 l8 \ [# Y - * This program is distributed "as is" WITHOUT ANY WARRANTY of any
* M3 K9 I4 B& ]7 |+ U - * kind, whether express or implied; without even the implied warranty
/ G) r) F8 G1 Q' t$ @' }3 D - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
% C6 i+ J' K% l1 R$ i - * GNU General Public License for more details.& O4 f$ e& m7 ?1 i+ x* B# X& ~
- */6 y5 f4 V" H+ @, K3 w" R- q
- ( i! E, T! ?9 Q" m5 Y5 y
- #include <linux/module.h>" C& O! A# h% f5 ]$ T
- #include <linux/init.h>
0 [* F9 F1 Z, q3 k2 z8 w, `& U* Z - #include <linux/errno.h>
l% h9 D6 m% o- V9 B' Q% T - #include <linux/types.h>3 g% L2 S" O% \; v
- #include <linux/interrupt.h>
: u2 `& \9 z) l/ K4 { - #include <asm/io.h>
6 G" z! G# W0 a# x4 }% I8 I( \! R - #include <linux/moduleparam.h>
9 a- r! y' O1 _ F* z' d* G - #include <linux/sysctl.h>
: X: e1 Z6 ^, B" p! P - #include <linux/mm.h>
4 }+ \% r; `. X2 f3 {4 _ - #include <linux/dma-mapping.h>
6 H4 Z9 ~8 k ]2 M - 6 y2 m# i; ` W. A0 z) C
- #include <mach/memory.h>
/ ]8 D2 @* e8 @; s6 [ - #include <mach/hardware.h>
( g# N' V- E: [" Z+ H. q* z - #include <mach/irqs.h>
( a# k4 Q# t! x3 P8 E - #include <asm/hardware/edma.h>2 o' O; @) P* T' K/ x0 n
- 0 E/ g3 ]3 d! A/ n& j1 F
- #undef EDMA3_DEBUG4 y$ P5 q; A* G
- /*#define EDMA3_DEBUG*/% \/ y5 {; \: W: J* G# L
8 I8 {& ?. E5 e t, d1 n' D) p7 ~- #ifdef EDMA3_DEBUG
$ A. F/ K3 c' Y8 N2 B - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
0 H8 a$ Q, ]0 p$ w - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__): i* L2 [/ L. L1 c
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
# M5 g( ~3 Y/ N, J - #else9 w3 m2 K& U7 T3 f, W
- #define DMA_PRINTK( x... )
7 t& N8 o8 L7 q% a, } - #define DMA_FN_IN
1 n9 `% o1 }7 V5 D - #define DMA_FN_OUT5 a3 Z) A1 T+ s& A$ U
- #endif
' A4 T. @+ I& p - ) R+ k# a( q; p# {, \* a
- #define MAX_DMA_TRANSFER_IN_BYTES (32768); L8 V V/ g& j7 h& Z1 B
- #define STATIC_SHIFT 3$ k6 j9 V- m+ @* B
- #define TCINTEN_SHIFT 20& _# K7 N% w: G/ A, r4 n
- #define ITCINTEN_SHIFT 21/ D' R9 H3 Z' V" u! `6 i. k
- #define TCCHEN_SHIFT 22
G; f/ Z' ?' I/ I% n0 { - #define ITCCHEN_SHIFT 23# Y6 ^9 \( A# I1 C* t
- 7 B# S# W; K& d; k7 X* [
- static volatile int irqraised1 = 0;3 t+ c, X9 `$ ]
- static volatile int irqraised2 = 0;
1 }/ E7 t0 {0 T4 w
6 \" ~. x/ _. s, T% ^5 h- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);8 V6 o5 @1 Y+ d! u; d
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);* a# U" }, T! x) [; x6 |
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);3 }, r1 P# P& F3 g7 C
" C" F& R+ w D m9 S6 D- @- dma_addr_t dmaphyssrc1 = 0;3 {0 v& q/ Y! y1 [) m8 C3 ~
- dma_addr_t dmaphyssrc2 = 0;
! Q# o& u+ T) b# Z) ~4 }% g - dma_addr_t dmaphysdest1 = 0;
) k9 C0 N* G4 T) ?% { - dma_addr_t dmaphysdest2 = 0;1 O M% p5 p& G! R
- / X ? {" J# r! H" v
- char *dmabufsrc1 = NULL;
# a/ }: [3 c1 ^$ }# u* k - char *dmabufsrc2 = NULL;( @7 w* K1 M. ]; Y6 c
- char *dmabufdest1 = NULL;
8 k2 v. O# Q: n+ [ - char *dmabufdest2 = NULL;, N! O: Z6 o) K: D5 H
8 N7 H/ R/ i) i ^- M9 k- static int acnt = 512;* \; X: k) x& }; \5 R1 ^. A8 A
- static int bcnt = 8;- j( W4 S: t4 W1 |8 O, B1 a; O3 k
- static int ccnt = 8;5 }/ b! a/ p# ]) Y
- . R5 c' J) M! W% ?9 N
- module_param(acnt, int, S_IRUGO);
( |- `) q2 l0 c! M9 m - module_param(bcnt, int, S_IRUGO);' r+ y' g, k/ z2 u. y2 o
- module_param(ccnt, int, S_IRUGO);
复制代码
) {" |8 q% o4 t h) m- m. I' L+ Q
" d! F0 H3 q; {0 Y2 @ 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
" F3 K, |1 n3 j' e7 I% o5 f, barm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
: _% Y- j' h9 }7 u4 J& S$ C/ e. L" `. e 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。9 X* y" E/ d$ q6 L: O# z T! e
5 Z! O" a5 T, ~, r! Q4 w8 l' H# u* C- d9 Q5 ^ D' {( q9 }9 F
|
|