|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 2 k, V, K( w6 N, ^0 g
- [code]EDMA sample test application
5 M7 N- ]3 U! g- m# N' m - /*
9 @" _, n6 ]. w. s! A7 y - * edma_test.c: |9 A( B7 v$ g2 z! k+ h+ Q" u
- *6 K. s. H5 A8 K0 I+ t& F: K
- * brief EDMA3 Test Application+ {" {* K: i9 k( J1 v0 [( ]3 i" a
- *" z( j4 u" q6 A. `
- * This file contains EDMA3 Test code.
: r% I3 Y( [ T! p. x$ a$ q9 X - *
5 U j% x8 n$ g+ L8 v0 P - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE. C- J( Z$ T, {& Q
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT( w, b9 j; d9 y) r* r
- * TO CHANGE.
, Q; X1 ~: P6 E - *
4 m- |9 }5 J8 C. k0 _ - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
. u6 F. y$ y, {/ A/ r: \ - *
; t$ j% v7 _: U8 R! e& \ - * This program is free software; you can redistribute it and/or
; d6 U% J/ X8 P2 @7 ] - * modify it under the terms of the GNU General Public License as
6 d! E0 k1 b3 U2 y - * published by the Free Software Foundation version 2.! X$ i% T6 x! Q, y8 }0 [2 i7 B
- *
8 V& M. A0 B0 y% q5 _/ p5 B - * This program is distributed "as is" WITHOUT ANY WARRANTY of any
; o% W' i8 @1 |/ B - * kind, whether express or implied; without even the implied warranty& B8 i9 Z' F8 ~. P1 L
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
$ @+ s. [3 [2 W - * GNU General Public License for more details.
0 ?4 S0 \ \9 z& B - */
# {& x- X8 j# Y - / p+ z! y+ |0 G* z3 x- i2 Z- F
- #include <linux/module.h>
# b B2 ?3 q8 }$ n8 P - #include <linux/init.h>7 l( h' S8 g$ k8 {0 q! B$ c6 W' [
- #include <linux/errno.h>
/ F5 j! n* g( E! C" ]+ C1 g; i - #include <linux/types.h>
- c2 O7 o" p3 t* R - #include <linux/interrupt.h>: L; P! n, n' b* w( U: p# Y- z$ m
- #include <asm/io.h>
. N! J2 U2 E9 r1 u" l - #include <linux/moduleparam.h>% Z4 m; h9 { ?
- #include <linux/sysctl.h>* Z+ m8 p/ D+ z
- #include <linux/mm.h>
0 r+ W N3 W$ e# |' c; b - #include <linux/dma-mapping.h>
# N. Q8 q: h- X: n" G0 ^+ D - ) g2 ^' J4 e" S1 {' E9 ~; I
- #include <mach/memory.h>
* |- A6 I5 e; \ - #include <mach/hardware.h>3 W; Z. B5 f3 `$ k
- #include <mach/irqs.h>
# K$ b) `6 o/ z7 ~+ ` - #include <asm/hardware/edma.h>
, [ f! c% v# Z! [4 u1 T - 5 I$ Y- T- o8 z' j
- #undef EDMA3_DEBUG
$ ^6 s+ p4 i5 M g+ i; u; P7 \ - /*#define EDMA3_DEBUG*/% ~- \( v8 Z8 S# `" G4 h4 r
! F! E0 C% n; e6 O, G; K- #ifdef EDMA3_DEBUG
( i+ I( X6 X r: T5 e1 J& Q9 ? - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)" W) G7 {9 t# E4 I8 G. s0 g
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
$ V: K( T( Q6 k8 W) T! n - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
9 x6 W: A) z3 V2 U- Z! y - #else
2 s; C9 O/ H8 t( e5 i - #define DMA_PRINTK( x... )% l2 M2 A2 m2 _
- #define DMA_FN_IN
* p, V6 k7 H2 G4 k: V( W1 i - #define DMA_FN_OUT
4 E1 R. F% f& w6 {/ c/ |6 g" `! Y - #endif7 @ \5 b: A8 W
- 2 ~/ {- r8 } |& \
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)0 @' J2 k, g f6 z& V2 E
- #define STATIC_SHIFT 3, ^: k, H- s5 X" v8 o1 t, @, Q: D
- #define TCINTEN_SHIFT 20( r& g) |* ]% h# K
- #define ITCINTEN_SHIFT 21! @+ M5 a' J4 V9 P! a; |' s
- #define TCCHEN_SHIFT 22: F2 O; X7 K- a6 K* S9 [& F2 P
- #define ITCCHEN_SHIFT 23
[" B3 }# h) D# Z - ! c* C, T6 c- `% q
- static volatile int irqraised1 = 0;8 w5 @8 _$ T: p8 l
- static volatile int irqraised2 = 0;
+ S) _! G* [. i. Y - ) N" j V) D3 n% J: h
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);* B" `$ j, V: i: I
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);& f9 m1 L) V6 `( }; K2 a$ B
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
- E" F6 H8 `$ L* I' F& B& L n6 i+ b
% \. N7 u& h, \$ |( J2 M% ^- dma_addr_t dmaphyssrc1 = 0;5 Z3 S( i1 O0 |/ C1 O6 }0 ^
- dma_addr_t dmaphyssrc2 = 0;
" I( `" G5 [7 w `7 u* w( s - dma_addr_t dmaphysdest1 = 0;
1 B. t9 H$ C! M6 x9 @* J - dma_addr_t dmaphysdest2 = 0;
! L. p3 |6 h) B8 M, l" R- f8 d - ' [4 D" B u3 i- K) |
- char *dmabufsrc1 = NULL;* x, Z* p& D7 ^5 b Z' V
- char *dmabufsrc2 = NULL;( j' ~5 V! H, `3 ^- P
- char *dmabufdest1 = NULL;/ o) X. o) Y; P' Z! U6 w* k
- char *dmabufdest2 = NULL;9 h2 u7 a& }7 [6 U
+ t* D& ^! F( `4 b( |- static int acnt = 512;+ o4 C9 n4 W4 h: d! f
- static int bcnt = 8;
5 {% {6 I2 Q8 t8 o - static int ccnt = 8;2 A- o0 U4 i; t* R
- " L) f0 ^+ k8 {+ g
- module_param(acnt, int, S_IRUGO);
$ k' t7 @# Q) W0 }5 H8 \2 M - module_param(bcnt, int, S_IRUGO);
- U: }& V7 _6 j - module_param(ccnt, int, S_IRUGO);
复制代码 & _; `! j& F4 r4 w; S0 H
% C5 H, m( `6 z2 s) r/ }# k 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用2 q0 G/ y. v; s- t; U: F
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
4 s# L) ?- Y& L+ r* _5 e' c 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
9 r" ]) n2 M1 \! S& d0 T7 y; J9 t/ Z0 J
- J u. I5 n4 z+ d |
|