|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
. _- t4 }1 R- r8 t- [code]EDMA sample test application
- ^% w: H9 Q3 c* U - /*
) Z3 R& t* M% o: o0 |& N7 r' h/ @4 ~ - * edma_test.c% q9 ^' w) n [7 p' H
- *
# G" Q% ]4 A6 T& U2 Q4 b - * brief EDMA3 Test Application* |0 z- f3 G" W0 W
- *
- J. O& a& z K/ }9 ]% M - * This file contains EDMA3 Test code.$ d! G f2 C0 Y; Z2 d) Z, h
- *
/ @" p) t, p! C7 x! [ - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
. D/ R; E4 ^- b0 E* U5 t - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT7 e# W6 U: A$ D# u- k
- * TO CHANGE.
/ u6 K# u/ F/ j8 b& W, c3 E d - *
* _4 K2 V2 o: R - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
4 F3 e* {3 D1 ~ - *
2 w. x& v. h H7 t: Y% | - * This program is free software; you can redistribute it and/or8 a5 X$ d, a: _. L0 k
- * modify it under the terms of the GNU General Public License as3 _" o8 o0 Y2 {" |
- * published by the Free Software Foundation version 2.& @5 _# h' p$ t/ o3 G0 o
- *
3 n5 f6 ~" N; l2 v" k2 j0 n - * This program is distributed "as is" WITHOUT ANY WARRANTY of any' k" a7 l" _" O. b( v5 ~
- * kind, whether express or implied; without even the implied warranty
! R- [5 z( i* h% K# o* B3 | - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the z4 t2 @7 j. K
- * GNU General Public License for more details.( m* {+ \: \, v* {5 t
- */. P; T" d( |1 A% m8 d
3 e, d5 [. n1 R! }# a; c: K- #include <linux/module.h>
; P2 ?2 X2 R7 a( }- U) l - #include <linux/init.h>
" I, w$ I& W e c - #include <linux/errno.h>1 a* b5 \8 B, t; O1 _9 V
- #include <linux/types.h>+ C' R) f. A# O9 g
- #include <linux/interrupt.h>
, D5 e0 J7 y! I, A; G$ u - #include <asm/io.h>& ^! e" f6 q/ I! m+ M
- #include <linux/moduleparam.h>
' m! g. D! f0 E) W: w, d5 y - #include <linux/sysctl.h>8 }( M, M1 b1 c8 }1 ]' |7 s
- #include <linux/mm.h>% [: o k: s9 b, V, Q
- #include <linux/dma-mapping.h>
- U* j6 g _! B: B8 i
2 O0 S% p* L! C0 U3 V( P- #include <mach/memory.h>6 U# i) L# `2 S2 _" Z! I; r" e& @
- #include <mach/hardware.h>
2 w) W. w# k/ x! c - #include <mach/irqs.h>
* J. C) n! Q, q/ v5 T - #include <asm/hardware/edma.h>
: i; q/ f. M: ^6 X s' n; p. D
2 t' O9 U2 g/ C/ C! y3 j1 Y- #undef EDMA3_DEBUG
9 ?! n4 l; Z/ M& {* {6 J4 K, B - /*#define EDMA3_DEBUG*/0 @% r3 t; A; h4 X
- ; A1 w8 ^& [$ }+ Q
- #ifdef EDMA3_DEBUG4 V7 P- }/ |+ k
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)- x5 m- u+ `3 D+ y
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
/ @3 o( ] e) D- G( ^ - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)3 |: G# @. U8 ~& o# l
- #else
X- _1 g* I% I" ]+ I7 P - #define DMA_PRINTK( x... )
[+ X+ z) S* \6 i, I5 B - #define DMA_FN_IN) {. g, A% \, X; e& Z9 P) D' N
- #define DMA_FN_OUT0 n& O6 h1 p P$ ^: F/ p0 i
- #endif. G0 r, y( \5 t* {% j
; v; L( F3 U! C) i- b- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
2 l" `" i9 n9 X. ^3 f J - #define STATIC_SHIFT 3
' ]; j; ^0 V' _+ q2 g - #define TCINTEN_SHIFT 202 V% R3 W( R- [7 i4 l
- #define ITCINTEN_SHIFT 21
8 c7 |2 }: J: `% e8 N7 ? - #define TCCHEN_SHIFT 22
: ~. `1 \% E5 x4 o - #define ITCCHEN_SHIFT 23* R2 T( B9 O" `2 ^0 U6 Q; Y# g
& E/ K/ ]& R8 R' ^5 @- static volatile int irqraised1 = 0; T4 r8 J) ~5 R+ \ w/ @2 T' U. d! p
- static volatile int irqraised2 = 0;0 I9 \" M: Y; \; k' m6 H
; R8 g' T' u# Y* T- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);& z: U2 O/ }, W9 q
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);6 [5 n7 R- v$ z6 u% k
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
+ Z/ ^/ W8 [ r$ J- r
$ j6 a) @: r! c3 o! u% U/ {) p- dma_addr_t dmaphyssrc1 = 0;( D2 w" ?; l; g _
- dma_addr_t dmaphyssrc2 = 0;
! a6 N& j7 @% A# r/ [2 Y! @6 o - dma_addr_t dmaphysdest1 = 0;
. C% b' q' C! a - dma_addr_t dmaphysdest2 = 0;
: ^$ _, X" W' |( E2 ] - . Y5 }* k. D/ d5 m/ _
- char *dmabufsrc1 = NULL;6 u0 ] w- X* s3 U
- char *dmabufsrc2 = NULL;2 N r( n8 {+ a" x, m
- char *dmabufdest1 = NULL;& h1 \# _; H/ O# \$ z; q3 V
- char *dmabufdest2 = NULL;
5 t9 U+ k" \) d7 G8 \# A" I - $ |: M, }4 |3 o6 G7 l8 T: T
- static int acnt = 512;3 t* j" _( x) h* a( K
- static int bcnt = 8;3 T. V( W& O! y, y8 T! j
- static int ccnt = 8;# P2 r1 b0 a" N7 g* k( W+ C# d
$ T# V; e/ T3 [) G- module_param(acnt, int, S_IRUGO);; q; Q5 b' S: Y# S' h2 W D( `
- module_param(bcnt, int, S_IRUGO);
+ t9 f" x3 r4 X& a& V, s - module_param(ccnt, int, S_IRUGO);
复制代码
( N4 u& M# V7 O3 ~$ I% T! r" n1 u- K( E4 T. P8 j; M6 o$ k" I
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
) d) R. I$ \9 p. barm-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 }6 f" n/ L$ @7 n' y, S2 w
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。3 h/ S: C( e: t
2 N+ f* Z z+ C" _5 _; n2 S) @" |1 o1 [; P6 S$ q9 e" h/ x
|
|