|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 & X* M4 g, N: K
- [code]EDMA sample test application
- c/ Z2 e$ _0 }% R2 @2 X1 t+ v - /*
C" Z- l" Y3 G- @, ? - * edma_test.c5 |. G: _" o! v/ J; m. V( e
- * E# r! J+ K. h5 b, q0 |
- * brief EDMA3 Test Application
- h, t0 i4 [1 s" ` - *
9 ^& |% u" Y i. f6 {$ U a- P* n - * This file contains EDMA3 Test code.
6 e9 k% E# K/ r - *- j- h8 r1 x; M) H H& B& E, `
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
0 R6 u8 v. V, ` - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT$ ^9 x. c" i3 Q% O5 K
- * TO CHANGE.% O; r; q6 m* c
- *0 K7 t! Q% h: |7 Q
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
$ L5 L3 T' o3 Y! ?2 V - *
, I4 d7 |& R. E5 B2 y8 X - * This program is free software; you can redistribute it and/or
6 u- ^3 {9 ~% g - * modify it under the terms of the GNU General Public License as9 O7 e5 }% F/ A
- * published by the Free Software Foundation version 2.$ q. y0 B+ w9 ~
- *
# t7 j: q: ~3 f: W) N5 T - * This program is distributed "as is" WITHOUT ANY WARRANTY of any
: N, D1 I. @$ y8 L# W6 Y3 s; E - * kind, whether express or implied; without even the implied warranty
0 v0 K. G J& V" e) K( b- U) y - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the: i! C& o. o0 Q. S8 O3 e# k
- * GNU General Public License for more details.* S2 D+ Z% Q n7 h
- */+ J' ` b, F$ N5 M
. k& c) U" C8 w1 i! M- #include <linux/module.h>: u P. Q0 f0 O0 @* z+ K( I* I
- #include <linux/init.h>
6 _' ^5 w0 s# o - #include <linux/errno.h>
7 P8 `' R- L! J, Z - #include <linux/types.h>; l/ P8 p5 Z6 E- l3 X* R3 ?
- #include <linux/interrupt.h>
/ l9 w& Y$ y+ N) j; Q( C - #include <asm/io.h>
O( Y4 h/ o5 v - #include <linux/moduleparam.h>
- ?" y) m- z) F" b1 T - #include <linux/sysctl.h>
, S$ E: V, @, G. C) O: o7 Q - #include <linux/mm.h>. M8 ]$ ^+ ^4 c3 ~6 a
- #include <linux/dma-mapping.h>% [- h/ U2 h# ]* A# z, V
, l7 I! R* N; t& j/ x1 y& ?- #include <mach/memory.h>
( N1 t. M0 m4 Z, ]8 w - #include <mach/hardware.h>. i/ p! ?6 W8 Y: U& o
- #include <mach/irqs.h>5 M: a# R) v2 N1 b, P
- #include <asm/hardware/edma.h>
: U. i6 o& |" N4 C( A+ ] - 4 {% g% f0 W5 f2 G; {6 i) z
- #undef EDMA3_DEBUG& N) a3 ?6 n" M0 O# h% }% ]
- /*#define EDMA3_DEBUG*/
8 x! j3 F# V- K" k6 o
9 s* n' T. X6 n# z- #ifdef EDMA3_DEBUG
' W- Q: w8 T: w: I* |! N+ u7 o - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS), B0 E J$ j5 ?2 v/ N" b: M# ^
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
; M) t/ M$ h5 I7 Q# E) n9 w - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)) m5 U) B1 j+ P! D! o. ]
- #else) W; i, W- f" h! N- [' |: a
- #define DMA_PRINTK( x... )
& R$ ]# o, `* }1 y - #define DMA_FN_IN
0 h9 F/ T& i2 h6 P# [) c8 L& B! ^ - #define DMA_FN_OUT
s3 P8 O7 O6 H. _* G( G - #endif
- r0 u9 T: B' p3 ^0 g - + ^' F0 t; f! i& M
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)* _0 }2 m2 D* V' Y
- #define STATIC_SHIFT 3
# D: }- z$ Q2 S! [+ k3 A& Z - #define TCINTEN_SHIFT 20, ^/ q5 q0 k) m. b& Z3 A& C/ y. P) ?
- #define ITCINTEN_SHIFT 21
' w! S* K: X- R% a( a7 [! N - #define TCCHEN_SHIFT 22
* U1 t% Z0 @3 G7 e. F - #define ITCCHEN_SHIFT 23- [* L6 Q1 H4 w
0 j* a8 f# H, W# |5 `) ]. V; ?- R- static volatile int irqraised1 = 0;
e2 D! s, H# r" v" F' t - static volatile int irqraised2 = 0;
; P F: m- x5 L0 P( C4 L
1 Z6 [3 H3 f: J" ^0 w- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);* e" Q5 b! L. X) l" T, N$ [. v
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);! S* O8 I: ~* b6 A) Q: Z+ T6 A4 K
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
# f5 c6 K$ R+ I5 R- B2 s# Z
! e; s, p5 }( D: K' [ d- dma_addr_t dmaphyssrc1 = 0;; D8 z4 p0 h N+ t' H
- dma_addr_t dmaphyssrc2 = 0;
\6 k% i" S6 y1 x' z" t; v- S2 k/ ~/ Y - dma_addr_t dmaphysdest1 = 0;
: n5 f w+ S9 y" C+ w% z6 J - dma_addr_t dmaphysdest2 = 0;
4 {8 z" E& C( I6 ?
2 _9 L3 a: f* r$ o' C6 F- char *dmabufsrc1 = NULL;
G% l5 V; \5 Z0 K - char *dmabufsrc2 = NULL;
i& b! U H* U$ }+ v - char *dmabufdest1 = NULL;
2 I* l O1 c. p$ B9 s! J - char *dmabufdest2 = NULL;
) }. X! j1 K8 w% E+ H, [7 x; A
8 M- X$ w) S. G7 ~: ~1 D- static int acnt = 512;
j5 z5 B* G1 K& W) i3 b. G2 ? - static int bcnt = 8;& P: h6 x! ~3 h: T) i F
- static int ccnt = 8;; J9 T' N; l. {2 ~- z: a; A9 y6 l
3 Q. F! q9 R9 h0 M- module_param(acnt, int, S_IRUGO);# n4 {0 ^3 m* e9 H/ W
- module_param(bcnt, int, S_IRUGO);4 Y6 O4 @7 x$ l% U
- module_param(ccnt, int, S_IRUGO);
复制代码
3 W# X- B! ~% R- W. t# j. ~) u1 ~$ P( {8 ]; v$ [
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
# U9 f3 y4 ?, @9 parm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。* l+ w" B# n- E" W
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。8 t% j9 W w c
i5 j9 c/ j6 {7 t( O
# G1 |3 ^: s3 C/ n+ R
|
|