|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 / M( M- H7 {0 W$ z0 V- O) U* `
- [code]EDMA sample test application
) l7 j, Q0 ?: K) ` - /*
. M6 U* j4 O" D7 c, o# I. V' N1 l - * edma_test.c$ b- |: _7 i& l* T) t7 u
- *- I( O6 d* u1 F: ~: f+ p0 R
- * brief EDMA3 Test Application
: u, K2 c; \4 z7 Y& v( ^% z - *' `# V; b! b4 \ A }( I, ^5 u4 N
- * This file contains EDMA3 Test code.; v/ m0 U2 i1 Q8 Z' ]
- *, P8 a! v. s' D4 Q
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE5 i# b7 F, z. M3 \2 I% g$ r) o
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
! p4 E% ?/ W- U! s - * TO CHANGE.5 W0 Y. V5 v, u& o) C3 D6 c. e4 O
- *6 @$ Y* \7 `' j! X" Z7 `* s
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
' Z8 I/ r# R* d; e/ o8 d, ~5 H - *6 o$ a) K4 q& X4 z- f
- * This program is free software; you can redistribute it and/or
8 ~1 d& U; U# \8 ^ q - * modify it under the terms of the GNU General Public License as
7 h. g& g5 `0 o+ z/ T$ E2 M( R - * published by the Free Software Foundation version 2.
$ f p0 G3 E4 f Y4 i3 a: \ - *
; E# {" r: f- R' X# i% N" f - * This program is distributed "as is" WITHOUT ANY WARRANTY of any
$ b5 H* p8 N: q - * kind, whether express or implied; without even the implied warranty/ e- E" {& g6 S- _3 g2 C P6 _! B+ H
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the: f# b; _! s- G( X( M# `
- * GNU General Public License for more details.
& n9 ~% T: P2 m) G5 ]' |+ f# A$ [ - */
; A! s3 b9 e) C1 p X5 x) t9 W
5 p- Z! H9 f1 `( m% O+ ]- #include <linux/module.h>
3 [3 g7 o; p1 Q$ Z( y - #include <linux/init.h>
+ y3 h# Y, x* z7 I - #include <linux/errno.h>' T& y$ q+ p" U) ?5 m
- #include <linux/types.h>
2 F' H |# [' Z - #include <linux/interrupt.h>2 u- p( I: o U. M" e8 ?7 l
- #include <asm/io.h> N3 J5 i9 a! k' o6 D
- #include <linux/moduleparam.h>
, }( |# N( \' J" Y1 V - #include <linux/sysctl.h>+ C3 e$ k) g* A8 V8 Q
- #include <linux/mm.h>- }" p* T ~1 b/ J G
- #include <linux/dma-mapping.h>" y! _8 U! A' o/ f$ _9 E W
- ' C7 Y$ O3 a- w+ [4 Q. \: O
- #include <mach/memory.h>
5 t6 k, }4 b: N$ Y: v( d0 D - #include <mach/hardware.h>
% i- y7 m: O+ l2 h/ A6 R9 E( m - #include <mach/irqs.h>
1 N7 o( X+ w/ V' e0 g( C1 @) J - #include <asm/hardware/edma.h>5 d$ F7 I9 u, D1 Y6 L* x0 ]- [6 W2 r
. t) {% E; P" C" z% O: v( X1 F( B' [- #undef EDMA3_DEBUG, n' J7 O# i- I0 Y2 ?* V
- /*#define EDMA3_DEBUG*/) Q C- t) t) W3 p! o" W
- / A. N: j8 R k' b
- #ifdef EDMA3_DEBUG/ x* K2 k+ Z9 y
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)0 [0 u7 R- T% W, E
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)) R. `, q7 u3 j# F
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)5 ^2 q1 r; V* |. w2 ~- h
- #else
: I4 g, d" }) c { - #define DMA_PRINTK( x... )& ?. {; E5 G1 i* h( v- a
- #define DMA_FN_IN
- Z x- r- D1 X9 V% _8 E - #define DMA_FN_OUT
) z/ S. w. k$ [% z$ J2 _" e7 ] - #endif/ B+ b5 G6 D; z$ }' Z% ]
8 x2 a0 T; d# h2 R* H0 ?- #define MAX_DMA_TRANSFER_IN_BYTES (32768)* G. o+ D) w+ ^" d' M
- #define STATIC_SHIFT 37 ^1 p) k8 j- w( P2 Z
- #define TCINTEN_SHIFT 20# d$ N& E; y6 X& b3 s5 {) Q$ r# Y, V
- #define ITCINTEN_SHIFT 21
' ^5 F' M5 Y2 j t5 J6 \ - #define TCCHEN_SHIFT 22
& l/ D7 }: Y6 c# \# Y5 z - #define ITCCHEN_SHIFT 239 P6 O; k4 H- x+ W
8 u0 a1 n8 C8 |* H# `- static volatile int irqraised1 = 0;
% ~* @. |$ U3 Y2 s: c; C- | - static volatile int irqraised2 = 0;
) Y9 t- o$ M k' r4 x+ ~ - : G' y4 q' M5 h- ^" U/ u
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
4 s. w1 s& l) a! G - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
; G$ y; z9 Y8 C2 s5 e - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
' i: t: P7 n1 R( [2 m
& X7 B+ O8 U- ]- dma_addr_t dmaphyssrc1 = 0;9 B( l% t* I/ T/ v g8 s
- dma_addr_t dmaphyssrc2 = 0; g/ {& p+ t' t; h( S6 a" M, K) W
- dma_addr_t dmaphysdest1 = 0;: m/ }! Y; A- E* x* w
- dma_addr_t dmaphysdest2 = 0;& G: |) n$ L T6 Z2 Q- @0 y
- * r3 Q9 n3 y+ O# n5 a
- char *dmabufsrc1 = NULL;
. Y; a" d, y5 U: R# j w( Y Q8 X - char *dmabufsrc2 = NULL;
' d! H/ r6 `: Q2 C; j - char *dmabufdest1 = NULL;$ W! [+ o: |* r; l
- char *dmabufdest2 = NULL;
: ~( Y& V" W2 B3 u! h; L2 R! s: X
" s0 ]8 B4 q! W: l5 ]% @3 E- static int acnt = 512;
* U% ?- {" f+ d. U' | K: \; ?, N - static int bcnt = 8;
8 u+ h% g; d/ Z2 o - static int ccnt = 8;5 y9 z# r+ _4 W+ q/ v
; [8 j( b" L% H1 t, Q! F* j- module_param(acnt, int, S_IRUGO);5 j/ Z2 x6 u+ j$ c8 a7 [. B8 s
- module_param(bcnt, int, S_IRUGO);3 l( X0 O; j3 o$ b
- module_param(ccnt, int, S_IRUGO);
复制代码
% N( a' @) T0 d1 @: u
. X7 p# m. M/ Q) \1 s 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
9 k$ U* \$ k& Q* d- [8 {4 |! x, Iarm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。' D' |+ Y2 {# x2 j0 ~% R$ Y
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。4 U, S% X# z Y) Q5 D
/ [- b3 ?( s! r: U: i) j- C
; g; N4 b F) ^9 j9 {* I4 L+ e |
|