|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
% u2 N& O9 f% k' ]- [code]EDMA sample test application
: V% M* _4 k4 n* A - /*
V+ Y; S* r) K2 @* j" v - * edma_test.c8 @2 C8 a9 n; l, n7 q/ C0 K* Z
- *
4 [8 L5 D* P/ y4 x$ Q - * brief EDMA3 Test Application' n( N. ?2 E. |3 ]: [
- *5 p6 D. [6 \3 A- W: O b2 P$ ?
- * This file contains EDMA3 Test code.5 Q" q B9 Z: W7 _* W
- *7 E- z; v. x7 }: B7 J, s
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE4 o P E' I" J' t1 N
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT2 R; `6 m/ H/ c4 R: f$ z2 |+ n5 J
- * TO CHANGE.) s/ ~! c! {) W: D& _: v# i7 M
- *& R9 S. O: n6 G! Y& g4 H* \( S& U3 U
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
1 y/ Z$ R% p7 N0 Z$ y t w - *
' ~& z4 t% R, ~) a- k2 e. p& t2 d - * This program is free software; you can redistribute it and/or, v' Q0 Z# `% F4 h" t
- * modify it under the terms of the GNU General Public License as4 S+ G, r- M& N1 Y. c, }# U M
- * published by the Free Software Foundation version 2./ ^6 \8 b6 s4 l3 K( \1 f
- *
: X m# u. {* k- E. W, z - * This program is distributed "as is" WITHOUT ANY WARRANTY of any6 S6 f0 _' e+ k" o5 Q2 ]
- * kind, whether express or implied; without even the implied warranty9 Z8 h0 Z1 F7 G/ h1 ]; N0 I
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the# x2 `1 L' a- O5 F7 X4 y& T
- * GNU General Public License for more details." d9 F3 K; @' p) n
- */
) `; H" l, C% k7 \/ p6 G
) q0 B4 H$ W: Y( G1 {- #include <linux/module.h>9 h/ Y7 v$ c: n1 h; u9 G8 Y
- #include <linux/init.h>$ O1 R d( A& S0 B- v: j2 U
- #include <linux/errno.h>
$ D5 Z' w, I4 m8 i( a1 n: w( x - #include <linux/types.h>- |5 m7 u! A! J/ T2 q
- #include <linux/interrupt.h>
: c/ f/ u8 y( e2 u8 N - #include <asm/io.h># {# i3 o+ N% f8 l' W$ [$ e- |
- #include <linux/moduleparam.h>
" F! T$ ~% \/ `: N2 a - #include <linux/sysctl.h>
" j, X8 k! w) Y: Z+ j+ U1 \ - #include <linux/mm.h>5 B8 k. k2 M- j5 ]$ S4 V: ^7 Q
- #include <linux/dma-mapping.h>& k' g' {# B+ }3 U8 x
$ A! ^: c, P I! D7 v! w- #include <mach/memory.h>5 l2 R, {* Q. m; R8 g+ N7 Q
- #include <mach/hardware.h>
2 O8 q; w8 ] R - #include <mach/irqs.h>4 z5 @. i `* H5 M X
- #include <asm/hardware/edma.h>+ A& S5 D# j# @( X6 d v
- 9 f% _; \) I: J& p1 V- ?
- #undef EDMA3_DEBUG- E* } N. ^$ n" g( U- _
- /*#define EDMA3_DEBUG*/
! e* J# v4 i- T! Q6 I9 r6 e/ _
4 D# Q! n- a. ?1 H5 g3 }/ q- #ifdef EDMA3_DEBUG$ [) F" @8 f+ u1 c. r: ^/ I
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
/ C( a& }2 P4 P* K/ d$ G% K( K - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
1 [; B0 ^+ ~; _3 }; {( R9 E - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
8 ~1 j% R) j& i. n - #else
8 f. U$ A1 j( p: i3 ^3 O& D0 R - #define DMA_PRINTK( x... )
# M6 H, |1 }1 |# w2 L6 A. o - #define DMA_FN_IN
% Z7 z# U* l% Y7 k* K - #define DMA_FN_OUT
) O7 p2 U% K. d$ h4 h - #endif. L* @' j# t. V; d- y
; L/ W: J; r" ?3 G1 c- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
( t) Q. D0 ?) ]4 ?! q1 d ]# N. a; M - #define STATIC_SHIFT 3( P2 B9 e1 p9 ]# j
- #define TCINTEN_SHIFT 20
F7 D: G6 x3 p. q2 [# W - #define ITCINTEN_SHIFT 21
e% T% ?& `" }- [( z% f: m - #define TCCHEN_SHIFT 22
) Q9 r: @/ V( q2 H! m - #define ITCCHEN_SHIFT 23
" r8 q( J- W1 b0 Q# ]; k - 3 S: [( w) n9 I& s# E. @
- static volatile int irqraised1 = 0;
7 d. M, e! {. y6 \/ F5 W - static volatile int irqraised2 = 0;# |+ t$ P4 |( U
! ~/ S) M/ R# P3 E3 \3 P- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
# F1 q3 O, {; b - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);4 Q" a0 j- F7 M, \& @6 I
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);( L/ q6 ?+ ^/ x$ \7 g2 [
- # }& C/ a7 S0 s- z9 F' M
- dma_addr_t dmaphyssrc1 = 0;
" n( ^/ E1 a" b3 ], [6 Y - dma_addr_t dmaphyssrc2 = 0;" q5 [8 w" c8 I- e
- dma_addr_t dmaphysdest1 = 0;1 s( c3 ~9 E: G2 S6 Q9 H
- dma_addr_t dmaphysdest2 = 0;& ~8 N0 A' B9 g4 j/ o: K( o+ }
+ t+ X2 c" j# _; ]7 ~% w- char *dmabufsrc1 = NULL;% S4 x; [/ P1 C3 \' C& [$ |0 l- Z
- char *dmabufsrc2 = NULL;
( k% a: Z4 R, h: Q5 u$ E - char *dmabufdest1 = NULL;! Y1 K9 r4 a- U1 m3 s; d0 G
- char *dmabufdest2 = NULL;
3 o' h+ a) t( m2 u8 L - + s" t9 @/ d! E) y, w, f
- static int acnt = 512;
+ _4 f g+ g4 z - static int bcnt = 8;
1 L. B! a) Z: b9 X5 D8 _# n+ G - static int ccnt = 8;
, `( M3 q6 p; |$ o - 2 S0 |' T1 \% N* H& ^, E3 t
- module_param(acnt, int, S_IRUGO);
K0 _5 l, L7 q% q& u - module_param(bcnt, int, S_IRUGO);; S+ ]! G4 R2 ]! A0 a& L1 ~3 Q" i K0 |
- module_param(ccnt, int, S_IRUGO);
复制代码
9 X- @+ i2 F: g3 r# s+ J. B* R
& F7 |6 s/ M' @1 g( {% E 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用* ^7 d2 x6 ?0 z3 m
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
# P8 `5 Z. @/ T9 E 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。4 r) k+ u `# a/ ~3 x2 q0 J
0 J4 I! U; _, S3 i
- T9 j# _9 t( o* u! Q H# } |
|