|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 3 S& {) |; z0 ^7 r7 e9 A
- [code]EDMA sample test application
, T0 g, b: e* Q) R8 E% \ - /*
# C& B' p1 E5 t% ~* ^# H& ^7 A - * edma_test.c
) ^3 }9 k0 B( p) l - *
/ _9 N% c! \: r1 r8 q8 K0 R - * brief EDMA3 Test Application2 q& K( p+ i# B, y7 U9 J
- *
6 Q1 J# I$ Q9 C% v - * This file contains EDMA3 Test code.
) V2 c5 |$ S3 A5 S, L: ]0 k8 q - *
+ c" R$ c: ]9 E8 o - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE% R( |' n4 \# @% V2 W h
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
7 y7 p/ f) L* b - * TO CHANGE.# k6 _: T$ n9 g# f6 b
- ** I/ j+ f& F$ c6 [ R- ^1 p1 u( ?- c
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
- ^# y; c. R9 D* t - *
$ v& j# p* k5 V% b# } - * This program is free software; you can redistribute it and/or
8 q' g* m% @ z: }9 ?, k' T- q - * modify it under the terms of the GNU General Public License as
0 a% ^. c4 H( ]2 W - * published by the Free Software Foundation version 2.
# u+ m' T8 d* R* T) _6 Q4 J - * Z! {. I V, Q/ m; g0 r6 U
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any: b3 k- v0 ~/ ]' k2 M8 {, B# {
- * kind, whether express or implied; without even the implied warranty+ F. U7 Q" o) f3 E. u
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the/ R3 `7 |; z/ v/ q0 c& Z
- * GNU General Public License for more details.
+ H" I9 a1 l7 n! p+ A1 Z+ K M* \ - */ c& e x. K4 ~( D( E
- 7 S, S2 j1 U6 u0 E% [# w7 i: ^
- #include <linux/module.h>
, F! w. V+ d& b; }6 _$ \& K - #include <linux/init.h>8 _- s4 m& R; Y6 `
- #include <linux/errno.h>
9 K2 j% q! i/ o& v4 W( J - #include <linux/types.h>
1 L1 e2 T% U$ ~5 u) ?2 u$ ?& G - #include <linux/interrupt.h>8 {" K7 E6 R9 O3 l& U
- #include <asm/io.h>, b6 U* F* O9 J" {2 w
- #include <linux/moduleparam.h>- L8 z0 c! s7 B4 u. C
- #include <linux/sysctl.h>
5 P" ]; X$ ]* N! `# V* r3 i - #include <linux/mm.h>5 M( A+ t9 H' N, ~
- #include <linux/dma-mapping.h>9 h* l# Q5 m5 @8 y0 A3 X4 F6 a
- ! ^5 M. X8 ~( B0 {
- #include <mach/memory.h>) L5 ]2 p9 \! H. m, [. O: T" c/ r. b
- #include <mach/hardware.h># r$ |4 z5 |2 `% ^4 w
- #include <mach/irqs.h>
3 M, @% @6 ?9 W2 P - #include <asm/hardware/edma.h>$ \7 k9 q& N% _) k* B8 w/ [
- : d8 p9 K. B& I7 E- l
- #undef EDMA3_DEBUG
! G9 Q8 v! V- T ^* Z0 |! m - /*#define EDMA3_DEBUG*/
0 `2 C2 o& s: p; g - 8 g0 \, C1 u" g& C8 Z6 K" y( A5 \
- #ifdef EDMA3_DEBUG
7 N [% N, _( V! C* @ - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
" _; ?1 b% o A. h' x; B _ - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
7 d1 |+ |8 l, |& T! Z - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)& K: E% o N% x1 X
- #else9 |! l; @3 I" a- {
- #define DMA_PRINTK( x... )
' L& M( M) \9 }1 o z# c - #define DMA_FN_IN
- u: c6 r0 |& f* n - #define DMA_FN_OUT
( y6 C [0 X' U/ q1 T, P- A - #endif* O+ t! U5 N6 o2 ?5 f! N; h
) U- w# S% u8 E j5 c- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
+ W$ m% C$ W: z! x5 h - #define STATIC_SHIFT 3, X. j# I1 u0 @2 J0 C, r# ^7 ]
- #define TCINTEN_SHIFT 20$ ~* `; `4 A: e* d f$ C2 }
- #define ITCINTEN_SHIFT 21! Z% g2 p' @. ^4 `/ z* Y7 Q! ?
- #define TCCHEN_SHIFT 22
0 H+ Y- w0 Q) d+ J! ~) h - #define ITCCHEN_SHIFT 23
* b1 @2 D4 N0 d1 \
8 u& B l+ b6 X, W& u* X# R- static volatile int irqraised1 = 0;
! z$ g* s# l" S. B a - static volatile int irqraised2 = 0;
/ L/ [0 D: K! T' N$ U* d$ L - ' s- j5 q6 J) }% R- b: U" y
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);* J% h9 V; d* D) \0 q+ C
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);( e8 h' `" K2 G# B2 C$ A
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
/ q! o) ~1 n! f& J6 J6 l! V
o3 X0 |$ n- P" N' O; ]$ E- dma_addr_t dmaphyssrc1 = 0;
, f' W, G8 c" Q, C3 f - dma_addr_t dmaphyssrc2 = 0;9 U- b% g4 w1 @, v( z7 w
- dma_addr_t dmaphysdest1 = 0;
F# \) x o4 Z1 n: `) a3 Y- j" ~ - dma_addr_t dmaphysdest2 = 0;
) ? q' G) M% x4 r2 i p. S$ h y3 A
# L9 Z6 H& |/ L- char *dmabufsrc1 = NULL;8 z) W- N0 |0 Y, v# s7 L+ t
- char *dmabufsrc2 = NULL;
2 w5 |$ g" |0 h- D7 M6 f v - char *dmabufdest1 = NULL;8 Z1 u6 O1 \) L W" N* S3 O
- char *dmabufdest2 = NULL;
. e4 t7 l# ^2 R4 O - 0 q8 C# j8 f& i8 g" x0 w9 [
- static int acnt = 512;; Y3 x: o# f7 O/ O6 w( ^
- static int bcnt = 8;$ m+ s7 Q9 w7 Z. w1 D( u* H
- static int ccnt = 8;, I a H1 D, {) m! g* r
- 0 W4 b3 H8 h) h' L/ O( Z8 [
- module_param(acnt, int, S_IRUGO);
1 f9 G5 G/ U: J8 d# c* X9 O1 [ - module_param(bcnt, int, S_IRUGO);
. C4 d# | K' z- j7 I. p* | - module_param(ccnt, int, S_IRUGO);
复制代码
: |; _7 _6 O0 P' E* ~6 H) l( u- u/ J# e" w& u
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
# {2 z+ e7 j0 R- q: uarm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。! j- Y1 d% Y% j+ b4 T4 N
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
, Y, _! o H& A/ K; ^
# \! J' N7 h# Y/ ?" o# D- }5 ^& [
: O. Q5 j; I! b( @: U |
|