|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
' g) g! O. D. V# L; j# ~! X8 z- [code]EDMA sample test application
" [5 `8 y2 F2 t5 @3 Y- g - /*
& \# @' m8 D% o6 e - * edma_test.c4 y: @: m; f! M# u/ D/ Y/ F. A* X3 v
- *- z5 {: F& U; }9 u0 g, m, R! |) o: G
- * brief EDMA3 Test Application: w) t4 T- e3 @6 |, W5 i" j
- *. Y) B8 u8 D) H1 b e* D g3 P
- * This file contains EDMA3 Test code.' C' `1 n. E0 V5 |
- *3 Y8 }, r& D; g( e) b- n! W
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
# P' F) f# J8 k& X! ~" h, t) b& } - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
# d, C: Y/ e5 y; J9 ?+ @$ ^ - * TO CHANGE.
# g* d. P# _, N1 R+ F - *
" V% x x& ]" \; h- |$ y - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/1 l- h& t7 \. p8 D" b, z$ c
- *
6 V, H2 d. K1 S, t0 x0 H8 ~) h9 _ - * This program is free software; you can redistribute it and/or
+ A, o% C- b9 `" P! g - * modify it under the terms of the GNU General Public License as( f3 t0 ?0 C! q# {" t
- * published by the Free Software Foundation version 2.
: @+ I* a1 H# R! ~( F! t: q4 Y - *
7 H5 ]+ y7 f' ]& P - * This program is distributed "as is" WITHOUT ANY WARRANTY of any
/ P* |# [) {' y( a1 J# Y: Y y2 b - * kind, whether express or implied; without even the implied warranty8 q9 p2 a. i+ S8 |
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the* y5 U/ Q; \+ @6 f. ]" J( ~' z
- * GNU General Public License for more details.
$ C/ U2 T) O" f! w - */
# S* z0 k" e) y5 S$ P: o% Z - $ O, U* a( y" V+ C; x9 X
- #include <linux/module.h>
( ~- H$ p7 E+ Q" q4 e+ } - #include <linux/init.h>6 S% A$ ?+ k: J) v* ]
- #include <linux/errno.h>
8 L/ k' \ s: j4 w - #include <linux/types.h>
8 C1 m) u) K, _+ a+ { - #include <linux/interrupt.h>
. P* w& |: j6 o3 r1 [* n0 g7 t - #include <asm/io.h>4 @% c% D5 V& l8 G+ z0 o, k* [/ }- w
- #include <linux/moduleparam.h>) w6 N0 U- O& D- y& L7 q
- #include <linux/sysctl.h>
, \ G! I" g) f0 m" F# E - #include <linux/mm.h>) r+ v( m2 A9 P6 y$ l( r
- #include <linux/dma-mapping.h>+ F6 N7 k. q5 C- b# R" `7 _
- # V- X, g( H2 y* l+ o4 y: i; _
- #include <mach/memory.h>
5 r( u7 u. c1 m- ?( @ - #include <mach/hardware.h>
8 H( w2 |* K8 N; d& L5 b2 A& |9 u - #include <mach/irqs.h>0 P. u9 ?6 x0 I$ C H" Z5 w- Y
- #include <asm/hardware/edma.h>$ J/ X# V) _8 a5 R. o
- " m( Y7 ^8 I6 P, h
- #undef EDMA3_DEBUG
0 E# c2 l9 S/ p - /*#define EDMA3_DEBUG*/. J( T* T H. V" i8 M* |
- 1 c& Y- N5 N5 _5 V* R I5 }1 l
- #ifdef EDMA3_DEBUG
7 R v0 y. `& Z - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)8 f, T" l4 m5 D% e7 t1 K
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)7 a, Y: P; l9 l. |7 a' }% N
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)8 G. I0 _. o2 v; n4 a- g* T/ @! {
- #else
% w; f$ Z3 |* y- G, z B, e - #define DMA_PRINTK( x... )2 A+ T+ m. E% S4 k! X
- #define DMA_FN_IN2 H6 {% \, ^5 G4 m* L9 \/ F% j
- #define DMA_FN_OUT
: f$ {" t2 d5 W+ A: T) m9 C - #endif
2 z& l2 ?! b; s8 |) m, U
; ~1 C' b, O5 q, W. l- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
* S6 {: k3 j* b6 u$ f0 h, T6 e1 W - #define STATIC_SHIFT 32 e6 y5 S+ P' U+ T
- #define TCINTEN_SHIFT 20# V; Z7 z+ N p& d! x5 m% T) D
- #define ITCINTEN_SHIFT 21
( W0 A8 z( F) h- g$ s9 y - #define TCCHEN_SHIFT 22, _# i. G( _0 a: O
- #define ITCCHEN_SHIFT 23: K. _7 N$ [! {8 ~! X3 D& F
- S6 ^& {# K+ {, j+ O9 c6 {. a- static volatile int irqraised1 = 0;
& D& `8 a1 i# p" d - static volatile int irqraised2 = 0;: ?' o1 B; V Z2 S- u
7 ?% v1 S* M" t' ^6 t9 Z9 Z- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);# w* q: R0 x; E* b, {0 l3 t
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
8 ~' Y& e, {, P* w - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);0 G Z4 b, J9 h: o5 L
8 Q6 J/ j7 V/ d# V, e0 d0 }- dma_addr_t dmaphyssrc1 = 0;
* s! H5 X' }! ^% U u - dma_addr_t dmaphyssrc2 = 0;- k; n/ H, R7 {6 m5 a
- dma_addr_t dmaphysdest1 = 0;: t' q/ v2 Q" E
- dma_addr_t dmaphysdest2 = 0;" z. N, l1 m1 S
- % R9 k% w$ d! G4 Z, ]# x- m! i
- char *dmabufsrc1 = NULL;' p! u/ r& r& a' \* X/ ~
- char *dmabufsrc2 = NULL;3 i0 M- B6 Q2 B$ K
- char *dmabufdest1 = NULL;
( @5 O( C" ~* H' M3 _& q - char *dmabufdest2 = NULL;
! o' @$ A& F" P* K- o& ` - & ~: o. v$ r4 x7 I* ^
- static int acnt = 512;# C$ |# m3 S. E; s; |& f
- static int bcnt = 8;
+ Q5 D6 k0 o( s. \ - static int ccnt = 8;8 Y! F, R- D2 b, i' o
9 @) Q. L) y4 ~- module_param(acnt, int, S_IRUGO);
, r$ f$ O) C( Q0 t9 s# s - module_param(bcnt, int, S_IRUGO);4 f M# t, Q6 I! J/ t& z! I1 }. L
- module_param(ccnt, int, S_IRUGO);
复制代码
( i0 w: o- ?4 R
8 {- r# u5 m4 |+ m* C 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
! L8 x, l. e P6 [" h1 H' Yarm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。- X' y8 y2 Z( P" ~# P
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。2 V$ {; v$ p$ {
+ H4 P# i1 m9 h1 n
! S2 v& A- n, e( ? |
|