|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
+ }% r1 ^1 T. Q* y: a- c- [code]EDMA sample test application
5 U* t0 f' S5 t5 z/ s, d - /* l+ s& w8 ^- q) W
- * edma_test.c
: j; c# w: }& s. g$ Q* Z - ** q! G" m: c ?, r6 U7 ~2 L
- * brief EDMA3 Test Application
% D) H+ \1 ^! O8 O/ U) s3 R - *, L, @, B6 \! S' a' z9 C; N9 _
- * This file contains EDMA3 Test code., C: k5 N$ S5 k( z0 b/ Y _
- *
; g+ g9 z0 w2 T& X6 N ^0 d. Y9 @ - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
; U3 I. i* r% R( M5 Q, o- Y - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT! h' m9 U+ Y+ X. P* e, s9 ]$ w5 I
- * TO CHANGE.8 J8 _0 q, }0 B7 S: z' |
- *
. ^6 d t" L. a) X. \+ i - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/6 d8 w. a7 N+ K4 B$ e
- *. A4 J2 ]- v5 Y5 g9 Q
- * This program is free software; you can redistribute it and/or
" q$ V, ] {0 ~5 |& v$ p1 W - * modify it under the terms of the GNU General Public License as
7 p3 \. x: v) ~( `0 |- `4 A9 c, q- S% v - * published by the Free Software Foundation version 2.
' n1 z$ C) Y9 U - *
% d1 G3 s4 R' ? P0 q - * This program is distributed "as is" WITHOUT ANY WARRANTY of any' W# v# w) V, ]) `5 q
- * kind, whether express or implied; without even the implied warranty, o9 L. m3 C) y2 k
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the& z: u4 N) u$ v. e
- * GNU General Public License for more details.3 y2 r6 u0 k: e% @# o5 j
- */, B" f8 o r; P$ ~2 u
8 x" j- H$ l' L6 b# t- #include <linux/module.h>; N, P; A. ]! a$ J0 W- V1 a
- #include <linux/init.h>6 q5 @: ?" g3 O9 Q( `
- #include <linux/errno.h>
& E0 v" v+ U# D0 e) V - #include <linux/types.h>4 V! T3 h; f. J, o: T/ v
- #include <linux/interrupt.h>3 D7 P a7 n- ^) H6 y9 I$ A
- #include <asm/io.h>$ e; v+ I1 i7 W
- #include <linux/moduleparam.h>
* {( j+ z0 q0 v& y - #include <linux/sysctl.h>7 P8 i0 p6 E7 o) u9 O" O( Y
- #include <linux/mm.h>
$ G8 q6 N) Z$ N0 G3 L+ Y$ Q }& O8 Z j - #include <linux/dma-mapping.h>% }- M# _0 I9 l, v; V& U F
. j9 G U, z6 o3 Z7 q7 a- #include <mach/memory.h>6 c1 E" ]" {" Z
- #include <mach/hardware.h>
" j1 q; o0 n, w' D1 t: T - #include <mach/irqs.h>8 |" a) b# Q8 N$ p7 g4 q
- #include <asm/hardware/edma.h>
0 Q$ x2 y; E* J9 q5 M6 L: k9 q5 }# q
- ?# W8 @; G0 v, n- #undef EDMA3_DEBUG
d: S: M! m) v( v } - /*#define EDMA3_DEBUG*/
% ~# @- Z+ j4 L9 B - 1 X- u0 x1 P0 h/ B
- #ifdef EDMA3_DEBUG
* P3 g9 d# F# w1 s0 R& f# e - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
: g: ? Z. S# f# v - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)0 I2 V( J6 z* D5 ~' X
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
) h) B e% n3 n& H/ k - #else
2 A9 ~ y' h, p& i - #define DMA_PRINTK( x... )
5 K2 K1 ^1 S# N4 k, T7 T - #define DMA_FN_IN
4 q# i/ U2 _" R* _3 F$ b* A - #define DMA_FN_OUT. D f O# u) |) L, h7 a) e
- #endif
7 _6 p' i0 z0 i# J3 ?+ D - ; p2 ? p" q/ C9 ]& E$ e5 \' U
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)# B5 i: C" d" a" \. {5 P
- #define STATIC_SHIFT 3/ T$ Z# r9 v& k: d# Q
- #define TCINTEN_SHIFT 204 d1 X f. A @- R
- #define ITCINTEN_SHIFT 21
5 l, p4 _1 L8 B" @ - #define TCCHEN_SHIFT 22
8 `+ E6 j' N6 p2 b - #define ITCCHEN_SHIFT 230 j% `0 Z3 e& | z) a& d* W/ D
- ; S/ O$ k3 k0 p$ Z6 m4 `5 V5 _ P
- static volatile int irqraised1 = 0;* z! i0 q- V$ Z2 n9 J( s
- static volatile int irqraised2 = 0;- G; ]& m% n# {. r. c
! u6 n k/ A) `; n- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);. e' K1 V; m; k9 U8 {3 C2 c9 V1 `
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);! U V$ t; I8 ], k
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);+ A7 E5 m* u) V- g
; W' _- R1 i) U \# B( C- dma_addr_t dmaphyssrc1 = 0;
/ W/ o$ Z4 K( O/ [( E1 E - dma_addr_t dmaphyssrc2 = 0;. t# `7 `. _9 ^2 l
- dma_addr_t dmaphysdest1 = 0;1 r- ~ W/ F% Q
- dma_addr_t dmaphysdest2 = 0;
4 J: r& q) t6 u4 S& |# P; p" E9 p
3 b P x; I& {8 o i- char *dmabufsrc1 = NULL;7 b- v: D; y; |8 }
- char *dmabufsrc2 = NULL;
5 _+ d& J; C, s4 t; C/ l. J - char *dmabufdest1 = NULL;
6 x6 p# n2 L; I% k( b2 c - char *dmabufdest2 = NULL;5 z1 Q5 e' ]8 I+ J
- # `. T# d2 h4 X( r2 ~
- static int acnt = 512;/ H5 B- A0 R% y% o, j# z1 b
- static int bcnt = 8;# \6 f' n% k; \, c2 g' o) D
- static int ccnt = 8;! e `4 J7 W5 t/ P
- T- A/ Z9 _3 W- module_param(acnt, int, S_IRUGO);
% m+ {+ ?6 Z( n# J2 f6 y - module_param(bcnt, int, S_IRUGO);( J8 C; x9 o. F% P
- module_param(ccnt, int, S_IRUGO);
复制代码
% ? o8 ?; s |2 y# A2 a' a p. L( E
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用" g8 Q& K( {: C% f, @1 ^9 B
arm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。1 ^8 l+ T- B( L. Z( q. H6 D
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。6 |% `9 `3 g$ N
/ V- H+ ?' h0 i8 C' g; L1 r/ j' Y
6 ^# P/ R/ p' W |
|