|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 + W0 P! T! Y1 R
- [code]EDMA sample test application
$ L) C! a- R0 t: h! i - /*& J, f* ^- S% q
- * edma_test.c
& I' @! G, g4 p - *8 C7 _( `1 O" u' [) [% V
- * brief EDMA3 Test Application
6 w! J1 N* b( v7 B1 t3 B8 T - *
& R, ~" X" W; P, U$ o - * This file contains EDMA3 Test code.9 A, ]3 N- `5 ]$ x' x+ [& b% X+ N
- *
5 @. J0 ]! ^2 U9 T; a6 y2 f - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE5 ~, j4 f3 q8 d( w% N& k
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
( t S; o" N2 x. z( N3 m( b2 R8 F$ Z - * TO CHANGE.
6 a7 Z( W1 |% X1 h4 P: U8 j' } - *
3 I( j8 l5 `7 s; d5 ~ - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
1 P! Y$ G1 L) D+ }6 |( I - *- Z1 L; Q# K/ [8 t P+ Y) D
- * This program is free software; you can redistribute it and/or
4 X H1 |/ t) B6 h - * modify it under the terms of the GNU General Public License as& k( ]) m ]2 R4 h
- * published by the Free Software Foundation version 2. ~1 _# d& q1 J% n' l/ e- h3 ^+ s
- *' C' G# s+ O: o) R' }, D1 |6 L
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any2 u! X" ^+ p. h5 l
- * kind, whether express or implied; without even the implied warranty
% Z& {4 R. h: y3 g# U, x; e - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the7 F- {! z6 s9 n/ Q0 ~: D& w
- * GNU General Public License for more details.5 j9 g) T- N2 [3 [6 h7 E
- */# u. v% `" ]' |, l
* W$ i8 }9 X- V! E2 T/ {; Y- #include <linux/module.h>; J- C6 z* D; e5 b( a+ P% g
- #include <linux/init.h>9 o5 K2 S* N* {0 q8 l$ i, W) {
- #include <linux/errno.h>3 o; `( @3 J" N0 K
- #include <linux/types.h>
4 N" C+ S. S, b8 j: @# Q6 C - #include <linux/interrupt.h>
" t. E; o. `+ b0 i: y' ^: b0 l - #include <asm/io.h>7 m6 X* q; U- s9 W# m0 y
- #include <linux/moduleparam.h>9 h, \3 z4 J x* b4 o
- #include <linux/sysctl.h>
4 b" n* J% Y- m$ r* I2 I* S. ~ - #include <linux/mm.h>; ^7 B7 i9 @6 W) V$ @
- #include <linux/dma-mapping.h>
M! z* A6 b; w! y - + C7 W+ S" r0 I* T# m
- #include <mach/memory.h>
& T3 h0 S( x8 A6 u+ x3 | - #include <mach/hardware.h>
4 j" z+ q# W5 S* o& q - #include <mach/irqs.h>
$ Q2 r- C& G2 | - #include <asm/hardware/edma.h>) f! U4 l2 M, K
- 6 g: L9 g4 Q' d' K6 X
- #undef EDMA3_DEBUG( c6 H) y0 ]. g4 W
- /*#define EDMA3_DEBUG*/
- G& ^; [) s1 _' h# k: I
( b' d( W& N4 p3 R- #ifdef EDMA3_DEBUG
) B2 _# F6 E# k, Z - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)4 H5 _4 X5 N) l6 q- g
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
7 A8 {, X9 S( V* M, ]# @" Z; m7 z/ ? - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)9 {: m0 g6 F' _' m# M: b" Q: E& }
- #else* {4 ]6 E' l2 w6 ~3 c# e$ o
- #define DMA_PRINTK( x... )
. \7 B$ G( g5 `0 x% f - #define DMA_FN_IN( b# V: I ?% X& o2 G* Y, [
- #define DMA_FN_OUT! J( e( W* o+ w' _/ ?: J- o
- #endif% y0 z2 }8 n1 P& d
- x# U9 P# r$ Q8 k" S$ S- #define MAX_DMA_TRANSFER_IN_BYTES (32768)+ a: \' K% z: b# B% ]0 p
- #define STATIC_SHIFT 3
& V' t" _. a7 k1 M - #define TCINTEN_SHIFT 20% `: \/ M4 R; B# B
- #define ITCINTEN_SHIFT 21$ @5 f4 O) P% a3 u3 L
- #define TCCHEN_SHIFT 220 C0 p( j! y) \$ _7 ?2 x
- #define ITCCHEN_SHIFT 23
: M2 j- j8 D' v8 P9 i
& H c6 ?! F3 T3 ~; e) u8 u- static volatile int irqraised1 = 0;0 w; p4 U: I, r: m* z" G' z1 ~/ h$ V9 E
- static volatile int irqraised2 = 0;
/ t* z' {& W' C& r5 ^- G* n3 ?
# n+ A1 w( n5 S( E& R- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
, R! n T; j4 P - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue); @1 N( y5 E* R$ s+ A
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);. ^( {! d% Q( s
- 8 \, x3 E) |# s( Z1 x: y8 o1 R1 G
- dma_addr_t dmaphyssrc1 = 0;
( Z; [+ E8 J% W, p& u8 i2 }8 A - dma_addr_t dmaphyssrc2 = 0;
, r" Q" g% @3 W - dma_addr_t dmaphysdest1 = 0;0 E0 |* f/ u u% L E0 ^. b) R
- dma_addr_t dmaphysdest2 = 0;' l4 `/ s& ^$ f* V$ C* _1 b) s
- - I; w2 z1 c6 l/ `/ w
- char *dmabufsrc1 = NULL;
1 B& m7 R8 F' b - char *dmabufsrc2 = NULL;; n0 N0 \# @) k1 `- K6 }
- char *dmabufdest1 = NULL;5 n7 Y5 y% \3 @; J5 Q- y
- char *dmabufdest2 = NULL;
6 R$ W+ w2 s/ e* F( @" W, S - 3 ~9 Y$ o3 w- I3 e# I( B) `
- static int acnt = 512;
: ]: G: b: u! x0 W* k# c - static int bcnt = 8;
5 d( \% u: Y; n% i - static int ccnt = 8;
; w, L, r, j Z5 {& | - - K# e9 T2 l+ [/ o( N: r
- module_param(acnt, int, S_IRUGO);* T, g H1 e( g, X3 T( J5 o% C% V) D8 u
- module_param(bcnt, int, S_IRUGO);
( L. s0 G5 q3 v. U- _" p. f0 O4 T+ @: s: D - module_param(ccnt, int, S_IRUGO);
复制代码
$ x4 X) y7 w7 ?& ~
( ~2 h5 n! ?9 w 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
" P9 H- A* {5 O' garm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
* |; g% q2 _1 e% ]5 u) t 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。8 k- }, X5 @4 V! A! s
& O9 p! s, t* V: o5 d' R4 v
) I; e" {' @, i0 z6 A( G4 } |
|