|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
; W4 L. B: w7 E* S8 q- [code]EDMA sample test application
" b$ x8 c c( S* N- Z$ C2 E - /*# r7 r1 G) n A
- * edma_test.c" O! U# T/ o/ @" v3 Z; y8 \" k
- *
3 M9 d8 }9 U5 A3 i6 }# `) E" T - * brief EDMA3 Test Application6 O$ z5 S, A a- g5 }
- *
0 C" q- ]1 _# D - * This file contains EDMA3 Test code.2 K) W8 p/ K1 n; }- n
- *- [( g% S4 u# T, P" }
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE# x7 ]- l# m/ g- ]
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT5 [# |# ?/ u& C+ x
- * TO CHANGE.$ v. i1 D# F2 V/ N- O$ u
- *0 `0 D, B8 I7 C" d* c0 ?: O
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
) h; _3 M& U2 U4 f6 Z! ^" X+ f - *
1 V2 Q$ V2 P, S9 n. `! Y - * This program is free software; you can redistribute it and/or
' [% v7 U* |9 `2 M - * modify it under the terms of the GNU General Public License as
3 `2 |6 k/ E1 F - * published by the Free Software Foundation version 2.
7 V6 p9 D1 t0 o8 A8 m2 g3 @1 q - *0 w* d5 x" l, K" Z2 V0 P# `
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any
( z+ Z `' p" x G# c) R# x, m - * kind, whether express or implied; without even the implied warranty+ F/ A: I6 L( r
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the' M6 j1 g G5 y+ J, T( B5 _# y
- * GNU General Public License for more details./ }' y! _7 c9 `! H% o! {3 }
- */8 _9 R& p* d' j+ ~* w' B
- C8 w/ q( Q1 K1 m- #include <linux/module.h>& N7 D- J# l I6 [/ l9 z( W. B
- #include <linux/init.h>
* T8 x* I; c5 \, u+ s! M6 F - #include <linux/errno.h>! v: o/ x0 L5 u B
- #include <linux/types.h>8 e5 u M/ ^9 ~" R5 n
- #include <linux/interrupt.h>
1 z" ?7 _8 r0 e0 f* H - #include <asm/io.h>3 z Y, }, q# ^) e0 r1 P& ~% V+ R: h
- #include <linux/moduleparam.h>6 N7 t7 ~( C# E6 I) ]
- #include <linux/sysctl.h>
) T* h0 n$ u$ ^4 b! V" ` - #include <linux/mm.h>
6 X, R, Z( d h$ l G7 f5 v - #include <linux/dma-mapping.h>) ? Z" V! ^6 V g& w4 `
- + {( C5 ^7 {* B, d, [( {
- #include <mach/memory.h>: P7 I+ w R/ U( B* d
- #include <mach/hardware.h> c8 P! n' ^- F) b$ g2 m V
- #include <mach/irqs.h>
8 }& b$ k( [5 f+ Y+ @ - #include <asm/hardware/edma.h>
7 K! \) g- d3 x: Q* f y
5 o9 S) J8 z+ ?- #undef EDMA3_DEBUG
8 {( d9 K! y# E; P - /*#define EDMA3_DEBUG*/
& |/ G$ d( G i - : T4 |, N: D8 q/ {% a4 n
- #ifdef EDMA3_DEBUG0 Y) Q* l% V. b7 q3 L
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
" i% p$ d2 t, {4 A - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)" ^0 I) ~* m' u1 Z
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)% O) y( \. h6 e4 `
- #else
) y, z; Y2 D N/ v& s/ \6 j5 e$ a - #define DMA_PRINTK( x... )- u4 c9 P1 u% g, L o
- #define DMA_FN_IN
3 P% x! A: G7 z# Y" U4 I; I - #define DMA_FN_OUT" Q( y9 A/ i4 q- d7 F
- #endif, p v/ G7 P) e y- V
3 a- c7 Y, t5 |2 G _- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
3 t+ o( g" p1 N6 N/ y1 p& o - #define STATIC_SHIFT 3/ M6 g' _7 V# B/ A7 Z C# @
- #define TCINTEN_SHIFT 20 b$ X! U* R7 _
- #define ITCINTEN_SHIFT 21
3 ?: }# A! v, { k5 X - #define TCCHEN_SHIFT 22$ q4 X" Y! f% w( G
- #define ITCCHEN_SHIFT 231 h% Y5 c+ ?# K
" `/ q- A" b7 T9 n+ {# s- static volatile int irqraised1 = 0;; b, U# C; a2 A# }5 Y6 |; a# k, K0 W
- static volatile int irqraised2 = 0;: Q, q7 Q2 C2 H( v; l, c
3 v' q: i2 K$ ?' c+ ?- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);, L* m5 l' K) c9 T. `
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);% F) W; J: }1 Y% d6 l# ~
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);* S/ i0 A2 n4 O0 @) [
0 n: H5 I } B+ ]' G9 }- dma_addr_t dmaphyssrc1 = 0;$ p9 m; c- K9 Q8 ^9 B" R' Z
- dma_addr_t dmaphyssrc2 = 0;6 [( x8 d4 r; W8 `; e- J$ Z
- dma_addr_t dmaphysdest1 = 0;
* G" z0 B0 l& H2 U2 Z" l - dma_addr_t dmaphysdest2 = 0;
" P* \9 E' M2 T5 Z H# e* j - 3 q6 K6 B" y% |) c- u" H5 {
- char *dmabufsrc1 = NULL;1 P- h/ J1 \& b6 f7 c4 r8 J' G
- char *dmabufsrc2 = NULL;
( A ~; X5 m6 V0 s - char *dmabufdest1 = NULL;3 D" h3 E& d! r
- char *dmabufdest2 = NULL;
& B6 p P. ]' f$ j( a
8 k/ y+ j- I& P. Y: \8 ^+ r- static int acnt = 512;
7 T" n( s; @1 ~7 I1 ^* j3 i - static int bcnt = 8;
4 b4 ]; P3 M I$ s - static int ccnt = 8;, p" B Z) Y8 p6 W. n' Z5 Y- y$ g4 K. ?
- 0 q! p$ ?, K/ A2 l. q% Y: |
- module_param(acnt, int, S_IRUGO);: ]& }% D2 M& d% ]# e7 b
- module_param(bcnt, int, S_IRUGO);( r. C+ B W! i0 f( [
- module_param(ccnt, int, S_IRUGO);
复制代码
( A/ s# m1 `4 r3 x3 a
- ~- r" A$ ?( w( C 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
& o9 a) G- c# x; V; }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 K2 L5 M4 O' E- ?
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。2 }3 a( N. p( A( O0 j
; [& L' K- b: [$ i! F
9 W$ ^. P& @6 a: V. Z |
|