|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 : z: }, e7 `4 o, m' a
- [code]EDMA sample test application
# N9 y) K5 B, c; v& A - /*
) G2 T/ ]. w Z {; [ - * edma_test.c
1 C+ |* C Y- M4 d - *
4 W' ^3 l6 e k9 c - * brief EDMA3 Test Application
8 a* O6 G+ g2 w5 ^0 d4 a - *. q& Y( _, S. }
- * This file contains EDMA3 Test code. U, r# l% ^7 R1 n% E9 v. `. O [
- *$ ?* a: w6 C$ T, `1 w
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE. L1 x* H$ w' h0 B
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
; ~7 ~# g$ ^( X& D% [; J - * TO CHANGE.
& L7 v2 }, ] v - *
! N6 S0 l+ n2 C" i - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/# @2 P- S+ _1 b9 ^& t% t
- *- ^1 A. a! D( d. t6 t, m
- * This program is free software; you can redistribute it and/or8 ~& R' ]7 {$ a1 M4 n5 @6 ^
- * modify it under the terms of the GNU General Public License as ~* w/ o! W1 `( A$ I; i
- * published by the Free Software Foundation version 2.
2 ~! u/ A i/ D/ N- J( G, J! W% d - *
8 L# d; G# Z# P% h - * This program is distributed "as is" WITHOUT ANY WARRANTY of any
2 d9 Z7 R3 O0 ^+ d - * kind, whether express or implied; without even the implied warranty
- O+ A4 G1 F9 g- Q0 e9 {" M3 F- O - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9 @# T) [3 Q9 `# p7 E. r# j - * GNU General Public License for more details.
5 j+ d9 |* z2 ?2 J - */3 x O' j* Z. i; w
- ! _3 j' }2 Y+ h' P
- #include <linux/module.h>9 m! s1 J1 l7 ?+ S' M5 O
- #include <linux/init.h>
- q& I1 G+ P1 ]3 N+ T2 u$ m - #include <linux/errno.h>
/ h% K' ~- {* E- a, c - #include <linux/types.h>
; E1 [9 j( A/ Q% q - #include <linux/interrupt.h>9 |4 k- h) l3 o3 k5 W
- #include <asm/io.h>
2 d0 L% v9 h0 v - #include <linux/moduleparam.h>
* g {' t0 a# l - #include <linux/sysctl.h>
; a4 m4 J" _0 ~" r! F" M, ~; J - #include <linux/mm.h>2 _4 D- I- C% n1 A9 e; Q% P9 J
- #include <linux/dma-mapping.h>
v, r; ~9 k0 J% ~
- W9 N$ J. e. ^% J, u; v- #include <mach/memory.h>! L( m% a/ V' r* j) b
- #include <mach/hardware.h>; t6 p! t5 Y: n/ U) W* D
- #include <mach/irqs.h>& q- R' G' X1 ]3 o5 x' s
- #include <asm/hardware/edma.h>" V3 _) i* @0 X# d+ K* ~9 k
- # m! Q, ~4 {) V5 Q2 ^
- #undef EDMA3_DEBUG2 Z5 {3 t2 c4 D5 q6 f5 L N
- /*#define EDMA3_DEBUG*/: o( c* E1 N6 z2 k/ n" F# ^
- * e. [( C2 T5 O+ \4 t3 n
- #ifdef EDMA3_DEBUG: x z) L" P& H
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
; c- V! W- ~* i8 s& X& b0 X( O. L - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
- @3 {1 T! }" q1 \+ C$ t/ a4 r - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)& A+ c7 [+ `: W* K7 ~& h
- #else* l' M" R3 m( G9 u
- #define DMA_PRINTK( x... )8 M; z7 J9 p. ]8 [9 e/ s
- #define DMA_FN_IN- O7 j& x, e1 f( F9 T+ g
- #define DMA_FN_OUT" o8 g4 ^5 D. r
- #endif& W, q$ S: Z! o/ E# }
- ! X3 R; X: a) a5 i9 w
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
) M# n" Z; O9 `1 } - #define STATIC_SHIFT 39 B, N! Z# ]9 {! V6 }; \8 h
- #define TCINTEN_SHIFT 20& A: W! s* W: t
- #define ITCINTEN_SHIFT 218 f) |' T" ~/ d$ t6 @. l" x; O
- #define TCCHEN_SHIFT 22
5 s/ o) q3 m5 c( X( ]( d; {3 i! H - #define ITCCHEN_SHIFT 23
: M; N% }1 H- o - ) _( \( z* z% i) S/ ^
- static volatile int irqraised1 = 0;
7 W( h2 H; t/ I8 I7 @ - static volatile int irqraised2 = 0;
& k3 l4 h/ @. Y+ s - g# }+ y9 o+ u$ T) k
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
( F3 I" {1 S) L' [3 A& v, N - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
* x) p6 C* V! _ - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);( N0 E+ }% g9 _
' ]6 _2 i& f% P h) r# r# x- dma_addr_t dmaphyssrc1 = 0;1 P" t# C) m: J
- dma_addr_t dmaphyssrc2 = 0;
/ X$ k, X% A. G6 T8 q# |' x - dma_addr_t dmaphysdest1 = 0;9 G. k4 ~% ~1 O7 Z) a9 D
- dma_addr_t dmaphysdest2 = 0;5 c$ P w$ O2 q( `* ?
- 1 k/ M3 }! @. p' k! Q, c( ~
- char *dmabufsrc1 = NULL;& Q* e* ?: l! O+ u
- char *dmabufsrc2 = NULL;+ d4 F" J2 R; ^2 n
- char *dmabufdest1 = NULL;
: M0 P5 X! h9 O- m- u& }+ f - char *dmabufdest2 = NULL;1 e# \; I8 H9 j: j7 v
- 6 Y, I$ [/ v; e( F% a2 C
- static int acnt = 512;
6 v) [1 U; g, H! i0 b8 P' C - static int bcnt = 8;
; q& i6 K X6 W0 Q0 m& a u6 K' l - static int ccnt = 8;
8 q5 v$ S. Y+ R# | - 2 h G. q9 Z8 O& w1 E
- module_param(acnt, int, S_IRUGO);
; w0 d C7 F4 s$ C - module_param(bcnt, int, S_IRUGO);6 y) c( i+ H# A# ` j
- module_param(ccnt, int, S_IRUGO);
复制代码 8 H1 a* Z9 {7 t" i! D4 |
/ S: D& ?! J) }/ j 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用& N9 o4 r. c# y. ?$ b1 O9 b8 r. C
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 n1 x; R& |9 y* ?5 f) v/ C 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
4 R# w3 T6 a7 A+ }2 {4 b& X
" k! [2 D I5 E! ^) [( M' V" v) O$ l
|
|