|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
5 C# Z) U# q* {) H, ?2 C7 q$ Y( b- [code]EDMA sample test application# C3 S$ ?, P2 ^/ X& Y6 i
- /*4 X% `3 d' j, u" @
- * edma_test.c+ f" T4 y; O% M& C: U# p
- *
; z+ y; y# c0 S/ V6 \ - * brief EDMA3 Test Application
( X) _1 @2 O' j6 _4 G - *5 n0 G1 A- U6 T! [" Y
- * This file contains EDMA3 Test code.7 Z! I9 @. s& j
- * d! h2 Q/ h: A+ Z8 \. D
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE6 T+ _. o: R0 w+ X6 G3 x7 X% Y# a
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT$ [# I0 S: G M+ }1 C2 h
- * TO CHANGE.
) @% N( ?$ y* W' A2 n - *
, a) _# q; |+ p - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
2 m3 M5 _. i4 M# a) l7 N2 e - *
9 L9 _6 }, h* @4 f/ J - * This program is free software; you can redistribute it and/or- E, Z6 t1 ^0 c! j. U7 ?5 O
- * modify it under the terms of the GNU General Public License as
$ k! r( _- i) a) L - * published by the Free Software Foundation version 2.
$ W4 I, u6 r. y* T# @6 G5 G: a - *9 T2 A5 m5 b0 E3 _
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any% H i* \4 T- b; d+ K
- * kind, whether express or implied; without even the implied warranty! a- i7 I# A0 e$ a/ i0 h2 l
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the- M) T- ` W2 A
- * GNU General Public License for more details.8 m! A5 l1 L h9 m
- */
* I, S/ k0 k5 Q5 f$ v' t - : H) h1 Y* P4 u1 C2 G& t R1 B! a
- #include <linux/module.h>+ B3 n3 x4 O S5 Q% T1 L# @
- #include <linux/init.h>9 W9 {7 u2 }$ {0 k8 b/ ?% J6 F
- #include <linux/errno.h>
9 b. r% `1 F' ~* h5 A' ^7 |) x - #include <linux/types.h>
. ?1 g$ j: r5 S8 P% Z/ @" \# i - #include <linux/interrupt.h>" n! f+ g, B! b$ C5 V; @) [
- #include <asm/io.h>& | p) R" k. z: Z# ]
- #include <linux/moduleparam.h>
$ ?5 e' _$ P$ K - #include <linux/sysctl.h>, Y8 E( A% s+ E" @& R! |' Y
- #include <linux/mm.h>
3 z0 u; `) A. }1 [ - #include <linux/dma-mapping.h>0 |. r% h/ W* U( z) g7 R0 z
- 6 ]! L& t$ u) N% {: u
- #include <mach/memory.h>
7 Y9 [% r4 }; n J/ p; V - #include <mach/hardware.h>
. N" H3 ]7 v2 \. c - #include <mach/irqs.h>; O+ y$ A$ R0 i: n4 j$ G
- #include <asm/hardware/edma.h>
6 B$ k: M/ e2 I' c+ J' w; G* b0 x$ Z - - @2 {9 ^" Z0 w2 W: q( I( X3 A
- #undef EDMA3_DEBUG; q7 J! P3 R' E5 |* [" {
- /*#define EDMA3_DEBUG*/5 C( s- t0 z& t- r
; m8 o D! r$ [6 t- #ifdef EDMA3_DEBUG
( @. c" ]/ F# V) J( }, U - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
; m" O. P1 u8 z C" W - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)( _* W! z0 U: ]% f' ^* i# D1 n
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)/ P! w8 A$ i; b6 m. F8 I
- #else
8 [3 f% ]$ ^3 E - #define DMA_PRINTK( x... )- L; _+ z4 X ^- Y8 v1 @* D
- #define DMA_FN_IN- ~2 C+ B/ u+ t# I
- #define DMA_FN_OUT
# g6 G( p7 J! r - #endif! G/ K U1 _* T2 q: N; C/ g
3 w' p! A$ d [' }- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
- Z; H, n+ A) P: k, h% v - #define STATIC_SHIFT 3+ |& C3 j4 W: @# H5 k
- #define TCINTEN_SHIFT 206 {5 F7 |# Q" ~$ ^6 j; ^9 }
- #define ITCINTEN_SHIFT 21
- b( V0 m4 P" h - #define TCCHEN_SHIFT 22
+ i6 o( n# ]7 J5 m; ` - #define ITCCHEN_SHIFT 237 d) v$ w3 |( p, U$ t7 \; [
- ) ^& a* y) h6 h- y9 v
- static volatile int irqraised1 = 0;4 C0 [. h1 u8 Z% `" ~1 `
- static volatile int irqraised2 = 0;; h% I5 Q- | [# j- m$ p% ], O$ \
$ l8 i- A# U# M' }9 Z% j- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);7 ?7 x4 a1 V' G/ X; v! b' T0 T- _
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);* r% A4 ^# r+ C0 W9 V5 l
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);& F9 y1 T) J) l, k) s
9 ~3 P/ h, ]2 F5 B- dma_addr_t dmaphyssrc1 = 0;. r1 I0 F2 P( M: a9 R
- dma_addr_t dmaphyssrc2 = 0;
# A1 q9 {+ r! U6 I - dma_addr_t dmaphysdest1 = 0;1 Q& g n" _* A1 l
- dma_addr_t dmaphysdest2 = 0;
2 e# A8 y K F% m# J9 N - ' Q8 i; I( p$ O2 J( O' q
- char *dmabufsrc1 = NULL;( e& _2 Z9 G% c; v0 z0 d
- char *dmabufsrc2 = NULL;( w9 U3 \0 m% Q( k( K
- char *dmabufdest1 = NULL;
8 C! O+ Q( Q1 m, D' ?9 x* b& A; u - char *dmabufdest2 = NULL;
" h- `6 v) ?; _$ V
8 N6 `4 }4 F4 J( z( r5 j- static int acnt = 512;# x" |: U' |. U
- static int bcnt = 8;) F; Q4 i8 M( ^3 o- Q
- static int ccnt = 8;3 E) P3 w5 T5 o; i! N
- ' p" J6 Y: X' {3 x) a
- module_param(acnt, int, S_IRUGO);
- V: U; y1 _$ h - module_param(bcnt, int, S_IRUGO);
2 d3 e0 E4 ~# \& G# n - module_param(ccnt, int, S_IRUGO);
复制代码
; z3 A7 `1 p% W/ h8 s( v( z9 b$ X6 r0 ~
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
' _$ E' t+ W. F; Y' X6 v& 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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。7 e5 E4 N$ E8 v$ H! a5 b
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
) k6 {7 C# a9 F6 l* a1 l
3 P! u7 `- p4 u# {" d: m
( L0 u: _6 n# ]/ }8 Q/ h |
|