|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 , Y3 ]" L( {, ^
- [code]EDMA sample test application
8 n: {1 l9 @) ~+ Q) o - /*
! F% b) t, V% G y - * edma_test.c
9 o" ]) O: P% J+ T( G - *
) B4 E6 |2 _& U! I* E* P$ W - * brief EDMA3 Test Application
: v5 `* R% [. [ - *3 {1 p# m U! i1 j* ]/ x7 z
- * This file contains EDMA3 Test code.
$ a2 B% {6 E3 C/ ^$ T - *" H5 u8 O$ [/ g9 c/ [6 q1 Z6 h
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
& B1 G7 k' p$ p& e# W. T' l( ]1 s - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT* U) g: p6 Q5 C! y1 s
- * TO CHANGE.
t* o Y* g+ P, ]0 y& ^ - *+ M5 g5 u( B: Z- |
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
0 @, h# M2 G/ N3 i - *
, S g7 ?* W/ W2 ], ~ - * This program is free software; you can redistribute it and/or
3 a$ L- o6 Q1 { - * modify it under the terms of the GNU General Public License as
, N& G9 e0 P' Z4 d - * published by the Free Software Foundation version 2.
4 R7 o7 K1 T8 V$ p0 q ^ - *
, F3 i5 F1 J* Y$ f5 g, t' X - * This program is distributed "as is" WITHOUT ANY WARRANTY of any" J$ v# o# ?; y
- * kind, whether express or implied; without even the implied warranty
% _. u3 `% z# Z' t6 q - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1 F$ d9 z' ^9 u% D' g4 u - * GNU General Public License for more details.
! Z) d7 w- d8 o6 t; H; _ w - */
) [" t/ F% q$ Z @/ y8 H4 M - & o8 w& }1 B; A2 z' \
- #include <linux/module.h>( m! h: h q3 b- j% o
- #include <linux/init.h>+ T6 F- L( d* g5 R- l3 C' l# @* c
- #include <linux/errno.h>
8 Q/ M8 F3 }& H, c0 p: H - #include <linux/types.h>
& p' ^' J4 Z1 G* V4 ?9 d6 t - #include <linux/interrupt.h>
/ [, X( ]6 }1 B3 C - #include <asm/io.h>
' r; ^* C) l5 P/ ~0 |/ c - #include <linux/moduleparam.h>
8 _9 @: S- O4 ?9 R* W- H7 E - #include <linux/sysctl.h>" f, I. W% x+ i9 b8 K" b+ {* f& W- l
- #include <linux/mm.h>
3 ]. m, b$ @3 {# i - #include <linux/dma-mapping.h>. n8 j" p5 E5 q) u$ z$ o9 z
- 0 r, F8 S& R( y+ B+ C
- #include <mach/memory.h>$ Y1 ?1 @/ H# Z; j6 C4 i
- #include <mach/hardware.h>- l, ~% c m' J" X1 o' Y( C
- #include <mach/irqs.h>1 ~& n1 b- L3 _9 Z9 u- N+ J
- #include <asm/hardware/edma.h>
, Q2 h* B. k+ O; o6 S( U2 e; c - - a% i" g& f3 ~7 u5 c
- #undef EDMA3_DEBUG, S) n+ X" G* \& i1 F
- /*#define EDMA3_DEBUG*/( G6 H" R+ {* j- E. b
- + H4 E9 G( ?0 t$ x0 l5 ^ u% j
- #ifdef EDMA3_DEBUG& X* Y, L, ]5 u( r& U4 O; O3 ]& D& T% J
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
! m' j. { j) T: k - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
. ]/ ]9 J, t5 E$ j2 b - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)2 ^" g9 S2 S2 Y3 j& G, R
- #else& x5 q; `! E. X& v
- #define DMA_PRINTK( x... )8 m3 y D% {7 j5 \- Y6 a1 x
- #define DMA_FN_IN
2 e1 W" ~- A6 A% G" M - #define DMA_FN_OUT
+ Y' r q9 O# ]8 M( E5 j9 X7 ^ - #endif
4 T& p' u# \2 C5 H/ s. x- H* j1 t
( s, h, u! A4 z4 \: v7 x, M- #define MAX_DMA_TRANSFER_IN_BYTES (32768)+ `$ y0 i0 p2 Z1 \ G5 T
- #define STATIC_SHIFT 3
1 b& X8 k9 _1 ^( _+ F6 m1 E' Q - #define TCINTEN_SHIFT 206 Q1 B3 q9 I. s2 ?, Q; R- U
- #define ITCINTEN_SHIFT 219 u& p! N, O4 s! |. Z9 \
- #define TCCHEN_SHIFT 22
. r) o5 @. a$ f( V0 K4 n - #define ITCCHEN_SHIFT 23
8 [" Q; e* Z. C7 X
`9 F& V$ B+ P, Z- Q9 M* O k8 a5 G- static volatile int irqraised1 = 0;* y" g5 m3 _. }- D
- static volatile int irqraised2 = 0;
: ?5 z& _8 q! Y0 q* w - U6 ]+ y6 A. v& }
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
- p# t1 X7 {! J' Z( G: l. a - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);# q9 _& j% u' N* a
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
; c0 u: [/ }/ x( D3 v$ c% o
4 p: O9 l, \' w$ k- dma_addr_t dmaphyssrc1 = 0;4 _' m9 _2 @4 f3 K
- dma_addr_t dmaphyssrc2 = 0;
8 y7 H. x% b+ r3 O: u) Y - dma_addr_t dmaphysdest1 = 0;
2 p4 B5 h8 V/ h7 x* f& y# T - dma_addr_t dmaphysdest2 = 0;+ o+ W4 d! u! P2 _( V
- 8 N, g, i8 S; \
- char *dmabufsrc1 = NULL;
5 L9 q4 x; T# y3 I4 } - char *dmabufsrc2 = NULL;
% |3 F# C! I, L) i - char *dmabufdest1 = NULL;9 g" i0 T& \9 I( i# k d
- char *dmabufdest2 = NULL;( [" o6 P+ m% j! W- o! O4 ?$ W7 G9 e
/ H3 |* ^0 w i: i) W% D- i$ M- static int acnt = 512;
9 ~1 P4 F& N& A' k( m# E - static int bcnt = 8;
; R$ q( ?5 ?! w - static int ccnt = 8;9 ]- f9 P2 c0 w( s- p. M% f( _) z' j
- 3 A; |; F, R# z
- module_param(acnt, int, S_IRUGO);
/ W8 b) N6 X, [2 J - module_param(bcnt, int, S_IRUGO);7 ]0 F+ `* s; d" [( e, Y6 z
- module_param(ccnt, int, S_IRUGO);
复制代码
9 `/ B! w- z* Y3 e* g+ d! k" S4 ?* Q6 b) ]+ D3 o
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
1 j1 M0 ^8 E* L$ |* J, @% Qarm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。$ {- C. Y8 |, ?+ [9 [
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。. ]7 `4 C; u4 F
2 \$ R4 S' \# e
( w+ O) O! p) u* g2 x |
|