|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
2 G$ g: C. X% ], @3 v- [code]EDMA sample test application
% z( l! L$ ]! V! ?* d" @ - /*
2 C5 q6 l' v3 s5 O- V3 t - * edma_test.c
2 K$ h( o" x' W. w# [) d - *
1 L2 U- [" G& J - * brief EDMA3 Test Application
# @ C" e Q: ~3 {7 l - *$ _3 H U( Q* Z# W
- * This file contains EDMA3 Test code.
5 r/ l+ d& N" U% x0 m8 b' z( W. n - *! O1 [( Y. q {" r6 `+ J& t5 L
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
9 L: V' ?: @( c$ L7 ~' s. O - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
* K2 t8 @) _" a$ B* d# l8 @* o - * TO CHANGE.
% N3 L9 c# ]/ z# D: e+ [ - *
1 W" O: o, S E3 j& x) n - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
: b1 m; |3 F3 |7 }7 t0 ?- X - *
; J! z! l6 R0 X/ a) ?* a - * This program is free software; you can redistribute it and/or
+ c, j1 [" l, g( V& V: Y - * modify it under the terms of the GNU General Public License as, W% |; ?- b% ^1 Y. W! R$ v
- * published by the Free Software Foundation version 2.
0 ^: x1 h8 ~6 A' { - *
1 U, c" N, {3 q1 s4 R. y& _6 l4 { - * This program is distributed "as is" WITHOUT ANY WARRANTY of any
; N& D! E8 n J0 |2 p - * kind, whether express or implied; without even the implied warranty
: q% P" i! B Y - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the5 y4 {) p, C( l; T Y
- * GNU General Public License for more details.
& L6 W, j; l Y$ G3 K - */; v$ M* X2 U' a9 P
) }5 n. s5 T) \1 b( y* _3 P- #include <linux/module.h>
2 V& ?9 _0 c5 x- [- | - #include <linux/init.h>3 G$ c& K+ N& b# t3 t" B X
- #include <linux/errno.h>
# S5 C( L" K; @9 z z - #include <linux/types.h>9 ^2 r5 F1 C( b) Q* r6 i$ |( k
- #include <linux/interrupt.h>
1 X- Z7 p7 y: J* e6 A - #include <asm/io.h>! G; B# b: v* \+ ^
- #include <linux/moduleparam.h>
+ @3 u* |7 W y+ l5 v - #include <linux/sysctl.h>
" _& m( |6 M2 n- S) u! r - #include <linux/mm.h>' U |/ G) S5 K. R, f) u |7 J3 w& h
- #include <linux/dma-mapping.h>
b! r5 L; r* a0 R9 w - 1 e- h: Q' Z" P' f3 ~2 \
- #include <mach/memory.h>" G( p9 I; i! y6 b7 B& K
- #include <mach/hardware.h>/ }- D( r1 T8 g$ m O# P( E
- #include <mach/irqs.h>
! d A& U" u8 k1 T# K9 ]/ U - #include <asm/hardware/edma.h>
% }$ e3 s) z! |- A7 N
& v7 ^, x# |2 `! [5 y- #undef EDMA3_DEBUG
, K! q* v+ ?" n: r - /*#define EDMA3_DEBUG*/& X2 m2 y5 S4 U( ]/ i' \
0 q! i, I, w, J' F+ m- #ifdef EDMA3_DEBUG
- Z+ m; F4 L/ Q3 |( v+ m - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
$ Y' \7 ~5 h+ Z* {( X3 _& d - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
9 \2 m' j* K4 U - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)& p4 Q' |! Q' q6 ?
- #else
/ G" Z. E2 ~0 L$ R5 A0 f - #define DMA_PRINTK( x... )* _" v$ a7 p P4 q3 c
- #define DMA_FN_IN# A. o+ `8 b) o/ y4 k3 z
- #define DMA_FN_OUT
# p/ {# b; i8 l4 j' [ - #endif
# m% i* a+ l2 V - " E& O- l& ]2 o$ v# C- t/ C
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
$ w$ s# D; I: C5 F - #define STATIC_SHIFT 39 A& ~! [* c$ q* }
- #define TCINTEN_SHIFT 202 I0 [3 {' J0 V( b( o3 z
- #define ITCINTEN_SHIFT 213 g% m" p, z; P) N/ p# I' k
- #define TCCHEN_SHIFT 22
% w( m( N* s3 a3 N: i - #define ITCCHEN_SHIFT 23
B2 X, Z; l- C; f- \% P - " o6 a8 z9 z2 M J* ]
- static volatile int irqraised1 = 0;$ d0 q D6 a& U+ T/ U
- static volatile int irqraised2 = 0;
" Q+ [4 t" G4 y0 p - ' p9 U Q9 K: R1 B9 R
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);' f& T* E9 B; j5 [* W: B
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);. d8 _, g9 f' n, g
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);) Y$ p4 P1 u0 e/ G
- ; G% l+ Y( C& a5 f
- dma_addr_t dmaphyssrc1 = 0;
. ?4 q$ ^1 p6 h" p - dma_addr_t dmaphyssrc2 = 0;
, L; |1 e+ ^' L' `: C. e - dma_addr_t dmaphysdest1 = 0;
# |+ S. h* e* k! q* H+ ^ - dma_addr_t dmaphysdest2 = 0;
& a! S' @! Z _
7 f4 U& w, Z" a0 ^& f- char *dmabufsrc1 = NULL;
( I1 b% \& W ~& v+ P4 z( ~0 I. C - char *dmabufsrc2 = NULL;
2 z/ I* R! f% F9 \# u$ k - char *dmabufdest1 = NULL;" X/ B* ]# w+ p% s
- char *dmabufdest2 = NULL;) O9 r' q) `9 v2 B3 I" F
- L" {6 j/ L+ v a/ |, `+ |/ H- static int acnt = 512;4 P4 A' ?& k, T9 A+ K; q3 S7 g% Q
- static int bcnt = 8;
# Z, a. u: F2 Z/ Q$ v! H5 [" Z" ~6 J - static int ccnt = 8;( v6 `+ e+ `2 T0 `6 S
( R p: V* b* z8 E- O. A* F' J- module_param(acnt, int, S_IRUGO); N: @. q; N- r8 p2 M4 ^
- module_param(bcnt, int, S_IRUGO);- y7 F& d$ ~9 h% I
- module_param(ccnt, int, S_IRUGO);
复制代码 , b% o# u* w( e
, e4 A) j) K c6 k. S9 `( p
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
; t6 m. H' L/ m! A5 O3 E$ 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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。/ N! Y1 x+ b) j' ^6 e
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。' [, \7 u( ]& n
* Z' l8 S3 k5 p( a- s ?8 b: i
6 V$ K# d( v+ M& B |
|