|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
. Q' R! g; G4 \! Z- [code]EDMA sample test application" E# C0 O/ l }$ \$ F5 R) I
- /*
2 S1 r4 y' W+ r- r - * edma_test.c
8 V# v% l2 }: a5 Q - *
" ~" o6 D/ c/ N, {. l! G - * brief EDMA3 Test Application
U- W5 R5 |7 Q4 \7 k' O1 s - *
1 w0 \# f$ P/ L. v - * This file contains EDMA3 Test code.
: {4 {' n2 P, z# i3 U4 I3 F3 }+ @' u - *; y- U2 S z' K; C
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
4 R9 z0 z7 b) `3 S4 ~. T& M - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT) R0 \( d. f9 Z2 |0 g- Z* o
- * TO CHANGE.
) v9 g' b( a. }+ }# F; n+ X - *
# }0 z' }) a9 }5 E% y1 j9 X( m& O - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/; o/ P6 Y. Q3 I
- *
! G3 K s. c1 n/ B$ q& @5 P# L - * This program is free software; you can redistribute it and/or
& w# m/ t- T* V# O - * modify it under the terms of the GNU General Public License as
2 ?* T, s! N3 G1 p - * published by the Free Software Foundation version 2.6 v# E6 U$ I( g" {+ C; d
- *
& V6 t4 ]. z3 [) l2 \" N - * This program is distributed "as is" WITHOUT ANY WARRANTY of any) c; J! g8 Q" ^8 E9 m
- * kind, whether express or implied; without even the implied warranty
2 Z, s4 b, B! m9 b7 ]5 X - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the8 _5 P2 i! m2 d D R
- * GNU General Public License for more details.' G# G: A' [! }; q- _
- */
4 M# o" Z2 N1 D* T) `& z7 @5 n - % y1 R# R9 {, O- l3 M& I5 X
- #include <linux/module.h>
0 ?' q1 t0 Y4 y4 L: B8 f5 P - #include <linux/init.h>
0 m8 W1 c& C7 a3 ^, s - #include <linux/errno.h>
; c x4 E, m! G$ z/ R" O8 y+ L' t - #include <linux/types.h>" g% l* @: |% ~9 Q' e* k9 ^
- #include <linux/interrupt.h>0 ~( g- P3 S3 d* g3 W- E" X
- #include <asm/io.h>8 I$ y2 J3 o( |: G# }) P$ E8 Q
- #include <linux/moduleparam.h>
# j8 [3 n5 x! n( n% X o6 y) e0 } - #include <linux/sysctl.h>
/ R" d z# \4 p$ U - #include <linux/mm.h>
% P1 T9 I6 c5 F$ ~$ d - #include <linux/dma-mapping.h>
~, Q4 A6 k z
! z' n8 F- X) c& x- #include <mach/memory.h>
. N* T ?* L( U/ a& l# q! S - #include <mach/hardware.h>4 N0 w# x& A; Q' o- g+ V0 A. A6 Q
- #include <mach/irqs.h>& Z k6 [* m- a/ N+ c
- #include <asm/hardware/edma.h>
& J1 Q! W& R" w. h4 |
: o( A( _, V; W, w. b- #undef EDMA3_DEBUG T/ k( \$ E6 N; t; I- R" |: s* B
- /*#define EDMA3_DEBUG*/
C5 c2 w' p- O - ! t8 W+ q, U" g" c, u! L7 `$ e5 \
- #ifdef EDMA3_DEBUG
U& Q1 c- S9 w. M7 R - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)6 q$ y" L( s$ m [
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)9 {/ j2 G7 n4 Q# Y6 G# y
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)! `! W+ ?% z, E# Q0 P$ d; J
- #else
3 T% X% l( Q" _/ d) G+ {. X - #define DMA_PRINTK( x... )
# l1 p! C9 l' H+ B% K - #define DMA_FN_IN; W. r' h* F4 M; y9 U! Y, N
- #define DMA_FN_OUT8 s1 Q. A; _2 @0 k+ r& U3 g
- #endif* ~* a; g5 u9 _4 t
- 4 F, @5 v3 ]- J8 o/ D! x, A
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
X9 s1 [1 C5 M+ M - #define STATIC_SHIFT 3
4 @1 z0 E. @7 H, c4 m/ x, }# ^ - #define TCINTEN_SHIFT 20
" {; K/ Z! f+ B% Z6 E" u - #define ITCINTEN_SHIFT 21
J, M/ D( i9 F! k% A& @1 ^ - #define TCCHEN_SHIFT 22/ m$ t* ^- s! k6 |2 R6 R2 |
- #define ITCCHEN_SHIFT 23
4 ]3 f$ c# P0 ]! G' n: L L
]) y. \1 m/ M7 E9 q+ G- static volatile int irqraised1 = 0;
' l# S9 I) W, z# Q/ U - static volatile int irqraised2 = 0;$ Q2 g* y4 f7 z' \/ `% q& o1 m) r1 U
4 S5 y z4 m( T- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);& Q4 P, Y6 @- d
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
' T& k. r: ?. V2 E( ?& j - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);. t/ B! ^, d8 @5 d6 D; M
- ) M" }" ]. a# H0 G, A) w' I5 E
- dma_addr_t dmaphyssrc1 = 0;
m/ z3 b. `- W6 N- d- Z" Y1 \ - dma_addr_t dmaphyssrc2 = 0;& i: ? y6 z/ Y2 L# o! Y
- dma_addr_t dmaphysdest1 = 0;( F9 @0 M: T. D
- dma_addr_t dmaphysdest2 = 0;+ B0 D4 p' p. N% C6 o
- # I" r7 k' U, P6 e
- char *dmabufsrc1 = NULL;& O8 T0 G2 K0 a/ z: a! O
- char *dmabufsrc2 = NULL;2 ]: ]0 `4 I0 v( ]! F
- char *dmabufdest1 = NULL;! a! u1 |: |$ U
- char *dmabufdest2 = NULL;, a+ G: M: J. H- k [" `1 Q$ G
- * j- B. U7 q! v( ?8 s9 x+ [2 t
- static int acnt = 512;; E! ~+ \; y m" h
- static int bcnt = 8;
- h% V8 j; i2 H- T4 c - static int ccnt = 8;
2 h5 ]5 F2 S( b3 @6 y/ B) ^6 j& A; k
5 ]6 O2 k' x# b9 j' O7 o- module_param(acnt, int, S_IRUGO);
, ?$ {; r: q4 m8 h* |' Y% T - module_param(bcnt, int, S_IRUGO);
# u( `% X! ]) @( w+ v5 k - module_param(ccnt, int, S_IRUGO);
复制代码 / P0 X+ ^. ?: E3 I" D1 V. `
6 \& u; _9 w$ T. `0 [
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用6 t* D) w J: L# A
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。; ?7 q9 c# ~" K; N" B
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
% {# R* u; j0 |/ H# Y6 C! Q k& M) `2 q2 ?
: h3 m! p5 C) I$ u |
|