|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
; h2 K- g/ S. a& V+ w% A) k( ~- [code]EDMA sample test application
/ \" t# n2 t# ^* D" f6 H - /*! a/ K3 Y) `6 h2 Y$ k5 J8 a) h
- * edma_test.c
6 ~( L4 k- W+ P) t5 M! Z - *5 L$ \" C8 E* N4 q# D
- * brief EDMA3 Test Application; r$ m9 w+ M) @: U9 s& l# f
- *
9 T+ c: |( E5 K! T0 m) E - * This file contains EDMA3 Test code.5 w4 c J3 J& l: @
- ** ~: d' g" j- u% B, O
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE, u5 G- j, |8 u$ F7 m! n, H
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
) T1 ^9 E/ X( A, ]. w. g7 m- T - * TO CHANGE.) G* F- a" V2 t1 q" \- P# o9 n
- *$ Y0 ~# _. N/ j6 T
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
$ i3 ^1 j f7 q0 G: {; x - *3 h1 D/ j6 i6 Z0 j. l1 Z
- * This program is free software; you can redistribute it and/or
2 `+ ~- Q* o2 d( V- X+ P0 } - * modify it under the terms of the GNU General Public License as9 q0 Q- U: B- L4 z# n
- * published by the Free Software Foundation version 2.* Y) x6 e/ l# Q) |" p5 d
- *
% J7 S. ?* H- P) P6 H - * This program is distributed "as is" WITHOUT ANY WARRANTY of any7 n, a k8 m2 I+ v
- * kind, whether express or implied; without even the implied warranty0 `% O/ v3 W) N0 X2 `) C
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the1 u( {" m9 j3 |# @: f- `$ @
- * GNU General Public License for more details.! z" ~2 I* @0 p( z; [7 @
- */
2 j& s1 O/ i6 `. A - - @* ]9 F8 A# g7 [1 _
- #include <linux/module.h>& w( M: V3 {8 z8 W8 \, G/ L
- #include <linux/init.h>
8 A4 Q6 B! I* _# F. P - #include <linux/errno.h>
% Z) M7 m1 ] |6 S - #include <linux/types.h>) W6 D. L9 B6 i" S
- #include <linux/interrupt.h>. @* Q: R- D, t3 G# ~
- #include <asm/io.h>
0 V; \0 W! @2 s" M* w1 Y, F2 s - #include <linux/moduleparam.h>
& G! t& B# \( q# P+ q$ N: b - #include <linux/sysctl.h>
; R6 G: ?# l ~4 L3 {. O1 F e - #include <linux/mm.h>+ Q3 T1 b$ h4 u9 g* [/ R% W
- #include <linux/dma-mapping.h>
8 J, ~0 n% H2 t' K2 L0 | - + E7 G, d/ J4 P
- #include <mach/memory.h>
9 m5 M+ Q9 y) ?) C# L) i - #include <mach/hardware.h>: n( T0 R! I p. L" H
- #include <mach/irqs.h>$ V0 ~! E- p; Y) d, S# o' s* Z/ @
- #include <asm/hardware/edma.h>8 C% c t, X, C
}) I9 ]4 o/ m- #undef EDMA3_DEBUG
" o% P! k/ O# }: }( i2 k! R) p8 k$ a - /*#define EDMA3_DEBUG*/& N2 @1 r9 x# G
- 5 y# |% ?. w3 b
- #ifdef EDMA3_DEBUG8 h5 p3 E3 o& L. R7 j3 _
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
, d5 K4 C/ L0 O# m - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)8 M3 W" n! w+ C, k" S8 y, f
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)! j/ ]3 u* _7 D2 J
- #else
) P0 f2 m# |* { - #define DMA_PRINTK( x... )
! h& N. P, D/ b2 f - #define DMA_FN_IN3 n: ^: J3 x" g) Y
- #define DMA_FN_OUT: v. E" J3 Y _( E- ]. c, H: S% k: ^
- #endif
. I' x! p {) N0 ` - ( d8 e5 L6 ]6 @
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)8 S- r" C0 |! h$ p$ z
- #define STATIC_SHIFT 3
" I5 V- N6 ~0 ]; i' k - #define TCINTEN_SHIFT 20
% b, E# W- ~# t- y6 l - #define ITCINTEN_SHIFT 21
$ D+ R# c' P: V( z3 \ - #define TCCHEN_SHIFT 22
" E7 M6 y1 m2 H8 O- A/ k - #define ITCCHEN_SHIFT 238 H- h3 u' \7 G* ~
, T" J* h; y% A* K- static volatile int irqraised1 = 0;( p# Q( Q: v: C v, U$ B/ |* w
- static volatile int irqraised2 = 0;
# V& P# y& D# }9 w$ c - $ Q q2 H3 S. F6 l0 F# |, k; V2 H
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);4 t$ u) {% ^- V) N u4 A1 s2 _) C# k
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
; a) S* w# R0 D3 Y( g" f - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);8 v. [3 @0 u8 r" n
- : C: }7 K% E2 A B( ~
- dma_addr_t dmaphyssrc1 = 0;
6 r" a) ?- b& O5 p8 h" ~ - dma_addr_t dmaphyssrc2 = 0;
, N h% q: `' V) e# d% k; K - dma_addr_t dmaphysdest1 = 0;
9 H: n9 a1 G- D# g0 F }* a - dma_addr_t dmaphysdest2 = 0;; u1 x! d p0 C* A" t& ^
5 _5 z6 A# V1 H- char *dmabufsrc1 = NULL;3 E" l% W' ?7 U! D" W: n: k* J2 m
- char *dmabufsrc2 = NULL;" `1 D5 }! E; h; z
- char *dmabufdest1 = NULL;. ^! o9 f( A. I. C2 k' h( Z
- char *dmabufdest2 = NULL;
! R, V; W Z5 \5 Q2 A3 Q
7 a8 j, q7 T6 G5 S9 X- static int acnt = 512;9 p* L: Z' x' @( P- m
- static int bcnt = 8;
( l) i/ M) G9 F, K( _ - static int ccnt = 8;, Y# I; {2 e6 a+ c# R r3 w
% z8 g& L8 K7 b3 m- module_param(acnt, int, S_IRUGO);
: Z" v% r) ^& e L: Y5 f f/ [) z7 v - module_param(bcnt, int, S_IRUGO);9 c9 H: ?8 `$ F' p+ Y- c& P# y# s
- module_param(ccnt, int, S_IRUGO);
复制代码 : m" a8 a$ H# b, o
$ _1 C) W" ~" D/ Q8 j+ Y 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
* v- V% T: U* \4 `. K+ S, jarm-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' J1 y, J6 ~" j8 {% S 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。9 j- t8 K9 k4 u% B
$ k, e/ |5 a) p
0 G* B9 I1 B4 F b2 o
|
|