|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 8 c- H: J( h9 k z0 w- i
- [code]EDMA sample test application
' I# l1 [9 n( u" l2 b+ O: \( c - /*
- }9 `2 ]; _5 _# _, R - * edma_test.c
+ Y2 c" ~: E2 T - *
8 n0 o" \ A1 Y+ s0 l) { - * brief EDMA3 Test Application( k( V3 p9 B o8 n
- ** ^/ L) s! b& ^
- * This file contains EDMA3 Test code.
8 M3 a6 w# k9 P/ | - *
- y1 H8 Q8 _1 M( e' s& } - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
3 p: s& e" U0 ?4 ]9 f! U+ _ - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT9 \2 R7 u0 v, L# B& y
- * TO CHANGE.: b; h1 I. x C8 }% S$ H' @% n
- ** r0 I: H) e+ v3 \2 ~
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
8 ~. I: E3 L$ r5 R {- L) ]7 o/ l - */ \0 J$ S/ R d! o, X; j8 x
- * This program is free software; you can redistribute it and/or
0 G6 P y6 Z3 m$ T - * modify it under the terms of the GNU General Public License as
( e) T! O2 f9 b/ g+ v4 W# M9 P- L - * published by the Free Software Foundation version 2.
5 `" @) |8 }3 M4 p0 M& B+ u5 Q% @ - *
' [1 e0 p1 @# ~ v - * This program is distributed "as is" WITHOUT ANY WARRANTY of any K) `; j+ p1 B* _% F8 k# i z
- * kind, whether express or implied; without even the implied warranty
! ~8 R/ {; M. y, P - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ b/ m! s& W. P% E - * GNU General Public License for more details.
7 A6 n: S+ V3 w - */8 X1 K- s+ N3 W+ ]8 `: }0 Y
6 G. ~/ Q7 F& T6 ]5 J9 E) B- #include <linux/module.h>% G' P" [( K6 B7 L' f2 Z+ ]9 N0 ~- s
- #include <linux/init.h>
, I2 b0 P4 y5 U1 F: u6 N k - #include <linux/errno.h>3 f8 Y3 [6 ?0 f, J
- #include <linux/types.h>, ]. q% P5 y# m$ `; i/ H0 o
- #include <linux/interrupt.h>' {% y3 y7 t# U( l' u a; ?. F& ?
- #include <asm/io.h>
% j0 a6 k5 n8 X* m$ G6 ? - #include <linux/moduleparam.h>
3 s S" E* B6 @+ P$ E8 M5 F* R - #include <linux/sysctl.h>
& D( O; j& _5 M7 y$ @( M5 S1 o - #include <linux/mm.h>! ~+ s+ _$ g2 l0 M8 [
- #include <linux/dma-mapping.h>
! E. L: o/ Z6 v# m - . q* _- U4 x) \7 h4 z& a
- #include <mach/memory.h>0 x- ~/ `. b# B" }
- #include <mach/hardware.h>
6 ?$ _" Q( |5 w5 e1 b2 k - #include <mach/irqs.h>9 j F7 A: k/ v: U
- #include <asm/hardware/edma.h>
# K$ e) U2 F" w4 Z$ D - 1 P7 P; P( R% T
- #undef EDMA3_DEBUG
; M3 D7 J8 Z) g) I - /*#define EDMA3_DEBUG*/
1 W; e# h$ z* @2 t$ E
5 {: w) s; t" N9 P% E- #ifdef EDMA3_DEBUG
* u( G* q! _- @- h, } - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)0 A/ [" c- R6 Q' x1 @# H
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)& i" }+ l4 ~( I c- M* Z
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__) v3 d w0 z7 b* \6 M
- #else P5 ~1 N0 l( z5 Z O, @
- #define DMA_PRINTK( x... )' }9 L3 n+ D- ^. ?& e. _5 [% v2 q; U- a, C
- #define DMA_FN_IN
9 F% h9 z C; [+ V ?& R - #define DMA_FN_OUT
6 S; n( e6 x$ n0 \; j( X+ l - #endif
( [7 M, L0 ?% s$ h" P$ L& p
8 t: @3 c0 R. x" u. _- #define MAX_DMA_TRANSFER_IN_BYTES (32768)+ a4 U- I/ I' l. x
- #define STATIC_SHIFT 3
3 h; j4 j% M, _! q7 f" o2 p6 Z - #define TCINTEN_SHIFT 20
8 [, z: S) P: D4 \ - #define ITCINTEN_SHIFT 21
, ]7 b" D2 w, v: [" }% b - #define TCCHEN_SHIFT 226 M1 T0 y3 C( t4 `( c
- #define ITCCHEN_SHIFT 230 i9 w3 v# X! T# F* T7 I& ^4 s
, `! Q" h7 E n1 r/ U s- static volatile int irqraised1 = 0;9 |- u6 k2 U' F" E) E3 V/ j1 n
- static volatile int irqraised2 = 0;/ }2 h. \3 Z# J8 ]1 m
- R, J1 ]" |- H, o4 o9 f- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);; a- |# L F$ _1 L# K: d6 x
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);3 g4 m4 w4 o' {
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);' n' ]2 s) d" g+ ~2 z5 o$ ?
- q- q J1 V/ a; s# w- dma_addr_t dmaphyssrc1 = 0;
3 F9 I f2 _8 z/ t, E o - dma_addr_t dmaphyssrc2 = 0;
+ x9 U# i5 H6 o" e4 n, ] - dma_addr_t dmaphysdest1 = 0;) D$ o9 K1 i4 D1 _! k0 r
- dma_addr_t dmaphysdest2 = 0;1 w$ K4 {! S# i7 s6 F2 [& x- ^) k. v
% r4 h, h. U+ w& l5 O+ [: l7 V' t- char *dmabufsrc1 = NULL;5 R1 X8 v: f9 z7 M5 b
- char *dmabufsrc2 = NULL;% Z* b* f+ Z! d1 ]; `
- char *dmabufdest1 = NULL;& j" q4 f, c* g' f
- char *dmabufdest2 = NULL;0 S! T6 t2 m, A1 y
- 5 N8 N0 v s- p. ], e5 a
- static int acnt = 512;
9 t2 U' f8 Q0 R - static int bcnt = 8;/ y# p1 d' ?8 C3 w% {
- static int ccnt = 8;
2 s' i( f. ^6 F, V2 ^ - 2 I! D) \' U! l$ X0 t- n
- module_param(acnt, int, S_IRUGO);& Y: ~; C, S( y* @( m$ e
- module_param(bcnt, int, S_IRUGO);: v. p3 t7 O4 C3 `) N* J( b
- module_param(ccnt, int, S_IRUGO);
复制代码 # c/ f6 d2 x5 B9 F% e6 z
) {$ R0 o* {# s b. e* `, n# { 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
8 P; m9 ~8 r. q1 l* V! m1 ]arm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
2 |& _2 _5 K" ?+ P% |% a 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。% B4 R3 h' [$ h) t: h* u0 Q
( v; C" B4 D' V( f! J4 V/ F0 A& q1 [& g' ^7 @" \2 ~: m9 e% W
|
|