|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 9 I& K. L2 |, V \2 {( ~- P' K8 N
- [code]EDMA sample test application
( `7 p% E- X" A$ |( a - /*
) S% e& r- z' E$ W, k% q7 \ - * edma_test.c
$ [; Y7 q9 z5 ?4 p% J - *9 R8 j4 n5 N: N% d/ P- x( R7 O
- * brief EDMA3 Test Application
- f4 h3 b* n8 G2 u N* ` - *+ ]$ l) C8 k- U- e; n y1 f; I
- * This file contains EDMA3 Test code.# {6 Y6 B/ ~6 x+ Z5 i
- *- `! X' A- p, d
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE4 r7 H3 T& R7 l7 ^! v; `
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT1 N9 i! h2 p' h% u
- * TO CHANGE.
3 z5 o% k) P# W6 ?) f5 N - *5 y- E9 d1 T8 O9 @ X+ y# ~
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/! ?9 j7 ]* T! o3 N, H; M; u
- *
4 T' o7 [3 d$ q0 U4 A1 A( _1 m; @ - * This program is free software; you can redistribute it and/or
- m; U$ ]' A2 } - * modify it under the terms of the GNU General Public License as3 ], ~+ ~9 i& e% M1 m! ^
- * published by the Free Software Foundation version 2.% i; ]7 r" ]6 Q% n4 [# G+ X7 n% \
- */ @ h& F% T7 K3 Z2 p; c
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any
' Z8 ^. X4 W+ Q% U" w7 T - * kind, whether express or implied; without even the implied warranty7 Q' R; ]0 X3 e. W, C7 g0 K$ w
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the" y+ k( x4 I9 j: T2 q# _6 W
- * GNU General Public License for more details.
8 n& c; c. V1 ?1 r1 q - */5 D! ] M/ c# C X# V
T* b2 C) O$ @9 S \* s9 @0 P- #include <linux/module.h>
+ @7 o. r8 w- B/ }& L. q - #include <linux/init.h>7 x. g( l1 S9 z0 M' S! r
- #include <linux/errno.h>7 @1 E C8 Z* {, ~1 G! ]
- #include <linux/types.h>) s0 m% h$ d7 @ a( C/ I2 P3 A2 E
- #include <linux/interrupt.h>
1 l X6 H- I( F- x4 H, ^3 ] - #include <asm/io.h>$ H, p f& ~% U. C. r# j, w
- #include <linux/moduleparam.h>- [$ f' F" K% F( X6 h- F4 m6 Z, G
- #include <linux/sysctl.h>4 ^# R4 ?' g! B9 q6 W& b- b
- #include <linux/mm.h>
8 t, E& Q/ G: V* v5 h. w. r5 U5 S7 z - #include <linux/dma-mapping.h>7 ~7 s. d+ a/ S( t
- 8 p, G% H1 @9 m' I' o i3 c+ h
- #include <mach/memory.h>
1 M' c5 h* _6 R' q) M* |8 u - #include <mach/hardware.h>
+ U; Q3 T3 \8 P- m - #include <mach/irqs.h>
" N' D! {! ]# K+ T6 }( ~* W0 p - #include <asm/hardware/edma.h>) J( h3 I" [3 Z1 C: e+ r* ^
- ' Q7 p( z* O8 A/ q
- #undef EDMA3_DEBUG
6 H2 B/ _ @: E7 D( |- H! z/ g- W - /*#define EDMA3_DEBUG*/7 U; Z( x: N9 ?1 ]1 P# @/ `: b
- - ?4 [# y: A, W) F; V! I' a* U& G
- #ifdef EDMA3_DEBUG
7 J. s! F' _4 f3 }/ E - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
1 Z, p0 \7 e1 p0 M' W - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)# Q" @) }0 z% p# C
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
8 B, W' Q! r7 c2 |& k) ` - #else
2 m) @8 o7 X* R - #define DMA_PRINTK( x... )& ^% n% |& F6 v; I' M( f% c- ^( x
- #define DMA_FN_IN
( r% W9 `% Z( w) _ - #define DMA_FN_OUT" E {/ W, s( k6 W
- #endif7 M, z2 F' V6 M3 c3 S
- 2 i4 f! R9 C4 p1 V2 u, ?- ]/ R. O
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
0 x! ]- ?, [7 i - #define STATIC_SHIFT 30 C8 d7 @# w6 o8 M
- #define TCINTEN_SHIFT 20# Y8 I3 C- {8 t1 y8 k- d
- #define ITCINTEN_SHIFT 21
8 d. _5 _2 z% x8 M4 ?' W1 S - #define TCCHEN_SHIFT 22
6 ?0 ]2 K: d6 `. P% ? - #define ITCCHEN_SHIFT 23
) d" G( A, ~4 u! _4 V. G* {* [$ r - 0 {- A' ?* X: c+ u0 o7 r# R5 c
- static volatile int irqraised1 = 0;$ m2 s/ w* l# Q( l! { b' O/ [
- static volatile int irqraised2 = 0;$ B) r% J; x( m$ r6 {
- : H* F- Z$ Q+ E* _8 `+ y
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
! J( l& l: C: x - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
1 W! Z- ?5 r. I3 D - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);9 N) }$ t% b% V2 h6 o) q% o
1 }/ g4 N1 a$ ^0 o- F- dma_addr_t dmaphyssrc1 = 0;4 F! H z& I c5 Z
- dma_addr_t dmaphyssrc2 = 0;1 L6 s! ^3 i: U, Z
- dma_addr_t dmaphysdest1 = 0;
) q- C" H8 @) [" J P - dma_addr_t dmaphysdest2 = 0;! {7 \, z1 ]5 C, Q; ^6 T
- # M+ p# {, g6 k: N! Z/ c
- char *dmabufsrc1 = NULL;0 T% g) y$ B {4 Q5 E3 l+ I
- char *dmabufsrc2 = NULL;! f1 z! k' ~$ c0 H2 ?
- char *dmabufdest1 = NULL;
' o( I, `" a" ^& C2 a- x# b - char *dmabufdest2 = NULL;* l3 M4 v8 N) l3 U' Y0 ~; P
# S, s; J- j5 R% K- static int acnt = 512;
- O# G R3 f! u% x: W! l - static int bcnt = 8;# |9 Y5 d4 K5 f) H
- static int ccnt = 8;5 ~% S$ {: f& O3 j, @' \
- # J/ ^ j9 Q( f2 [
- module_param(acnt, int, S_IRUGO);
; r/ O0 }& N% S8 f# l4 X - module_param(bcnt, int, S_IRUGO);
8 x* p# a0 @! K+ J b4 M - module_param(ccnt, int, S_IRUGO);
复制代码 * ~: `, `( z7 s- Y1 C
1 c( n1 @' N4 ?9 T+ p
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
& q) \$ l9 O- A9 v" _& I$ b1 warm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。0 R3 u$ P2 s$ G+ T& @
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。5 q/ P$ Z& p% v9 _1 q( a
7 l j) c' {& K9 X6 D# Q/ q( C4 G: l8 _! g2 z
|
|