|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 8 O, M- b) @ n H; O/ N! J M
- [code]EDMA sample test application
/ F9 h2 R% [5 s. c1 V) j - /*, F' Q/ J$ g' V. A, j" _
- * edma_test.c
5 p! V9 M) ?2 U F2 f y1 M; S - *: ]' q5 s6 S# j. X2 H
- * brief EDMA3 Test Application
; W/ n) f# Z2 F' V( a - *& Y+ ]" ?* d+ Y, g
- * This file contains EDMA3 Test code.$ q% M! z& i+ b9 z, g
- *
" ^3 G3 l) n& m7 ?& j - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
+ E$ D: ~6 ]" @ - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
% o. S2 k+ x( x6 n$ h+ c - * TO CHANGE.
7 c2 ^) }* }$ C7 [: c8 n0 F. W - *
" {' Z/ G0 Z% ~0 U - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
" s! O* x; U' y+ A - *
; v% p7 D3 a* ~* _6 A+ D - * This program is free software; you can redistribute it and/or5 L- U9 a) m. ~
- * modify it under the terms of the GNU General Public License as$ V# q, p2 g5 T- B' `
- * published by the Free Software Foundation version 2.& s' X g3 U5 f. c6 D+ \
- *
6 t" C& v. ^ }% S - * This program is distributed "as is" WITHOUT ANY WARRANTY of any
1 F }. J/ c2 T. _9 T( f* D D - * kind, whether express or implied; without even the implied warranty
8 t! t7 M v. C5 h7 ~3 c$ y - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
0 M8 g6 ^# y$ R0 ] - * GNU General Public License for more details.
; k1 o- w$ N+ q) o& \ - */6 u3 I0 m+ }9 t" s# ]& g1 P2 z, N
- % m: k& W/ _9 W& z* L
- #include <linux/module.h>
; _" \+ |7 c2 g; l5 N$ h - #include <linux/init.h>, x9 ]' c% v7 U, }7 ]' `
- #include <linux/errno.h>; R+ x0 D- R, O( Z! Z! N
- #include <linux/types.h>
# c7 V L9 F# O7 n! { L# S* B& g - #include <linux/interrupt.h>% E: l( _; @( u" P$ {
- #include <asm/io.h>8 i& J4 X" g7 p* w7 T
- #include <linux/moduleparam.h>& z0 g' a+ B( l K$ L J
- #include <linux/sysctl.h>* h' g* @+ w M6 ]" ^
- #include <linux/mm.h>& W# i1 K* `( }
- #include <linux/dma-mapping.h>" }" f/ `2 e( V
- 7 b1 O' R, G0 Q2 I4 |! N+ k5 |. x
- #include <mach/memory.h>* B3 S2 f5 N9 M0 f9 {& c
- #include <mach/hardware.h>5 {1 U$ _. {5 }0 \. O% G4 r
- #include <mach/irqs.h>
3 Q0 c/ i# ?; y4 N2 [ - #include <asm/hardware/edma.h>7 ?' k, w4 n% j& F* J+ \
- u& F+ P" Z V5 O; i! X- k
- #undef EDMA3_DEBUG
8 Z9 i* }4 g- ]& r8 s" d - /*#define EDMA3_DEBUG*/5 H3 _/ K9 o8 B5 j, ~7 X# N
7 V7 m& h; Q/ l# R; d, F- #ifdef EDMA3_DEBUG
% i: D s6 B9 ` - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)- l2 D( T O6 u
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
0 h. O, @- R, Z+ V/ t - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
! i/ S0 u5 y- L9 c - #else; n; I! `8 R3 _. Q, v! _
- #define DMA_PRINTK( x... )
" S' o2 J a% ^" s1 ` - #define DMA_FN_IN1 u5 M7 c4 L7 J% i6 I+ ^7 |) ?
- #define DMA_FN_OUT# b w: }* W) u- H' T
- #endif
5 F( K$ B% M$ b8 y9 c
5 s4 K' C( {' U( ]8 e3 ?- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
& n6 `$ h% ~# x, y* C - #define STATIC_SHIFT 3* P1 ?' E, U* f! t5 h$ b5 ~4 g
- #define TCINTEN_SHIFT 20: @$ s' M0 {+ m! E5 |
- #define ITCINTEN_SHIFT 21# a+ V2 h) c! g. S" r# Q: v
- #define TCCHEN_SHIFT 22
; A6 U" G- N1 E - #define ITCCHEN_SHIFT 23
, G$ Z8 e9 @- v4 M J& o, H% a
% o; @7 h( Y+ `2 p1 ~' ~- static volatile int irqraised1 = 0;; R9 Y3 N. T y
- static volatile int irqraised2 = 0;
) }3 U1 v! Q6 M+ V" N; v3 n7 K& [/ F$ Q
4 v4 W6 n9 X3 x6 D$ }2 s( C8 E" [- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);. \" m, N2 |( v7 `( o
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
% w( p& M: v3 n" g+ T& s - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
) g1 J+ P0 U* ?* P5 T4 v! Z3 v. p - ( N2 N b/ S8 c- ]+ N- q
- dma_addr_t dmaphyssrc1 = 0;$ K& ^8 L" ~$ R
- dma_addr_t dmaphyssrc2 = 0;
5 A3 q8 s$ n7 f4 R5 e* g( } d - dma_addr_t dmaphysdest1 = 0;
# i- V6 G" D* {( X. L: u - dma_addr_t dmaphysdest2 = 0;6 ?0 x% J4 Y9 \
2 B2 f W0 O. x$ ^& O+ b* ]+ B* x- char *dmabufsrc1 = NULL;$ D1 B; }9 A. k
- char *dmabufsrc2 = NULL;$ P' Z- G4 Y; ^. V' q3 q
- char *dmabufdest1 = NULL;3 }) P6 I# f6 p
- char *dmabufdest2 = NULL;
$ q8 x0 m. A8 M4 f- P
! o3 g* g, @* _* E: N# ?- static int acnt = 512;1 `$ W1 f* Y0 k! g
- static int bcnt = 8;# t& C! L+ _" r4 Q, U
- static int ccnt = 8;) T" G- G3 {# w
- / `! @- G' D- B9 I
- module_param(acnt, int, S_IRUGO);* N, {. }3 P1 {5 y2 J
- module_param(bcnt, int, S_IRUGO);& C' I. ?4 Q! m. o* z% _ v1 l5 p, _; U
- module_param(ccnt, int, S_IRUGO);
复制代码
8 m* L) R: E7 P- H2 w/ J$ f1 \) `+ o, D
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
, {, `- \; \& u8 x5 x$ M: rarm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。( Z5 ~ j4 O- v8 x+ c8 w E
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。# j9 g. ~" b/ o$ l6 H' E% t
# `/ y* l o) }1 q
: M# I+ I" \2 X |
|